Commit 275c58d77062bbb85dbeb3843ba04f34aa50cf8e

Authored by Toshi Kani
Committed by Len Brown
1 parent f8f5701bda

ACPI: Add an interface to evaluate _OST

Added acpi_evaluate_hotplug_opt(). All ACPI hotplug handlers must call
this function when evaluating _OST for hotplug operations. If the
platform does not support _OST, this function returns AE_NOT_FOUND and
has no effect on the platform.

ACPI_HOTPLUG_OST is defined when all relevant ACPI hotplug operations,
such as CPU, memory and container hotplug, are enabled. This assures
consistent behavior among the hotplug operations with regarding the
_OST support. When ACPI_HOTPLUG_OST is not defined, this function is
a no-op.

ACPI PCI hotplug is not enhanced to support _OST at this time since it
is a legacy method being replaced by PCIe native hotplug. _OST support
for ACPI PCI hotplug may be added in future if necessary.

Some platforms may require the OS to support _OST in order to support
ACPI hotplug operations. For example, if a platform has the management
console where user can request a hotplug operation from, this _OST
support would be required for the management console to show the result
of the hotplug request to user.

Added macro definitions of _OST source events and status codes.
Also renamed OSC_SB_CPUHP_OST_SUPPORT to OSC_SB_HOTPLUG_OST_SUPPORT
since this _OSC bit is not specific to CPU hotplug. This bit is
defined in Table 6-147 of ACPI 5.0 as follows.

  Bits:       3
  Field Name: Insertion / Ejection _OST Processing Support
  Definition: This bit is set if OSPM will evaluate the _OST
              object defined under a device when processing
              insertion and ejection source event codes.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>

Showing 3 changed files with 84 additions and 1 deletions Side-by-side Diff

drivers/acpi/utils.c
... ... @@ -412,4 +412,46 @@
412 412 return status;
413 413 }
414 414 EXPORT_SYMBOL(acpi_get_physical_device_location);
  415 +
  416 +/**
  417 + * acpi_evaluate_hotplug_ost: Evaluate _OST for hotplug operations
  418 + * @handle: ACPI device handle
  419 + * @source_event: source event code
  420 + * @status_code: status code
  421 + * @status_buf: optional detailed information (NULL if none)
  422 + *
  423 + * Evaluate _OST for hotplug operations. All ACPI hotplug handlers
  424 + * must call this function when evaluating _OST for hotplug operations.
  425 + * When the platform does not support _OST, this function has no effect.
  426 + */
  427 +acpi_status
  428 +acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
  429 + u32 status_code, struct acpi_buffer *status_buf)
  430 +{
  431 +#ifdef ACPI_HOTPLUG_OST
  432 + union acpi_object params[3] = {
  433 + {.type = ACPI_TYPE_INTEGER,},
  434 + {.type = ACPI_TYPE_INTEGER,},
  435 + {.type = ACPI_TYPE_BUFFER,}
  436 + };
  437 + struct acpi_object_list arg_list = {3, params};
  438 + acpi_status status;
  439 +
  440 + params[0].integer.value = source_event;
  441 + params[1].integer.value = status_code;
  442 + if (status_buf != NULL) {
  443 + params[2].buffer.pointer = status_buf->pointer;
  444 + params[2].buffer.length = status_buf->length;
  445 + } else {
  446 + params[2].buffer.pointer = NULL;
  447 + params[2].buffer.length = 0;
  448 + }
  449 +
  450 + status = acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
  451 + return status;
  452 +#else
  453 + return AE_OK;
  454 +#endif
  455 +}
  456 +EXPORT_SYMBOL(acpi_evaluate_hotplug_ost);
include/acpi/acpi_bus.h
... ... @@ -50,6 +50,9 @@
50 50 acpi_string pathname,
51 51 struct acpi_object_list *arguments,
52 52 struct acpi_handle_list *list);
  53 +acpi_status
  54 +acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
  55 + u32 status_code, struct acpi_buffer *status_buf);
53 56  
54 57 struct acpi_pld {
55 58 unsigned int revision:7; /* 0 */
include/linux/acpi.h
... ... @@ -277,7 +277,7 @@
277 277 #define OSC_SB_PAD_SUPPORT 1
278 278 #define OSC_SB_PPC_OST_SUPPORT 2
279 279 #define OSC_SB_PR3_SUPPORT 4
280   -#define OSC_SB_CPUHP_OST_SUPPORT 8
  280 +#define OSC_SB_HOTPLUG_OST_SUPPORT 8
281 281 #define OSC_SB_APEI_SUPPORT 16
282 282  
283 283 extern bool osc_sb_apei_support_acked;
... ... @@ -309,6 +309,44 @@
309 309  
310 310 extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
311 311 u32 *mask, u32 req);
  312 +
  313 +/* Enable _OST when all relevant hotplug operations are enabled */
  314 +#if defined(CONFIG_ACPI_HOTPLUG_CPU) && \
  315 + (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \
  316 + defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) && \
  317 + (defined(CONFIG_ACPI_CONTAINER) || \
  318 + defined(CONFIG_ACPI_CONTAINER_MODULE))
  319 +#define ACPI_HOTPLUG_OST
  320 +#endif
  321 +
  322 +/* _OST Source Event Code (OSPM Action) */
  323 +#define ACPI_OST_EC_OSPM_SHUTDOWN 0x100
  324 +#define ACPI_OST_EC_OSPM_EJECT 0x103
  325 +#define ACPI_OST_EC_OSPM_INSERTION 0x200
  326 +
  327 +/* _OST General Processing Status Code */
  328 +#define ACPI_OST_SC_SUCCESS 0x0
  329 +#define ACPI_OST_SC_NON_SPECIFIC_FAILURE 0x1
  330 +#define ACPI_OST_SC_UNRECOGNIZED_NOTIFY 0x2
  331 +
  332 +/* _OST OS Shutdown Processing (0x100) Status Code */
  333 +#define ACPI_OST_SC_OS_SHUTDOWN_DENIED 0x80
  334 +#define ACPI_OST_SC_OS_SHUTDOWN_IN_PROGRESS 0x81
  335 +#define ACPI_OST_SC_OS_SHUTDOWN_COMPLETED 0x82
  336 +#define ACPI_OST_SC_OS_SHUTDOWN_NOT_SUPPORTED 0x83
  337 +
  338 +/* _OST Ejection Request (0x3, 0x103) Status Code */
  339 +#define ACPI_OST_SC_EJECT_NOT_SUPPORTED 0x80
  340 +#define ACPI_OST_SC_DEVICE_IN_USE 0x81
  341 +#define ACPI_OST_SC_DEVICE_BUSY 0x82
  342 +#define ACPI_OST_SC_EJECT_DEPENDENCY_BUSY 0x83
  343 +#define ACPI_OST_SC_EJECT_IN_PROGRESS 0x84
  344 +
  345 +/* _OST Insertion Request (0x200) Status Code */
  346 +#define ACPI_OST_SC_INSERT_IN_PROGRESS 0x80
  347 +#define ACPI_OST_SC_DRIVER_LOAD_FAILURE 0x81
  348 +#define ACPI_OST_SC_INSERT_NOT_SUPPORTED 0x82
  349 +
312 350 extern void acpi_early_init(void);
313 351  
314 352 extern int acpi_nvs_register(__u64 start, __u64 size);