Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752561Ab3FNMO1 (ORCPT ); Fri, 14 Jun 2013 08:14:27 -0400 Received: from hydra.sisk.pl ([212.160.235.94]:37225 "EHLO hydra.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752461Ab3FNMOZ (ORCPT ); Fri, 14 Jun 2013 08:14:25 -0400 From: "Rafael J. Wysocki" To: Jiang Liu Cc: Bjorn Helgaas , Yinghai Lu , "Alexander E . Patrakov" , Greg Kroah-Hartman , Yijing Wang , Jiang Liu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , stable@vger.kernel.org Subject: Re: [BUGFIX 2/9] ACPIPHP: fix device destroying order issue when handling dock notification Date: Fri, 14 Jun 2013 14:23:34 +0200 Message-ID: <2301639.HY0nSRLtah@vostro.rjw.lan> User-Agent: KMail/4.9.5 (Linux/3.10.0-rc5+; KDE/4.9.5; x86_64; ; ) In-Reply-To: <2448481.HbOiE9Npmq@vostro.rjw.lan> References: <1371141152-9468-1-git-send-email-jiang.liu@huawei.com> <1371141152-9468-3-git-send-email-jiang.liu@huawei.com> <2448481.HbOiE9Npmq@vostro.rjw.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3778 Lines: 94 On Thursday, June 13, 2013 09:59:44 PM Rafael J. Wysocki wrote: > On Friday, June 14, 2013 12:32:25 AM Jiang Liu wrote: > > Current ACPI glue logic expects that physical devices are destroyed > > before destroying companion ACPI devices, otherwise it will break the > > ACPI unbind logic and cause following warning messages: > > [ 185.026073] usb usb5: Oops, 'acpi_handle' corrupt > > [ 185.035150] pci 0000:1b:00.0: Oops, 'acpi_handle' corrupt > > [ 185.035515] pci 0000:18:02.0: Oops, 'acpi_handle' corrupt > > [ 180.013656] port1: Oops, 'acpi_handle' corrupt > > Please refer to https://bugzilla.kernel.org/attachment.cgi?id=104321 > > for full log message. > > So my question is, did we have this problem before commit 3b63aaa70e1? > > If we did, then when did it start? Or was it present forever? > > > Above warning messages are caused by following scenario: > > 1) acpi_dock_notifier_call() queues a task (T1) onto kacpi_hotplug_wq > > 2) kacpi_hotplug_wq handles T1, which invokes acpi_dock_deferred_cb() > > ->dock_notify()-> handle_eject_request()->hotplug_dock_devices() > > 3) hotplug_dock_devices() first invokes registered hotplug callbacks to > > destroy physical devices, then destroys all affected ACPI devices. > > Everything seems perfect until now. But the acpiphp dock notification > > handler will queue another task (T2) onto kacpi_hotplug_wq to really > > destroy affected physical devices. > > Would not the solution be to modify it so that it didn't spawn the other > task (T2), but removed the affected physical devices synchronously? > > > 4) kacpi_hotplug_wq finishes T1, and all affected ACPI devices have > > been destroyed. > > 5) kacpi_hotplug_wq handles T2, which destroys all affected physical > > devices. > > > > So it breaks ACPI glue logic's expection because ACPI devices are destroyed > > in step 3 and physical devices are destroyed in step 5. > > > > Signed-off-by: Jiang Liu > > Reported-by: Alexander E. Patrakov > > Cc: Bjorn Helgaas > > Cc: Yinghai Lu > > Cc: "Rafael J. Wysocki" > > Cc: linux-pci@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Cc: stable@vger.kernel.org > > --- > > Hi Bjorn and Rafael, > > The recursive lock changes haven't been tested yet, need help > > from Alexander for testing. > > Well, let's just say I'm not a fan of recursive locks. Is that unavoidable > here? What about the appended patch (on top of [1/9], untested)? Rafael --- drivers/pci/hotplug/acpiphp_glue.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c =================================================================== --- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c +++ linux-pm/drivers/pci/hotplug/acpiphp_glue.c @@ -145,9 +145,20 @@ static int post_dock_fixups(struct notif return NOTIFY_OK; } +static void handle_dock_event_func(acpi_handle handle, u32 event, void *context) +{ + if (event == ACPI_NOTIFY_EJECT_REQUEST) { + struct acpiphp_func *func = context; + + if (!acpiphp_disable_slot(func->slot)) + acpiphp_eject_slot(func->slot); + } else { + handle_hotplug_event_func(handle, event, context); + } +} static const struct acpi_dock_ops acpiphp_dock_ops = { - .handler = handle_hotplug_event_func, + .handler = handle_dock_event_func, }; /* Check whether the PCI device is managed by native PCIe hotplug driver */ -- 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/