Skip to contentSkip to conversation

ne driver crashes when unloaded in 2.6.22.6

PATCH Chris Rankin 2 participants 8 messages Sep 9, 2007 – Sep 16, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

While trying to get my NE2000 ISA card working with NetworkManager and Linux 2.6.22.6, I discovered that the ne module will cause the kernel to oops when it is unloaded. The problem is that the module's clean-up function tries to unregister a platform driver unconditionally, although the platform driver may never have been registered in the first place. I have created a patch which seems to work OK. The idea behind the patch is to de-initialise the unregistered ne_driver structure to the point where the unregister function will abort without error:

net/ne.c 2007-09-09 20:04:28.000000000 +0100 renamed from net/ne.c.orig 2007-07-21 17:00:52.000000000 +0100 +2 -0
@@ -272,6 +272,7 @@
                                pnp_device_detach(idev);
                                return -ENXIO;
                        }
+                       SET_NETDEV_DEV(dev, &idev->dev);
                        ei_status.priv = (unsigned long)idev;
                        break;
                }
@@ -827,6 +828,7 @@
                free_netdev(dev);
                return err;
        }
+       SET_NETDEV_DEV(dev, &pdev->dev);
        platform_set_drvdata(pdev, dev);
        return 0;
 }
@@ -909,11 +911,14 @@
 is at boot) and so the probe will get confused by any other 8390 cards.
 ISA device autoprobes on a running machine are not recommended anyway. */
 

int __init init_module(void)

 {
        int this_dev, found = 0;
        int plat_found = !ne_init();

+ if ( !plat_found )
+ ne_driver.driver.bus = NULL;
+

        for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
                struct net_device *dev = alloc_ei_netdev();
                if (!dev)

The patch also contains a few SET_NETDEV_DEV() statements, which I am hoping will help these network cards work with NetworkManager. This isn't a complete solution because it still doesn't address the non-PnP ISA case. However, I think it's a start... At the moment, my eth device appears in /sys/class/net but is also completely ignored by lshal.

Cheers,
Chris

      ___________________________________________________________ 

Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html

#1 lore raw
Quoted 43 lines · Chris Rankin

Hi,

While trying to get my NE2000 ISA card working with NetworkManager and Linux 2.6.22.6, I discovered that the ne module will cause the kernel to oops when it is unloaded. The problem is that the module's clean-up function tries to unregister a platform driver unconditionally, although the platform driver may never have been registered in the first place. I have created a patch which seems to work OK. The idea behind the patch is to de-initialise the unregistered ne_driver structure to the point where the unregister function will abort without error:

net/ne.c 2007-09-09 20:04:28.000000000 +0100 renamed from net/ne.c.orig 2007-07-21 17:00:52.000000000 +0100 +5 -0
@@ -272,6 +272,7 @@
                                pnp_device_detach(idev);
                                return -ENXIO;
                        }
+                       SET_NETDEV_DEV(dev, &idev->dev);
                        ei_status.priv = (unsigned long)idev;
                        break;
                }
@@ -827,6 +828,7 @@
                free_netdev(dev);
                return err;
        }
+       SET_NETDEV_DEV(dev, &pdev->dev);
        platform_set_drvdata(pdev, dev);
        return 0;
 }
@@ -909,11 +911,14 @@
 is at boot) and so the probe will get confused by any other 8390 cards.
 ISA device autoprobes on a running machine are not recommended anyway. */
 
 int __init init_module(void)
 {
        int this_dev, found = 0;
        int plat_found = !ne_init();
 
+       if ( !plat_found )
+               ne_driver.driver.bus = NULL;
+
        for (this_dev = 0; this_dev < MAX_NE_CARDS; this_dev++) {
                struct net_device *dev = alloc_ei_netdev();
                if (!dev)
Quoted 4 lines

The patch also contains a few SET_NETDEV_DEV() statements, which I am hoping will help these network cards work with NetworkManager. This isn't a complete solution because it still doesn't address the non-PnP ISA case. However, I think it's a start... At the moment, my eth device appears in /sys/class/net but is also completely ignored by lshal.

Awesome. SET_NETDEV_DEV is required because it establishes the 'device' link in sysfs that HAL uses for additional information about the card. At some point all drivers should get audited for SET_NETDEV_DEV (or rather lack of it) and get fixed if they don't have it.

Offhand question, does your ne2000 card support carrier detection?

Dan

#2 lore raw
Quoted 1 line · --- Dan Williams

Offhand question, does your ne2000 card support carrier detection?

Err... there is a /sys/class/net/eth0/carrier entry (I think - not in front of that machine right now). IIRC it said "1" when I read it.

Cheers,
Chris

      ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now.
http://uk.answers.yahoo.com/

#3 lore raw
Quoted 5 lines · Chris Rankin
Quoted 1 line · --- Dan Williams

Offhand question, does your ne2000 card support carrier detection?

Err... there is a /sys/class/net/eth0/carrier entry (I think - not in front of that machine right now). IIRC it said "1" when I read it.

Does it read '0' when you unplug the cable?

Dan

Quoted 9 lines

Cheers,
Chris

      ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now.
http://uk.answers.yahoo.com/

#4 lore raw
Quoted 5 lines · --- Dan Williams
Quoted 3 lines
Quoted 1 line

Offhand question, does your ne2000 card support carrier detection?

Err... there is a /sys/class/net/eth0/carrier entry

Does it read '0' when you unplug the cable?

Hmm, apparently not. The light on the card goes out though, so could this just be a lack of driver support?

Cheers,
Chris

      ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now.
http://uk.answers.yahoo.com/

#5 lore raw
Quoted 9 lines · Chris Rankin
Quoted 5 lines · --- Dan Williams
Quoted 3 lines
Quoted 1 line

Offhand question, does your ne2000 card support carrier detection?

Err... there is a /sys/class/net/eth0/carrier entry

Does it read '0' when you unplug the cable?

Hmm, apparently not. The light on the card goes out though, so could this just be a lack of driver support?

Likely, yes.

dan

Quoted 9 lines

Cheers,
Chris

      ___________________________________________________________

Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now.
http://uk.answers.yahoo.com/

#6 lore raw
Quoted 6 lines · --- Dan Williams
Quoted 1 line · Chris Rankin

Hmm, apparently not. The light on the card goes out though, so could this just be a lack of

driver

Quoted 1 line

support?

Likely, yes.

I've been trawling the Internet for 8390 specifications and have discovered that there is a "Carrier Sense Loss" flag on the "Transmit Status Register". However, there doesn't seem to be an explicit "media status" test. Would this more likely be part of the NE2000's functionality? I can't find any signs of MII support, but then the NE2000 is so heavily cloned that "NE2000-compatible" seems to have become more of a generic description these days.

Does anyone have any ideas, please? Does NetworkManager even need full carrier-detection support?

Cheers,
Chris

      ___________________________________________________________ 

Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html

#7 lore raw
Quoted 8 lines · Chris Rankin
Quoted 6 lines · --- Dan Williams
Quoted 1 line · Chris Rankin

Hmm, apparently not. The light on the card goes out though, so could this just be a lack of

driver

Quoted 1 line

support?

Likely, yes.

Quoted 7 lines

I've been trawling the Internet for 8390 specifications and have discovered that there is a "Carrier Sense Loss" flag on the "Transmit Status Register". However, there doesn't seem to be an explicit "media status" test. Would this more likely be part of the NE2000's functionality? I can't find any signs of MII support, but then the NE2000 is so heavily cloned that "NE2000-compatible" seems to have become more of a generic description these days.

Does anyone have any ideas, please? Does NetworkManager even need full carrier-detection support?

NM needs it if you want the interface to be automatically handled in 0.6.x and earlier. In 0.7.x and later you'll be able to have NM just set up the interface even if it doesn't have a link (if you set it to autoconnect), but of course that means that whenever you start NM the interface will be up with the settings you specify because, of course, NM can't automatically figure out when the card is up or down and do something intelligent.

dan