linux/drivers/acpi
Rafael J. Wysocki caa73ea158 ACPI / hotplug / driver core: Handle containers in a special way
ACPI container devices require special hotplug handling, at least
on some systems, since generally user space needs to carry out
system-specific cleanup before it makes sense to offline devices in
the container.  However, the current ACPI hotplug code for containers
first attempts to offline devices in the container and only then it
notifies user space of the container offline.

Moreover, after commit 202317a573 (ACPI / scan: Add acpi_device
objects for all device nodes in the namespace), ACPI device objects
representing containers are present as long as the ACPI namespace
nodes corresponding to them are present, which may be forever, even
if the container devices are physically detached from the system (the
return values of the corresponding _STA methods change in those
cases, but generally the namespace nodes themselves are still there).
Thus it is useful to introduce entities representing containers that
will go away during container hot-unplug.

The goal of this change is to address both the above issues.

The idea is to create a "companion" container system device for each
of the ACPI container device objects during the initial namespace
scan or on a hotplug event making the container present.  That system
device will be unregistered on container removal.  A new bus type
for container devices is added for this purpose, because device
offline and online operations need to be defined for them.  The
online operation is a trivial function that is always successful
and the offline uses a callback pointed to by the container device's
offline member.

For ACPI containers that callback simply walks the list of ACPI
device objects right below the container object (its children) and
checks if all of their physical companion devices are offline.  If
that's not the case, it returns -EBUSY and the container system
devivce cannot be put offline.  Consequently, to put the container
system device offline, it is necessary to put all of the physical
devices depending on its ACPI companion object offline beforehand.

Container system devices created for ACPI container objects are
initially online.  They are created by the container ACPI scan
handler whose hotplug.demand_offline flag is set.  That causes
acpi_scan_hot_remove() to check if the companion container system
device is offline before attempting to remove an ACPI container or
any devices below it.  If the check fails, a KOBJ_CHANGE uevent is
emitted for the container system device in question and user space
is expected to offline all devices below the container and the
container itself in response to it.  Then, user space can finalize
the removal of the container with the help of its ACPI device
object's eject attribute in sysfs.

Tested-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-12-29 15:25:48 +01:00
..
acpica Merge branch 'acpica' into acpi-hotplug 2013-11-22 21:48:20 +01:00
apei ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
ac.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
acpi_cmos_rtc.c ACPI: Add CMOS RTC Operation Region handler support 2013-06-27 21:35:37 +02:00
acpi_extlog.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
acpi_ipmi.c ACPI / IPMI: Cleanup coding styles 2013-09-30 19:46:13 +02:00
acpi_lpss.c Merge branch 'acpi-lpss' 2013-11-16 15:45:13 +01:00
acpi_memhotplug.c ACPI / bind: Pass struct acpi_device pointer to acpi_bind_one() 2013-12-07 01:05:50 +01:00
acpi_pad.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
acpi_platform.c ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node 2013-11-14 23:14:43 +01:00
acpi_processor.c ACPI / bind: Pass struct acpi_device pointer to acpi_bind_one() 2013-12-07 01:05:50 +01:00
battery.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
bgrt.c acpi: bgrt: fix build error due to attribute change 2013-08-22 08:34:39 -07:00
blacklist.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
bus.c Merge branch 'acpi-cleanup' into acpi-hotplug 2013-12-07 01:05:17 +01:00
button.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
container.c ACPI / hotplug / driver core: Handle containers in a special way 2013-12-29 15:25:48 +01:00
custom_method.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
debugfs.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
device_pm.c ACPI / scan: Add acpi_device objects for all device nodes in the namespace 2013-11-22 21:54:37 +01:00
dock.c Merge branch 'acpi-cleanup' into acpi-hotplug 2013-12-07 01:05:17 +01:00
ec_sys.c ACPI / EC: access user space with get_user()/put_user() 2013-06-19 23:29:20 +02:00
ec.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
event.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
fan.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
glue.c ACPI / bind: Move acpi_get_child() to drivers/ide/ide-acpi.c 2013-12-07 01:05:50 +01:00
hed.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
internal.h ACPI / hotplug / driver core: Handle containers in a special way 2013-12-29 15:25:48 +01:00
Kconfig Merge branch 'acpi-config' 2013-11-16 15:45:00 +01:00
Makefile ACPI and power management updates for 3.13-rc1 2013-11-14 13:41:48 +09:00
numa.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
nvs.c ACPI / PM: print physical addresses consistently with other parts of kernel 2012-03-30 02:46:57 -04:00
osl.c Merge branch 'acpi-cleanup' into acpi-hotplug 2013-12-07 01:05:17 +01:00
pci_irq.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
pci_link.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
pci_root.c Merge branch 'acpi-cleanup' into acpi-hotplug 2013-12-07 01:05:17 +01:00
pci_slot.c ACPI / PCI: Make bus registration and unregistration symmetric 2013-07-23 03:58:42 +02:00
power.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
proc.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
processor_core.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
processor_driver.c ACPI / processor: Do not request ACPI cpufreq module directly 2013-10-30 00:00:30 +01:00
processor_idle.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
processor_perflib.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
processor_thermal.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
processor_throttling.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
reboot.c Revert "ACPI: ignore FADT reset-reg-sup flag" 2012-04-20 11:19:35 -07:00
resource.c ACPI: introduce helper function acpi_has_method() 2013-07-15 01:33:10 +02:00
sbs.c ACPI / SBS: Remove SBS's proc directory 2013-10-12 00:19:44 +02:00
sbshc.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
sbshc.h
scan.c ACPI / hotplug / driver core: Handle containers in a special way 2013-12-29 15:25:48 +01:00
sleep.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
sleep.h ACPI: Drop power resources driver 2013-01-17 14:11:06 +01:00
sysfs.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
tables.c ACPICA: Cleanup table handler naming conflicts. 2013-01-11 13:10:16 +01:00
thermal.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
utils.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
video_detect.c ACPI / video: Add Lenovo IdeaPad Yoga 13 to acpi video detect blacklist 2013-10-16 01:27:33 +02:00
video.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00
wakeup.c ACPI: Clean up inclusions of ACPI header files 2013-12-07 01:03:14 +01:00