From: Jiang Liu <liuj97@gmail.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Jiang Liu <jiang.liu@huawei.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Yinghai Lu <yinghai@kernel.org>,
"Alexander E . Patrakov" <patrakov@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Yijing Wang <wangyijing@huawei.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
stable@vger.kernel.org
Subject: Re: [BUGFIX 2/9] ACPIPHP: fix device destroying order issue when handling dock notification
Date: Fri, 14 Jun 2013 21:57:15 +0800 [thread overview]
Message-ID: <51BB213B.7010807@gmail.com> (raw)
In-Reply-To: <2301639.HY0nSRLtah@vostro.rjw.lan>
On 06/14/2013 08:23 PM, Rafael J. Wysocki wrote:
> 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 <jiang.liu@huawei.com>
>>> Reported-by: Alexander E. Patrakov <patrakov@gmail.com>
>>> Cc: Bjorn Helgaas <bhelgaas@google.com>
>>> Cc: Yinghai Lu <yinghai@kernel.org>
>>> Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
>>> 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
It should have similar effect as patch 2/9, and it will encounter the
same deadlock scenario as 2/9 too.
>
>
> ---
> 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 */
>
next prev parent reply other threads:[~2013-06-14 13:57 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-13 16:32 [BUGFIX 0/9] Fix bug 59501 and code improvement for dock driver Jiang Liu
2013-06-13 16:32 ` [BUGFIX 1/9] ACPI, DOCK: initialize dock subsystem before scanning PCI root buses Jiang Liu
2013-06-13 18:22 ` Rafael J. Wysocki
2013-06-13 18:24 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 2/9] ACPIPHP: fix device destroying order issue when handling dock notification Jiang Liu
2013-06-13 19:59 ` Rafael J. Wysocki
2013-06-14 12:23 ` Rafael J. Wysocki
2013-06-14 12:30 ` Alexander E. Patrakov
2013-06-14 12:53 ` Rafael J. Wysocki
2013-06-14 16:58 ` Alexander E. Patrakov
2013-06-14 13:57 ` Jiang Liu [this message]
2013-06-14 14:12 ` Rafael J. Wysocki
2013-06-14 15:30 ` Jiang Liu
2013-06-14 23:12 ` Rafael J. Wysocki
2013-06-14 13:53 ` Jiang Liu
2013-06-14 14:05 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 3/9] ACPI, DOCK: clean up unused module related code Jiang Liu
2013-06-13 18:26 ` Rafael J. Wysocki
2013-06-13 18:39 ` Rafael J. Wysocki
2013-06-14 14:04 ` Jiang Liu
2013-06-14 14:16 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 4/9] ACPI, DOCK: avoid initializing acpi_dock_notifier_list multiple times Jiang Liu
2013-06-13 18:27 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 5/9] ACPI, DOCK: kill redundant spin lock in dock device object Jiang Liu
2013-06-13 18:28 ` Rafael J. Wysocki
2013-06-14 14:05 ` Jiang Liu
2013-06-14 14:16 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 6/9] ACPI, DOCK: mark initialization functions with __init Jiang Liu
2013-06-13 18:29 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 7/9] ACPI, DOCK: simplify implementation of dock_create_acpi_device() Jiang Liu
2013-06-13 16:32 ` [BUGFIX 8/9] ACPI: introduce several helper functions Jiang Liu
2013-06-13 18:36 ` Rafael J. Wysocki
2013-06-13 16:32 ` [BUGFIX 9/9] ACPI: use new helper functions to simpilify code Jiang Liu
2013-06-13 17:34 ` Alexander E. Patrakov
2013-06-13 18:38 ` Rafael J. Wysocki
2013-06-13 17:43 ` [BUGFIX 0/9] Fix bug 59501 and code improvement for dock driver Alexander E. Patrakov
2013-06-13 18:26 ` Alexander E. Patrakov
2013-06-13 18:42 ` Yinghai Lu
2013-06-13 19:02 ` Rafael J. Wysocki
2013-06-13 19:08 ` Yinghai Lu
2013-06-14 2:06 ` Alexander E. Patrakov
2013-06-14 3:22 ` Yinghai Lu
2013-06-14 3:57 ` Alexander E. Patrakov
2013-06-14 2:09 ` Jiang Liu (Gerry)
2013-06-14 2:30 ` Yinghai Lu
2013-06-14 2:40 ` Alexander E. Patrakov
2013-06-14 2:51 ` Jiang Liu (Gerry)
2013-06-14 3:30 ` Yinghai Lu
2013-06-14 3:43 ` Yinghai Lu
2013-06-14 3:56 ` Jiang Liu (Gerry)
2013-06-14 3:53 ` Yinghai Lu
2013-06-14 4:07 ` Alexander E. Patrakov
2013-06-14 4:14 ` Jiang Liu (Gerry)
2013-06-14 4:43 ` Alexander E. Patrakov
2013-06-14 5:11 ` Jiang Liu (Gerry)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51BB213B.7010807@gmail.com \
--to=liuj97@gmail.com \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jiang.liu@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=patrakov@gmail.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rjw@sisk.pl \
--cc=stable@vger.kernel.org \
--cc=wangyijing@huawei.com \
--cc=yinghai@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).