Skip to contentSkip to conversation

Backport of a 2.6.x USB driver to 2.4.32 - help needed

DISCUSSION Heiko Gerstung 4 participants 8 messages Jun 6, 2006 – Jun 7, 2006

lore
Share & tools
lore
#0 lore raw

Hi!

Short Version (tm): I try to backport a USB driver (rtl8150.c) from 2.6.15.x to 2.4.32 and have no idea how to substitue two functions:
in_atomic() and schedule_timeout_uninterruptible() ... I really would appreciate any help, because I am no kernel hacker at all ...

Long Version (tm):
I have problems backporting a USB driver from 2.6.15.x to 2.4.32 and I am at a total loss because I am not really a device driver hacker and it seems that the original author/maintainer is currently very busy and has no chance to support me in this case (although his support so far was excellent!).

I still fight with the driver for Realtek 8150 based USB-to-Ethernet products (drivers/usb/net/rtl8150.c in 2.6.x kernels, /drivers/usb/rtl8150.c in the 2.4 kernel tree).

Under 2.4.32 this driver crashes (kernel panic) when I try to enslave a network interface handled by it, with a 2.6 kernel there is no such problem. Unfortunately I cannot go ahead with a 2.6 kernel at the moment, because it lacks a properly running PPS support.

I therefore backported the 2.6.x driver to compile cleanly under 2.4.32 and it still crashes when I try to enslave such an interface in miimon mode. I think there is a difference in the way the bonding module checks
the MII link status of the device. The maintainer of the driver
modified a few things for me in order to address this problem ("it happens because get/set_registers() are called with no process context"), but he was only able to modify the 2.6.x driver for me.

I started to backport the modified version, but it seems that I ran into dependency hell because I get the following two missing functions reported when I try to compile the backported module:

rtl8150.c: In Funktion »rtl8150_get_settings«:
rtl8150.c:790: Warnung: implicit declaration of function `in_atomic' rtl8150.c: In Funktion »rtl8150_thread«:
rtl8150.c:857: Warnung: implicit declaration of function `schedule_timeout_uninterruptible'

Now I would need help in finding a way to substitute the two missing functions in a 2.4 kernel environment and I desperately hope that someone sees my dilemma and can help me somehow...

Anyway, thank you for spending the time to at least read this post (and thanks a lot if you could spend a few cycles on thinking about a possible solution!).

Kind regards,
Heiko

Signature · 13 lines
------------------------------------------------------------------------

*MEINBERG Funkuhren GmbH & Co. KG*
Auf der Landwehr 22
D-31812 Bad Pyrmont, Germany
Tel.: ++49 (0)5281 9309-25
Fax: ++49 (0)5281 9309-30
eMail: [email protected] <mailto:[email protected]>
Internet: www.meinberg.de <http://www.meinberg.de/>

------------------------------------------------------------------------

Meinberg radio clocks: 25 years of accurate time worldwide
#1 lore raw
Quoted 7 lines · Heiko Gerstung

Hi!

Short Version (tm): I try to backport a USB driver (rtl8150.c) from 2.6.15.x to 2.4.32 and have no idea how to substitue two functions:
in_atomic() and schedule_timeout_uninterruptible() ... I really would appreciate any help, because I am no kernel hacker at all ...

in_atomic() is used to test if the kernel is in a state where sleeping is allowed or not. The 2.4.x kernel is not preemptive and has quite coarse grained SMP support (the BKL "Big Kernel Lock"), it didin't need in_atomic() in the same way as 2.6.x does.

schedule_timeout_uninterruptible() is used to sleep on a wait-queue, which 2.4.x does not have.

[snip]

Quoted 6 lines

Under 2.4.32 this driver crashes (kernel panic) when I try to enslave a network interface handled by it, with a 2.6 kernel there is no such problem. Unfortunately I cannot go ahead with a 2.6 kernel at the moment, because it lacks a properly running PPS support.

Wouldn't it make more sense to work on improving PPS (I assume you are refering to NTP "pulse per second" btw) support in 2.6.x rather than backporting an USB driver to 2.4.x ???

[snip]

Quoted 5 lines

Now I would need help in finding a way to substitute the two missing functions in a 2.4 kernel environment and I desperately hope that someone sees my dilemma and can help me somehow...

The book "Linux Device Drivers" third edition is available for free online and describes 2.6.x USB drivers in a fair bit of detail. Earlier editions of the book describe the 2.4.x kernel (don't know if those are available for free, but it should be possible to get them from a bookstore in any case).

Getting hold of the second & third editions of LDD and comparing the USB info from both should give you some idea of where to start...

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html
#2 lore raw
Quoted 4 lines · Jesper Juhl

in_atomic() is used to test if the kernel is in a state where sleeping is allowed or not. The 2.4.x kernel is not preemptive and has quite coarse grained SMP support (the BKL "Big Kernel Lock"), it didin't need in_atomic() in the same way as 2.6.x does.

OK, so I guess I can safely ommit this.

Quoted 2 lines

schedule_timeout_uninterruptible() is used to sleep on a wait-queue, which 2.4.x does not have.

Is there any similiar functionality in a 2.4 kernel environment? A pointer to a 2.4 kernel driver using such a mechanism would be a good starter...

Quoted 4 lines

[snip]
Wouldn't it make more sense to work on improving PPS (I assume you are refering to NTP "pulse per second" btw) support in 2.6.x rather than backporting an USB driver to 2.4.x ???

Yes, but unfortunately I have no chance to do this and therefore I rely on others to do this. Well, the same applies to [me] and [kernel drivers], but I hoped that it might be easier to try and backport one driver instead of trying to improve other people's code (maybe that is what OPC stands for :-)), especially when this code has a much larger impact on several parts of the kernel.

Quoted 9 lines

[snip]
The book "Linux Device Drivers" third edition is available for free online and describes 2.6.x USB drivers in a fair bit of detail. Earlier editions of the book describe the 2.4.x kernel (don't know if those are available for free, but it should be possible to get them from a bookstore in any case).

Getting hold of the second & third editions of LDD and comparing the USB info from both should give you some idea of where to start...

OK, I will try to do so, but I am afraid that I will run out of time in the meantime.

Thank you very much for your help and your fast response.

Kind regards,
Heiko

Signature · 13 lines
------------------------------------------------------------------------

*MEINBERG Funkuhren GmbH & Co. KG*
Auf der Landwehr 22
D-31812 Bad Pyrmont, Germany
Tel.: ++49 (0)5281 9309-25
Fax: ++49 (0)5281 9309-30
eMail: [email protected] <mailto:[email protected]>
Internet: www.meinberg.de <http://www.meinberg.de/>

------------------------------------------------------------------------

Meinberg radio clocks: 25 years of accurate time worldwide
#3 lore raw
Quoted 6 lines · Heiko Gerstung

Yes, but unfortunately I have no chance to do this and therefore I rely on others to do this. Well, the same applies to [me] and [kernel drivers], but I hoped that it might be easier to try and backport one driver instead of trying to improve other people's code (maybe that is what OPC stands for :-)), especially when this code has a much larger impact on several parts of the kernel.

Which part of PPS doesn't work on 2.6 if you have the PPS-kit-light installed? There is a version for 2.6.15 around, which applies to 2.6.16 with minimal fixing. Only problem I found so far with the code was that it breaks the serial console on my system, but that was easy to fix. I still have to test it though since my serial port has the CD line stuck high at the moment until I can get the board fixed, so testing is a bit tricky.

I know I have run a gps receiver with PPS on the CD line under 2.6.8 using PPS-kit-light, and it worked rather well.

Len Sorensen

#4 lore raw

Hi, Lennart:

Quoted 16 lines · Lennart Sorensen
Quoted 6 lines · Heiko Gerstung

Yes, but unfortunately I have no chance to do this and therefore I rely on others to do this. Well, the same applies to [me] and [kernel drivers], but I hoped that it might be easier to try and backport one driver instead of trying to improve other people's code (maybe that is what OPC stands for :-)), especially when this code has a much larger impact on several parts of the kernel.

Which part of PPS doesn't work on 2.6 if you have the PPS-kit-light installed? There is a version for 2.6.15 around, which applies to 2.6.16 with minimal fixing. Only problem I found so far with the code was that it breaks the serial console on my system, but that was easy to fix. I still have to test it though since my serial port has the CD line stuck high at the moment until I can get the board fixed, so testing is a bit tricky.

Quoted 2 lines

I know I have run a gps receiver with PPS on the CD line under 2.6.8 using PPS-kit-light, and it worked rather well.

It works but on my system it takes ~4 hours before I reach lower microsecond offsets, where the 2.4 ppskit is below 10 microseconds after four polling cycles. I already tried to fix that but the internal kernel pps discipline is not working as good as it did with the 2.4 ppskit versions.

Quoted 2 lines

Len Sorensen

Kind regards,
Heiko

Signature · 13 lines
------------------------------------------------------------------------

*MEINBERG Funkuhren GmbH & Co. KG*
Auf der Landwehr 22
D-31812 Bad Pyrmont, Germany
Tel.: ++49 (0)5281 9309-25
Fax: ++49 (0)5281 9309-30
eMail: [email protected] <mailto:[email protected]>
Internet: www.meinberg.de <http://www.meinberg.de/>

------------------------------------------------------------------------

Meinberg radio clocks: 25 years of accurate time worldwide
#5 lore raw
Quoted 5 lines · Heiko Gerstung

It works but on my system it takes ~4 hours before I reach lower microsecond offsets, where the 2.4 ppskit is below 10 microseconds after four polling cycles. I already tried to fix that but the internal kernel pps discipline is not working as good as it did with the 2.4 ppskit versions.

I guess that is the light part. :)

Len Sorensen

#6 lore raw
In reply to Jesper Juhl
Quoted 8 lines · Jesper Juhl
Quoted 7 lines · Heiko Gerstung

Hi!

Short Version (tm): I try to backport a USB driver (rtl8150.c) from 2.6.15.x to 2.4.32 and have no idea how to substitue two functions:
in_atomic() and schedule_timeout_uninterruptible() ... I really would appreciate any help, because I am no kernel hacker at all ...

Quoted 7 lines

in_atomic() is used to test if the kernel is in a state where sleeping is allowed or not. The 2.4.x kernel is not preemptive and has quite coarse grained SMP support (the BKL "Big Kernel Lock"), it didin't need in_atomic() in the same way as 2.6.x does.

schedule_timeout_uninterruptible() is used to sleep on a wait-queue, which 2.4.x does not have.

schedule_timeout_uninterruptible(timeout_value) is just a wrapper for

set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(timeout_value);

Maybe you were thinking of sleep_on*()?

Thanks,
Nish

#7 lore raw
Quoted 17 lines · Nish Aravamudan
Quoted 8 lines · Jesper Juhl
Quoted 7 lines · Heiko Gerstung

Hi!

Short Version (tm): I try to backport a USB driver (rtl8150.c) from 2.6.15.x to 2.4.32 and have no idea how to substitue two functions:
in_atomic() and schedule_timeout_uninterruptible() ... I really would appreciate any help, because I am no kernel hacker at all ...

Quoted 7 lines

in_atomic() is used to test if the kernel is in a state where sleeping is allowed or not. The 2.4.x kernel is not preemptive and has quite coarse grained SMP support (the BKL "Big Kernel Lock"), it didin't need in_atomic() in the same way as 2.6.x does.

schedule_timeout_uninterruptible() is used to sleep on a wait-queue, which 2.4.x does not have.

Quoted 7 lines

schedule_timeout_uninterruptible(timeout_value) is just a wrapper for

set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(timeout_value);

Maybe you were thinking of sleep_on*()?

Yeah, you are right, that was what I was thinking of. My bad. Thank you for the correction.

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html