From: Yinghai Lu <yinghai@kernel.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
"Alexander E . Patrakov" <patrakov@gmail.com>,
Jiang Liu <jiang.liu@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Yijing Wang <wangyijing@huawei.com>, Jiang Liu <liuj97@gmail.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] ACPI / dock / PCI: Synchronous handling of dock events for PCI devices
Date: Sat, 22 Jun 2013 17:22:20 -0700 [thread overview]
Message-ID: <CAE9FiQV7R5mQKEFx+JhE7E1MjWSSxe2+WeK0aN_hVh6sZJ2GdQ@mail.gmail.com> (raw)
In-Reply-To: <15269989.ojxutYs2L1@vostro.rjw.lan>
On Sat, Jun 22, 2013 at 2:25 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> To resolve that deadlock use the observation that
> unregister_hotplug_dock_device() won't need to acquire hp_lock
> if PCI bridges the devices on the dock station depend on are
> prevented from being removed prematurely while the first loop in
> hotplug_dock_devices() is in progress.
>
> To make that possible, introduce a mechanism by which the callers of
> register_hotplug_dock_device() can provide "init" and "release"
> routines that will be executed, respectively, after the addition
> and removal of the physical device object associated with the
> given ACPI device handle. Make acpiphp use two new functions,
> acpiphp_dock_init() and acpiphp_dock_release(), respectively,
> calling get_bridge() and put_bridge() on the PCI bridge holding the
> given device, respectively, for this purpose.
>
> In addition to that, remove the dock station's list of
> "hotplug devices" and make the dock code always walk the whole list
> of "dependent devices" instead in such a way that the loops in
> hotplug_dock_devices() and dock_event() (replacing the loops over
> "hotplug devices") will take references to the list entries that
> register_hotplug_dock_device() has been called for. That prevents
> the "release" routines associated with those entries from being
> called while the given entry is being processed and for PCI
> devices this means that their bridges won't be removed (by a
> concurrent thread) while hotplug_event_func() handling them is
> being executed.
..
> -static void
> -dock_del_hotplug_device(struct dock_station *ds,
> - struct dock_dependent_device *dd)
> +static void dock_release_hotplug(struct dock_dependent_device *dd)
> {
> - mutex_lock(&ds->hp_lock);
> - list_del(&dd->hotplug_list);
> - mutex_unlock(&ds->hp_lock);
> + void (*release)(void *) = NULL;
> + void *context = NULL;
> +
> + mutex_lock(&hotplug_lock);
> +
> + if (dd->hp_context && !--dd->hp_refcount) {
> + dd->hp_ops = NULL;
> + context = dd->hp_context;
> + dd->hp_context = NULL;
> + release = dd->hp_release;
> + dd->hp_release = NULL;
> + }
> +
> + if (release && context)
> + release(context);
> +
> + mutex_unlock(&hotplug_lock);
> +}
> +
> +static void dock_hotplug_event(struct dock_dependent_device *dd, u32 event,
> + bool uevent)
> +{
> + acpi_notify_handler cb = NULL;
> + bool run = false;
> +
> + mutex_lock(&hotplug_lock);
> +
> + if (dd->hp_context) {
> + run = true;
> + dd->hp_refcount++;
> + if (dd->hp_ops)
> + cb = uevent ? dd->hp_ops->uevent : dd->hp_ops->handler;
> + }
> +
> + mutex_unlock(&hotplug_lock);
> +
> + if (!run)
> + return;
> +
> + if (cb)
> + cb(dd->handle, event, dd->hp_context);
> +
> + dock_release_hotplug(dd);
during DOCKING, dock_release_hotplug get called too?
Yinghai
next prev parent reply other threads:[~2013-06-23 0:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-22 21:19 [PATCH 0/3] ACPI / dock / PCI: Fix problems with dock and PCI hotplug Rafael J. Wysocki
2013-06-22 21:21 ` [PATCH 1/3] ACPI / dock: Initialize ACPI dock subsystem upfront Rafael J. Wysocki
2013-06-22 21:39 ` Yinghai Lu
2013-06-22 21:22 ` [PATCH 2/3] PCI / ACPI: Use boot-time resource allocation rules during hotplug Rafael J. Wysocki
2013-06-22 21:25 ` [PATCH 3/3] ACPI / dock / PCI: Synchronous handling of dock events for PCI devices Rafael J. Wysocki
2013-06-23 0:22 ` Yinghai Lu [this message]
2013-06-23 9:59 ` Rafael J. Wysocki
2013-06-23 19:49 ` Yinghai Lu
2013-06-23 15:54 ` Jiang Liu
2013-06-23 19:57 ` Yinghai Lu
2013-06-23 20:29 ` Yinghai Lu
2013-06-23 21:42 ` [Update][PATCH " Rafael J. Wysocki
2013-06-23 23:04 ` Yinghai Lu
2013-06-24 0:40 ` Rafael J. Wysocki
2013-06-24 4:34 ` Yinghai Lu
2013-06-24 9:55 ` Rafael J. Wysocki
2013-06-22 21:43 ` [PATCH 0/3] ACPI / dock / PCI: Fix problems with dock and PCI hotplug Illya Klymov
2013-06-22 23:26 ` Rafael J. Wysocki
2013-06-23 17:50 ` Alexander E. Patrakov
2013-06-23 21:25 ` Rafael J. Wysocki
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=CAE9FiQV7R5mQKEFx+JhE7E1MjWSSxe2+WeK0aN_hVh6sZJ2GdQ@mail.gmail.com \
--to=yinghai@kernel.org \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jiang.liu@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=liuj97@gmail.com \
--cc=patrakov@gmail.com \
--cc=rjw@sisk.pl \
--cc=wangyijing@huawei.com \
/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).