From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Toshi Kani <toshi.kani@hp.com>, Yinghai Lu <yinghai@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Aaron Lu <aaron.lu@intel.com>
Subject: Re: [PATCH 1/2][Untested] ACPI / hotplug: Add demand_offline hotplug profile flag
Date: Thu, 26 Dec 2013 12:10:04 +0900 [thread overview]
Message-ID: <52BB9E0C.8020102@jp.fujitsu.com> (raw)
In-Reply-To: <2003756.4bDvk8cJ93@vostro.rjw.lan>
(2013/12/23 23:00), Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Add a new ACPI hotplug profile flag, demand_offline, such that if
> set for the given ACPI device object's scan handler, it will cause
> acpi_scan_hot_remove() to check if that device object's physical
> companions are offline upfront and fail the hot removal if that
> is not the case.
>
> That flag will be useful to overcome a problem with containers on
> some system where they can only be hot-removed after some cleanup
> operations carried out by user space, which needs to be notified
> of the container hot-removal before the kernel attempts to offline
> devices in the container. In those cases the current implementation
> of acpi_scan_hot_remove() is not sufficient, because it first tries
> to offline the devices in the container and only if that is
> suffcessful it tries to offline the container itself. As a result,
> the container hot-removal notification is not delivered to user space
> at the right time.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/acpi/scan.c | 41 +++++++++++++++++++++++++++++++++++++----
> include/acpi/acpi_bus.h | 3 ++-
> 2 files changed, 39 insertions(+), 5 deletions(-)
>
> Index: linux-pm/drivers/acpi/scan.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/scan.c
> +++ linux-pm/drivers/acpi/scan.c
> @@ -126,6 +126,24 @@ acpi_device_modalias_show(struct device
> }
> static DEVICE_ATTR(modalias, 0444, acpi_device_modalias_show, NULL);
>
> +static bool acpi_scan_is_offline(struct acpi_device *adev)
> +{
> + struct acpi_device_physical_node *pn;
> + bool offline = true;
> +
> + mutex_lock(&adev->physical_node_lock);
> +
> + list_for_each_entry(pn, &adev->physical_node_list, node)
> + if (!pn->dev->offline) {
Please check pn->dev->bus and pn->dev->bus->offline too as follow:
if (pn->dev->bus && pn->dev->bus->offline &&
!pn->dev->offline) {
My container has CPU and Memory and PCI root bridge. PCI root bridge
does not has offline function (pn->dev->bus->offline). So I cannot offline
the device and pn->dev->offline of the device is always 0. Therefore,
following operation always returns -EBUSY even if I offline CPUs and
all memory sections on a container device.
echo 0 > /sys/bus/container/devices/ACPI0004:01/online
Thanks,
Yasuaki Ishimatsu
> + kobject_uevent(&pn->dev->kobj, KOBJ_CHANGE);
> + offline = false;
> + break;
> + }
> +
> + mutex_unlock(&adev->physical_node_lock);
> + return offline;
> +}
> +
> static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
> void **ret_p)
> {
> @@ -196,12 +214,11 @@ static acpi_status acpi_bus_online(acpi_
> return AE_OK;
> }
>
> -static int acpi_scan_hot_remove(struct acpi_device *device)
> +static int acpi_scan_try_to_offline(struct acpi_device *device)
> {
> acpi_handle handle = device->handle;
> - struct device *errdev;
> + struct device *errdev = NULL;
> acpi_status status;
> - unsigned long long sta;
>
> /*
> * Carry out two passes here and ignore errors in the first pass,
> @@ -212,7 +229,6 @@ static int acpi_scan_hot_remove(struct a
> *
> * If the first pass is successful, the second one isn't needed, though.
> */
> - errdev = NULL;
> status = acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
> NULL, acpi_bus_offline, (void *)false,
> (void **)&errdev);
> @@ -241,6 +257,23 @@ static int acpi_scan_hot_remove(struct a
> return -EBUSY;
> }
> }
> + return 0;
> +}
> +
> +static int acpi_scan_hot_remove(struct acpi_device *device)
> +{
> + acpi_handle handle = device->handle;
> + unsigned long long sta;
> + acpi_status status;
> +
> + if (device->handler->hotplug.demand_offline && !acpi_force_hot_remove) {
> + if (!acpi_scan_is_offline(device))
> + return -EBUSY;
> + } else {
> + int error = acpi_scan_try_to_offline(device);
> + if (error)
> + return error;
> + }
>
> ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> "Hot-removing device %s...\n", dev_name(&device->dev)));
> Index: linux-pm/include/acpi/acpi_bus.h
> ===================================================================
> --- linux-pm.orig/include/acpi/acpi_bus.h
> +++ linux-pm/include/acpi/acpi_bus.h
> @@ -91,8 +91,9 @@ struct acpi_device;
>
> struct acpi_hotplug_profile {
> struct kobject kobj;
> - bool enabled:1;
> int (*scan_dependent)(struct acpi_device *adev);
> + bool enabled:1;
> + bool demand_offline:1;
> };
>
> static inline struct acpi_hotplug_profile *to_acpi_hotplug_profile(
>
next prev parent reply other threads:[~2013-12-26 3:10 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-17 16:29 [PATCH 0/10] ACPI: Device objects for all namespace nodes and PCI root hotplug integration Rafael J. Wysocki
2013-11-17 16:31 ` [PATCH 1/10] ACPICA: Delete all attached data objects on node deletion Rafael J. Wysocki
2013-11-17 16:31 ` [PATCH 2/10] ACPI / scan: Define non-empty device removal handler Rafael J. Wysocki
2013-11-17 16:33 ` [PATCH 3/10] ACPI / scan: Add acpi_device objects for all device nodes in the namespace Rafael J. Wysocki
2013-11-17 16:33 ` [PATCH 4/10] ACPI / hotplug: Do not fail bus and device checks for disabled hotplug Rafael J. Wysocki
2013-11-17 16:34 ` [PATCH 5/10] ACPI / hotplug: Introduce common hotplug function acpi_device_hotplug() Rafael J. Wysocki
2013-11-17 16:35 ` [PATCH 6/10] ACPI / hotplug: Make ACPI PCI root hotplug use common hotplug code Rafael J. Wysocki
2013-11-17 16:36 ` [PATCH 7/10] ACPI / hotplug: Move container-specific code out of the core Rafael J. Wysocki
2013-11-29 2:36 ` Yasuaki Ishimatsu
2013-11-29 13:08 ` Rafael J. Wysocki
2013-12-03 2:46 ` Yasuaki Ishimatsu
2013-12-03 13:15 ` Rafael J. Wysocki
2013-12-04 5:43 ` Yasuaki Ishimatsu
2013-12-13 2:56 ` Yasuaki Ishimatsu
2013-12-13 4:56 ` Rafael J. Wysocki
2013-12-13 5:17 ` Yasuaki Ishimatsu
2013-12-14 5:07 ` Rafael J. Wysocki
2013-12-23 13:58 ` Rafael J. Wysocki
2013-12-23 14:00 ` [PATCH 1/2][Untested] ACPI / hotplug: Add demand_offline hotplug profile flag Rafael J. Wysocki
2013-12-26 3:10 ` Yasuaki Ishimatsu [this message]
2013-12-26 4:10 ` Yasuaki Ishimatsu
2013-12-27 0:58 ` Rafael J. Wysocki
2013-12-27 5:18 ` Yasuaki Ishimatsu
2013-12-27 5:34 ` Yasuaki Ishimatsu
2013-12-27 11:52 ` Rafael J. Wysocki
2013-12-27 11:51 ` Rafael J. Wysocki
2013-12-27 22:21 ` [PATCH 0/2] ACPI / hotplug / driver core: Special handling for container devices Rafael J. Wysocki
2013-12-27 22:23 ` [PATCH 1/2] ACPI / hotplug: Add demand_offline hotplug profile flag Rafael J. Wysocki
2013-12-27 22:28 ` [PATCH 2/2] ACPI / hotplug / driver core: Handle containers in a special way Rafael J. Wysocki
2013-12-29 3:58 ` Greg Kroah-Hartman
2013-12-29 3:59 ` [PATCH 0/2] ACPI / hotplug / driver core: Special handling for container devices Greg Kroah-Hartman
2013-12-29 14:20 ` Rafael J. Wysocki
2013-12-27 0:33 ` [PATCH 1/2][Untested] ACPI / hotplug: Add demand_offline hotplug profile flag Rafael J. Wysocki
2013-12-23 14:02 ` [PATCH 2/2][Untested] ACPI / hotplug / driver core: Handle containers in a special way Rafael J. Wysocki
2013-12-24 0:41 ` [Update][PATCH 2/2] " Rafael J. Wysocki
2013-12-26 1:01 ` [PATCH 7/10] ACPI / hotplug: Move container-specific code out of the core Rafael J. Wysocki
2013-12-26 2:53 ` Yasuaki Ishimatsu
2013-12-27 0:31 ` Rafael J. Wysocki
2013-11-17 16:36 ` [PATCH 8/10] ACPI / hotplug: Rework generic code to handle suprise removals Rafael J. Wysocki
2013-11-17 16:37 ` [PATCH 9/10] ACPI / hotplug: Drop unfinished global notification handling routines Rafael J. Wysocki
2013-11-17 16:38 ` [PATCH 10/10] ACPI: Introduce acpi_set_device_status() Rafael J. Wysocki
2013-11-19 14:30 ` [PATCH 0/10] ACPI: Device objects for all namespace nodes and PCI root hotplug integration Mika Westerberg
2013-11-19 20:51 ` Rafael J. Wysocki
2013-11-19 21:05 ` Mika Westerberg
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=52BB9E0C.8020102@jp.fujitsu.com \
--to=isimatu.yasuaki@jp.fujitsu.com \
--cc=aaron.lu@intel.com \
--cc=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
--cc=toshi.kani@hp.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
Powered by JetHome