]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ACPI / scan: Indicate to platform when hot remove returns busy
authorLee, Chun-Yi <joeyli.kernel@gmail.com>
Mon, 3 Jul 2017 13:26:10 +0000 (21:26 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 4 Jul 2017 19:45:41 +0000 (21:45 +0200)
In hotplug logic, it always indicates non-specific failure to
platform through _OST when handing ACPI hot-remove event failed. Then
platform terminates the hot-remove process but it can not identify
the reason.

Base on current hot-remove code, there have two situations that it
returns busy:

 - OSPM try to offline an individual device, but the device offline
   function returns "busy".

 - When the ejection event is applied to an "not offlined yet"
   container.  OSPM sends a kobject change event to userspace and
   returns "busy".

Both of them will returns -EBUSY to ACPI device hotplug function.
Then, the hotplug function indicates non-specific failure to platform
just like for any other error, e.g. -ENODEV or -EIO.

The benefit to the platform for identifying the OS "busy" state is
that it can use a different approach to handle the "busy" instead of
simply terminating the hot-remove operation for an unknown reason.
For example, the platform can wait for a while and then re-trigger
hot-remove.

Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
[ rjw: Changelog massage ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/scan.c

index d53162997f32002828a6db353bcd1926f2a8dc97..ce88175032629cc21a8e6d98d190ee9025b9b741 100644 (file)
@@ -404,10 +404,6 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
                error = dock_notify(adev, src);
        } else if (adev->flags.hotplug_notify) {
                error = acpi_generic_hotplug_event(adev, src);
-               if (error == -EPERM) {
-                       ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
-                       goto err_out;
-               }
        } else {
                int (*notify)(struct acpi_device *, u32);
 
@@ -423,8 +419,20 @@ void acpi_device_hotplug(struct acpi_device *adev, u32 src)
                else
                        goto out;
        }
-       if (!error)
+       switch (error) {
+       case 0:
                ost_code = ACPI_OST_SC_SUCCESS;
+               break;
+       case -EPERM:
+               ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED;
+               break;
+       case -EBUSY:
+               ost_code = ACPI_OST_SC_DEVICE_BUSY;
+               break;
+       default:
+               ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
+               break;
+       }
 
  err_out:
        acpi_evaluate_ost(adev->handle, src, ost_code, NULL);