LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-15-2018, 02:27 PM   #1
HMan81
LQ Newbie
 
Registered: Dec 2018
Posts: 5

Rep: Reputation: Disabled
Porting pre-4.15 timer code for mali450 GPU kernel driver on ARM64


Hi folks,

I have an old TV box based off the Amlogic S905X ARM64 SoC, a Tanix TX5, which originally ran Android on it. I don't like being locked out of the potential of my hardware, so I followed closely the progress of the Armbian project, and I recently have installed version 5.67, which is based off Ubuntu Bionic, running on Linux 4.19.6.

Everything works great, there are working drivers for ethernet, wifi, blutooth, etc, but there is unfortunately no kernel driver included to support the integrated mali450 gpu. The hdmi output does work, but Xorg is running on fbdev, and screen updating is painfully slow, videos are unwatchable in full screen. I'm not too sure what the story is but apparently amlogic keeps their current version of the driver to themselves. However by going on their FTP site, I found an old source tree for the kernel driver ( http://openlinux.amlogic.com:8000/do...d7b1d1b.tar.gz ). It is out of date, but I have made some headway into porting it to the current kernel, with mostly easy fixes up to now. I can now compile about half of the source files just fine.

I should clarify I'm not a linux developer by trade, I'm not even a C developer... I dabble, I know just enough to be dangerous, and I'm highly motivated. My daily trade is C# though, so I do know more or less what I'm doing.

The current issue I am having is with mali/linux/mali_osk_timers.c . This is the original code:

Code:
/*
 * Copyright (C) 2010-2014, 2016 ARM Limited. All rights reserved.
 * 
 * This program is free software and is provided to you under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
 * 
 * A copy of the licence is included with the program, and can also be obtained from Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

/**
 * @file mali_osk_timers.c
 * Implementation of the OS abstraction layer for the kernel device driver
 */

#include <linux/timer.h>
#include <linux/slab.h>
#include "mali_osk.h"
#include "mali_kernel_common.h"

struct _mali_osk_timer_t_struct {
    struct timer_list timer;
};

typedef void (*timer_timeout_function_t)(unsigned long);

_mali_osk_timer_t *_mali_osk_timer_init(void)
{
    _mali_osk_timer_t *t = (_mali_osk_timer_t *)kmalloc(sizeof(_mali_osk_timer_t), GFP_KERNEL);
    if (NULL != t) init_timer(&t->timer);
    return t;
}

void _mali_osk_timer_add(_mali_osk_timer_t *tim, unsigned long ticks_to_expire)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    tim->timer.expires = jiffies + ticks_to_expire;
    add_timer(&(tim->timer));
}

void _mali_osk_timer_mod(_mali_osk_timer_t *tim, unsigned long ticks_to_expire)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    mod_timer(&(tim->timer), jiffies + ticks_to_expire);
}

void _mali_osk_timer_del(_mali_osk_timer_t *tim)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    del_timer_sync(&(tim->timer));
}

void _mali_osk_timer_del_async(_mali_osk_timer_t *tim)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    del_timer(&(tim->timer));
}

mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    return 1 == timer_pending(&(tim->timer));
}

void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    tim->timer.data = (unsigned long)data;
    tim->timer.function = (timer_timeout_function_t)callback;
}

void _mali_osk_timer_term(_mali_osk_timer_t *tim)
{
    MALI_DEBUG_ASSERT_POINTER(tim);
    kfree(tim);
}
The main problem here is that this code uses the timers via an interface that was deprecated long ago, and removed entirely from the kernel in 4.15. I was able to look up how to port this code, and managed almost the entire file, but in the end I'm not familiar enough with C syntax and pointer usage rules to figure out how to do it. The main problematic is the _mali_osk_timer_setcallback() function. I'm not really sure how to go about modifying it while also keeping the same function signature.
 
Old 12-17-2018, 11:28 AM   #2
HMan81
LQ Newbie
 
Registered: Dec 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
Disregard this thread, I have solved the issue with some help from StackOverflow.

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Does blacklisting discrete GPU driver completely disables discrete GPU, or using acpi_call is better decision? SuperPrower Linux - Hardware 2 08-21-2017 08:32 PM
Allocate physical memory buffer for ARM64 Linux Device Driver (without DMA support) bluebit Linux - Embedded & Single-board computer 1 09-04-2015 10:49 AM
LXer: Red Hat developers porting OpenJDK to ARM64 LXer Syndicated Linux News 0 10-26-2012 04:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration