From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: rafael@kernel.org
Cc: "Len Brown" <lenb@kernel.org>, "Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Maximilian Luz" <luzmaximilian@gmail.com>,
"Shyam Sundar S K" <Shyam-sundar.S-k@amd.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
"Derek J. Clark" <derekjohn.clark@gmail.com>,
"Daniel Lezcano" <daniel.lezcano@kernel.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>,
"Jai Luthra" <jai.luthra@ideasonboard.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Armin Wolf" <W_Armin@gmx.de>, "Jack Wu" <jackbb_wu@compal.com>,
"Mario Limonciello (AMD)" <superm1@kernel.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-pm@vger.kernel.org,
platform-driver-x86@vger.kernel.org
Subject: [PATCH v1 2/4] platform profile: Extract the core from ACPI
Date: Wed, 14 Oct 2026 15:24:45 +0200 [thread overview]
Message-ID: <20261014132500.3817549-3-daniel.lezcano@oss.qualcomm.com> (raw)
In-Reply-To: <20261014132500.3817549-1-daniel.lezcano@oss.qualcomm.com>
Platform profile providers already use device-based callbacks and do not
need ACPI types. The core is nevertheless confined to the ACPI build and
refuses to initialize when ACPI is disabled.
Move the implementation to drivers/platform/profile and introduce the
firmware-independent PLATFORM_PROFILE symbol. Update all provider
selectors. Keep provider-specific ACPI dependencies and the
platform_profile module name.
Isolate access to the legacy ACPI kobject in an optional compatibility
object linked into the same module. Retain the legacy ABI on active ACPI
systems, and initialize the class even when ACPI is absent or disabled.
Use subsys_initcall_sync so the class is ready before built-in thermal
and CPUFreq providers, but after ACPI has initialized its compatibility
kobject.
Assisted-by: OpenCode:gpt-6.1-sol
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
---
drivers/acpi/Kconfig | 3 -
drivers/acpi/Makefile | 1 -
drivers/cpufreq/Kconfig.x86 | 2 +-
drivers/platform/Kconfig | 16 +++++
drivers/platform/Makefile | 2 +
drivers/platform/profile/Makefile | 5 ++
drivers/platform/profile/acpi.c | 15 +++++
.../profile/core.c} | 64 +++++++++++++------
drivers/platform/profile/profile.h | 17 +++++
drivers/platform/surface/Kconfig | 6 +-
drivers/platform/x86/Kconfig | 10 +--
drivers/platform/x86/amd/pmf/Kconfig | 2 +-
drivers/platform/x86/dell/Kconfig | 4 +-
drivers/platform/x86/hp/Kconfig | 2 +-
drivers/platform/x86/lenovo/Kconfig | 6 +-
drivers/thermal/intel/int340x_thermal/Kconfig | 2 +-
16 files changed, 118 insertions(+), 39 deletions(-)
create mode 100644 drivers/platform/profile/Makefile
create mode 100644 drivers/platform/profile/acpi.c
rename drivers/{acpi/platform_profile.c => platform/profile/core.c} (94%)
create mode 100644 drivers/platform/profile/profile.h
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index f165d14cf61a..dd00312217de 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 ""
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d1b0affb844f..f8af27341805 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -91,7 +91,6 @@ obj-$(CONFIG_ACPI_PROCESSOR) += processor.o
obj-$(CONFIG_ACPI) += container.o
obj-$(CONFIG_ACPI_THERMAL_LIB) += thermal_lib.o
obj-$(CONFIG_ACPI_THERMAL) += thermal.o
-obj-$(CONFIG_ACPI_PLATFORM_PROFILE) += platform_profile.o
obj-$(CONFIG_ACPI_NFIT) += nfit/
obj-$(CONFIG_ACPI_NHLT) += nhlt.o
obj-$(CONFIG_ACPI_NUMA) += numa/
diff --git a/drivers/cpufreq/Kconfig.x86 b/drivers/cpufreq/Kconfig.x86
index d6190b8dde4b..9e1e3391a084 100644
--- a/drivers/cpufreq/Kconfig.x86
+++ b/drivers/cpufreq/Kconfig.x86
@@ -39,7 +39,7 @@ config X86_AMD_PSTATE
select ACPI_PROCESSOR
select ACPI_CPPC_LIB if X86_64
select CPU_FREQ_GOV_SCHEDUTIL if SMP
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select POWER_SUPPLY
help
This driver adds a CPUFreq driver which utilizes a fine grain
diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig
index 312788f249c9..bc5acd3ebd2f 100644
--- a/drivers/platform/Kconfig
+++ b/drivers/platform/Kconfig
@@ -1,4 +1,20 @@
# SPDX-License-Identifier: GPL-2.0-only
+config PLATFORM_PROFILE
+ tristate "Platform profile support"
+ help
+ Provide a common sysfs interface for selecting platform power,
+ performance and cooling profiles. Platform-specific provider drivers
+ map their operating modes onto standard profile names, independently
+ of the firmware interface they use.
+
+ The core exposes per-provider controls and a system-wide interface
+ for profiles supported by all registered providers. A provider driver
+ must register before profile attributes become available. ACPI is not
+ required; on ACPI systems the legacy sysfs interface is also provided.
+
+ To compile this as a module, choose M here: the module will be called
+ platform_profile.
+
source "drivers/platform/mips/Kconfig"
source "drivers/platform/loongarch/Kconfig"
diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile
index fa322e7f8716..b6732f2f3c85 100644
--- a/drivers/platform/Makefile
+++ b/drivers/platform/Makefile
@@ -3,6 +3,8 @@
# Makefile for linux/drivers/platform
#
+obj-$(CONFIG_PLATFORM_PROFILE) += profile/
+
obj-$(CONFIG_X86) += x86/
obj-$(CONFIG_LOONGARCH) += loongarch/
obj-$(CONFIG_MELLANOX_PLATFORM) += mellanox/
diff --git a/drivers/platform/profile/Makefile b/drivers/platform/profile/Makefile
new file mode 100644
index 000000000000..ae95ba09383c
--- /dev/null
+++ b/drivers/platform/profile/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_PLATFORM_PROFILE) += platform_profile.o
+
+platform_profile-y := core.o
+platform_profile-$(CONFIG_ACPI) += acpi.o
diff --git a/drivers/platform/profile/acpi.c b/drivers/platform/profile/acpi.c
new file mode 100644
index 000000000000..ff925dedacaf
--- /dev/null
+++ b/drivers/platform/profile/acpi.c
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Compatibility with the original ACPI platform profile sysfs ABI. */
+
+#include <linux/acpi.h>
+#include <linux/kobject.h>
+
+#include "profile.h"
+
+struct kobject *platform_profile_compat_kobj(void)
+{
+ if (acpi_disabled)
+ return NULL;
+
+ return kobject_get(acpi_kobj);
+}
diff --git a/drivers/acpi/platform_profile.c b/drivers/platform/profile/core.c
similarity index 94%
rename from drivers/acpi/platform_profile.c
rename to drivers/platform/profile/core.c
index f98ce4cda02c..f18fd96b942c 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/platform/profile/core.c
@@ -4,21 +4,36 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#include <linux/acpi.h>
+#include <linux/bitmap.h>
#include <linux/bits.h>
#include <linux/cleanup.h>
#include <linux/init.h>
+#include <linux/idr.h>
+#include <linux/kobject.h>
#include <linux/list.h>
+#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/platform_profile.h>
+#include <linux/slab.h>
#include <linux/sysfs.h>
+#include "profile.h"
+
#define to_pprof_handler(d) (container_of(d, struct platform_profile_handler, dev))
static DEFINE_MUTEX(profile_lock);
/* Serialize registration and sysfs updates without blocking sysfs callbacks. */
static DEFINE_MUTEX(profile_registration_lock);
static LIST_HEAD(profile_handlers);
+static struct kobject *compat_kobj;
+
+static void profile_notify(void)
+{
+ if (compat_kobj)
+ sysfs_notify(compat_kobj, NULL, "platform_profile");
+}
+
+static int profile_update(void);
struct platform_profile_handler {
struct list_head node;
@@ -237,7 +252,7 @@ static ssize_t profile_store(struct device *dev,
return ret;
}
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ profile_notify();
return count;
}
@@ -452,7 +467,7 @@ static ssize_t platform_profile_store(struct kobject *kobj,
return ret;
}
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ profile_notify();
return count;
}
@@ -478,6 +493,14 @@ static const struct attribute_group platform_profile_group = {
.is_visible = profile_class_is_visible,
};
+static int profile_update(void)
+{
+ if (compat_kobj)
+ return sysfs_update_group(compat_kobj, &platform_profile_group);
+
+ return 0;
+}
+
/**
* platform_profile_notify - Notify class device and legacy sysfs interface
* @dev: The class device
@@ -487,7 +510,7 @@ void platform_profile_notify(struct device *dev)
scoped_cond_guard(mutex_intr, return, &profile_lock) {
_notify_class_profile(dev, NULL);
}
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ profile_notify();
}
EXPORT_SYMBOL_GPL(platform_profile_notify);
@@ -534,7 +557,7 @@ int platform_profile_cycle(void)
return err;
}
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ profile_notify();
return 0;
}
@@ -609,9 +632,9 @@ struct device *platform_profile_register(struct device *dev, const char *name,
scoped_guard(mutex, &profile_lock)
list_add_tail(&to_pprof_handler(ppdev)->node, &profile_handlers);
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ profile_notify();
- err = sysfs_update_group(acpi_kobj, &platform_profile_group);
+ err = profile_update();
if (err)
goto cleanup_cur;
@@ -650,8 +673,8 @@ void platform_profile_remove(struct device *dev)
ida_free(&platform_profile_ida, pprof->minor);
device_unregister(&pprof->dev);
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
- sysfs_update_group(acpi_kobj, &platform_profile_group);
+ profile_notify();
+ profile_update();
}
EXPORT_SYMBOL_GPL(platform_profile_remove);
@@ -699,28 +722,33 @@ static int __init platform_profile_init(void)
{
int err;
- if (acpi_disabled)
- return -EOPNOTSUPP;
-
err = class_register(&platform_profile_class);
if (err)
return err;
- err = sysfs_create_group(acpi_kobj, &platform_profile_group);
- if (err)
- class_unregister(&platform_profile_class);
+ compat_kobj = platform_profile_compat_kobj();
+ if (compat_kobj) {
+ err = sysfs_create_group(compat_kobj, &platform_profile_group);
+ if (err) {
+ kobject_put(compat_kobj);
+ class_unregister(&platform_profile_class);
+ }
+ }
return err;
}
static void __exit platform_profile_exit(void)
{
- sysfs_remove_group(acpi_kobj, &platform_profile_group);
+ if (compat_kobj) {
+ sysfs_remove_group(compat_kobj, &platform_profile_group);
+ kobject_put(compat_kobj);
+ }
class_unregister(&platform_profile_class);
}
-module_init(platform_profile_init);
+subsys_initcall_sync(platform_profile_init);
module_exit(platform_profile_exit);
MODULE_AUTHOR("Mark Pearson <markpearson@lenovo.com>");
-MODULE_DESCRIPTION("ACPI platform profile sysfs interface");
+MODULE_DESCRIPTION("Platform profile sysfs interface");
MODULE_LICENSE("GPL");
diff --git a/drivers/platform/profile/profile.h b/drivers/platform/profile/profile.h
new file mode 100644
index 000000000000..910c9f7da6a0
--- /dev/null
+++ b/drivers/platform/profile/profile.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef _PLATFORM_PROFILE_INTERNAL_H
+#define _PLATFORM_PROFILE_INTERNAL_H
+
+#include <linux/kconfig.h>
+#include <linux/kobject.h>
+
+#ifdef CONFIG_ACPI
+struct kobject *platform_profile_compat_kobj(void);
+#else
+static inline struct kobject *platform_profile_compat_kobj(void)
+{
+ return NULL;
+}
+#endif
+
+#endif
diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig
index f775c6ca1ec1..08f15f72f8ed 100644
--- a/drivers/platform/surface/Kconfig
+++ b/drivers/platform/surface/Kconfig
@@ -203,12 +203,12 @@ config SURFACE_PLATFORM_PROFILE
tristate "Surface Platform Profile Driver"
depends on ACPI
depends on SURFACE_AGGREGATOR_REGISTRY
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
help
- Provides support for the ACPI platform profile on 5th- and later
+ Provides support for platform profiles on 5th- and later
generation Microsoft Surface devices.
- More specifically, this driver provides ACPI platform profile support
+ More specifically, this driver provides platform profile support
on Microsoft Surface devices with a Surface System Aggregator Module
(SSAM) connected via the Surface Serial Hub (SSH / SAM-over-SSH). In
other words, this driver provides platform profile support on the
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index b54b5212b204..76b42f68c9cc 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -120,7 +120,7 @@ config BITLAND_MIFS_WMI
depends on INPUT
depends on LEDS_CLASS
depends on POWER_SUPPLY
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select INPUT_SPARSEKMAP
help
This is a driver for Bitland MiInterface based laptops.
@@ -180,7 +180,7 @@ config ACER_WMI
select INPUT_SPARSEKMAP
select LEDS_CLASS
select NEW_LEDS
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
help
This is a driver for newer Acer (and Wistron) laptops. It adds
wireless radio and bluetooth control, and on some laptops,
@@ -279,7 +279,7 @@ config ASUS_WMI
select INPUT_SPARSEKMAP
select LEDS_CLASS
select NEW_LEDS
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
help
Say Y here if you have a WMI aware Asus laptop (like Eee PCs or new
Asus Notebooks).
@@ -646,7 +646,7 @@ config SAMSUNG_GALAXYBOOK
depends on INPUT
depends on LEDS_CLASS
depends on SERIO_I8042
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select FW_ATTR_CLASS
help
This is a driver for Samsung Galaxy Book series notebooks. It adds
@@ -906,7 +906,7 @@ config TOUCHSCREEN_DMI
config INSPUR_PLATFORM_PROFILE
tristate "Inspur WMI platform profile driver"
depends on ACPI_WMI
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
help
This will allow users to determine and control the platform modes
between low-power, balanced and performance modes.
diff --git a/drivers/platform/x86/amd/pmf/Kconfig b/drivers/platform/x86/amd/pmf/Kconfig
index 25b8f7ae3abd..a0bdd85db6a0 100644
--- a/drivers/platform/x86/amd/pmf/Kconfig
+++ b/drivers/platform/x86/amd/pmf/Kconfig
@@ -8,7 +8,7 @@ config AMD_PMF
depends on ACPI && PCI
depends on POWER_SUPPLY
depends on AMD_NODE
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
depends on TEE && AMDTEE
depends on AMD_SFH_HID
depends on HAS_IOMEM
diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/Kconfig
index 9f0016056d7e..f6acf1cc2a2f 100644
--- a/drivers/platform/x86/dell/Kconfig
+++ b/drivers/platform/x86/dell/Kconfig
@@ -44,7 +44,7 @@ config ALIENWARE_WMI_WMAX
bool "Alienware WMAX WMI device driver"
default y
depends on ALIENWARE_WMI
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
help
Alienware WMI driver with AlienFX LED, HDMI, amplifier, deep sleep and
AWCC thermal control capabilities.
@@ -120,7 +120,7 @@ config DELL_PC
depends on ACPI
depends on DMI
depends on DELL_SMBIOS
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
help
This driver adds support for controlling the fan modes via platform_profile
on supported Dell systems regardless of formfactor.
diff --git a/drivers/platform/x86/hp/Kconfig b/drivers/platform/x86/hp/Kconfig
index dd51491b9bcd..81a52194ff42 100644
--- a/drivers/platform/x86/hp/Kconfig
+++ b/drivers/platform/x86/hp/Kconfig
@@ -43,7 +43,7 @@ config HP_WMI
depends on RFKILL || RFKILL = n
select POWER_SUPPLY
select INPUT_SPARSEKMAP
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select HWMON
help
Say Y here if you want to support WMI-based hotkeys on HP laptops and
diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig
index 4443f40ef8aa..c8606ad56139 100644
--- a/drivers/platform/x86/lenovo/Kconfig
+++ b/drivers/platform/x86/lenovo/Kconfig
@@ -12,7 +12,7 @@ config IDEAPAD_LAPTOP
depends on BACKLIGHT_CLASS_DEVICE
depends on ACPI_VIDEO || ACPI_VIDEO = n
depends on ACPI_WMI || ACPI_WMI = n
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select INPUT_SPARSEKMAP
select NEW_LEDS
select LEDS_CLASS
@@ -63,7 +63,7 @@ config THINKPAD_ACPI
depends on BACKLIGHT_CLASS_DEVICE
depends on I2C
depends on DRM
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select DRM_PRIVACY_SCREEN
select HWMON
select NVRAM
@@ -250,7 +250,7 @@ config LENOVO_WMI_GAMEZONE
tristate "Lenovo GameZone WMI Driver"
depends on ACPI_WMI
depends on DMI
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select LENOVO_WMI_EVENTS
select LENOVO_WMI_HELPERS
help
diff --git a/drivers/thermal/intel/int340x_thermal/Kconfig b/drivers/thermal/intel/int340x_thermal/Kconfig
index 4ced7bdcd62c..3026a0a8d073 100644
--- a/drivers/thermal/intel/int340x_thermal/Kconfig
+++ b/drivers/thermal/intel/int340x_thermal/Kconfig
@@ -12,7 +12,7 @@ config INT340X_THERMAL
select ACPI_THERMAL_LIB
select INTEL_SOC_DTS_IOSF_CORE
select INTEL_TCC
- select ACPI_PLATFORM_PROFILE
+ select PLATFORM_PROFILE
select PROC_THERMAL_MMIO_RAPL if POWERCAP
help
Newer laptops and tablets that use ACPI may have thermal sensors and
--
2.43.0
next prev parent reply other threads:[~2026-10-14 13:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 13:24 [PATCH v1 0/4] Make platform profiles firmware independent Daniel Lezcano
2026-10-14 13:24 ` [PATCH v1 1/4] platform profile: Separate handler locking from sysfs lifetime Daniel Lezcano
2026-10-14 13:24 ` Daniel Lezcano [this message]
2026-10-14 13:24 ` [PATCH v1 3/4] platform profile: Add firmware-neutral aggregate sysfs interface Daniel Lezcano
2026-10-14 13:24 ` [PATCH v1 4/4] platform profile: Document firmware-independent profile selection Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014132500.3817549-3-daniel.lezcano@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=W_Armin@gmx.de \
--cc=corbet@lwn.net \
--cc=daniel.lezcano@kernel.org \
--cc=derekjohn.clark@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jackbb_wu@compal.com \
--cc=jai.luthra@ideasonboard.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=luzmaximilian@gmail.com \
--cc=mpearson-lenovo@squebb.ca \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=skhan@linuxfoundation.org \
--cc=superm1@kernel.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.