From 4dfa5b6658331ccd3a8ea03fd04fff06b07ea2e9 Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Fri, 20 Nov 2026 06:31:31 -0500 Subject: [PATCH] soc: apple: clpc: offer platform profiles in kernels without ACPI Distribution kernels build without ACPI. ACPI_PLATFORM_PROFILE sat under `if ACPI` and was built only inside drivers/acpi/, so APPLE_CLPC's `select ACPI_PLATFORM_PROFILE if ACPI` did nothing there and the driver skipped devm_platform_profile_register(): no /sys/class/platform-profile on the M5 Pro. The class needs nothing from ACPI. Define the symbol outside `if ACPI`, build platform_profile.o without ACPI too, select it unconditionally, and request it in asahi.config so a distribution build fails loudly if it is ever dropped again. Signed-off-by: Diljit Singh Co-Authored-By: Claude Opus 5.5 --- arch/arm64/configs/asahi.config | 2 ++ drivers/Makefile | 4 ++++ drivers/acpi/Kconfig | 8 +++++--- drivers/acpi/platform_profile.c | 35 +++++++++++++++++++++++++-------- drivers/soc/apple/Kconfig | 2 +- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/arch/arm64/configs/asahi.config b/arch/arm64/configs/asahi.config index 9921de094ba9f..a702e0f0fadfc 100644 --- a/arch/arm64/configs/asahi.config +++ b/arch/arm64/configs/asahi.config @@ -159,6 +159,8 @@ CONFIG_APPLE_T6041_CIO_RECONFIG=y CONFIG_APPLE_PMC=y CONFIG_APPLE_CLUSTER_PWRGATE=y CONFIG_APPLE_CLPC=y +# Its power modes as platform profiles (/sys/class/platform-profile). +CONFIG_ACPI_PLATFORM_PROFILE=y CONFIG_APPLE_MCC=y CONFIG_APPLE_DISPLAY_GATE=y CONFIG_APPLE_PMP=m diff --git a/drivers/Makefile b/drivers/Makefile index 0841ea851847e..9cde182eb67ed 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -31,6 +31,10 @@ obj-y += idle/ obj-y += char/ipmi/ obj-$(CONFIG_ACPI) += acpi/ +# Without ACPI, of drivers/acpi/ only the platform profile class is built. +ifndef CONFIG_ACPI +obj-$(CONFIG_ACPI_PLATFORM_PROFILE) += acpi/platform_profile.o +endif # PnP must come after ACPI since it will eventually need to check if acpi # was used and do nothing if so diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index f165d14cf61a3..0d842f5ef98b5 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -351,9 +351,6 @@ config ACPI_THERMAL To compile this driver as a module, choose M here: the module will be called thermal. -config ACPI_PLATFORM_PROFILE - tristate - config ACPI_CUSTOM_DSDT_FILE string "Custom DSDT Table file to include" default "" @@ -609,6 +606,11 @@ config ACPI_PRMT endif # ACPI +# The class interface (/sys/class/platform-profile) needs nothing from ACPI, +# so device tree platforms without ACPI can select it too. +config ACPI_PLATFORM_PROFILE + tristate + config X86_PM_TIMER bool "Power Management Timer Support" if EXPERT depends on X86 && (ACPI || JAILHOUSE_GUEST) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index f5453b0bdf019..98475a30b5bab 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -193,16 +193,32 @@ static ssize_t profile_show(struct device *dev, static const struct attribute_group platform_profile_group; -/* The legacy /sys/firmware/acpi files exist only where ACPI firmware runs. */ +/* + * The legacy /sys/firmware/acpi files exist only where ACPI firmware runs, + * and never in a kernel built without ACPI. + */ +static struct kobject *platform_profile_legacy_kobj(void) +{ +#ifdef CONFIG_ACPI + return acpi_kobj; +#else + return NULL; +#endif +} + static void platform_profile_legacy_notify(void) { - if (acpi_kobj) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); + struct kobject *kobj = platform_profile_legacy_kobj(); + + if (kobj) + sysfs_notify(kobj, NULL, "platform_profile"); } static int platform_profile_legacy_update(void) { - return acpi_kobj ? sysfs_update_group(acpi_kobj, &platform_profile_group) : 0; + struct kobject *kobj = platform_profile_legacy_kobj(); + + return kobj ? sysfs_update_group(kobj, &platform_profile_group) : 0; } /** @@ -702,6 +718,7 @@ EXPORT_SYMBOL_GPL(devm_platform_profile_register); static int __init platform_profile_init(void) { + struct kobject *kobj = platform_profile_legacy_kobj(); int err; err = class_register(&platform_profile_class); @@ -709,10 +726,10 @@ static int __init platform_profile_init(void) return err; /* Without ACPI firmware (a device tree boot) only the class interface exists. */ - if (!acpi_kobj) + if (!kobj) return 0; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); + err = sysfs_create_group(kobj, &platform_profile_group); if (err) class_unregister(&platform_profile_class); @@ -721,8 +738,10 @@ static int __init platform_profile_init(void) static void __exit platform_profile_exit(void) { - if (acpi_kobj) - sysfs_remove_group(acpi_kobj, &platform_profile_group); + struct kobject *kobj = platform_profile_legacy_kobj(); + + if (kobj) + sysfs_remove_group(kobj, &platform_profile_group); class_unregister(&platform_profile_class); } module_init(platform_profile_init); diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index a0c18035d2168..0a1fb05447840 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -318,7 +318,7 @@ config APPLE_CLPC depends on ARCH_APPLE || COMPILE_TEST depends on APPLE_PMC && CPU_FREQ depends on MFD_MACSMC || !MFD_MACSMC - select ACPI_PLATFORM_PROFILE if ACPI + select ACPI_PLATFORM_PROFILE default ARCH_APPLE help Raises the DRAM controller and SoC fabric performance floors of the