OSDN Git Service

eeepc-laptop: fix hot-unplug on resume
authorCorentin Chary <corentincj@iksaif.net>
Sun, 27 Sep 2009 19:05:14 +0000 (21:05 +0200)
committerCorentin Chary <corentincj@iksaif.net>
Wed, 30 Sep 2009 20:17:44 +0000 (22:17 +0200)
OOPS on resume when the wireless adaptor is disabled during suspend was
introduced by "eeepc-laptop: read rfkill soft-blocked state on resume".

Unable to handle kernel NULL pointer dereference

Process s2disk
Tainted: G W
IP: klist_put

Call trace:
? klist_del
? device_del
? device_unregister
? pci_stop_dev
? pci_stop_bus
? pci_remove_device
? eeepc_rfkill_hotplug [eeepc_laptop]
? eeepc_hotk_resume [eeepc_laptop]
? acpi_device_resume
? device_resume
? hibernation_snapshot

It appears the PCI device is removed twice.  The eeepc_rfkill_hotplug()
call from the resume handler is racing against the call from the ACPI
notifier callback.  The ACPI notification is triggered by the resume
handler when it refreshes the value of CM_ASL_WLAN.

The fix is to serialize hotplug calls using a workqueue.

http://bugzilla.kernel.org/show_bug.cgi?id=13825

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Acked-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/platform/x86/eeepc-laptop.c

index 0ad8ead..387e31b 100644 (file)
@@ -143,6 +143,7 @@ struct eeepc_hotk {
        struct rfkill *bluetooth_rfkill;
        struct rfkill *wwan3g_rfkill;
        struct hotplug_slot *hotplug_slot;
+       struct work_struct hotplug_work;
 };
 
 /* The actual device the driver binds to */
@@ -664,7 +665,7 @@ static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
        return 0;
 }
 
-static void eeepc_rfkill_hotplug(void)
+static void eeepc_hotplug_work(struct work_struct *work)
 {
        struct pci_dev *dev;
        struct pci_bus *bus = pci_find_bus(0, 1);
@@ -705,7 +706,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
        if (event != ACPI_NOTIFY_BUS_CHECK)
                return;
 
-       eeepc_rfkill_hotplug();
+       schedule_work(&ehotk->hotplug_work);
 }
 
 static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data)
@@ -906,7 +907,7 @@ static int eeepc_hotk_resume(struct acpi_device *device)
                rfkill_force_state(ehotk->wlan_rfkill,
                                   wlan != 1);
 
-               eeepc_rfkill_hotplug();
+               schedule_work(&ehotk->hotplug_work);
        }
 
        if (ehotk->bluetooth_rfkill)
@@ -1127,6 +1128,8 @@ static int eeepc_rfkill_init(struct device *dev)
 {
        int result = 0;
 
+       INIT_WORK(&ehotk->hotplug_work, eeepc_hotplug_work);
+
        eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
        eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");