Message ID | 2547688.l8Q1XKb3Ol@vostro.rjw.lan (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
Hi Rafael, Replying to this mail may be wrong. Do you remember following your patch? http://lkml.org/lkml/2013/2/23/97 I want to add autoeject variable in acpi_hotplug_profile structure and set autoecjet of container device "false". Currently, I have a problem on ejecting container device. Since linux-3.12, container device is removed by acpi_scan_hot_remove. I think this has two problems. 1. easily fail My container device has CPU device and Memory device, and maximum size of memory is 3Tbyte. In my environment, hot removing container device fails on offlining memory if memory is used by application. I think if offlininig memory, we must retly to offline memory several times. 2. cannot work with userland's application Hot removing CPU and memory on container device, we need take care of userland application. Before linux-3.12, container device just notifies KOBJ_OFFLINE to udev. So by using udev, if application binds to removed CPU or node, applications can change them before hot removing container device. Currently, KOBJ_OFFLINE is notified to udev. But acpi_scan_hot_remove also runs simultaneously for hot removing container device. So when applications runs for corresponding to the deletion of the devices, the devices may have been deleted. I don't know what devices are on hotpluggable conatainer device of other vendors. At least, my container device cannot be hot removed correctly. Then I want to add autoeject variable in acpi_hotplug_profile so that user can change the parameter to "true" or "false". Thanks, Yasuaki Ishimatsu (2013/11/18 1:36), Rafael J. Wysocki wrote: > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > > Move container-specific uevents from the core hotplug code to the > container scan handler's .attach() and .detach() callbacks. > > This way the core will not have to special-case containers and > the uevents will be guaranteed to happen every time a container > is either scanned or trimmed as appropriate. > > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > drivers/acpi/container.c | 11 ++++++++--- > drivers/acpi/scan.c | 8 +------- > include/acpi/acpi_bus.h | 7 ------- > 3 files changed, 9 insertions(+), 17 deletions(-) > > Index: linux-pm/drivers/acpi/container.c > =================================================================== > --- linux-pm.orig/drivers/acpi/container.c > +++ linux-pm/drivers/acpi/container.c > @@ -44,19 +44,24 @@ static const struct acpi_device_id conta > {"", 0}, > }; > > -static int container_device_attach(struct acpi_device *device, > +static int container_device_attach(struct acpi_device *adev, > const struct acpi_device_id *not_used) > { > - /* This is necessary for container hotplug to work. */ > + kobject_uevent(&adev->dev.kobj, KOBJ_ONLINE); > return 1; > } > > +static void container_device_detach(struct acpi_device *adev) > +{ > + kobject_uevent(&adev->dev.kobj, KOBJ_OFFLINE); > +} > + > static struct acpi_scan_handler container_handler = { > .ids = container_device_ids, > .attach = container_device_attach, > + .detach = container_device_detach, > .hotplug = { > .enabled = true, > - .mode = AHM_CONTAINER, > }, > }; > > Index: linux-pm/drivers/acpi/scan.c > =================================================================== > --- linux-pm.orig/drivers/acpi/scan.c > +++ linux-pm/drivers/acpi/scan.c > @@ -206,9 +206,6 @@ static int acpi_scan_hot_remove(struct a > acpi_status status; > unsigned long long sta; > > - if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) > - kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); > - > /* > * Carry out two passes here and ignore errors in the first pass, > * because if the devices in question are memory blocks and > @@ -288,10 +285,7 @@ static int acpi_scan_device_check(struct > dev_warn(&adev->dev, "Namespace scan failure\n"); > return error; > } > - if (adev->handler) { > - if (adev->handler->hotplug.mode == AHM_CONTAINER) > - kobject_uevent(&adev->dev.kobj, KOBJ_ONLINE); > - } else { > + if (!adev->handler) { > dev_warn(&adev->dev, "Enumeration failure\n"); > return -ENODEV; > } > Index: linux-pm/include/acpi/acpi_bus.h > =================================================================== > --- linux-pm.orig/include/acpi/acpi_bus.h > +++ linux-pm/include/acpi/acpi_bus.h > @@ -91,16 +91,9 @@ struct acpi_device; > * ----------------- > */ > > -enum acpi_hotplug_mode { > - AHM_GENERIC = 0, > - AHM_CONTAINER, > - AHM_COUNT > -}; > - > struct acpi_hotplug_profile { > struct kobject kobj; > bool enabled:1; > - enum acpi_hotplug_mode mode; > int (*scan_dependent)(struct acpi_device *adev); > }; > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Friday, November 29, 2013 11:36:55 AM Yasuaki Ishimatsu wrote: > Hi Rafael, Hi, > Replying to this mail may be wrong. OK, so this particular patch doesn't break things any more? > Do you remember following your patch? > http://lkml.org/lkml/2013/2/23/97 > > I want to add autoeject variable in acpi_hotplug_profile structure and > set autoecjet of container device "false". Then after the series the $subject patch belongs to it will work almost the same way as /sys/firmware/acpi/container/enabled (hot add will still work after patch [4/10] if "enabled" is 0), but only for containers. > Currently, I have a problem on ejecting container device. Since linux-3.12, > container device is removed by acpi_scan_hot_remove. > > I think this has two problems. > > 1. easily fail > My container device has CPU device and Memory device, and maximum size of > memory is 3Tbyte. In my environment, hot removing container device fails > on offlining memory if memory is used by application. > I think if offlininig memory, we must retly to offline memory several > times. Yes, that's correct. But then you can try to offline the memory upfront and only remove the container after that has been successful. > 2. cannot work with userland's application > Hot removing CPU and memory on container device, we need take care of > userland application. Before linux-3.12, container device just notifies > KOBJ_OFFLINE to udev. So by using udev, if application binds to removed > CPU or node, applications can change them before hot removing container > device. > Currently, KOBJ_OFFLINE is notified to udev. But acpi_scan_hot_remove > also runs simultaneously for hot removing container device. So when > applications runs for corresponding to the deletion of the devices, > the devices may have been deleted. So the expectation is that the container will refuse to offline, but instead it will emit KOBJ_OFFLINE so that user space can do some cleanup and offline it through the "eject" attribute, right? > I don't know what devices are on hotpluggable conatainer device of other > vendors. At least, my container device cannot be hot removed correctly. > Then I want to add autoeject variable in acpi_hotplug_profile so that user > can change the parameter to "true" or "false". I have a different idea. Why don't we create a bus type for containers in analogy with CPUs and memory and make it support offline. Then, the container scan handler will create a "physical" container device under that bus type and the new bus type code will implement the logic you need (that is, it will have a sysfs flag that will cause the offline to fail emitting a uevent of some sort if set and will allow the offline to happen when unset). That "physical" container device will go away (again, via the container scan handler) during container removal. The eject work flow can be: (1) an eject event occurs, (2) the container "physical" device fails offline in acpi_scan_hot_remove() emmitting, say, KOBJ_CHANGE for the "physical" device, (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, (4) user space changes the "physical" container device flag controlling offline to 0, (5) user space uses the sysfs "eject" attribute of the ACPI container object to finally eject the container, (6) the offline in acpi_scan_hot_remove() is now successful, because the flag controlling it has been set to 0 in step (4), (7) the "physical" container device goes away before executing _EJ0, (8) the container is ejected. Of course, if the flag controlling container offline is 0 to start with, step (6) will now occur directly after (1), so whoever wants containers to be hot-removed automatically may just clear that flag for all of them on boot. How does that sound? Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
(2013/11/29 22:08), Rafael J. Wysocki wrote: > On Friday, November 29, 2013 11:36:55 AM Yasuaki Ishimatsu wrote: >> Hi Rafael, > > Hi, > >> Replying to this mail may be wrong. > > OK, so this particular patch doesn't break things any more? Yes. > >> Do you remember following your patch? >> http://lkml.org/lkml/2013/2/23/97 >> >> I want to add autoeject variable in acpi_hotplug_profile structure and >> set autoecjet of container device "false". > > Then after the series the $subject patch belongs to it will work almost the > same way as /sys/firmware/acpi/container/enabled (hot add will still work after > patch [4/10] if "enabled" is 0), but only for containers. > >> Currently, I have a problem on ejecting container device. Since linux-3.12, >> container device is removed by acpi_scan_hot_remove. >> >> I think this has two problems. >> >> 1. easily fail >> My container device has CPU device and Memory device, and maximum size of >> memory is 3Tbyte. In my environment, hot removing container device fails >> on offlining memory if memory is used by application. >> I think if offlininig memory, we must retly to offline memory several >> times. > > Yes, that's correct. But then you can try to offline the memory upfront > and only remove the container after that has been successful. > >> 2. cannot work with userland's application >> Hot removing CPU and memory on container device, we need take care of >> userland application. Before linux-3.12, container device just notifies >> KOBJ_OFFLINE to udev. So by using udev, if application binds to removed >> CPU or node, applications can change them before hot removing container >> device. >> Currently, KOBJ_OFFLINE is notified to udev. But acpi_scan_hot_remove >> also runs simultaneously for hot removing container device. So when >> applications runs for corresponding to the deletion of the devices, >> the devices may have been deleted. > > So the expectation is that the container will refuse to offline, but instead > it will emit KOBJ_OFFLINE so that user space can do some cleanup and offline > it through the "eject" attribute, right? Yes, that's right. > >> I don't know what devices are on hotpluggable conatainer device of other >> vendors. At least, my container device cannot be hot removed correctly. >> Then I want to add autoeject variable in acpi_hotplug_profile so that user >> can change the parameter to "true" or "false". > > I have a different idea. > > Why don't we create a bus type for containers in analogy with CPUs and memory > and make it support offline. Then, the container scan handler will create a > "physical" container device under that bus type and the new bus type code will > implement the logic you need (that is, it will have a sysfs flag that will > cause the offline to fail emitting a uevent of some sort if set and will allow > the offline to happen when unset). That "physical" container device will go > away (again, via the container scan handler) during container removal. > > The eject work flow can be: > (1) an eject event occurs, > (2) the container "physical" device fails offline in acpi_scan_hot_remove() > emmitting, say, KOBJ_CHANGE for the "physical" device, > (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, > (4) user space changes the "physical" container device flag controlling > offline to 0, > (5) user space uses the sysfs "eject" attribute of the ACPI container object > to finally eject the container, > (6) the offline in acpi_scan_hot_remove() is now successful, because the > flag controlling it has been set to 0 in step (4), > (7) the "physical" container device goes away before executing _EJ0, > (8) the container is ejected. > > Of course, if the flag controlling container offline is 0 to start with, step > (6) will now occur directly after (1), so whoever wants containers to be > hot-removed automatically may just clear that flag for all of them on boot. > > How does that sound? The above ideas are almost O.K. I want kernel to notify user space of KOBJ_OFFLINE. Even if user space catches "KOBJ_CHANGE", user doesn't know whether the notification is offline or not. Thanks, Yasuaki Ishimatsu > Rafael > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tuesday, December 03, 2013 11:46:24 AM Yasuaki Ishimatsu wrote: > (2013/11/29 22:08), Rafael J. Wysocki wrote: > > On Friday, November 29, 2013 11:36:55 AM Yasuaki Ishimatsu wrote: > >> Hi Rafael, > > > > Hi, > > > >> Replying to this mail may be wrong. > > > > OK, so this particular patch doesn't break things any more? > > Yes. > > > > >> Do you remember following your patch? > >> http://lkml.org/lkml/2013/2/23/97 > >> > >> I want to add autoeject variable in acpi_hotplug_profile structure and > >> set autoecjet of container device "false". > > > > Then after the series the $subject patch belongs to it will work almost the > > same way as /sys/firmware/acpi/container/enabled (hot add will still work after > > patch [4/10] if "enabled" is 0), but only for containers. > > > >> Currently, I have a problem on ejecting container device. Since linux-3.12, > >> container device is removed by acpi_scan_hot_remove. > >> > >> I think this has two problems. > >> > >> 1. easily fail > >> My container device has CPU device and Memory device, and maximum size of > >> memory is 3Tbyte. In my environment, hot removing container device fails > >> on offlining memory if memory is used by application. > >> I think if offlininig memory, we must retly to offline memory several > >> times. > > > > Yes, that's correct. But then you can try to offline the memory upfront > > and only remove the container after that has been successful. > > > >> 2. cannot work with userland's application > >> Hot removing CPU and memory on container device, we need take care of > >> userland application. Before linux-3.12, container device just notifies > >> KOBJ_OFFLINE to udev. So by using udev, if application binds to removed > >> CPU or node, applications can change them before hot removing container > >> device. > >> Currently, KOBJ_OFFLINE is notified to udev. But acpi_scan_hot_remove > >> also runs simultaneously for hot removing container device. So when > >> applications runs for corresponding to the deletion of the devices, > >> the devices may have been deleted. > > > > > So the expectation is that the container will refuse to offline, but instead > > it will emit KOBJ_OFFLINE so that user space can do some cleanup and offline > > it through the "eject" attribute, right? > > Yes, that's right. > > > > >> I don't know what devices are on hotpluggable conatainer device of other > >> vendors. At least, my container device cannot be hot removed correctly. > >> Then I want to add autoeject variable in acpi_hotplug_profile so that user > >> can change the parameter to "true" or "false". > > > > I have a different idea. > > > > Why don't we create a bus type for containers in analogy with CPUs and memory > > and make it support offline. Then, the container scan handler will create a > > "physical" container device under that bus type and the new bus type code will > > implement the logic you need (that is, it will have a sysfs flag that will > > cause the offline to fail emitting a uevent of some sort if set and will allow > > the offline to happen when unset). That "physical" container device will go > > away (again, via the container scan handler) during container removal. > > > > > The eject work flow can be: > > (1) an eject event occurs, > > (2) the container "physical" device fails offline in acpi_scan_hot_remove() > > emmitting, say, KOBJ_CHANGE for the "physical" device, > > (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, > > (4) user space changes the "physical" container device flag controlling > > offline to 0, > > (5) user space uses the sysfs "eject" attribute of the ACPI container object > > to finally eject the container, > > (6) the offline in acpi_scan_hot_remove() is now successful, because the > > flag controlling it has been set to 0 in step (4), > > (7) the "physical" container device goes away before executing _EJ0, > > (8) the container is ejected. > > > > Of course, if the flag controlling container offline is 0 to start with, step > > (6) will now occur directly after (1), so whoever wants containers to be > > hot-removed automatically may just clear that flag for all of them on boot. > > > > How does that sound? > > > The above ideas are almost O.K. I want kernel to notify user space of KOBJ_OFFLINE. > Even if user space catches "KOBJ_CHANGE", user doesn't know whether the notification > is offline or not. It is easy to figure out, though. Since the KOBJ_CHANGE will be emitted for container devices only in that situation, user space can see that (1) it is from a container and (2) it is KOBJ_CHANGE, so it must mean "container offline has been attempted". My concern with using KOBJ_OFFLINE for that is that device_offline() emits it too on success and it may be easily confused with the one emitted on failure for containers. Thanks, Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
(2013/12/03 22:15), Rafael J. Wysocki wrote: > On Tuesday, December 03, 2013 11:46:24 AM Yasuaki Ishimatsu wrote: >> (2013/11/29 22:08), Rafael J. Wysocki wrote: >>> On Friday, November 29, 2013 11:36:55 AM Yasuaki Ishimatsu wrote: >>>> Hi Rafael, >>> >>> Hi, >>> >>>> Replying to this mail may be wrong. >>> >>> OK, so this particular patch doesn't break things any more? >> >> Yes. >> >>> >>>> Do you remember following your patch? >>>> http://lkml.org/lkml/2013/2/23/97 >>>> >>>> I want to add autoeject variable in acpi_hotplug_profile structure and >>>> set autoecjet of container device "false". >>> >>> Then after the series the $subject patch belongs to it will work almost the >>> same way as /sys/firmware/acpi/container/enabled (hot add will still work after >>> patch [4/10] if "enabled" is 0), but only for containers. >>> >>>> Currently, I have a problem on ejecting container device. Since linux-3.12, >>>> container device is removed by acpi_scan_hot_remove. >>>> >>>> I think this has two problems. >>>> >>>> 1. easily fail >>>> My container device has CPU device and Memory device, and maximum size of >>>> memory is 3Tbyte. In my environment, hot removing container device fails >>>> on offlining memory if memory is used by application. >>>> I think if offlininig memory, we must retly to offline memory several >>>> times. >>> >>> Yes, that's correct. But then you can try to offline the memory upfront >>> and only remove the container after that has been successful. >>> >>>> 2. cannot work with userland's application >>>> Hot removing CPU and memory on container device, we need take care of >>>> userland application. Before linux-3.12, container device just notifies >>>> KOBJ_OFFLINE to udev. So by using udev, if application binds to removed >>>> CPU or node, applications can change them before hot removing container >>>> device. >>>> Currently, KOBJ_OFFLINE is notified to udev. But acpi_scan_hot_remove >>>> also runs simultaneously for hot removing container device. So when >>>> applications runs for corresponding to the deletion of the devices, >>>> the devices may have been deleted. >>> >> >>> So the expectation is that the container will refuse to offline, but instead >>> it will emit KOBJ_OFFLINE so that user space can do some cleanup and offline >>> it through the "eject" attribute, right? >> >> Yes, that's right. >> >>> >>>> I don't know what devices are on hotpluggable conatainer device of other >>>> vendors. At least, my container device cannot be hot removed correctly. >>>> Then I want to add autoeject variable in acpi_hotplug_profile so that user >>>> can change the parameter to "true" or "false". >>> >>> I have a different idea. >>> >>> Why don't we create a bus type for containers in analogy with CPUs and memory >>> and make it support offline. Then, the container scan handler will create a >>> "physical" container device under that bus type and the new bus type code will >>> implement the logic you need (that is, it will have a sysfs flag that will >>> cause the offline to fail emitting a uevent of some sort if set and will allow >>> the offline to happen when unset). That "physical" container device will go >>> away (again, via the container scan handler) during container removal. >>> >> >>> The eject work flow can be: >>> (1) an eject event occurs, >>> (2) the container "physical" device fails offline in acpi_scan_hot_remove() >>> emmitting, say, KOBJ_CHANGE for the "physical" device, >>> (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, >>> (4) user space changes the "physical" container device flag controlling >>> offline to 0, >>> (5) user space uses the sysfs "eject" attribute of the ACPI container object >>> to finally eject the container, >>> (6) the offline in acpi_scan_hot_remove() is now successful, because the >>> flag controlling it has been set to 0 in step (4), >>> (7) the "physical" container device goes away before executing _EJ0, >>> (8) the container is ejected. >>> >>> Of course, if the flag controlling container offline is 0 to start with, step >>> (6) will now occur directly after (1), so whoever wants containers to be >>> hot-removed automatically may just clear that flag for all of them on boot. >>> >>> How does that sound? >> >> >> The above ideas are almost O.K. I want kernel to notify user space of KOBJ_OFFLINE. >> Even if user space catches "KOBJ_CHANGE", user doesn't know whether the notification >> is offline or not. > > It is easy to figure out, though. Since the KOBJ_CHANGE will be emitted for > container devices only in that situation, user space can see that (1) it is > from a container and (2) it is KOBJ_CHANGE, so it must mean "container offline > has been attempted". > > My concern with using KOBJ_OFFLINE for that is that device_offline() emits it > too on success and it may be easily confused with the one emitted on failure > for containers. I have no objection. Thanks, Yasuaki Ishimatsu > > Thanks, > Rafael > -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Rafael, Please share your more detailed idea. I started to implement the following idea. But the idea has one problem. >>> The eject work flow can be: >>> (1) an eject event occurs, >>> (2) the container "physical" device fails offline in acpi_scan_hot_remove() >>> emmitting, say, KOBJ_CHANGE for the "physical" device, >>> (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, >>> (4) user space changes the "physical" container device flag controlling >>> offline to 0, >>> (5) user space uses the sysfs "eject" attribute of the ACPI container object >>> to finally eject the container, >>> (6) the offline in acpi_scan_hot_remove() is now successful, because the >>> flag controlling it has been set to 0 in step (4), >>> (7) the "physical" container device goes away before executing _EJ0, >>> (8) the container is ejected. I want to emit KOBJ_CHANGE before offlining devices on container device at (2). But acpi_scan_hot_remove() offlines devices on container device at first. So when offline container device, devices on container has been offlined. Thus the idea cannot fulfill my necessary feature. Thanks, Yasauaki Ishimatsu Thanks, Yasauaki Ishimatsu >>> >>> Of course, if the flag controlling container offline is 0 to start with, step >>> (6) will now occur directly after (1), so whoever wants containers to be >>> hot-removed automatically may just clear that flag for all of them on boot. >>> >>> How does that sound? >> >> >> The above ideas are almost O.K. I want kernel to notify user space of KOBJ_OFFLINE. >> Even if user space catches "KOBJ_CHANGE", user doesn't know whether the notification >> is offline or not. > > It is easy to figure out, though. Since the KOBJ_CHANGE will be emitted for > container devices only in that situation, user space can see that (1) it is > from a container and (2) it is KOBJ_CHANGE, so it must mean "container offline > has been attempted". > > My concern with using KOBJ_OFFLINE for that is that device_offline() emits it > too on success and it may be easily confused with the one emitted on failure > for containers. > > Thanks, > Rafael > -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Friday, December 13, 2013 11:56:32 AM Yasuaki Ishimatsu wrote: > Hi Rafael, Hi, > Please share your more detailed idea. I started to implement the following > idea. But the idea has one problem. > > >>> The eject work flow can be: > >>> (1) an eject event occurs, > >>> (2) the container "physical" device fails offline in acpi_scan_hot_remove() > >>> emmitting, say, KOBJ_CHANGE for the "physical" device, > >>> (3) user space notices the KOBJ_CHANGE and does the cleanup as needed, > >>> (4) user space changes the "physical" container device flag controlling > >>> offline to 0, > >>> (5) user space uses the sysfs "eject" attribute of the ACPI container object > >>> to finally eject the container, > >>> (6) the offline in acpi_scan_hot_remove() is now successful, because the > >>> flag controlling it has been set to 0 in step (4), > >>> (7) the "physical" container device goes away before executing _EJ0, > >>> (8) the container is ejected. > > I want to emit KOBJ_CHANGE before offlining devices on container device at (2). > But acpi_scan_hot_remove() offlines devices on container device at first. > So when offline container device, devices on container has been offlined. > > Thus the idea cannot fulfill my necessary feature. Well, in that case we need to treat containers in a special way at the ACPI level. Which is a bit unfortunate so to speak. To that end I'd try to add a new flag to struct acpi_hotplug_profile, say .verify_offline, such that if set, it would cause acpi_scan_hot_remove() to check if all of the "physical" companions of the top-level device are offline to start with, and if not, it would just emit KOBJ_CHANGE for the companions that are not offline and bail out. So the above algorithm would become: (1) an eject event occurs, (2) acpi_scan_hot_remove() checks the verify_offline flag in the target device's scan_handler structure, (3) if set (it would always be set for containers), acpi_scan_hot_remove() checks the status of the target device's "physical" companions; if at least one of them is offline, KOBJ_CHANGE is emitted for that "physical" device, and acpi_scan_hot_remove() returns, [I guess we can just emit KOBJ_CHANGE for the first companion that is not offline at this point.] (4) user space notices the KOBJ_CHANGE and does the cleanup as needed; in the process it carries out the offline operation for the container's "physical" companion (there's only one such companion for each container), [That operation for the container itself is trivial, but to succeed it requires all devices below the container to be taken offline in advance.] (5) user space uses the sysfs "eject" attribute of the ACPI container object to finally eject the container, (6) acpi_scan_hot_remove() is now successful, because the container's "physical" companion is now offline, (7) the "physical" container device goes away before executing _EJ0, (8) the container is ejected. I think that should work for you. Thanks, Rafael -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Index: linux-pm/drivers/acpi/container.c =================================================================== --- linux-pm.orig/drivers/acpi/container.c +++ linux-pm/drivers/acpi/container.c @@ -44,19 +44,24 @@ static const struct acpi_device_id conta {"", 0}, }; -static int container_device_attach(struct acpi_device *device, +static int container_device_attach(struct acpi_device *adev, const struct acpi_device_id *not_used) { - /* This is necessary for container hotplug to work. */ + kobject_uevent(&adev->dev.kobj, KOBJ_ONLINE); return 1; } +static void container_device_detach(struct acpi_device *adev) +{ + kobject_uevent(&adev->dev.kobj, KOBJ_OFFLINE); +} + static struct acpi_scan_handler container_handler = { .ids = container_device_ids, .attach = container_device_attach, + .detach = container_device_detach, .hotplug = { .enabled = true, - .mode = AHM_CONTAINER, }, }; Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -206,9 +206,6 @@ static int acpi_scan_hot_remove(struct a acpi_status status; unsigned long long sta; - if (device->handler && device->handler->hotplug.mode == AHM_CONTAINER) - kobject_uevent(&device->dev.kobj, KOBJ_OFFLINE); - /* * Carry out two passes here and ignore errors in the first pass, * because if the devices in question are memory blocks and @@ -288,10 +285,7 @@ static int acpi_scan_device_check(struct dev_warn(&adev->dev, "Namespace scan failure\n"); return error; } - if (adev->handler) { - if (adev->handler->hotplug.mode == AHM_CONTAINER) - kobject_uevent(&adev->dev.kobj, KOBJ_ONLINE); - } else { + if (!adev->handler) { dev_warn(&adev->dev, "Enumeration failure\n"); return -ENODEV; } Index: linux-pm/include/acpi/acpi_bus.h =================================================================== --- linux-pm.orig/include/acpi/acpi_bus.h +++ linux-pm/include/acpi/acpi_bus.h @@ -91,16 +91,9 @@ struct acpi_device; * ----------------- */ -enum acpi_hotplug_mode { - AHM_GENERIC = 0, - AHM_CONTAINER, - AHM_COUNT -}; - struct acpi_hotplug_profile { struct kobject kobj; bool enabled:1; - enum acpi_hotplug_mode mode; int (*scan_dependent)(struct acpi_device *adev); };