Skip to content

Commit 314b97c

Browse files
committed
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
5 parents bf978a8 + 0c99923 + 2e433a9 + c42fa24 + e86801b commit 314b97c

10 files changed

Lines changed: 64 additions & 19 deletions

File tree

drivers/acpi/acpica/nswalk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ acpi_ns_walk_namespace(acpi_object_type type,
169169

170170
if (start_node == ACPI_ROOT_OBJECT) {
171171
start_node = acpi_gbl_root_node;
172+
if (!start_node) {
173+
return_ACPI_STATUS(AE_NO_NAMESPACE);
174+
}
172175
}
173176

174177
/* Null child means "get first node" */

drivers/acpi/bus.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ EXPORT_SYMBOL_GPL(osc_pc_lpi_support_confirmed);
283283
bool osc_sb_native_usb4_support_confirmed;
284284
EXPORT_SYMBOL_GPL(osc_sb_native_usb4_support_confirmed);
285285

286+
bool osc_sb_cppc_not_supported;
287+
286288
static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
287289
static void acpi_bus_osc_negotiate_platform_control(void)
288290
{
@@ -332,21 +334,38 @@ static void acpi_bus_osc_negotiate_platform_control(void)
332334
if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
333335
return;
334336

335-
kfree(context.ret.pointer);
337+
capbuf_ret = context.ret.pointer;
338+
if (context.ret.length <= OSC_SUPPORT_DWORD) {
339+
kfree(context.ret.pointer);
340+
return;
341+
}
342+
343+
#ifdef CONFIG_X86
344+
if (boot_cpu_has(X86_FEATURE_HWP))
345+
osc_sb_cppc_not_supported = !(capbuf_ret[OSC_SUPPORT_DWORD] &
346+
(OSC_SB_CPC_SUPPORT | OSC_SB_CPCV2_SUPPORT));
347+
#endif
336348

337-
/* Now run _OSC again with query flag clear */
349+
/*
350+
* Now run _OSC again with query flag clear and with the caps
351+
* supported by both the OS and the platform.
352+
*/
338353
capbuf[OSC_QUERY_DWORD] = 0;
354+
capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD];
355+
kfree(context.ret.pointer);
339356

340357
if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
341358
return;
342359

343360
capbuf_ret = context.ret.pointer;
344-
osc_sb_apei_support_acked =
345-
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
346-
osc_pc_lpi_support_confirmed =
347-
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
348-
osc_sb_native_usb4_support_confirmed =
349-
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
361+
if (context.ret.length > OSC_SUPPORT_DWORD) {
362+
osc_sb_apei_support_acked =
363+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
364+
osc_pc_lpi_support_confirmed =
365+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
366+
osc_sb_native_usb4_support_confirmed =
367+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
368+
}
350369

351370
kfree(context.ret.pointer);
352371
}
@@ -1043,7 +1062,12 @@ struct bus_type acpi_bus_type = {
10431062
.remove = acpi_device_remove,
10441063
.uevent = acpi_device_uevent,
10451064
};
1046-
EXPORT_SYMBOL_GPL(acpi_bus_type);
1065+
1066+
int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data)
1067+
{
1068+
return bus_for_each_dev(&acpi_bus_type, NULL, data, fn);
1069+
}
1070+
EXPORT_SYMBOL_GPL(acpi_bus_for_each_dev);
10471071

10481072
/* --------------------------------------------------------------------------
10491073
Initialization/Cleanup

drivers/acpi/cppc_acpi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
656656
acpi_status status;
657657
int ret = -EFAULT;
658658

659+
if (osc_sb_cppc_not_supported)
660+
return -ENODEV;
661+
659662
/* Parse the ACPI _CPC table for this CPU. */
660663
status = acpi_evaluate_object_typed(handle, "_CPC", NULL, &output,
661664
ACPI_TYPE_PACKAGE);

drivers/acpi/osl.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -642,22 +642,24 @@ u64 acpi_os_get_timer(void)
642642
(ACPI_100NSEC_PER_SEC / HZ);
643643
}
644644

645-
acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
645+
acpi_status acpi_os_read_port(acpi_io_address port, u32 *value, u32 width)
646646
{
647647
u32 dummy;
648648

649-
if (!value)
649+
if (value)
650+
*value = 0;
651+
else
650652
value = &dummy;
651653

652-
*value = 0;
653654
if (width <= 8) {
654-
*(u8 *) value = inb(port);
655+
*value = inb(port);
655656
} else if (width <= 16) {
656-
*(u16 *) value = inw(port);
657+
*value = inw(port);
657658
} else if (width <= 32) {
658-
*(u32 *) value = inl(port);
659+
*value = inl(port);
659660
} else {
660-
BUG();
661+
pr_debug("%s: Access width %d not supported\n", __func__, width);
662+
return AE_BAD_PARAMETER;
661663
}
662664

663665
return AE_OK;
@@ -674,7 +676,8 @@ acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
674676
} else if (width <= 32) {
675677
outl(value, port);
676678
} else {
677-
BUG();
679+
pr_debug("%s: Access width %d not supported\n", __func__, width);
680+
return AE_BAD_PARAMETER;
678681
}
679682

680683
return AE_OK;

drivers/acpi/tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
545545
ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
546546
ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
547547
ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
548-
ACPI_SIG_NHLT, ACPI_SIG_AEST };
548+
ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI };
549549

550550
#define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
551551

drivers/usb/typec/port-mapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int typec_link_ports(struct typec_port *con)
5959
if (!has_acpi_companion(&con->dev))
6060
return 0;
6161

62-
bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);
62+
acpi_bus_for_each_dev(typec_port_match, &arg);
6363
if (!arg.match)
6464
return 0;
6565

include/acpi/acpi_bus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ void acpi_initialize_hp_context(struct acpi_device *adev,
480480
/* acpi_device.dev.bus == &acpi_bus_type */
481481
extern struct bus_type acpi_bus_type;
482482

483+
int acpi_bus_for_each_dev(int (*fn)(struct device *, void *), void *data);
484+
483485
/*
484486
* Events
485487
* ------

include/acpi/actypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,12 @@ typedef u64 acpi_integer;
507507
/* Pointer/Integer type conversions */
508508

509509
#define ACPI_TO_POINTER(i) ACPI_CAST_PTR (void, (acpi_size) (i))
510+
#ifndef ACPI_TO_INTEGER
510511
#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) 0)
512+
#endif
513+
#ifndef ACPI_OFFSET
511514
#define ACPI_OFFSET(d, f) ACPI_PTR_DIFF (&(((d *) 0)->f), (void *) 0)
515+
#endif
512516
#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i)
513517

514518
/* Optimizations for 4-character (32-bit) acpi_name manipulation */

include/acpi/platform/aclinux.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@
114114
#define acpi_raw_spinlock raw_spinlock_t *
115115
#define acpi_cpu_flags unsigned long
116116

117+
#define acpi_uintptr_t uintptr_t
118+
119+
#define ACPI_TO_INTEGER(p) ((uintptr_t)(p))
120+
#define ACPI_OFFSET(d, f) offsetof(d, f)
121+
117122
/* Use native linux version of acpi_os_allocate_zeroed */
118123

119124
#define USE_NATIVE_ALLOCATE_ZEROED

include/linux/acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
580580
extern bool osc_sb_apei_support_acked;
581581
extern bool osc_pc_lpi_support_confirmed;
582582
extern bool osc_sb_native_usb4_support_confirmed;
583+
extern bool osc_sb_cppc_not_supported;
583584

584585
/* USB4 Capabilities */
585586
#define OSC_USB_USB3_TUNNELING 0x00000001

0 commit comments

Comments
 (0)