Patch: linux-2.5.21/drivers/ide-disk.c crashed at shutdown

From: Adam J. Richter (adam@yggdrasil.com)
Date: Thu Jun 13 2002 - 04:37:55 EST


        There are two reasons why ide-disk crashes at system shutdown.

1. idedisk_devdrv.lock is not initialized (RW_LOCK_UNLOCKED is not all
    zeroes on x86).

2. The ide-disk module "manually" sets device->driver, but
   drivers/base/core.c assumes that if device->driver != NULL then
   a bunch of other fields also have valid data (driver->driver_list,
   for example). In this patch, I just clear drive->device.driver
   before calling put_device as a first step. Eventually, I would
   like to use {driver,device}_register than their generic
   matching facility, but that might take a day to get right and
   I would like to get this first step into the kernel tree and
   get your input on this idea.

        In my patch, I also reindented the fields for idedisk_devdrv.
It's just a suggestion.

        I'll cc this to linux-kernel since others have reported
this kernel BUG().

        By the way, with this patch I now get a crash at about
the same time in usbdevfs, but I believe that is not part of
this problem.

Adam J. Richter __ ______________ 575 Oroville Road
adam@yggdrasil.com \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
                         "Free Software For The Rest Of Us."

--- linux-2.5.21/drivers/ide/ide-disk.c 2002-06-08 22:26:29.000000000 -0700
+++ linux/drivers/ide/ide-disk.c 2002-06-13 02:08:46.000000000 -0700
@@ -822,8 +822,9 @@
  */
 
 static struct device_driver idedisk_devdrv = {
- suspend: idedisk_suspend,
- resume: idedisk_resume,
+ suspend: idedisk_suspend,
+ resume: idedisk_resume,
+ lock: RW_LOCK_UNLOCKED,
 };
 
 /*
@@ -1196,6 +1197,9 @@
        if (!drive)
            return 0;
 
+ /* Kludge: we never registered with device_attach, so prevent
+ put_device from trying to remove us from device->driver_list */
+ drive->device.driver = NULL;
        put_device(&drive->device);
        if ((drive->id->cfs_enable_2 & 0x3000) && drive->wcache)
                if (idedisk_flushcache(drive))

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:28 EST