Merge branches 'acpica', 'acpi-osl', 'acpi-bus' and 'acpi-tables'

Merge ACPICA changes, ACPI OS-layer changes, ACPI bus-type and _OSC
support changes and ACPI tables parsing changes for 5.18-rc1:

 - Use uintptr_t and offsetof() in the ACPICA code to avoid compiler
   warnings regarding NULL pointer arithmetic (Rafael Wysocki).

 - Fix possible NULL pointer dereference in acpi_ns_walk_namespace()
   when passed "acpi=off" in the command line (Rafael Wysocki).

 - Fix and clean up acpi_os_read/write_port() (Rafael Wysocki).

 - Introduce acpi_bus_for_each_dev() and use it for walking all ACPI
   device objects in the Type C code (Rafael Wysocki).

 - Fix the _OSC platform capabilities negotioation and prevent CPPC
   from being used if the platform firmware indicates that it not
   supported via _OSC (Rafael Wysocki).

 - Add AGDI and CEDT to the list of known ACPI table signatures (Ilkka
   Koskinen, Robert Kiraly).

* acpica:
  ACPICA: Avoid walking the ACPI Namespace if it is not there
  ACPICA: Use uintptr_t and offsetof() in Linux kernel builds

* acpi-osl:
  ACPI: OSL: Fix and clean up acpi_os_read/write_port()

* acpi-bus:
  ACPI: bus: Avoid using CPPC if not supported by firmware
  Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag"
  ACPI: bus: Introduce acpi_bus_for_each_dev()

* acpi-tables:
  ACPI: tables: Add AGDI to the list of known table signatures
  ACPI: tables: Add CEDT signature to the list of known tables
This commit is contained in:
Rafael J. Wysocki 2022-03-18 17:08:28 +01:00
10 changed files with 64 additions and 19 deletions

View File

@ -169,6 +169,9 @@ acpi_ns_walk_namespace(acpi_object_type type,
if (start_node == ACPI_ROOT_OBJECT) {
start_node = acpi_gbl_root_node;
if (!start_node) {
return_ACPI_STATUS(AE_NO_NAMESPACE);
}
}
/* Null child means "get first node" */

View File

@ -283,6 +283,8 @@ EXPORT_SYMBOL_GPL(osc_pc_lpi_support_confirmed);
bool osc_sb_native_usb4_support_confirmed;
EXPORT_SYMBOL_GPL(osc_sb_native_usb4_support_confirmed);
bool osc_sb_cppc_not_supported;
static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
static void acpi_bus_osc_negotiate_platform_control(void)
{
@ -332,21 +334,38 @@ static void acpi_bus_osc_negotiate_platform_control(void)
if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
return;
kfree(context.ret.pointer);
capbuf_ret = context.ret.pointer;
if (context.ret.length <= OSC_SUPPORT_DWORD) {
kfree(context.ret.pointer);
return;
}
/* Now run _OSC again with query flag clear */
#ifdef CONFIG_X86
if (boot_cpu_has(X86_FEATURE_HWP))
osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD] &
(OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT));
#endif
/*
* Now run _OSC again with query flag clear and with the caps
* supported by both the OS and the platform.
*/
capbuf[OSC_QUERY_DWORD] = 0;
capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD];
kfree(context.ret.pointer);
if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
return;
capbuf_ret = context.ret.pointer;
osc_sb_apei_support_acked =
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
osc_pc_lpi_support_confirmed =
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
osc_sb_native_usb4_support_confirmed =
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
if (context.ret.length > OSC_SUPPORT_DWORD) {
osc_sb_apei_support_acked =
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
osc_pc_lpi_support_confirmed =
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
osc_sb_native_usb4_support_confirmed =
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
}
kfree(context.ret.pointer);
}
@ -1043,7 +1062,12 @@ struct bus_type acpi_bus_type = {
.remove = acpi_device_remove,
.uevent = acpi_device_uevent,
};
EXPORT_SYMBOL_GPL(acpi_bus_type);
int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data)
{
return bus_for_each_dev(&acpi_bus_type, NULL, data, fn);
}
EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev);
/* --------------------------------------------------------------------------
Initialization/Cleanup

View File

@ -656,6 +656,9 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
acpi_status status;
int ret = -EFAULT;
if (osc_sb_cppc_not_supported)
return -ENODEV;
/* Parse the ACPI _CPC table for this CPU. */
status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,
ACPI_TYPE_PACKAGE);

View File

@ -642,22 +642,24 @@ u64 acpi_os_get_timer(void)
(ACPI_100NSEC_PER_SEC / HZ);
}
acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width)
{
u32 dummy;
if (!value)
if (value)
*value = 0;
else
value = &dummy;
*value = 0;
if (width <= 8) {
*(u8 *) value = inb(port);
*value = inb(port);
} else if (width <= 16) {
*(u16 *) value = inw(port);
*value = inw(port);
} else if (width <= 32) {
*(u32 *) value = inl(port);
*value = inl(port);
} else {
BUG();
pr_debug("%s: Access width %d not supported\n", __func__, width);
return AE_BAD_PARAMETER;
}
return AE_OK;
@ -674,7 +676,8 @@ acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
} else if (width <= 32) {
outl(value, port);
} else {
BUG();
pr_debug("%s: Access width %d not supported\n", __func__, width);
return AE_BAD_PARAMETER;
}
return AE_OK;

View File

@ -545,7 +545,7 @@ static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
ACPI_SIG_NHLT, ACPI_SIG_AEST };
ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI };
#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)

View File

@ -59,7 +59,7 @@ int typec_link_ports(struct typec_port *con)
if (!has_acpi_companion(&con->dev))
return 0;
bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);
acpi_bus_for_each_dev(typec_port_match, &arg);
if (!arg.match)
return 0;

View File

@ -480,6 +480,8 @@ void acpi_initialize_hp_context(struct acpi_device *adev,
/* acpi_device.dev.bus == &acpi_bus_type */
extern struct bus_type acpi_bus_type;
int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data);
/*
* Events
* ------

View File

@ -507,8 +507,12 @@ typedef u64 acpi_integer;
/* Pointer/Integer type conversions */
#define ACPI_TO_POINTER(i) ACPI_CAST_PTR (void, (acpi_size) (i))
#ifndef ACPI_TO_INTEGER
#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) 0)
#endif
#ifndef ACPI_OFFSET
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
#endif
#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
/* Optimizations for 4-character (32-bit) acpi_name manipulation */

View File

@ -114,6 +114,11 @@
#define acpi_raw_spinlock raw_spinlock_t *
#define acpi_cpu_flags unsigned long
#define acpi_uintptr_t uintptr_t
#define ACPI_TO_INTEGER(p) ((uintptr_t)(p))
#define ACPI_OFFSET(d, f) offsetof(d, f)
/* Use native linux version of acpi_os_allocate_zeroed */
#define USE_NATIVE_ALLOCATE_ZEROED

View File

@ -580,6 +580,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
extern bool osc_sb_apei_support_acked;
extern bool osc_pc_lpi_support_confirmed;
extern bool osc_sb_native_usb4_support_confirmed;
extern bool osc_sb_cppc_not_supported;
/* USB4 Capabilities */
#define OSC_USB_USB3_TUNNELING 0x00000001