* [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers
@ 2024-11-05 15:32 Mario Limonciello
2024-11-05 15:32 ` [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
` (20 more replies)
0 siblings, 21 replies; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:32 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
Currently there are a number of ASUS products on the market that happen to
have ACPI objects for amd-pmf to bind to as well as an ACPI platform
profile provided by asus-wmi.
The ACPI platform profile support created by amd-pmf on these ASUS
products is "Function 9" which is specifically for "BIOS or EC
notification" of power slider position. This feature is actively used
by some designs such as Framework 13 and Framework 16.
On these ASUS designs we keep on quirking more and more of them to turn
off this notification so that asus-wmi can bind.
This however isn't how Windows works. "Multiple" things are notified for
the power slider position. This series adjusts Linux to behave similarly.
Multiple drivers can now register an ACPI platform profile and will react
to set requests.
To avoid chaos, only positions that are common to both drivers are
accepted when the legacy /sys/firmware/acpi/platform_profile interface
is used.
This series also adds a new concept of a "custom" profile. This allows
userspace to discover that there are multiple driver handlers that are
configured differently.
This series also allows dropping all of the PMF quirks from amd-pmf.
v4:
* Drop the list; iterate classes
* Drop patches that didn't make sense without list
* Cover alienware-wmi as well (recently merged to platform-x86/for-next)
* Drop requirement for balanced
* Rename platform-profile class members to 'profile', 'options', 'name'
* Drop the name in /sys/class/platform-profile and just use ida value.
IE platform-profile-0
Mario Limonciello (20):
ACPI: platform-profile: Add a name member to handlers
platform/x86/dell: dell-pc: Create platform device
ACPI: platform_profile: Add device pointer into platform profile
handler
ACPI: platform_profile: Add platform handler argument to
platform_profile_remove()
ACPI: platform_profile: Move sanity check out of the mutex
ACPI: platform_profile: Move matching string for new profile out of
mutex
ACPI: platform_profile: Use guard(mutex) for register/unregister
ACPI: platform_profile: Use `scoped_cond_guard`
ACPI: platform_profile: Create class for ACPI platform profile
ACPI: platform_profile: Add name attribute to class interface
ACPI: platform_profile: Add choices attribute for class interface
ACPI: platform_profile: Add profile attribute for class interface
ACPI: platform_profile: Notify change events on register and
unregister
ACPI: platform_profile: Only show profiles common for all handlers
ACPI: platform_profile: Add concept of a "custom" profile
ACPI: platform_profile: Make sure all profile handlers agree on
profile
ACPI: platform_profile: Check all profile handler to calculate next
ACPI: platform_profile: Allow multiple handlers
platform/x86/amd: pmf: Drop all quirks
Documentation: Add documentation about class interface for platform
profiles
.../userspace-api/sysfs-platform_profile.rst | 28 ++
drivers/acpi/platform_profile.c | 446 ++++++++++++++----
.../surface/surface_platform_profile.c | 8 +-
drivers/platform/x86/acer-wmi.c | 10 +-
drivers/platform/x86/amd/pmf/Makefile | 2 +-
drivers/platform/x86/amd/pmf/core.c | 1 -
drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ---
drivers/platform/x86/amd/pmf/pmf.h | 3 -
drivers/platform/x86/amd/pmf/sps.c | 4 +-
drivers/platform/x86/asus-wmi.c | 6 +-
drivers/platform/x86/dell/alienware-wmi.c | 8 +-
drivers/platform/x86/dell/dell-pc.c | 39 +-
drivers/platform/x86/hp/hp-wmi.c | 8 +-
drivers/platform/x86/ideapad-laptop.c | 4 +-
.../platform/x86/inspur_platform_profile.c | 7 +-
drivers/platform/x86/thinkpad_acpi.c | 4 +-
include/linux/platform_profile.h | 7 +-
17 files changed, 456 insertions(+), 195 deletions(-)
delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
--
2.43.0
^ permalink raw reply [flat|nested] 55+ messages in thread
* [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
@ 2024-11-05 15:32 ` Mario Limonciello
2024-11-06 3:27 ` Armin Wolf
2024-11-05 15:32 ` [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
` (19 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:32 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
In order to prepare for allowing multiple handlers, introduce
a name field that can be used to distinguish between different
handlers.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v4:
* add alienware-wmi too
---
drivers/platform/surface/surface_platform_profile.c | 1 +
drivers/platform/x86/acer-wmi.c | 1 +
drivers/platform/x86/amd/pmf/sps.c | 1 +
drivers/platform/x86/asus-wmi.c | 1 +
drivers/platform/x86/dell/alienware-wmi.c | 1 +
drivers/platform/x86/dell/dell-pc.c | 1 +
drivers/platform/x86/hp/hp-wmi.c | 1 +
drivers/platform/x86/ideapad-laptop.c | 1 +
drivers/platform/x86/inspur_platform_profile.c | 1 +
drivers/platform/x86/thinkpad_acpi.c | 1 +
include/linux/platform_profile.h | 1 +
11 files changed, 11 insertions(+)
diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index 3de864bc66108..61aa488a80eb5 100644
--- a/drivers/platform/surface/surface_platform_profile.c
+++ b/drivers/platform/surface/surface_platform_profile.c
@@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
tpd->sdev = sdev;
+ tpd->handler.name = "Surface Platform Profile";
tpd->handler.profile_get = ssam_platform_profile_get;
tpd->handler.profile_set = ssam_platform_profile_set;
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index d09baa3d3d902..53fbc9b4d3df7 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void)
if (quirks->predator_v4) {
int err;
+ platform_profile_handler.name = "acer-wmi";
platform_profile_handler.profile_get =
acer_predator_v4_platform_profile_get;
platform_profile_handler.profile_set =
diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
index 92f7fb22277dc..e2d0cc92c4396 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
amd_pmf_set_sps_power_limits(dev);
}
+ dev->pprof.name = "amd-pmf";
dev->pprof.profile_get = amd_pmf_profile_get;
dev->pprof.profile_set = amd_pmf_profile_set;
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 2ccc23b259d3e..c7c104c65a85a 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3910,6 +3910,7 @@ static int platform_profile_setup(struct asus_wmi *asus)
dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n");
+ asus->platform_profile_handler.name = "asus-wmi";
asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get;
asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set;
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index a800c28bb4d51..ac0038afd98fa 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -1056,6 +1056,7 @@ static int create_thermal_profile(void)
pp_handler.profile_get = thermal_profile_get;
pp_handler.profile_set = thermal_profile_set;
+ pp_handler.name = "alienware-wmi";
return platform_profile_register(&pp_handler);
}
diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index 972385ca1990b..3cf79e55e3129 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -247,6 +247,7 @@ static int thermal_init(void)
thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL);
if (!thermal_handler)
return -ENOMEM;
+ thermal_handler->name = "dell-pc";
thermal_handler->profile_get = thermal_platform_profile_get;
thermal_handler->profile_set = thermal_platform_profile_set;
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 81ccc96ffe40a..26cac73caf2b9 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void)
set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
}
+ platform_profile_handler.name = "hp-wmi";
set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 9d8c3f064050e..1f94c14c3b832 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
mutex_init(&priv->dytc->mutex);
+ priv->dytc->pprof.name = "ideapad-laptop";
priv->dytc->priv = priv;
priv->dytc->pprof.profile_get = dytc_profile_get;
priv->dytc->pprof.profile_set = dytc_profile_set;
diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
index 8440defa67886..03da2c8cf6789 100644
--- a/drivers/platform/x86/inspur_platform_profile.c
+++ b/drivers/platform/x86/inspur_platform_profile.c
@@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
priv->wdev = wdev;
dev_set_drvdata(&wdev->dev, priv);
+ priv->handler.name = "inspur-wmi";
priv->handler.profile_get = inspur_platform_profile_get;
priv->handler.profile_set = inspur_platform_profile_set;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 4c1b0553f8720..c8c316b8507a5 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void)
}
static struct platform_profile_handler dytc_profile = {
+ .name = "thinkpad-acpi",
.profile_get = dytc_profile_get,
.profile_set = dytc_profile_set,
};
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index f5492ed413f36..6fa988e417428 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -27,6 +27,7 @@ enum platform_profile_option {
};
struct platform_profile_handler {
+ const char *name;
unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
int (*profile_get)(struct platform_profile_handler *pprof,
enum platform_profile_option *profile);
base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
2024-11-05 15:32 ` [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
@ 2024-11-05 15:32 ` Mario Limonciello
2024-11-06 19:37 ` Armin Wolf
2024-11-05 15:32 ` [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler Mario Limonciello
` (18 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:32 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
In order to have a device for the platform profile core to reference
create a platform device for dell-pc.
While doing this change the memory allocation for the thermal handler
to be device managed to follow the lifecycle of that device.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++--------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index 3cf79e55e3129..b145fedb6b710 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -18,10 +18,13 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_profile.h>
+#include <linux/platform_device.h>
#include <linux/slab.h>
#include "dell-smbios.h"
+static struct platform_device *platform_device;
+
static const struct dmi_system_id dell_device_table[] __initconst = {
{
.ident = "Dell Inc.",
@@ -244,9 +247,18 @@ static int thermal_init(void)
if (!supported_modes)
return 0;
- thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL);
- if (!thermal_handler)
+ platform_device = platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE);
+ if (!platform_device)
return -ENOMEM;
+ ret = platform_device_add(platform_device);
+ if (ret)
+ goto cleanup_platform_device;
+
+ thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL);
+ if (!thermal_handler) {
+ ret = -ENOMEM;
+ goto cleanup_platform_device;
+ }
thermal_handler->name = "dell-pc";
thermal_handler->profile_get = thermal_platform_profile_get;
thermal_handler->profile_set = thermal_platform_profile_set;
@@ -262,20 +274,25 @@ static int thermal_init(void)
/* Clean up if failed */
ret = platform_profile_register(thermal_handler);
- if (ret) {
- kfree(thermal_handler);
- thermal_handler = NULL;
- }
+ if (ret)
+ goto cleanup_thermal_handler;
+
+ return 0;
+
+cleanup_thermal_handler:
+ thermal_handler = NULL;
+
+cleanup_platform_device:
+ platform_device_del(platform_device);
return ret;
}
static void thermal_cleanup(void)
{
- if (thermal_handler) {
+ if (thermal_handler)
platform_profile_remove();
- kfree(thermal_handler);
- }
+ platform_device_unregister(platform_device);
}
static int __init dell_init(void)
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
2024-11-05 15:32 ` [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
2024-11-05 15:32 ` [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
@ 2024-11-05 15:32 ` Mario Limonciello
2024-11-06 3:32 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
` (17 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:32 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
In order to let platform profile handlers manage platform profile
for their driver the core code will need a pointer to the device.
Add this to the structure and use it in the trivial driver cases.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v4:
* add alienware-wmi too
---
drivers/acpi/platform_profile.c | 5 +++++
drivers/platform/surface/surface_platform_profile.c | 1 +
drivers/platform/x86/acer-wmi.c | 5 +++--
drivers/platform/x86/amd/pmf/sps.c | 1 +
drivers/platform/x86/asus-wmi.c | 1 +
drivers/platform/x86/dell/alienware-wmi.c | 5 +++--
drivers/platform/x86/dell/dell-pc.c | 1 +
drivers/platform/x86/hp/hp-wmi.c | 5 +++--
drivers/platform/x86/ideapad-laptop.c | 1 +
drivers/platform/x86/inspur_platform_profile.c | 1 +
drivers/platform/x86/thinkpad_acpi.c | 1 +
include/linux/platform_profile.h | 1 +
12 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index d2f7fd7743a13..5d9f3f7ba71c5 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -179,6 +179,11 @@ int platform_profile_register(struct platform_profile_handler *pprof)
{
int err;
+ if (!pprof->dev) {
+ pr_err("platform_profile: handler device is not set\n");
+ return -EINVAL;
+ }
+
mutex_lock(&profile_lock);
/* We can only have one active profile */
if (cur_profile) {
diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index 61aa488a80eb5..5f45f8e8cd69b 100644
--- a/drivers/platform/surface/surface_platform_profile.c
+++ b/drivers/platform/surface/surface_platform_profile.c
@@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
tpd->sdev = sdev;
tpd->handler.name = "Surface Platform Profile";
+ tpd->handler.dev = &sdev->dev;
tpd->handler.profile_get = ssam_platform_profile_get;
tpd->handler.profile_set = ssam_platform_profile_set;
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 53fbc9b4d3df7..aca4a5746bee1 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof,
return 0;
}
-static int acer_platform_profile_setup(void)
+static int acer_platform_profile_setup(struct platform_device *device)
{
if (quirks->predator_v4) {
int err;
platform_profile_handler.name = "acer-wmi";
+ platform_profile_handler.dev = &device->dev;
platform_profile_handler.profile_get =
acer_predator_v4_platform_profile_get;
platform_profile_handler.profile_set =
@@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device *device)
goto error_rfkill;
if (has_cap(ACER_CAP_PLATFORM_PROFILE)) {
- err = acer_platform_profile_setup();
+ err = acer_platform_profile_setup(device);
if (err)
goto error_platform_profile;
}
diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
index e2d0cc92c4396..1b94af7c0e0c4 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
}
dev->pprof.name = "amd-pmf";
+ dev->pprof.dev = dev->dev;
dev->pprof.profile_get = amd_pmf_profile_get;
dev->pprof.profile_set = amd_pmf_profile_set;
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index c7c104c65a85a..78621b2af0ddb 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3911,6 +3911,7 @@ static int platform_profile_setup(struct asus_wmi *asus)
dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n");
asus->platform_profile_handler.name = "asus-wmi";
+ asus->platform_profile_handler.dev = dev;
asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get;
asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set;
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index ac0038afd98fa..c03b1aa7dfb5f 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -1017,7 +1017,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof,
return wmax_thermal_control(supported_thermal_profiles[profile]);
}
-static int create_thermal_profile(void)
+static int create_thermal_profile(struct platform_device *platform_device)
{
u32 out_data;
enum wmax_thermal_mode mode;
@@ -1057,6 +1057,7 @@ static int create_thermal_profile(void)
pp_handler.profile_get = thermal_profile_get;
pp_handler.profile_set = thermal_profile_set;
pp_handler.name = "alienware-wmi";
+ pp_handler.dev = &platform_device->dev;
return platform_profile_register(&pp_handler);
}
@@ -1125,7 +1126,7 @@ static int __init alienware_wmi_init(void)
}
if (quirks->thermal) {
- ret = create_thermal_profile();
+ ret = create_thermal_profile(platform_device);
if (ret)
goto fail_prep_thermal_profile;
}
diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index b145fedb6b710..730f97aab70cd 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -260,6 +260,7 @@ static int thermal_init(void)
goto cleanup_platform_device;
}
thermal_handler->name = "dell-pc";
+ thermal_handler->dev = &platform_device->dev;
thermal_handler->profile_get = thermal_platform_profile_get;
thermal_handler->profile_set = thermal_platform_profile_set;
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 26cac73caf2b9..ffb09799142bc 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void)
unregister_acpi_notifier(&platform_power_source_nb);
}
-static int thermal_profile_setup(void)
+static int thermal_profile_setup(struct platform_device *device)
{
int err, tp;
@@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void)
}
platform_profile_handler.name = "hp-wmi";
+ platform_profile_handler.dev = &device->dev;
set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
@@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
if (err < 0)
return err;
- thermal_profile_setup();
+ thermal_profile_setup(device);
return 0;
}
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 1f94c14c3b832..24367c3590c99 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
mutex_init(&priv->dytc->mutex);
priv->dytc->pprof.name = "ideapad-laptop";
+ priv->dytc->pprof.dev = &priv->platform_device->dev;
priv->dytc->priv = priv;
priv->dytc->pprof.profile_get = dytc_profile_get;
priv->dytc->pprof.profile_set = dytc_profile_set;
diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
index 03da2c8cf6789..5a53949bbbf5f 100644
--- a/drivers/platform/x86/inspur_platform_profile.c
+++ b/drivers/platform/x86/inspur_platform_profile.c
@@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
dev_set_drvdata(&wdev->dev, priv);
priv->handler.name = "inspur-wmi";
+ priv->handler.dev = &wdev->dev;
priv->handler.profile_get = inspur_platform_profile_get;
priv->handler.profile_set = inspur_platform_profile_set;
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index c8c316b8507a5..222fba97d79a7 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
dbg_printk(TPACPI_DBG_INIT,
"DYTC version %d: thermal mode available\n", dytc_version);
+ dytc_profile.dev = &tpacpi_pdev->dev;
/* Create platform_profile structure and register */
err = platform_profile_register(&dytc_profile);
/*
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index 6fa988e417428..daec6b9bad81f 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -28,6 +28,7 @@ enum platform_profile_option {
struct platform_profile_handler {
const char *name;
+ struct device *dev;
unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
int (*profile_get)(struct platform_profile_handler *pprof,
enum platform_profile_option *profile);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove()
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (2 preceding siblings ...)
2024-11-05 15:32 ` [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 3:34 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
` (16 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
To allow registering and unregistering multiple platform handlers calls
to platform_profile_remove() will need to know which handler is to be
removed. Add an argument for this.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v4:
* Add alienware-wmi too
---
drivers/acpi/platform_profile.c | 2 +-
drivers/platform/surface/surface_platform_profile.c | 6 +++++-
drivers/platform/x86/acer-wmi.c | 4 ++--
drivers/platform/x86/amd/pmf/sps.c | 2 +-
drivers/platform/x86/asus-wmi.c | 4 ++--
drivers/platform/x86/dell/alienware-wmi.c | 2 +-
drivers/platform/x86/dell/dell-pc.c | 2 +-
drivers/platform/x86/hp/hp-wmi.c | 2 +-
drivers/platform/x86/ideapad-laptop.c | 2 +-
drivers/platform/x86/inspur_platform_profile.c | 5 ++++-
drivers/platform/x86/thinkpad_acpi.c | 2 +-
include/linux/platform_profile.h | 2 +-
12 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 5d9f3f7ba71c5..c76b8e3fdcde6 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -210,7 +210,7 @@ int platform_profile_register(struct platform_profile_handler *pprof)
}
EXPORT_SYMBOL_GPL(platform_profile_register);
-int platform_profile_remove(void)
+int platform_profile_remove(struct platform_profile_handler *pprof)
{
sysfs_remove_group(acpi_kobj, &platform_profile_group);
diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index 5f45f8e8cd69b..b449c4c8b883c 100644
--- a/drivers/platform/surface/surface_platform_profile.c
+++ b/drivers/platform/surface/surface_platform_profile.c
@@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
return -ENOMEM;
tpd->sdev = sdev;
+ ssam_device_set_drvdata(sdev, tpd);
tpd->handler.name = "Surface Platform Profile";
tpd->handler.dev = &sdev->dev;
@@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
static void surface_platform_profile_remove(struct ssam_device *sdev)
{
- platform_profile_remove();
+ struct ssam_platform_profile_device *tpd;
+
+ tpd = ssam_device_get_drvdata(sdev);
+ platform_profile_remove(&tpd->handler);
}
static const struct ssam_device_id ssam_platform_profile_match[] = {
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index aca4a5746bee1..b12965d9fcdb7 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device)
error_hwmon:
if (platform_profile_support)
- platform_profile_remove();
+ platform_profile_remove(&platform_profile_handler);
error_platform_profile:
acer_rfkill_exit();
error_rfkill:
@@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device)
acer_rfkill_exit();
if (platform_profile_support)
- platform_profile_remove();
+ platform_profile_remove(&platform_profile_handler);
}
#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
index 1b94af7c0e0c4..bd2bd6cfc39a0 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
void amd_pmf_deinit_sps(struct amd_pmf_dev *dev)
{
- platform_profile_remove();
+ platform_profile_remove(&dev->pprof);
}
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 78621b2af0ddb..0750e2fe65325 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -4886,7 +4886,7 @@ static int asus_wmi_add(struct platform_device *pdev)
fail_custom_fan_curve:
fail_platform_profile_setup:
if (asus->platform_profile_support)
- platform_profile_remove();
+ platform_profile_remove(&asus->platform_profile_handler);
fail_fan_boost_mode:
fail_platform:
kfree(asus);
@@ -4913,7 +4913,7 @@ static void asus_wmi_remove(struct platform_device *device)
asus_wmi_battery_exit(asus);
if (asus->platform_profile_support)
- platform_profile_remove();
+ platform_profile_remove(&asus->platform_profile_handler);
kfree(asus);
}
diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index c03b1aa7dfb5f..3cf6c371d4220 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -1065,7 +1065,7 @@ static int create_thermal_profile(struct platform_device *platform_device)
static void remove_thermal_profile(void)
{
if (quirks->thermal)
- platform_profile_remove();
+ platform_profile_remove(&pp_handler);
}
static int __init alienware_wmi_init(void)
diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index 730f97aab70cd..65989af2e4196 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -292,7 +292,7 @@ static int thermal_init(void)
static void thermal_cleanup(void)
{
if (thermal_handler)
- platform_profile_remove();
+ platform_profile_remove(thermal_handler);
platform_device_unregister(platform_device);
}
diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index ffb09799142bc..6d6e13a0c6e2d 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device)
}
if (platform_profile_support)
- platform_profile_remove();
+ platform_profile_remove(&platform_profile_handler);
}
static int hp_wmi_resume_handler(struct device *device)
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 24367c3590c99..80797c6ae8b0b 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv)
if (!priv->dytc)
return;
- platform_profile_remove();
+ platform_profile_remove(&priv->dytc->pprof);
mutex_destroy(&priv->dytc->mutex);
kfree(priv->dytc);
diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
index 5a53949bbbf5f..53af73a7fbf7b 100644
--- a/drivers/platform/x86/inspur_platform_profile.c
+++ b/drivers/platform/x86/inspur_platform_profile.c
@@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
static void inspur_wmi_remove(struct wmi_device *wdev)
{
- platform_profile_remove();
+ struct inspur_wmi_priv *priv;
+
+ priv = dev_get_drvdata(&wdev->dev);
+ platform_profile_remove(&priv->handler);
}
static const struct wmi_device_id inspur_wmi_id_table[] = {
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index 222fba97d79a7..13798c6d5fcf3 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
static void dytc_profile_exit(void)
{
- platform_profile_remove();
+ platform_profile_remove(&dytc_profile);
}
static struct ibm_struct dytc_profile_driver_data = {
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index daec6b9bad81f..bcaf3aa39160f 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -37,7 +37,7 @@ struct platform_profile_handler {
};
int platform_profile_register(struct platform_profile_handler *pprof);
-int platform_profile_remove(void);
+int platform_profile_remove(struct platform_profile_handler *pprof);
int platform_profile_cycle(void);
void platform_profile_notify(void);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (3 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 3:35 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
` (15 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
The sanity check that the platform handler had choices set doesn't
need the mutex taken. Move it to earlier in the registration.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index c76b8e3fdcde6..4e8a155589c21 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -179,6 +179,12 @@ int platform_profile_register(struct platform_profile_handler *pprof)
{
int err;
+ /* Sanity check the profile handler */
+ if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) ||
+ !pprof->profile_set || !pprof->profile_get) {
+ pr_err("platform_profile: handler is invalid\n");
+ return -EINVAL;
+ }
if (!pprof->dev) {
pr_err("platform_profile: handler device is not set\n");
return -EINVAL;
@@ -191,13 +197,6 @@ int platform_profile_register(struct platform_profile_handler *pprof)
return -EEXIST;
}
- /* Sanity check the profile handler field are set */
- if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) ||
- !pprof->profile_set || !pprof->profile_get) {
- mutex_unlock(&profile_lock);
- return -EINVAL;
- }
-
err = sysfs_create_group(acpi_kobj, &platform_profile_group);
if (err) {
mutex_unlock(&profile_lock);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (4 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-05 15:38 ` Ilpo Järvinen
2024-11-06 3:36 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
` (14 subsequent siblings)
20 siblings, 2 replies; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
Holding the mutex is not necessary while scanning the string passed into
platform_profile_store().
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 4e8a155589c21..70e7f1ba68676 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev,
{
int err, i;
+ /* Scan for a matching profile */
+ i = sysfs_match_string(profile_names, buf);
+ if (i < 0)
+ return -EINVAL;
+
err = mutex_lock_interruptible(&profile_lock);
if (err)
return err;
@@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev,
return -ENODEV;
}
- /* Scan for a matching profile */
- i = sysfs_match_string(profile_names, buf);
- if (i < 0) {
- mutex_unlock(&profile_lock);
- return -EINVAL;
- }
-
/* Check that platform supports this profile choice */
if (!test_bit(i, cur_profile->choices)) {
mutex_unlock(&profile_lock);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (5 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 3:37 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
` (13 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
guard(mutex) can be used to automatically release mutexes when going
out of scope.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 70e7f1ba68676..4454c4a903c8f 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -188,32 +188,26 @@ int platform_profile_register(struct platform_profile_handler *pprof)
return -EINVAL;
}
- mutex_lock(&profile_lock);
+ guard(mutex)(&profile_lock);
/* We can only have one active profile */
- if (cur_profile) {
- mutex_unlock(&profile_lock);
+ if (cur_profile)
return -EEXIST;
- }
err = sysfs_create_group(acpi_kobj, &platform_profile_group);
- if (err) {
- mutex_unlock(&profile_lock);
+ if (err)
return err;
- }
cur_profile = pprof;
- mutex_unlock(&profile_lock);
return 0;
}
EXPORT_SYMBOL_GPL(platform_profile_register);
int platform_profile_remove(struct platform_profile_handler *pprof)
{
- sysfs_remove_group(acpi_kobj, &platform_profile_group);
+ guard(mutex)(&profile_lock);
- mutex_lock(&profile_lock);
+ sysfs_remove_group(acpi_kobj, &platform_profile_group);
cur_profile = NULL;
- mutex_unlock(&profile_lock);
return 0;
}
EXPORT_SYMBOL_GPL(platform_profile_remove);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard`
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (6 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-05 15:54 ` Ilpo Järvinen
2024-11-05 15:33 ` [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
` (12 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
Migrate away from using an interruptible mutex to scoped_cond_guard
in all functions.
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 114 ++++++++++++--------------------
1 file changed, 44 insertions(+), 70 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 4454c4a903c8f..fd1c4e9dccf0a 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -27,25 +27,21 @@ static ssize_t platform_profile_choices_show(struct device *dev,
char *buf)
{
int len = 0;
- int err, i;
-
- err = mutex_lock_interruptible(&profile_lock);
- if (err)
- return err;
-
- if (!cur_profile) {
- mutex_unlock(&profile_lock);
- return -ENODEV;
- }
-
- for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) {
- if (len == 0)
- len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
- else
- len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
+ int i;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ if (!cur_profile)
+ return -ENODEV;
+
+ for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) {
+ if (len == 0)
+ len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
+ else
+ len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
+ }
}
len += sysfs_emit_at(buf, len, "\n");
- mutex_unlock(&profile_lock);
+
return len;
}
@@ -56,20 +52,15 @@ static ssize_t platform_profile_show(struct device *dev,
enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
int err;
- err = mutex_lock_interruptible(&profile_lock);
- if (err)
- return err;
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ if (!cur_profile)
+ return -ENODEV;
- if (!cur_profile) {
- mutex_unlock(&profile_lock);
- return -ENODEV;
+ err = cur_profile->profile_get(cur_profile, &profile);
+ if (err)
+ return err;
}
- err = cur_profile->profile_get(cur_profile, &profile);
- mutex_unlock(&profile_lock);
- if (err)
- return err;
-
/* Check that profile is valid index */
if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
return -EIO;
@@ -88,28 +79,20 @@ static ssize_t platform_profile_store(struct device *dev,
if (i < 0)
return -EINVAL;
- err = mutex_lock_interruptible(&profile_lock);
- if (err)
- return err;
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ if (!cur_profile)
+ return -ENODEV;
- if (!cur_profile) {
- mutex_unlock(&profile_lock);
- return -ENODEV;
- }
+ /* Check that platform supports this profile choice */
+ if (!test_bit(i, cur_profile->choices))
+ return -EOPNOTSUPP;
- /* Check that platform supports this profile choice */
- if (!test_bit(i, cur_profile->choices)) {
- mutex_unlock(&profile_lock);
- return -EOPNOTSUPP;
+ err = cur_profile->profile_set(cur_profile, i);
+ if (err)
+ return err;
}
- err = cur_profile->profile_set(cur_profile, i);
- if (!err)
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
-
- mutex_unlock(&profile_lock);
- if (err)
- return err;
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
return count;
}
@@ -140,36 +123,27 @@ int platform_profile_cycle(void)
enum platform_profile_option next;
int err;
- err = mutex_lock_interruptible(&profile_lock);
- if (err)
- return err;
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ if (!cur_profile)
+ return -ENODEV;
- if (!cur_profile) {
- mutex_unlock(&profile_lock);
- return -ENODEV;
- }
+ err = cur_profile->profile_get(cur_profile, &profile);
+ if (err)
+ return err;
- err = cur_profile->profile_get(cur_profile, &profile);
- if (err) {
- mutex_unlock(&profile_lock);
- return err;
- }
+ next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
+ profile + 1);
- next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
- profile + 1);
+ if (WARN_ON(next == PLATFORM_PROFILE_LAST))
+ return -EINVAL;
- if (WARN_ON(next == PLATFORM_PROFILE_LAST)) {
- mutex_unlock(&profile_lock);
- return -EINVAL;
+ err = cur_profile->profile_set(cur_profile, next);
+ if (err)
+ return err;
}
- err = cur_profile->profile_set(cur_profile, next);
- mutex_unlock(&profile_lock);
-
- if (!err)
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
-
- return err;
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ return 0;
}
EXPORT_SYMBOL_GPL(platform_profile_cycle);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (7 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 3:53 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
` (11 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
When registering a platform profile handler create a class device
that will allow changing a single platform profile handler.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 42 +++++++++++++++++++++++++++++---
include/linux/platform_profile.h | 2 ++
2 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index fd1c4e9dccf0a..f8e9dc9a10d54 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -5,6 +5,7 @@
#include <linux/acpi.h>
#include <linux/bits.h>
#include <linux/init.h>
+#include <linux/kdev_t.h>
#include <linux/mutex.h>
#include <linux/platform_profile.h>
#include <linux/sysfs.h>
@@ -22,6 +23,12 @@ static const char * const profile_names[] = {
};
static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
+static DEFINE_IDR(platform_profile_minor_idr);
+
+static const struct class platform_profile_class = {
+ .name = "platform-profile",
+};
+
static ssize_t platform_profile_choices_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -113,6 +120,8 @@ void platform_profile_notify(void)
{
if (!cur_profile)
return;
+ if (!class_is_registered(&platform_profile_class))
+ return;
sysfs_notify(acpi_kobj, NULL, "platform_profile");
}
EXPORT_SYMBOL_GPL(platform_profile_notify);
@@ -123,6 +132,9 @@ int platform_profile_cycle(void)
enum platform_profile_option next;
int err;
+ if (!class_is_registered(&platform_profile_class))
+ return -ENODEV;
+
scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
if (!cur_profile)
return -ENODEV;
@@ -167,12 +179,33 @@ int platform_profile_register(struct platform_profile_handler *pprof)
if (cur_profile)
return -EEXIST;
- err = sysfs_create_group(acpi_kobj, &platform_profile_group);
- if (err)
- return err;
+ if (!class_is_registered(&platform_profile_class)) {
+ /* class for individual handlers */
+ err = class_register(&platform_profile_class);
+ if (err)
+ return err;
+ /* legacy sysfs files */
+ err = sysfs_create_group(acpi_kobj, &platform_profile_group);
+ if (err)
+ goto cleanup_class;
+ }
+
+ /* create class interface for individual handler */
+ pprof->minor = idr_alloc(&platform_profile_minor_idr, pprof, 0, 0, GFP_KERNEL);
+ pprof->class_dev = device_create(&platform_profile_class, pprof->dev,
+ MKDEV(0, pprof->minor), NULL, "platform-profile-%d",
+ pprof->minor);
+ if (IS_ERR(pprof->class_dev))
+ return PTR_ERR(pprof->class_dev);
+ dev_set_drvdata(pprof->class_dev, pprof);
cur_profile = pprof;
return 0;
+
+cleanup_class:
+ class_unregister(&platform_profile_class);
+
+ return err;
}
EXPORT_SYMBOL_GPL(platform_profile_register);
@@ -181,6 +214,9 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
guard(mutex)(&profile_lock);
sysfs_remove_group(acpi_kobj, &platform_profile_group);
+
+ device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
+
cur_profile = NULL;
return 0;
}
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index bcaf3aa39160f..f81c3afcb7575 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -29,6 +29,8 @@ enum platform_profile_option {
struct platform_profile_handler {
const char *name;
struct device *dev;
+ struct device *class_dev;
+ int minor;
unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
int (*profile_get)(struct platform_profile_handler *pprof,
enum platform_profile_option *profile);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (8 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 3:56 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
` (10 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
The name attribute shows the name of the associated platform profile
handler.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index f8e9dc9a10d54..986bd636be226 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -25,8 +25,33 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
static DEFINE_IDR(platform_profile_minor_idr);
+/**
+ * name_show - Show the name of the profile handler
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to write to
+ * Return: The number of bytes written
+ */
+static ssize_t name_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct platform_profile_handler *handler = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%s\n", handler->name);
+}
+
+
+static DEVICE_ATTR_RO(name);
+static struct attribute *profile_attrs[] = {
+ &dev_attr_name.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(profile);
+
static const struct class platform_profile_class = {
.name = "platform-profile",
+ .dev_groups = profile_groups,
};
static ssize_t platform_profile_choices_show(struct device *dev,
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (9 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 1:09 ` kernel test robot
2024-11-06 4:00 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
` (9 subsequent siblings)
20 siblings, 2 replies; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
The `choices` file will show all possible choices that a given platform
profile handler can support.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 63 +++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 986bd636be226..e1b6569c4ee70 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -25,6 +25,47 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
static DEFINE_IDR(platform_profile_minor_idr);
+/**
+ * _commmon_choices_show - Show the available profile choices
+ * @choices: The available profile choices
+ * @buf: The buffer to write to
+ * Return: The number of bytes written
+ */
+static ssize_t _commmon_choices_show(unsigned long choices, char *buf)
+{
+ int i, len = 0;
+
+ for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) {
+ if (len == 0)
+ len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
+ else
+ len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
+ }
+ len += sysfs_emit_at(buf, len, "\n");
+
+ return len;
+}
+
+/**
+ * _get_class_choices - Get the available profile choices for a class device
+ * @dev: The class device
+ * Return: The available profile choices
+ */
+static int _get_class_choices(struct device *dev, unsigned long *choices)
+{
+ struct platform_profile_handler *handler;
+ int i;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ handler = dev_get_drvdata(dev);
+ for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
+ *choices |= BIT(i);
+ }
+
+ return 0;
+}
+
+
/**
* name_show - Show the name of the profile handler
* @dev: The device
@@ -41,10 +82,32 @@ static ssize_t name_show(struct device *dev,
return sysfs_emit(buf, "%s\n", handler->name);
}
+/**
+ * choices_show - Show the available profile choices
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to write to
+ */
+static ssize_t choices_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned long choices = 0;
+ int err;
+
+ err = _get_class_choices(dev, &choices);
+ if (err)
+ return err;
+
+ return _commmon_choices_show(choices, buf);
+}
+
static DEVICE_ATTR_RO(name);
+static DEVICE_ATTR_RO(choices);
static struct attribute *profile_attrs[] = {
&dev_attr_name.attr,
+ &dev_attr_choices.attr,
NULL
};
ATTRIBUTE_GROUPS(profile);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (10 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 4:10 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
` (8 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
Reading and writing the `profile` sysfs file will use the callbacks for
the platform profile handler to read or set the given profile.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 118 ++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index e1b6569c4ee70..79083d0bb22e3 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -65,6 +65,78 @@ static int _get_class_choices(struct device *dev, unsigned long *choices)
return 0;
}
+/**
+ * _store_class_profile - Set the profile for a class device
+ * @dev: The class device
+ * @data: The profile to set
+ */
+static int _store_class_profile(struct device *dev, void *data)
+{
+ enum platform_profile_option profile;
+ unsigned long choices;
+ int *i = (int *)data;
+ int err;
+
+ err = _get_class_choices(dev, &choices);
+ if (err)
+ return err;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ struct platform_profile_handler *handler;
+
+ if (!test_bit(*i, &choices))
+ return -EOPNOTSUPP;
+
+ handler = dev_get_drvdata(dev);
+ err = handler->profile_get(handler, &profile);
+ if (err)
+ return err;
+
+ err = handler->profile_set(handler, *i);
+ if (err) {
+ int recover_err;
+
+ dev_err(dev, "Failed to set profile: %d\n", err);
+ recover_err = handler->profile_set(handler, profile);
+ if (recover_err)
+ dev_err(dev, "Failed to reset profile: %d\n", recover_err);
+ }
+ sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile");
+ kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE);
+ }
+
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
+ return err ? err : 0;
+}
+
+/**
+ * get_class_profile - Show the current profile for a class device
+ * @dev: The class device
+ * @profile: The profile to return
+ * Return: 0 on success, -errno on failure
+ */
+static int get_class_profile(struct device *dev,
+ enum platform_profile_option *profile)
+{
+ struct platform_profile_handler *handler;
+ enum platform_profile_option val;
+ int err;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ handler = dev_get_drvdata(dev);
+ err = handler->profile_get(handler, &val);
+ if (err) {
+ pr_err("Failed to get profile for handler %s\n", handler->name);
+ return err;
+ }
+ }
+
+ if (WARN_ON(val >= PLATFORM_PROFILE_LAST))
+ return -EINVAL;
+ *profile = val;
+
+ return 0;
+}
/**
* name_show - Show the name of the profile handler
@@ -102,12 +174,58 @@ static ssize_t choices_show(struct device *dev,
return _commmon_choices_show(choices, buf);
}
+/**
+ * profile_show - Show the current profile for a class device
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to write to
+ * Return: The number of bytes written
+ */
+static ssize_t profile_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
+ int err;
+
+ err = get_class_profile(dev, &profile);
+ if (err)
+ return err;
+
+ return sysfs_emit(buf, "%s\n", profile_names[profile]);
+}
+
+/**
+ * profile_store - Set the profile for a class device
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to read from
+ * @count: The number of bytes to read
+ * Return: The number of bytes read
+ */
+static ssize_t profile_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int i, ret;
+
+ i = sysfs_match_string(profile_names, buf);
+ if (i < 0)
+ return -EINVAL;
+
+ ret = _store_class_profile(dev, (void *)(long)&i);
+
+ return ret ? ret : count;
+}
static DEVICE_ATTR_RO(name);
static DEVICE_ATTR_RO(choices);
+static DEVICE_ATTR_RW(profile);
+
static struct attribute *profile_attrs[] = {
&dev_attr_name.attr,
&dev_attr_choices.attr,
+ &dev_attr_profile.attr,
NULL
};
ATTRIBUTE_GROUPS(profile);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (11 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 19:40 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
` (7 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
As multiple platform profile handlers may come and go, send a notification
to userspace each time that a platform profile handler is registered or
unregistered.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 79083d0bb22e3..c9917daf683cb 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -404,6 +404,7 @@ int platform_profile_register(struct platform_profile_handler *pprof)
if (IS_ERR(pprof->class_dev))
return PTR_ERR(pprof->class_dev);
dev_set_drvdata(pprof->class_dev, pprof);
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
cur_profile = pprof;
return 0;
@@ -419,7 +420,9 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
{
guard(mutex)(&profile_lock);
- sysfs_remove_group(acpi_kobj, &platform_profile_group);
+ cur_profile = NULL;
+
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (12 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 19:41 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
` (6 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
If multiple platform profile handlers have been registered, don't allow
switching to profiles unique to only one handler.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 55 +++++++++++++++++++++++----------
1 file changed, 38 insertions(+), 17 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index c9917daf683cb..8de7c8352673e 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -235,27 +235,48 @@ static const struct class platform_profile_class = {
.dev_groups = profile_groups,
};
-static ssize_t platform_profile_choices_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+/**
+ * _aggregate_choices - Aggregate the available profile choices
+ * @dev: The device
+ * @data: The available profile choices
+ * Return: 0 on success, -errno on failure
+ */
+static int _aggregate_choices(struct device *dev, void *data)
{
- int len = 0;
- int i;
+ unsigned long *aggregate = data;
+ unsigned long choices = 0;
+ int err;
- scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
- if (!cur_profile)
- return -ENODEV;
+ err = _get_class_choices(dev, &choices);
+ if (err)
+ return err;
- for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) {
- if (len == 0)
- len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
- else
- len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
- }
- }
- len += sysfs_emit_at(buf, len, "\n");
+ if (!*aggregate)
+ *aggregate = choices;
+ else
+ *aggregate &= choices;
- return len;
+ return 0;
+}
+
+/**
+ * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to write to
+ * Return: The number of bytes written
+ */
+static ssize_t platform_profile_choices_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ unsigned long aggregate = 0;
+ int err;
+
+ err = class_for_each_device(&platform_profile_class, NULL,
+ &aggregate, _aggregate_choices);
+
+ return _commmon_choices_show(aggregate, buf);
}
static ssize_t platform_profile_show(struct device *dev,
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (13 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 19:17 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
` (5 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
When two profile handlers don't agree on the current profile it's ambiguous
what to show to the legacy sysfs interface.
Add a "custom" profile string that userspace will be able to distinguish
this situation when using the legacy sysfs interface.
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 1 +
include/linux/platform_profile.h | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 8de7c8352673e..d8c2d195106c2 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -20,6 +20,7 @@ static const char * const profile_names[] = {
[PLATFORM_PROFILE_BALANCED] = "balanced",
[PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance",
[PLATFORM_PROFILE_PERFORMANCE] = "performance",
+ [PLATFORM_PROFILE_CUSTOM] = "custom",
};
static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index f81c3afcb7575..d2a2ab4c6cee9 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -23,6 +23,7 @@ enum platform_profile_option {
PLATFORM_PROFILE_BALANCED,
PLATFORM_PROFILE_BALANCED_PERFORMANCE,
PLATFORM_PROFILE_PERFORMANCE,
+ PLATFORM_PROFILE_CUSTOM,
PLATFORM_PROFILE_LAST, /*must always be last */
};
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (14 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 20:58 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
` (4 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
If for any reason multiple profile handlers don't agree on the profile
return the custom profile.
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 84 +++++++++++++++++++++------------
1 file changed, 53 insertions(+), 31 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index d8c2d195106c2..7861fccc2e58c 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -280,55 +280,77 @@ static ssize_t platform_profile_choices_show(struct device *dev,
return _commmon_choices_show(aggregate, buf);
}
-static ssize_t platform_profile_show(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+/**
+ * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface
+ * @dev: The device
+ * @data: The profile to return
+ * Return: 0 on success, -errno on failure
+ */
+static int _aggregate_profiles(struct device *dev, void *data)
{
- enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
+ enum platform_profile_option *profile = data;
+ enum platform_profile_option val;
int err;
- scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
- if (!cur_profile)
- return -ENODEV;
+ err = get_class_profile(dev, &val);
+ if (err)
+ return err;
- err = cur_profile->profile_get(cur_profile, &profile);
- if (err)
- return err;
- }
+ if (*profile != PLATFORM_PROFILE_LAST && *profile != val)
+ *profile = PLATFORM_PROFILE_CUSTOM;
+ else
+ *profile = val;
- /* Check that profile is valid index */
- if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
- return -EIO;
+ return 0;
+}
+
+/**
+ * platform_profile_show - Show the current profile for legacy sysfs interface
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to write to
+ * Return: The number of bytes written
+ */
+static ssize_t platform_profile_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
+ int err;
+
+ err = class_for_each_device(&platform_profile_class, NULL,
+ &profile, _aggregate_profiles);
return sysfs_emit(buf, "%s\n", profile_names[profile]);
}
+/**
+ * platform_profile_store - Set the profile for legacy sysfs interface
+ * @dev: The device
+ * @attr: The attribute
+ * @buf: The buffer to read from
+ * @count: The number of bytes to read
+ * Return: The number of bytes read
+ */
static ssize_t platform_profile_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
+ struct device_attribute *attr,
+ const char *buf, size_t count)
{
- int err, i;
+ int ret;
+ int i;
/* Scan for a matching profile */
i = sysfs_match_string(profile_names, buf);
if (i < 0)
return -EINVAL;
-
- scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
- if (!cur_profile)
- return -ENODEV;
-
- /* Check that platform supports this profile choice */
- if (!test_bit(i, cur_profile->choices))
- return -EOPNOTSUPP;
-
- err = cur_profile->profile_set(cur_profile, i);
- if (err)
- return err;
+ if (i == PLATFORM_PROFILE_CUSTOM) {
+ pr_warn("Custom profile not supported for legacy sysfs interface\n");
+ return -EINVAL;
}
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
- return count;
+ ret = class_for_each_device(&platform_profile_class, NULL, &i, _store_class_profile);
+
+ return ret ? ret : count;
}
static DEVICE_ATTR_RO(platform_profile_choices);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (15 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 20:55 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
` (3 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
As multiple platform profile handlers might not all support the same
profile, cycling to the next profile could have a different result
depending on what handler are registered.
Check what is active and supported by all handlers to decide what
to do.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 35 ++++++++++++++++++---------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 7861fccc2e58c..568485e285061 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -378,34 +378,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify);
int platform_profile_cycle(void)
{
+ enum platform_profile_option next = PLATFORM_PROFILE_LAST;
enum platform_profile_option profile;
- enum platform_profile_option next;
+ unsigned long choices;
int err;
if (!class_is_registered(&platform_profile_class))
return -ENODEV;
- scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
- if (!cur_profile)
- return -ENODEV;
+ err = class_for_each_device(&platform_profile_class, NULL,
+ &profile, _aggregate_profiles);
+ if (err)
+ return err;
- err = cur_profile->profile_get(cur_profile, &profile);
- if (err)
- return err;
+ err = class_for_each_device(&platform_profile_class, NULL,
+ &choices, _aggregate_choices);
+ if (err)
+ return err;
- next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
- profile + 1);
+ next = find_next_bit_wrap(&choices,
+ PLATFORM_PROFILE_LAST,
+ profile + 1);
- if (WARN_ON(next == PLATFORM_PROFILE_LAST))
- return -EINVAL;
+ err = class_for_each_device(&platform_profile_class, NULL, &next,
+ _store_class_profile);
- err = cur_profile->profile_set(cur_profile, next);
- if (err)
- return err;
- }
+ if (err)
+ return err;
sysfs_notify(acpi_kobj, NULL, "platform_profile");
- return 0;
+
+ return err;
}
EXPORT_SYMBOL_GPL(platform_profile_cycle);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (16 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 19:21 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
` (2 subsequent siblings)
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
Multiple drivers may attempt to register platform profile handlers,
but only one may be registered and the behavior is non-deterministic
for which one wins. It's mostly controlled by probing order.
This can be problematic if one driver changes CPU settings and another
driver notifies the EC for changing fan curves.
Modify the ACPI platform profile handler to let multiple drivers
register platform profile handlers and abstract this detail from userspace.
To avoid undefined behaviors only offer profiles that are commonly
advertised across multiple handlers.
If any problems occur when changing profiles for any driver, then revert
back to the balanced profile, which is now required.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 568485e285061..b9eb25f58a2a2 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -10,7 +10,6 @@
#include <linux/platform_profile.h>
#include <linux/sysfs.h>
-static struct platform_profile_handler *cur_profile;
static DEFINE_MUTEX(profile_lock);
static const char * const profile_names[] = {
@@ -368,8 +367,7 @@ static const struct attribute_group platform_profile_group = {
void platform_profile_notify(void)
{
- if (!cur_profile)
- return;
+ guard(mutex)(&profile_lock);
if (!class_is_registered(&platform_profile_class))
return;
sysfs_notify(acpi_kobj, NULL, "platform_profile");
@@ -428,9 +426,6 @@ int platform_profile_register(struct platform_profile_handler *pprof)
}
guard(mutex)(&profile_lock);
- /* We can only have one active profile */
- if (cur_profile)
- return -EEXIST;
if (!class_is_registered(&platform_profile_class)) {
/* class for individual handlers */
@@ -451,9 +446,9 @@ int platform_profile_register(struct platform_profile_handler *pprof)
if (IS_ERR(pprof->class_dev))
return PTR_ERR(pprof->class_dev);
dev_set_drvdata(pprof->class_dev, pprof);
+
sysfs_notify(acpi_kobj, NULL, "platform_profile");
- cur_profile = pprof;
return 0;
cleanup_class:
@@ -467,13 +462,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
{
guard(mutex)(&profile_lock);
- cur_profile = NULL;
-
sysfs_notify(acpi_kobj, NULL, "platform_profile");
device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
- cur_profile = NULL;
return 0;
}
EXPORT_SYMBOL_GPL(platform_profile_remove);
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (17 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-06 19:30 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
2024-11-05 22:47 ` [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mark Pearson
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
As multiple platform profile handlers can now be registered, the quirks
to avoid registering amd-pmf as a handler are no longer necessary.
Drop them.
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/platform/x86/amd/pmf/Makefile | 2 +-
drivers/platform/x86/amd/pmf/core.c | 1 -
drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 -----------------------
drivers/platform/x86/amd/pmf/pmf.h | 3 --
4 files changed, 1 insertion(+), 71 deletions(-)
delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile
index 7d6079b02589c..6b26e48ce8ad2 100644
--- a/drivers/platform/x86/amd/pmf/Makefile
+++ b/drivers/platform/x86/amd/pmf/Makefile
@@ -7,4 +7,4 @@
obj-$(CONFIG_AMD_PMF) += amd-pmf.o
amd-pmf-objs := core.o acpi.o sps.o \
auto-mode.o cnqf.o \
- tee-if.o spc.o pmf-quirks.o
+ tee-if.o spc.o
diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
index 47126abd13ca0..6ad00b3d472fe 100644
--- a/drivers/platform/x86/amd/pmf/core.c
+++ b/drivers/platform/x86/amd/pmf/core.c
@@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev)
mutex_init(&dev->lock);
mutex_init(&dev->update_mutex);
- amd_pmf_quirks_init(dev);
apmf_acpi_init(dev);
platform_set_drvdata(pdev, dev);
amd_pmf_dbgfs_register(dev);
diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c
deleted file mode 100644
index 7cde5733b9cac..0000000000000
--- a/drivers/platform/x86/amd/pmf/pmf-quirks.c
+++ /dev/null
@@ -1,66 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * AMD Platform Management Framework Driver Quirks
- *
- * Copyright (c) 2024, Advanced Micro Devices, Inc.
- * All Rights Reserved.
- *
- * Author: Mario Limonciello <mario.limonciello@amd.com>
- */
-
-#include <linux/dmi.h>
-
-#include "pmf.h"
-
-struct quirk_entry {
- u32 supported_func;
-};
-
-static struct quirk_entry quirk_no_sps_bug = {
- .supported_func = 0x4003,
-};
-
-static const struct dmi_system_id fwbug_list[] = {
- {
- .ident = "ROG Zephyrus G14",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
- DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"),
- },
- .driver_data = &quirk_no_sps_bug,
- },
- {
- .ident = "ROG Ally X",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
- DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"),
- },
- .driver_data = &quirk_no_sps_bug,
- },
- {
- .ident = "ASUS TUF Gaming A14",
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
- DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"),
- },
- .driver_data = &quirk_no_sps_bug,
- },
- {}
-};
-
-void amd_pmf_quirks_init(struct amd_pmf_dev *dev)
-{
- const struct dmi_system_id *dmi_id;
- struct quirk_entry *quirks;
-
- dmi_id = dmi_first_match(fwbug_list);
- if (!dmi_id)
- return;
-
- quirks = dmi_id->driver_data;
- if (quirks->supported_func) {
- dev->supported_func = quirks->supported_func;
- pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n",
- dmi_id->ident);
- }
-}
diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
index 8ce8816da9c16..b89aa38434faa 100644
--- a/drivers/platform/x86/amd/pmf/pmf.h
+++ b/drivers/platform/x86/amd/pmf/pmf.h
@@ -795,7 +795,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
-/* Quirk infrastructure */
-void amd_pmf_quirks_init(struct amd_pmf_dev *dev);
-
#endif /* PMF_H */
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (18 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
@ 2024-11-05 15:33 ` Mario Limonciello
2024-11-05 22:49 ` Mark Pearson
2024-11-05 22:47 ` [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mark Pearson
20 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-05 15:33 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
The class interface allows changing multiple platform profiles on a system
to different values. The semantics of it are similar to the legacy
interface.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
.../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst
index 4fccde2e45639..418c61b096304 100644
--- a/Documentation/userspace-api/sysfs-platform_profile.rst
+++ b/Documentation/userspace-api/sysfs-platform_profile.rst
@@ -40,3 +40,31 @@ added. Drivers which wish to introduce new profile names must:
1. Explain why the existing profile names cannot be used.
2. Add the new profile name, along with a clear description of the
expected behaviour, to the sysfs-platform_profile ABI documentation.
+
+Multiple driver support
+=======================
+When multiple drivers on a system advertise a platform profile handler, the
+platform profile handler core will only advertise the profiles that are
+commong between all drivers to the ``/sys/firmware/acpi`` interfaces.
+
+This is to ensure there is no ambiguity on what the profile names mean when
+all handlers don't support a profile.
+
+Individual drivers will register a 'platform_profile' class device that has
+similar semantics as the ``/sys/firmware/acpi/platform_profile`` interface.
+
+To discover available profiles from the class interface the user can read the
+``choices`` attribute.
+
+If a user wants to select a profile for a specific driver, they can do so
+by writing to the ``profile`` attribute of the driver's class device.
+
+This will allow users to set different profiles for different drivers on the
+same system. If the selected profile by individual drivers differes the
+platform profile handler core will display the profile 'custom' to indicate
+that the profiles are not the same.
+
+While the ``platform_profile`` attribute has the value ``custom``, writing a
+common profile from ``platform_profile_choices`` to the platform_profile
+attribute of the platform profile handler core will set the profile for all
+drivers.
--
2.43.0
^ permalink raw reply related [flat|nested] 55+ messages in thread
* Re: [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex
2024-11-05 15:33 ` [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
@ 2024-11-05 15:38 ` Ilpo Järvinen
2024-11-06 3:36 ` Armin Wolf
1 sibling, 0 replies; 55+ messages in thread
From: Ilpo Järvinen @ 2024-11-05 15:38 UTC (permalink / raw)
To: Mario Limonciello
Cc: Hans de Goede, Rafael J . Wysocki, Len Brown, Maximilian Luz,
Lee Chun-Yi, Shyam Sundar S K, Corentin Chary, Luke D . Jones,
Ike Panhc, Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]
On Tue, 5 Nov 2024, Mario Limonciello wrote:
> Holding the mutex is not necessary while scanning the string passed into
> platform_profile_store().
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 4e8a155589c21..70e7f1ba68676 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev,
> {
> int err, i;
>
> + /* Scan for a matching profile */
> + i = sysfs_match_string(profile_names, buf);
> + if (i < 0)
> + return -EINVAL;
> +
> err = mutex_lock_interruptible(&profile_lock);
> if (err)
> return err;
> @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev,
> return -ENODEV;
> }
>
> - /* Scan for a matching profile */
> - i = sysfs_match_string(profile_names, buf);
> - if (i < 0) {
> - mutex_unlock(&profile_lock);
> - return -EINVAL;
> - }
> -
> /* Check that platform supports this profile choice */
> if (!test_bit(i, cur_profile->choices)) {
> mutex_unlock(&profile_lock);
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard`
2024-11-05 15:33 ` [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
@ 2024-11-05 15:54 ` Ilpo Järvinen
0 siblings, 0 replies; 55+ messages in thread
From: Ilpo Järvinen @ 2024-11-05 15:54 UTC (permalink / raw)
To: Mario Limonciello
Cc: Hans de Goede, Rafael J . Wysocki, Len Brown, Maximilian Luz,
Lee Chun-Yi, Shyam Sundar S K, Corentin Chary, Luke D . Jones,
Ike Panhc, Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
[-- Attachment #1: Type: text/plain, Size: 5301 bytes --]
On Tue, 5 Nov 2024, Mario Limonciello wrote:
> Migrate away from using an interruptible mutex to scoped_cond_guard
> in all functions.
>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 114 ++++++++++++--------------------
> 1 file changed, 44 insertions(+), 70 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 4454c4a903c8f..fd1c4e9dccf0a 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -27,25 +27,21 @@ static ssize_t platform_profile_choices_show(struct device *dev,
> char *buf)
> {
> int len = 0;
> - int err, i;
> -
> - err = mutex_lock_interruptible(&profile_lock);
> - if (err)
> - return err;
> -
> - if (!cur_profile) {
> - mutex_unlock(&profile_lock);
> - return -ENODEV;
> - }
> -
> - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) {
> - if (len == 0)
> - len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
> - else
> - len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
> + int i;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + if (!cur_profile)
> + return -ENODEV;
> +
> + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) {
> + if (len == 0)
> + len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
> + else
> + len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
> + }
> }
> len += sysfs_emit_at(buf, len, "\n");
> - mutex_unlock(&profile_lock);
> +
> return len;
> }
>
> @@ -56,20 +52,15 @@ static ssize_t platform_profile_show(struct device *dev,
> enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
> int err;
>
> - err = mutex_lock_interruptible(&profile_lock);
> - if (err)
> - return err;
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + if (!cur_profile)
> + return -ENODEV;
>
> - if (!cur_profile) {
> - mutex_unlock(&profile_lock);
> - return -ENODEV;
> + err = cur_profile->profile_get(cur_profile, &profile);
> + if (err)
> + return err;
> }
>
> - err = cur_profile->profile_get(cur_profile, &profile);
> - mutex_unlock(&profile_lock);
> - if (err)
> - return err;
> -
> /* Check that profile is valid index */
> if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
> return -EIO;
> @@ -88,28 +79,20 @@ static ssize_t platform_profile_store(struct device *dev,
> if (i < 0)
> return -EINVAL;
>
> - err = mutex_lock_interruptible(&profile_lock);
> - if (err)
> - return err;
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + if (!cur_profile)
> + return -ENODEV;
>
> - if (!cur_profile) {
> - mutex_unlock(&profile_lock);
> - return -ENODEV;
> - }
> + /* Check that platform supports this profile choice */
> + if (!test_bit(i, cur_profile->choices))
> + return -EOPNOTSUPP;
>
> - /* Check that platform supports this profile choice */
> - if (!test_bit(i, cur_profile->choices)) {
> - mutex_unlock(&profile_lock);
> - return -EOPNOTSUPP;
> + err = cur_profile->profile_set(cur_profile, i);
> + if (err)
> + return err;
> }
>
> - err = cur_profile->profile_set(cur_profile, i);
> - if (!err)
> - sysfs_notify(acpi_kobj, NULL, "platform_profile");
> -
> - mutex_unlock(&profile_lock);
> - if (err)
> - return err;
> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
Hi Mario,
While I think it's fine, could you please mention about this move outside
of the lock in the commit message.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
> return count;
> }
>
> @@ -140,36 +123,27 @@ int platform_profile_cycle(void)
> enum platform_profile_option next;
> int err;
>
> - err = mutex_lock_interruptible(&profile_lock);
> - if (err)
> - return err;
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + if (!cur_profile)
> + return -ENODEV;
>
> - if (!cur_profile) {
> - mutex_unlock(&profile_lock);
> - return -ENODEV;
> - }
> + err = cur_profile->profile_get(cur_profile, &profile);
> + if (err)
> + return err;
>
> - err = cur_profile->profile_get(cur_profile, &profile);
> - if (err) {
> - mutex_unlock(&profile_lock);
> - return err;
> - }
> + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
> + profile + 1);
>
> - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
> - profile + 1);
> + if (WARN_ON(next == PLATFORM_PROFILE_LAST))
> + return -EINVAL;
>
> - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) {
> - mutex_unlock(&profile_lock);
> - return -EINVAL;
> + err = cur_profile->profile_set(cur_profile, next);
> + if (err)
> + return err;
> }
>
> - err = cur_profile->profile_set(cur_profile, next);
> - mutex_unlock(&profile_lock);
> -
> - if (!err)
> - sysfs_notify(acpi_kobj, NULL, "platform_profile");
> -
> - return err;
> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
> + return 0;
> }
> EXPORT_SYMBOL_GPL(platform_profile_cycle);
>
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (19 preceding siblings ...)
2024-11-05 15:33 ` [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
@ 2024-11-05 22:47 ` Mark Pearson
2024-11-06 1:11 ` Mario Limonciello
20 siblings, 1 reply; 55+ messages in thread
From: Mark Pearson @ 2024-11-05 22:47 UTC (permalink / raw)
To: Limonciello, Mario, Hans de Goede, Ilpo Järvinen
Cc: Rafael J. Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
open list:THINKPAD ACPI EXTRAS DRIVER, Matthew Schwartz
Hi Mario,
On Tue, Nov 5, 2024, at 10:32 AM, Mario Limonciello wrote:
> Currently there are a number of ASUS products on the market that happen to
> have ACPI objects for amd-pmf to bind to as well as an ACPI platform
> profile provided by asus-wmi.
>
> The ACPI platform profile support created by amd-pmf on these ASUS
> products is "Function 9" which is specifically for "BIOS or EC
> notification" of power slider position. This feature is actively used
> by some designs such as Framework 13 and Framework 16.
>
> On these ASUS designs we keep on quirking more and more of them to turn
> off this notification so that asus-wmi can bind.
>
> This however isn't how Windows works. "Multiple" things are notified for
> the power slider position. This series adjusts Linux to behave similarly.
>
> Multiple drivers can now register an ACPI platform profile and will react
> to set requests.
>
> To avoid chaos, only positions that are common to both drivers are
> accepted when the legacy /sys/firmware/acpi/platform_profile interface
> is used.
>
> This series also adds a new concept of a "custom" profile. This allows
> userspace to discover that there are multiple driver handlers that are
> configured differently.
>
> This series also allows dropping all of the PMF quirks from amd-pmf.
>
> v4:
> * Drop the list; iterate classes
> * Drop patches that didn't make sense without list
> * Cover alienware-wmi as well (recently merged to platform-x86/for-next)
> * Drop requirement for balanced
> * Rename platform-profile class members to 'profile', 'options', 'name'
> * Drop the name in /sys/class/platform-profile and just use ida value.
> IE platform-profile-0
>
> Mario Limonciello (20):
> ACPI: platform-profile: Add a name member to handlers
> platform/x86/dell: dell-pc: Create platform device
> ACPI: platform_profile: Add device pointer into platform profile
> handler
> ACPI: platform_profile: Add platform handler argument to
> platform_profile_remove()
> ACPI: platform_profile: Move sanity check out of the mutex
> ACPI: platform_profile: Move matching string for new profile out of
> mutex
> ACPI: platform_profile: Use guard(mutex) for register/unregister
> ACPI: platform_profile: Use `scoped_cond_guard`
> ACPI: platform_profile: Create class for ACPI platform profile
> ACPI: platform_profile: Add name attribute to class interface
> ACPI: platform_profile: Add choices attribute for class interface
> ACPI: platform_profile: Add profile attribute for class interface
> ACPI: platform_profile: Notify change events on register and
> unregister
> ACPI: platform_profile: Only show profiles common for all handlers
> ACPI: platform_profile: Add concept of a "custom" profile
> ACPI: platform_profile: Make sure all profile handlers agree on
> profile
> ACPI: platform_profile: Check all profile handler to calculate next
> ACPI: platform_profile: Allow multiple handlers
> platform/x86/amd: pmf: Drop all quirks
> Documentation: Add documentation about class interface for platform
> profiles
>
> .../userspace-api/sysfs-platform_profile.rst | 28 ++
> drivers/acpi/platform_profile.c | 446 ++++++++++++++----
> .../surface/surface_platform_profile.c | 8 +-
> drivers/platform/x86/acer-wmi.c | 10 +-
> drivers/platform/x86/amd/pmf/Makefile | 2 +-
> drivers/platform/x86/amd/pmf/core.c | 1 -
> drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ---
> drivers/platform/x86/amd/pmf/pmf.h | 3 -
> drivers/platform/x86/amd/pmf/sps.c | 4 +-
> drivers/platform/x86/asus-wmi.c | 6 +-
> drivers/platform/x86/dell/alienware-wmi.c | 8 +-
> drivers/platform/x86/dell/dell-pc.c | 39 +-
> drivers/platform/x86/hp/hp-wmi.c | 8 +-
> drivers/platform/x86/ideapad-laptop.c | 4 +-
> .../platform/x86/inspur_platform_profile.c | 7 +-
> drivers/platform/x86/thinkpad_acpi.c | 4 +-
> include/linux/platform_profile.h | 7 +-
> 17 files changed, 456 insertions(+), 195 deletions(-)
> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>
>
> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
> --
> 2.43.0
For the series - I tried it out on my T14s G6 AMD, and it all looks to be working nicely and as expected.
The thinkpad-acpi and amd-pmf classes show up. I can tweak them individually and 'custom' shows up under firmware/acpi/platform_profile.
I tried various combo's and didn't see any issues.
If you have any recommendations of things to try let me know.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Mark
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles
2024-11-05 15:33 ` [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
@ 2024-11-05 22:49 ` Mark Pearson
0 siblings, 0 replies; 55+ messages in thread
From: Mark Pearson @ 2024-11-05 22:49 UTC (permalink / raw)
To: Limonciello, Mario, Hans de Goede, Ilpo Järvinen
Cc: Rafael J. Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
open list:THINKPAD ACPI EXTRAS DRIVER, Matthew Schwartz
Hi Mario,
On Tue, Nov 5, 2024, at 10:33 AM, Mario Limonciello wrote:
> The class interface allows changing multiple platform profiles on a system
> to different values. The semantics of it are similar to the legacy
> interface.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> .../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst
> b/Documentation/userspace-api/sysfs-platform_profile.rst
> index 4fccde2e45639..418c61b096304 100644
> --- a/Documentation/userspace-api/sysfs-platform_profile.rst
> +++ b/Documentation/userspace-api/sysfs-platform_profile.rst
> @@ -40,3 +40,31 @@ added. Drivers which wish to introduce new profile
> names must:
> 1. Explain why the existing profile names cannot be used.
> 2. Add the new profile name, along with a clear description of the
> expected behaviour, to the sysfs-platform_profile ABI
> documentation.
> +
> +Multiple driver support
> +=======================
> +When multiple drivers on a system advertise a platform profile
> handler, the
> +platform profile handler core will only advertise the profiles that are
> +commong between all drivers to the ``/sys/firmware/acpi`` interfaces.
Typo (commong)
> +
> +This is to ensure there is no ambiguity on what the profile names mean
> when
> +all handlers don't support a profile.
> +
> +Individual drivers will register a 'platform_profile' class device
> that has
> +similar semantics as the ``/sys/firmware/acpi/platform_profile``
> interface.
> +
> +To discover available profiles from the class interface the user can
> read the
> +``choices`` attribute.
> +
> +If a user wants to select a profile for a specific driver, they can do
> so
> +by writing to the ``profile`` attribute of the driver's class device.
> +
> +This will allow users to set different profiles for different drivers
> on the
> +same system. If the selected profile by individual drivers differes the
typo (differes)
> +platform profile handler core will display the profile 'custom' to
> indicate
> +that the profiles are not the same.
> +
> +While the ``platform_profile`` attribute has the value ``custom``,
> writing a
> +common profile from ``platform_profile_choices`` to the
> platform_profile
> +attribute of the platform profile handler core will set the profile
> for all
> +drivers.
> --
> 2.43.0
Thanks
Mark
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-05 15:33 ` [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
@ 2024-11-06 1:09 ` kernel test robot
2024-11-06 4:00 ` Armin Wolf
1 sibling, 0 replies; 55+ messages in thread
From: kernel test robot @ 2024-11-06 1:09 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: oe-kbuild-all, Rafael J . Wysocki, Len Brown, Maximilian Luz,
Lee Chun-Yi, Shyam Sundar S K, Corentin Chary, Luke D . Jones,
Ike Panhc, Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz, Mario Limonciello
Hi Mario,
kernel test robot noticed the following build warnings:
[auto build test WARNING on d68cb6023356af3bd3193983ad4ec03954a0b3e2]
url: https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-platform-profile-Add-a-name-member-to-handlers/20241105-233922
base: d68cb6023356af3bd3193983ad4ec03954a0b3e2
patch link: https://lore.kernel.org/r/20241105153316.378-12-mario.limonciello%40amd.com
patch subject: [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for class interface
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20241106/202411060835.GlMKVSsy-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241106/202411060835.GlMKVSsy-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411060835.GlMKVSsy-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/acpi/platform_profile.c:55: warning: Function parameter or struct member 'choices' not described in '_get_class_choices'
vim +55 drivers/acpi/platform_profile.c
48
49 /**
50 * _get_class_choices - Get the available profile choices for a class device
51 * @dev: The class device
52 * Return: The available profile choices
53 */
54 static int _get_class_choices(struct device *dev, unsigned long *choices)
> 55 {
56 struct platform_profile_handler *handler;
57 int i;
58
59 scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
60 handler = dev_get_drvdata(dev);
61 for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
62 *choices |= BIT(i);
63 }
64
65 return 0;
66 }
67
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers
2024-11-05 22:47 ` [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mark Pearson
@ 2024-11-06 1:11 ` Mario Limonciello
2024-11-06 21:04 ` Armin Wolf
0 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-06 1:11 UTC (permalink / raw)
To: Mark Pearson, Hans de Goede, Ilpo Järvinen
Cc: Rafael J. Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
open list:THINKPAD ACPI EXTRAS DRIVER, Matthew Schwartz
On 11/5/2024 16:47, Mark Pearson wrote:
> Hi Mario,
>
> On Tue, Nov 5, 2024, at 10:32 AM, Mario Limonciello wrote:
>> Currently there are a number of ASUS products on the market that happen to
>> have ACPI objects for amd-pmf to bind to as well as an ACPI platform
>> profile provided by asus-wmi.
>>
>> The ACPI platform profile support created by amd-pmf on these ASUS
>> products is "Function 9" which is specifically for "BIOS or EC
>> notification" of power slider position. This feature is actively used
>> by some designs such as Framework 13 and Framework 16.
>>
>> On these ASUS designs we keep on quirking more and more of them to turn
>> off this notification so that asus-wmi can bind.
>>
>> This however isn't how Windows works. "Multiple" things are notified for
>> the power slider position. This series adjusts Linux to behave similarly.
>>
>> Multiple drivers can now register an ACPI platform profile and will react
>> to set requests.
>>
>> To avoid chaos, only positions that are common to both drivers are
>> accepted when the legacy /sys/firmware/acpi/platform_profile interface
>> is used.
>>
>> This series also adds a new concept of a "custom" profile. This allows
>> userspace to discover that there are multiple driver handlers that are
>> configured differently.
>>
>> This series also allows dropping all of the PMF quirks from amd-pmf.
>>
>> v4:
>> * Drop the list; iterate classes
>> * Drop patches that didn't make sense without list
>> * Cover alienware-wmi as well (recently merged to platform-x86/for-next)
>> * Drop requirement for balanced
>> * Rename platform-profile class members to 'profile', 'options', 'name'
>> * Drop the name in /sys/class/platform-profile and just use ida value.
>> IE platform-profile-0
>>
>> Mario Limonciello (20):
>> ACPI: platform-profile: Add a name member to handlers
>> platform/x86/dell: dell-pc: Create platform device
>> ACPI: platform_profile: Add device pointer into platform profile
>> handler
>> ACPI: platform_profile: Add platform handler argument to
>> platform_profile_remove()
>> ACPI: platform_profile: Move sanity check out of the mutex
>> ACPI: platform_profile: Move matching string for new profile out of
>> mutex
>> ACPI: platform_profile: Use guard(mutex) for register/unregister
>> ACPI: platform_profile: Use `scoped_cond_guard`
>> ACPI: platform_profile: Create class for ACPI platform profile
>> ACPI: platform_profile: Add name attribute to class interface
>> ACPI: platform_profile: Add choices attribute for class interface
>> ACPI: platform_profile: Add profile attribute for class interface
>> ACPI: platform_profile: Notify change events on register and
>> unregister
>> ACPI: platform_profile: Only show profiles common for all handlers
>> ACPI: platform_profile: Add concept of a "custom" profile
>> ACPI: platform_profile: Make sure all profile handlers agree on
>> profile
>> ACPI: platform_profile: Check all profile handler to calculate next
>> ACPI: platform_profile: Allow multiple handlers
>> platform/x86/amd: pmf: Drop all quirks
>> Documentation: Add documentation about class interface for platform
>> profiles
>>
>> .../userspace-api/sysfs-platform_profile.rst | 28 ++
>> drivers/acpi/platform_profile.c | 446 ++++++++++++++----
>> .../surface/surface_platform_profile.c | 8 +-
>> drivers/platform/x86/acer-wmi.c | 10 +-
>> drivers/platform/x86/amd/pmf/Makefile | 2 +-
>> drivers/platform/x86/amd/pmf/core.c | 1 -
>> drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ---
>> drivers/platform/x86/amd/pmf/pmf.h | 3 -
>> drivers/platform/x86/amd/pmf/sps.c | 4 +-
>> drivers/platform/x86/asus-wmi.c | 6 +-
>> drivers/platform/x86/dell/alienware-wmi.c | 8 +-
>> drivers/platform/x86/dell/dell-pc.c | 39 +-
>> drivers/platform/x86/hp/hp-wmi.c | 8 +-
>> drivers/platform/x86/ideapad-laptop.c | 4 +-
>> .../platform/x86/inspur_platform_profile.c | 7 +-
>> drivers/platform/x86/thinkpad_acpi.c | 4 +-
>> include/linux/platform_profile.h | 7 +-
>> 17 files changed, 456 insertions(+), 195 deletions(-)
>> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>>
>>
>> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
>> --
>> 2.43.0
>
> For the series - I tried it out on my T14s G6 AMD, and it all looks to be working nicely and as expected.
> The thinkpad-acpi and amd-pmf classes show up. I can tweak them individually and 'custom' shows up under firmware/acpi/platform_profile.
> I tried various combo's and didn't see any issues.
> If you have any recommendations of things to try let me know.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>
> Mark
Thanks for testing! The fact that Lenovo and ASUS are both doing this
with recent laptops makes it all the stronger of a case to do it rather
than let them race for who gets the coveted platform profile slot.
If you've already tried mixing and matching combinations that's all I
was going to suggest.
I'll wait for Armin's review and then I'll respin with the tags and
small things you and Ilpo found.
BTW if I missed any important feedback of yours from v3 please let me
know. It was a lot of overhaul to switch to this way of doing things
and a lot of it didn't make sense anymore.
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers
2024-11-05 15:32 ` [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
@ 2024-11-06 3:27 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:27 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:32 schrieb Mario Limonciello:
> In order to prepare for allowing multiple handlers, introduce
> a name field that can be used to distinguish between different
> handlers.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v4:
> * add alienware-wmi too
> ---
> drivers/platform/surface/surface_platform_profile.c | 1 +
> drivers/platform/x86/acer-wmi.c | 1 +
> drivers/platform/x86/amd/pmf/sps.c | 1 +
> drivers/platform/x86/asus-wmi.c | 1 +
> drivers/platform/x86/dell/alienware-wmi.c | 1 +
> drivers/platform/x86/dell/dell-pc.c | 1 +
> drivers/platform/x86/hp/hp-wmi.c | 1 +
> drivers/platform/x86/ideapad-laptop.c | 1 +
> drivers/platform/x86/inspur_platform_profile.c | 1 +
> drivers/platform/x86/thinkpad_acpi.c | 1 +
> include/linux/platform_profile.h | 1 +
> 11 files changed, 11 insertions(+)
>
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 3de864bc66108..61aa488a80eb5 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -211,6 +211,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
>
> tpd->sdev = sdev;
>
> + tpd->handler.name = "Surface Platform Profile";
> tpd->handler.profile_get = ssam_platform_profile_get;
> tpd->handler.profile_set = ssam_platform_profile_set;
>
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index d09baa3d3d902..53fbc9b4d3df7 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -1878,6 +1878,7 @@ static int acer_platform_profile_setup(void)
> if (quirks->predator_v4) {
> int err;
>
> + platform_profile_handler.name = "acer-wmi";
> platform_profile_handler.profile_get =
> acer_predator_v4_platform_profile_get;
> platform_profile_handler.profile_set =
> diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
> index 92f7fb22277dc..e2d0cc92c4396 100644
> --- a/drivers/platform/x86/amd/pmf/sps.c
> +++ b/drivers/platform/x86/amd/pmf/sps.c
> @@ -405,6 +405,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
> amd_pmf_set_sps_power_limits(dev);
> }
>
> + dev->pprof.name = "amd-pmf";
> dev->pprof.profile_get = amd_pmf_profile_get;
> dev->pprof.profile_set = amd_pmf_profile_set;
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 2ccc23b259d3e..c7c104c65a85a 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3910,6 +3910,7 @@ static int platform_profile_setup(struct asus_wmi *asus)
>
> dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n");
>
> + asus->platform_profile_handler.name = "asus-wmi";
> asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get;
> asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set;
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index a800c28bb4d51..ac0038afd98fa 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -1056,6 +1056,7 @@ static int create_thermal_profile(void)
>
> pp_handler.profile_get = thermal_profile_get;
> pp_handler.profile_set = thermal_profile_set;
> + pp_handler.name = "alienware-wmi";
>
> return platform_profile_register(&pp_handler);
> }
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index 972385ca1990b..3cf79e55e3129 100644
> --- a/drivers/platform/x86/dell/dell-pc.c
> +++ b/drivers/platform/x86/dell/dell-pc.c
> @@ -247,6 +247,7 @@ static int thermal_init(void)
> thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL);
> if (!thermal_handler)
> return -ENOMEM;
> + thermal_handler->name = "dell-pc";
> thermal_handler->profile_get = thermal_platform_profile_get;
> thermal_handler->profile_set = thermal_platform_profile_set;
>
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 81ccc96ffe40a..26cac73caf2b9 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1624,6 +1624,7 @@ static int thermal_profile_setup(void)
> set_bit(PLATFORM_PROFILE_COOL, platform_profile_handler.choices);
> }
>
> + platform_profile_handler.name = "hp-wmi";
> set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
> set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
>
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 9d8c3f064050e..1f94c14c3b832 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -1102,6 +1102,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
>
> mutex_init(&priv->dytc->mutex);
>
> + priv->dytc->pprof.name = "ideapad-laptop";
> priv->dytc->priv = priv;
> priv->dytc->pprof.profile_get = dytc_profile_get;
> priv->dytc->pprof.profile_set = dytc_profile_set;
> diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
> index 8440defa67886..03da2c8cf6789 100644
> --- a/drivers/platform/x86/inspur_platform_profile.c
> +++ b/drivers/platform/x86/inspur_platform_profile.c
> @@ -177,6 +177,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
> priv->wdev = wdev;
> dev_set_drvdata(&wdev->dev, priv);
>
> + priv->handler.name = "inspur-wmi";
> priv->handler.profile_get = inspur_platform_profile_get;
> priv->handler.profile_set = inspur_platform_profile_set;
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 4c1b0553f8720..c8c316b8507a5 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10549,6 +10549,7 @@ static void dytc_profile_refresh(void)
> }
>
> static struct platform_profile_handler dytc_profile = {
> + .name = "thinkpad-acpi",
> .profile_get = dytc_profile_get,
> .profile_set = dytc_profile_set,
> };
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index f5492ed413f36..6fa988e417428 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -27,6 +27,7 @@ enum platform_profile_option {
> };
>
> struct platform_profile_handler {
> + const char *name;
> unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
> int (*profile_get)(struct platform_profile_handler *pprof,
> enum platform_profile_option *profile);
>
> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler
2024-11-05 15:32 ` [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler Mario Limonciello
@ 2024-11-06 3:32 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:32 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:32 schrieb Mario Limonciello:
> In order to let platform profile handlers manage platform profile
> for their driver the core code will need a pointer to the device.
>
> Add this to the structure and use it in the trivial driver cases.
>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v4:
> * add alienware-wmi too
> ---
> drivers/acpi/platform_profile.c | 5 +++++
> drivers/platform/surface/surface_platform_profile.c | 1 +
> drivers/platform/x86/acer-wmi.c | 5 +++--
> drivers/platform/x86/amd/pmf/sps.c | 1 +
> drivers/platform/x86/asus-wmi.c | 1 +
> drivers/platform/x86/dell/alienware-wmi.c | 5 +++--
> drivers/platform/x86/dell/dell-pc.c | 1 +
> drivers/platform/x86/hp/hp-wmi.c | 5 +++--
> drivers/platform/x86/ideapad-laptop.c | 1 +
> drivers/platform/x86/inspur_platform_profile.c | 1 +
> drivers/platform/x86/thinkpad_acpi.c | 1 +
> include/linux/platform_profile.h | 1 +
> 12 files changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index d2f7fd7743a13..5d9f3f7ba71c5 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -179,6 +179,11 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> {
> int err;
>
> + if (!pprof->dev) {
> + pr_err("platform_profile: handler device is not set\n");
> + return -EINVAL;
> + }
Is there a reason why we require "dev" to be set? AFAIK having no parent device should be ok.
Thanks,
Armin Wolf
> +
> mutex_lock(&profile_lock);
> /* We can only have one active profile */
> if (cur_profile) {
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 61aa488a80eb5..5f45f8e8cd69b 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
> tpd->sdev = sdev;
>
> tpd->handler.name = "Surface Platform Profile";
> + tpd->handler.dev = &sdev->dev;
> tpd->handler.profile_get = ssam_platform_profile_get;
> tpd->handler.profile_set = ssam_platform_profile_set;
>
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index 53fbc9b4d3df7..aca4a5746bee1 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -1873,12 +1873,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof,
> return 0;
> }
>
> -static int acer_platform_profile_setup(void)
> +static int acer_platform_profile_setup(struct platform_device *device)
> {
> if (quirks->predator_v4) {
> int err;
>
> platform_profile_handler.name = "acer-wmi";
> + platform_profile_handler.dev = &device->dev;
> platform_profile_handler.profile_get =
> acer_predator_v4_platform_profile_get;
> platform_profile_handler.profile_set =
> @@ -2531,7 +2532,7 @@ static int acer_platform_probe(struct platform_device *device)
> goto error_rfkill;
>
> if (has_cap(ACER_CAP_PLATFORM_PROFILE)) {
> - err = acer_platform_profile_setup();
> + err = acer_platform_profile_setup(device);
> if (err)
> goto error_platform_profile;
> }
> diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
> index e2d0cc92c4396..1b94af7c0e0c4 100644
> --- a/drivers/platform/x86/amd/pmf/sps.c
> +++ b/drivers/platform/x86/amd/pmf/sps.c
> @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
> }
>
> dev->pprof.name = "amd-pmf";
> + dev->pprof.dev = dev->dev;
> dev->pprof.profile_get = amd_pmf_profile_get;
> dev->pprof.profile_set = amd_pmf_profile_set;
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index c7c104c65a85a..78621b2af0ddb 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3911,6 +3911,7 @@ static int platform_profile_setup(struct asus_wmi *asus)
> dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n");
>
> asus->platform_profile_handler.name = "asus-wmi";
> + asus->platform_profile_handler.dev = dev;
> asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get;
> asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set;
>
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index ac0038afd98fa..c03b1aa7dfb5f 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -1017,7 +1017,7 @@ static int thermal_profile_set(struct platform_profile_handler *pprof,
> return wmax_thermal_control(supported_thermal_profiles[profile]);
> }
>
> -static int create_thermal_profile(void)
> +static int create_thermal_profile(struct platform_device *platform_device)
> {
> u32 out_data;
> enum wmax_thermal_mode mode;
> @@ -1057,6 +1057,7 @@ static int create_thermal_profile(void)
> pp_handler.profile_get = thermal_profile_get;
> pp_handler.profile_set = thermal_profile_set;
> pp_handler.name = "alienware-wmi";
> + pp_handler.dev = &platform_device->dev;
>
> return platform_profile_register(&pp_handler);
> }
> @@ -1125,7 +1126,7 @@ static int __init alienware_wmi_init(void)
> }
>
> if (quirks->thermal) {
> - ret = create_thermal_profile();
> + ret = create_thermal_profile(platform_device);
> if (ret)
> goto fail_prep_thermal_profile;
> }
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index b145fedb6b710..730f97aab70cd 100644
> --- a/drivers/platform/x86/dell/dell-pc.c
> +++ b/drivers/platform/x86/dell/dell-pc.c
> @@ -260,6 +260,7 @@ static int thermal_init(void)
> goto cleanup_platform_device;
> }
> thermal_handler->name = "dell-pc";
> + thermal_handler->dev = &platform_device->dev;
> thermal_handler->profile_get = thermal_platform_profile_get;
> thermal_handler->profile_set = thermal_platform_profile_set;
>
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 26cac73caf2b9..ffb09799142bc 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void)
> unregister_acpi_notifier(&platform_power_source_nb);
> }
>
> -static int thermal_profile_setup(void)
> +static int thermal_profile_setup(struct platform_device *device)
> {
> int err, tp;
>
> @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void)
> }
>
> platform_profile_handler.name = "hp-wmi";
> + platform_profile_handler.dev = &device->dev;
> set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices);
> set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices);
>
> @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
> if (err < 0)
> return err;
>
> - thermal_profile_setup();
> + thermal_profile_setup(device);
>
> return 0;
> }
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 1f94c14c3b832..24367c3590c99 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv)
> mutex_init(&priv->dytc->mutex);
>
> priv->dytc->pprof.name = "ideapad-laptop";
> + priv->dytc->pprof.dev = &priv->platform_device->dev;
> priv->dytc->priv = priv;
> priv->dytc->pprof.profile_get = dytc_profile_get;
> priv->dytc->pprof.profile_set = dytc_profile_set;
> diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
> index 03da2c8cf6789..5a53949bbbf5f 100644
> --- a/drivers/platform/x86/inspur_platform_profile.c
> +++ b/drivers/platform/x86/inspur_platform_profile.c
> @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
> dev_set_drvdata(&wdev->dev, priv);
>
> priv->handler.name = "inspur-wmi";
> + priv->handler.dev = &wdev->dev;
> priv->handler.profile_get = inspur_platform_profile_get;
> priv->handler.profile_set = inspur_platform_profile_set;
>
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index c8c316b8507a5..222fba97d79a7 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
> dbg_printk(TPACPI_DBG_INIT,
> "DYTC version %d: thermal mode available\n", dytc_version);
>
> + dytc_profile.dev = &tpacpi_pdev->dev;
> /* Create platform_profile structure and register */
> err = platform_profile_register(&dytc_profile);
> /*
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index 6fa988e417428..daec6b9bad81f 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -28,6 +28,7 @@ enum platform_profile_option {
>
> struct platform_profile_handler {
> const char *name;
> + struct device *dev;
> unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
> int (*profile_get)(struct platform_profile_handler *pprof,
> enum platform_profile_option *profile);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove()
2024-11-05 15:33 ` [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
@ 2024-11-06 3:34 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:34 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> To allow registering and unregistering multiple platform handlers calls
> to platform_profile_remove() will need to know which handler is to be
> removed. Add an argument for this.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v4:
> * Add alienware-wmi too
> ---
> drivers/acpi/platform_profile.c | 2 +-
> drivers/platform/surface/surface_platform_profile.c | 6 +++++-
> drivers/platform/x86/acer-wmi.c | 4 ++--
> drivers/platform/x86/amd/pmf/sps.c | 2 +-
> drivers/platform/x86/asus-wmi.c | 4 ++--
> drivers/platform/x86/dell/alienware-wmi.c | 2 +-
> drivers/platform/x86/dell/dell-pc.c | 2 +-
> drivers/platform/x86/hp/hp-wmi.c | 2 +-
> drivers/platform/x86/ideapad-laptop.c | 2 +-
> drivers/platform/x86/inspur_platform_profile.c | 5 ++++-
> drivers/platform/x86/thinkpad_acpi.c | 2 +-
> include/linux/platform_profile.h | 2 +-
> 12 files changed, 21 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 5d9f3f7ba71c5..c76b8e3fdcde6 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -210,7 +210,7 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> }
> EXPORT_SYMBOL_GPL(platform_profile_register);
>
> -int platform_profile_remove(void)
> +int platform_profile_remove(struct platform_profile_handler *pprof)
> {
> sysfs_remove_group(acpi_kobj, &platform_profile_group);
>
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 5f45f8e8cd69b..b449c4c8b883c 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
> return -ENOMEM;
>
> tpd->sdev = sdev;
> + ssam_device_set_drvdata(sdev, tpd);
>
> tpd->handler.name = "Surface Platform Profile";
> tpd->handler.dev = &sdev->dev;
> @@ -228,7 +229,10 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
>
> static void surface_platform_profile_remove(struct ssam_device *sdev)
> {
> - platform_profile_remove();
> + struct ssam_platform_profile_device *tpd;
> +
> + tpd = ssam_device_get_drvdata(sdev);
> + platform_profile_remove(&tpd->handler);
> }
>
> static const struct ssam_device_id ssam_platform_profile_match[] = {
> diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
> index aca4a5746bee1..b12965d9fcdb7 100644
> --- a/drivers/platform/x86/acer-wmi.c
> +++ b/drivers/platform/x86/acer-wmi.c
> @@ -2547,7 +2547,7 @@ static int acer_platform_probe(struct platform_device *device)
>
> error_hwmon:
> if (platform_profile_support)
> - platform_profile_remove();
> + platform_profile_remove(&platform_profile_handler);
> error_platform_profile:
> acer_rfkill_exit();
> error_rfkill:
> @@ -2570,7 +2570,7 @@ static void acer_platform_remove(struct platform_device *device)
> acer_rfkill_exit();
>
> if (platform_profile_support)
> - platform_profile_remove();
> + platform_profile_remove(&platform_profile_handler);
> }
>
> #ifdef CONFIG_PM_SLEEP
> diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c
> index 1b94af7c0e0c4..bd2bd6cfc39a0 100644
> --- a/drivers/platform/x86/amd/pmf/sps.c
> +++ b/drivers/platform/x86/amd/pmf/sps.c
> @@ -426,5 +426,5 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
>
> void amd_pmf_deinit_sps(struct amd_pmf_dev *dev)
> {
> - platform_profile_remove();
> + platform_profile_remove(&dev->pprof);
> }
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 78621b2af0ddb..0750e2fe65325 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -4886,7 +4886,7 @@ static int asus_wmi_add(struct platform_device *pdev)
> fail_custom_fan_curve:
> fail_platform_profile_setup:
> if (asus->platform_profile_support)
> - platform_profile_remove();
> + platform_profile_remove(&asus->platform_profile_handler);
> fail_fan_boost_mode:
> fail_platform:
> kfree(asus);
> @@ -4913,7 +4913,7 @@ static void asus_wmi_remove(struct platform_device *device)
> asus_wmi_battery_exit(asus);
>
> if (asus->platform_profile_support)
> - platform_profile_remove();
> + platform_profile_remove(&asus->platform_profile_handler);
>
> kfree(asus);
> }
> diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
> index c03b1aa7dfb5f..3cf6c371d4220 100644
> --- a/drivers/platform/x86/dell/alienware-wmi.c
> +++ b/drivers/platform/x86/dell/alienware-wmi.c
> @@ -1065,7 +1065,7 @@ static int create_thermal_profile(struct platform_device *platform_device)
> static void remove_thermal_profile(void)
> {
> if (quirks->thermal)
> - platform_profile_remove();
> + platform_profile_remove(&pp_handler);
> }
>
> static int __init alienware_wmi_init(void)
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index 730f97aab70cd..65989af2e4196 100644
> --- a/drivers/platform/x86/dell/dell-pc.c
> +++ b/drivers/platform/x86/dell/dell-pc.c
> @@ -292,7 +292,7 @@ static int thermal_init(void)
> static void thermal_cleanup(void)
> {
> if (thermal_handler)
> - platform_profile_remove();
> + platform_profile_remove(thermal_handler);
> platform_device_unregister(platform_device);
> }
>
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index ffb09799142bc..6d6e13a0c6e2d 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -1693,7 +1693,7 @@ static void __exit hp_wmi_bios_remove(struct platform_device *device)
> }
>
> if (platform_profile_support)
> - platform_profile_remove();
> + platform_profile_remove(&platform_profile_handler);
> }
>
> static int hp_wmi_resume_handler(struct device *device)
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
> index 24367c3590c99..80797c6ae8b0b 100644
> --- a/drivers/platform/x86/ideapad-laptop.c
> +++ b/drivers/platform/x86/ideapad-laptop.c
> @@ -1136,7 +1136,7 @@ static void ideapad_dytc_profile_exit(struct ideapad_private *priv)
> if (!priv->dytc)
> return;
>
> - platform_profile_remove();
> + platform_profile_remove(&priv->dytc->pprof);
> mutex_destroy(&priv->dytc->mutex);
> kfree(priv->dytc);
>
> diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c
> index 5a53949bbbf5f..53af73a7fbf7b 100644
> --- a/drivers/platform/x86/inspur_platform_profile.c
> +++ b/drivers/platform/x86/inspur_platform_profile.c
> @@ -191,7 +191,10 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context)
>
> static void inspur_wmi_remove(struct wmi_device *wdev)
> {
> - platform_profile_remove();
> + struct inspur_wmi_priv *priv;
> +
> + priv = dev_get_drvdata(&wdev->dev);
> + platform_profile_remove(&priv->handler);
> }
>
> static const struct wmi_device_id inspur_wmi_id_table[] = {
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
> index 222fba97d79a7..13798c6d5fcf3 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -10638,7 +10638,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm)
>
> static void dytc_profile_exit(void)
> {
> - platform_profile_remove();
> + platform_profile_remove(&dytc_profile);
> }
>
> static struct ibm_struct dytc_profile_driver_data = {
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index daec6b9bad81f..bcaf3aa39160f 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -37,7 +37,7 @@ struct platform_profile_handler {
> };
>
> int platform_profile_register(struct platform_profile_handler *pprof);
> -int platform_profile_remove(void);
> +int platform_profile_remove(struct platform_profile_handler *pprof);
> int platform_profile_cycle(void);
> void platform_profile_notify(void);
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex
2024-11-05 15:33 ` [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
@ 2024-11-06 3:35 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:35 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> The sanity check that the platform handler had choices set doesn't
> need the mutex taken. Move it to earlier in the registration.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index c76b8e3fdcde6..4e8a155589c21 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -179,6 +179,12 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> {
> int err;
>
> + /* Sanity check the profile handler */
> + if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) ||
> + !pprof->profile_set || !pprof->profile_get) {
> + pr_err("platform_profile: handler is invalid\n");
> + return -EINVAL;
> + }
> if (!pprof->dev) {
> pr_err("platform_profile: handler device is not set\n");
> return -EINVAL;
> @@ -191,13 +197,6 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> return -EEXIST;
> }
>
> - /* Sanity check the profile handler field are set */
> - if (!pprof || bitmap_empty(pprof->choices, PLATFORM_PROFILE_LAST) ||
> - !pprof->profile_set || !pprof->profile_get) {
> - mutex_unlock(&profile_lock);
> - return -EINVAL;
> - }
> -
> err = sysfs_create_group(acpi_kobj, &platform_profile_group);
> if (err) {
> mutex_unlock(&profile_lock);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex
2024-11-05 15:33 ` [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
2024-11-05 15:38 ` Ilpo Järvinen
@ 2024-11-06 3:36 ` Armin Wolf
1 sibling, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:36 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> Holding the mutex is not necessary while scanning the string passed into
> platform_profile_store().
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 4e8a155589c21..70e7f1ba68676 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -83,6 +83,11 @@ static ssize_t platform_profile_store(struct device *dev,
> {
> int err, i;
>
> + /* Scan for a matching profile */
> + i = sysfs_match_string(profile_names, buf);
> + if (i < 0)
> + return -EINVAL;
> +
> err = mutex_lock_interruptible(&profile_lock);
> if (err)
> return err;
> @@ -92,13 +97,6 @@ static ssize_t platform_profile_store(struct device *dev,
> return -ENODEV;
> }
>
> - /* Scan for a matching profile */
> - i = sysfs_match_string(profile_names, buf);
> - if (i < 0) {
> - mutex_unlock(&profile_lock);
> - return -EINVAL;
> - }
> -
> /* Check that platform supports this profile choice */
> if (!test_bit(i, cur_profile->choices)) {
> mutex_unlock(&profile_lock);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister
2024-11-05 15:33 ` [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
@ 2024-11-06 3:37 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:37 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> guard(mutex) can be used to automatically release mutexes when going
> out of scope.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 16 +++++-----------
> 1 file changed, 5 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 70e7f1ba68676..4454c4a903c8f 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -188,32 +188,26 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> return -EINVAL;
> }
>
> - mutex_lock(&profile_lock);
> + guard(mutex)(&profile_lock);
> /* We can only have one active profile */
> - if (cur_profile) {
> - mutex_unlock(&profile_lock);
> + if (cur_profile)
> return -EEXIST;
> - }
>
> err = sysfs_create_group(acpi_kobj, &platform_profile_group);
> - if (err) {
> - mutex_unlock(&profile_lock);
> + if (err)
> return err;
> - }
>
> cur_profile = pprof;
> - mutex_unlock(&profile_lock);
> return 0;
> }
> EXPORT_SYMBOL_GPL(platform_profile_register);
>
> int platform_profile_remove(struct platform_profile_handler *pprof)
> {
> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
> + guard(mutex)(&profile_lock);
>
> - mutex_lock(&profile_lock);
> + sysfs_remove_group(acpi_kobj, &platform_profile_group);
> cur_profile = NULL;
> - mutex_unlock(&profile_lock);
> return 0;
> }
> EXPORT_SYMBOL_GPL(platform_profile_remove);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile
2024-11-05 15:33 ` [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
@ 2024-11-06 3:53 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:53 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> When registering a platform profile handler create a class device
> that will allow changing a single platform profile handler.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 42 +++++++++++++++++++++++++++++---
> include/linux/platform_profile.h | 2 ++
> 2 files changed, 41 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index fd1c4e9dccf0a..f8e9dc9a10d54 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -5,6 +5,7 @@
> #include <linux/acpi.h>
> #include <linux/bits.h>
> #include <linux/init.h>
> +#include <linux/kdev_t.h>
> #include <linux/mutex.h>
> #include <linux/platform_profile.h>
> #include <linux/sysfs.h>
> @@ -22,6 +23,12 @@ static const char * const profile_names[] = {
> };
> static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
>
> +static DEFINE_IDR(platform_profile_minor_idr);
Please use a IDA instead, you can take a look at the hwmon subsystem for an example.
> +
> +static const struct class platform_profile_class = {
> + .name = "platform-profile",
> +};
> +
> static ssize_t platform_profile_choices_show(struct device *dev,
> struct device_attribute *attr,
> char *buf)
> @@ -113,6 +120,8 @@ void platform_profile_notify(void)
> {
> if (!cur_profile)
> return;
> + if (!class_is_registered(&platform_profile_class))
> + return;
> sysfs_notify(acpi_kobj, NULL, "platform_profile");
> }
> EXPORT_SYMBOL_GPL(platform_profile_notify);
> @@ -123,6 +132,9 @@ int platform_profile_cycle(void)
> enum platform_profile_option next;
> int err;
>
> + if (!class_is_registered(&platform_profile_class))
> + return -ENODEV;
> +
> scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> if (!cur_profile)
> return -ENODEV;
> @@ -167,12 +179,33 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> if (cur_profile)
> return -EEXIST;
>
> - err = sysfs_create_group(acpi_kobj, &platform_profile_group);
> - if (err)
> - return err;
> + if (!class_is_registered(&platform_profile_class)) {
> + /* class for individual handlers */
> + err = class_register(&platform_profile_class);
> + if (err)
> + return err;
I think it would be better to register the class during module initialization. This way userspace
applications can depend on the class directory being present if the driver has been loaded (even if
it might be empty).
> + /* legacy sysfs files */
> + err = sysfs_create_group(acpi_kobj, &platform_profile_group);
> + if (err)
> + goto cleanup_class;
> + }
> +
> + /* create class interface for individual handler */
> + pprof->minor = idr_alloc(&platform_profile_minor_idr, pprof, 0, 0, GFP_KERNEL);
> + pprof->class_dev = device_create(&platform_profile_class, pprof->dev,
> + MKDEV(0, pprof->minor), NULL, "platform-profile-%d",
> + pprof->minor);
Please use MKDEV(0, 0), as we have no associated character device.
> + if (IS_ERR(pprof->class_dev))
> + return PTR_ERR(pprof->class_dev);
You still need to free "minor" in case of an error.
> + dev_set_drvdata(pprof->class_dev, pprof);
Please use device_create() for setting the drvdata of the class device.
>
> cur_profile = pprof;
> return 0;
> +
> +cleanup_class:
> + class_unregister(&platform_profile_class);
> +
> + return err;
> }
> EXPORT_SYMBOL_GPL(platform_profile_register);
>
> @@ -181,6 +214,9 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
> guard(mutex)(&profile_lock);
>
> sysfs_remove_group(acpi_kobj, &platform_profile_group);
> +
> + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
Using device_unregister() would be more suitable here. Also keep in mind that "minor" still
needs to be freed. Again drivers/hwmon/hwmon.c could be useful in this regard.
Thanks,
Armin Wolf
> +
> cur_profile = NULL;
> return 0;
> }
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index bcaf3aa39160f..f81c3afcb7575 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -29,6 +29,8 @@ enum platform_profile_option {
> struct platform_profile_handler {
> const char *name;
> struct device *dev;
> + struct device *class_dev;
> + int minor;
> unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
> int (*profile_get)(struct platform_profile_handler *pprof,
> enum platform_profile_option *profile);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface
2024-11-05 15:33 ` [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
@ 2024-11-06 3:56 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 3:56 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> The name attribute shows the name of the associated platform profile
> handler.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index f8e9dc9a10d54..986bd636be226 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -25,8 +25,33 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
>
> static DEFINE_IDR(platform_profile_minor_idr);
>
> +/**
> + * name_show - Show the name of the profile handler
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to write to
> + * Return: The number of bytes written
> + */
> +static ssize_t name_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct platform_profile_handler *handler = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%s\n", handler->name);
> +}
> +
> +
Please don't use multiple blank lines.
Other than that:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> +static DEVICE_ATTR_RO(name);
> +static struct attribute *profile_attrs[] = {
> + &dev_attr_name.attr,
> + NULL
> +};
> +ATTRIBUTE_GROUPS(profile);
> +
> static const struct class platform_profile_class = {
> .name = "platform-profile",
> + .dev_groups = profile_groups,
> };
>
> static ssize_t platform_profile_choices_show(struct device *dev,
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-05 15:33 ` [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
2024-11-06 1:09 ` kernel test robot
@ 2024-11-06 4:00 ` Armin Wolf
1 sibling, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 4:00 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> The `choices` file will show all possible choices that a given platform
> profile handler can support.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 63 +++++++++++++++++++++++++++++++++
> 1 file changed, 63 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 986bd636be226..e1b6569c4ee70 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -25,6 +25,47 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
>
> static DEFINE_IDR(platform_profile_minor_idr);
>
> +/**
> + * _commmon_choices_show - Show the available profile choices
> + * @choices: The available profile choices
> + * @buf: The buffer to write to
> + * Return: The number of bytes written
> + */
> +static ssize_t _commmon_choices_show(unsigned long choices, char *buf)
> +{
> + int i, len = 0;
> +
> + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) {
> + if (len == 0)
> + len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
> + else
> + len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
> + }
> + len += sysfs_emit_at(buf, len, "\n");
> +
> + return len;
> +}
> +
> +/**
> + * _get_class_choices - Get the available profile choices for a class device
> + * @dev: The class device
> + * Return: The available profile choices
> + */
> +static int _get_class_choices(struct device *dev, unsigned long *choices)
> +{
> + struct platform_profile_handler *handler;
> + int i;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + handler = dev_get_drvdata(dev);
> + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
> + *choices |= BIT(i);
> + }
> +
> + return 0;
> +}
> +
> +
Please don't use multiple blank lines.
Other than that:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> /**
> * name_show - Show the name of the profile handler
> * @dev: The device
> @@ -41,10 +82,32 @@ static ssize_t name_show(struct device *dev,
> return sysfs_emit(buf, "%s\n", handler->name);
> }
>
> +/**
> + * choices_show - Show the available profile choices
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to write to
> + */
> +static ssize_t choices_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + unsigned long choices = 0;
> + int err;
> +
> + err = _get_class_choices(dev, &choices);
> + if (err)
> + return err;
> +
> + return _commmon_choices_show(choices, buf);
> +}
> +
>
> static DEVICE_ATTR_RO(name);
> +static DEVICE_ATTR_RO(choices);
> static struct attribute *profile_attrs[] = {
> &dev_attr_name.attr,
> + &dev_attr_choices.attr,
> NULL
> };
> ATTRIBUTE_GROUPS(profile);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-05 15:33 ` [PATCH v4 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
@ 2024-11-06 4:10 ` Armin Wolf
2024-11-06 5:46 ` Mario Limonciello
0 siblings, 1 reply; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 4:10 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> Reading and writing the `profile` sysfs file will use the callbacks for
> the platform profile handler to read or set the given profile.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 118 ++++++++++++++++++++++++++++++++
> 1 file changed, 118 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index e1b6569c4ee70..79083d0bb22e3 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -65,6 +65,78 @@ static int _get_class_choices(struct device *dev, unsigned long *choices)
> return 0;
> }
>
> +/**
> + * _store_class_profile - Set the profile for a class device
> + * @dev: The class device
> + * @data: The profile to set
> + */
> +static int _store_class_profile(struct device *dev, void *data)
> +{
> + enum platform_profile_option profile;
> + unsigned long choices;
> + int *i = (int *)data;
> + int err;
> +
> + err = _get_class_choices(dev, &choices);
> + if (err)
> + return err;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + struct platform_profile_handler *handler;
> +
> + if (!test_bit(*i, &choices))
> + return -EOPNOTSUPP;
> +
> + handler = dev_get_drvdata(dev);
> + err = handler->profile_get(handler, &profile);
> + if (err)
> + return err;
> +
> + err = handler->profile_set(handler, *i);
> + if (err) {
> + int recover_err;
> +
> + dev_err(dev, "Failed to set profile: %d\n", err);
> + recover_err = handler->profile_set(handler, profile);
> + if (recover_err)
> + dev_err(dev, "Failed to reset profile: %d\n", recover_err);
> + }
The whole recovery handling seems unnecessary to me. In setting the platform profile fails, then
we should just return an error. The platform profile handler will tell us the current platform
profile anyway.
> + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile");
> + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE);
Please avoid sending those events when the platform profile is changed through the class sysfs interface.
> + }
> +
> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
Please avoid sending this event when the platform profile is changed through the legacy sysfs interface.
> + return err ? err : 0;
> +}
> +
> +/**
> + * get_class_profile - Show the current profile for a class device
> + * @dev: The class device
> + * @profile: The profile to return
> + * Return: 0 on success, -errno on failure
> + */
> +static int get_class_profile(struct device *dev,
> + enum platform_profile_option *profile)
> +{
> + struct platform_profile_handler *handler;
> + enum platform_profile_option val;
> + int err;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + handler = dev_get_drvdata(dev);
> + err = handler->profile_get(handler, &val);
> + if (err) {
> + pr_err("Failed to get profile for handler %s\n", handler->name);
> + return err;
> + }
> + }
> +
> + if (WARN_ON(val >= PLATFORM_PROFILE_LAST))
> + return -EINVAL;
> + *profile = val;
> +
> + return 0;
> +}
>
> /**
> * name_show - Show the name of the profile handler
> @@ -102,12 +174,58 @@ static ssize_t choices_show(struct device *dev,
> return _commmon_choices_show(choices, buf);
> }
>
> +/**
> + * profile_show - Show the current profile for a class device
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to write to
> + * Return: The number of bytes written
> + */
> +static ssize_t profile_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
> + int err;
> +
> + err = get_class_profile(dev, &profile);
> + if (err)
> + return err;
> +
> + return sysfs_emit(buf, "%s\n", profile_names[profile]);
> +}
> +
> +/**
> + * profile_store - Set the profile for a class device
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to read from
> + * @count: The number of bytes to read
> + * Return: The number of bytes read
> + */
> +static ssize_t profile_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + int i, ret;
> +
> + i = sysfs_match_string(profile_names, buf);
> + if (i < 0)
> + return -EINVAL;
> +
> + ret = _store_class_profile(dev, (void *)(long)&i);
Please just pass &i.
Thanks,
Armin Wolf
> +
> + return ret ? ret : count;
> +}
>
> static DEVICE_ATTR_RO(name);
> static DEVICE_ATTR_RO(choices);
> +static DEVICE_ATTR_RW(profile);
> +
> static struct attribute *profile_attrs[] = {
> &dev_attr_name.attr,
> &dev_attr_choices.attr,
> + &dev_attr_profile.attr,
> NULL
> };
> ATTRIBUTE_GROUPS(profile);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-06 4:10 ` Armin Wolf
@ 2024-11-06 5:46 ` Mario Limonciello
2024-11-06 19:15 ` Armin Wolf
0 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-06 5:46 UTC (permalink / raw)
To: Armin Wolf, Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
On 11/5/24 22:10, Armin Wolf wrote:
> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>
>> Reading and writing the `profile` sysfs file will use the callbacks for
>> the platform profile handler to read or set the given profile.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> drivers/acpi/platform_profile.c | 118 ++++++++++++++++++++++++++++++++
>> 1 file changed, 118 insertions(+)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index e1b6569c4ee70..79083d0bb22e3 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -65,6 +65,78 @@ static int _get_class_choices(struct device *dev,
>> unsigned long *choices)
>> return 0;
>> }
>>
>> +/**
>> + * _store_class_profile - Set the profile for a class device
>> + * @dev: The class device
>> + * @data: The profile to set
>> + */
>> +static int _store_class_profile(struct device *dev, void *data)
>> +{
>> + enum platform_profile_option profile;
>> + unsigned long choices;
>> + int *i = (int *)data;
>> + int err;
>> +
>> + err = _get_class_choices(dev, &choices);
>> + if (err)
>> + return err;
>> +
>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> + struct platform_profile_handler *handler;
>> +
>> + if (!test_bit(*i, &choices))
>> + return -EOPNOTSUPP;
>> +
>> + handler = dev_get_drvdata(dev);
>> + err = handler->profile_get(handler, &profile);
>> + if (err)
>> + return err;
>> +
>> + err = handler->profile_set(handler, *i);
>> + if (err) {
>> + int recover_err;
>> +
>> + dev_err(dev, "Failed to set profile: %d\n", err);
>> + recover_err = handler->profile_set(handler, profile);
>> + if (recover_err)
>> + dev_err(dev, "Failed to reset profile: %d\n",
>> recover_err);
>> + }
>
> The whole recovery handling seems unnecessary to me. In setting the
> platform profile fails, then
> we should just return an error. The platform profile handler will tell
> us the current platform
> profile anyway.
Sure, makes sense. That also means no need to capture the profile
before setting it.
>
>> + sysfs_notify(&handler->class_dev->kobj, NULL,
>> "platform_profile");
>> + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE);
>
> Please avoid sending those events when the platform profile is changed
> through the class sysfs interface.
>
>> + }
>> +
>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>
> Please avoid sending this event when the platform profile is changed
> through the legacy sysfs interface.
In both above cases - why?
* If I change using class interface then that implicitly means that
legacy interface changes.
* If I change using legacy interface that implicitly means class
interface changes too.
>
>> + return err ? err : 0;
>> +}
>> +
>> +/**
>> + * get_class_profile - Show the current profile for a class device
>> + * @dev: The class device
>> + * @profile: The profile to return
>> + * Return: 0 on success, -errno on failure
>> + */
>> +static int get_class_profile(struct device *dev,
>> + enum platform_profile_option *profile)
>> +{
>> + struct platform_profile_handler *handler;
>> + enum platform_profile_option val;
>> + int err;
>> +
>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> + handler = dev_get_drvdata(dev);
>> + err = handler->profile_get(handler, &val);
>> + if (err) {
>> + pr_err("Failed to get profile for handler %s\n", handler-
>> >name);
>> + return err;
>> + }
>> + }
>> +
>> + if (WARN_ON(val >= PLATFORM_PROFILE_LAST))
>> + return -EINVAL;
>> + *profile = val;
>> +
>> + return 0;
>> +}
>>
>> /**
>> * name_show - Show the name of the profile handler
>> @@ -102,12 +174,58 @@ static ssize_t choices_show(struct device *dev,
>> return _commmon_choices_show(choices, buf);
>> }
>>
>> +/**
>> + * profile_show - Show the current profile for a class device
>> + * @dev: The device
>> + * @attr: The attribute
>> + * @buf: The buffer to write to
>> + * Return: The number of bytes written
>> + */
>> +static ssize_t profile_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
>> + int err;
>> +
>> + err = get_class_profile(dev, &profile);
>> + if (err)
>> + return err;
>> +
>> + return sysfs_emit(buf, "%s\n", profile_names[profile]);
>> +}
>> +
>> +/**
>> + * profile_store - Set the profile for a class device
>> + * @dev: The device
>> + * @attr: The attribute
>> + * @buf: The buffer to read from
>> + * @count: The number of bytes to read
>> + * Return: The number of bytes read
>> + */
>> +static ssize_t profile_store(struct device *dev,
>> + struct device_attribute *attr,
>> + const char *buf, size_t count)
>> +{
>> + int i, ret;
>> +
>> + i = sysfs_match_string(profile_names, buf);
>> + if (i < 0)
>> + return -EINVAL;
>> +
>> + ret = _store_class_profile(dev, (void *)(long)&i);
>
> Please just pass &i.
Ack.
>
> Thanks,
> Armin Wolf
>
>> +
>> + return ret ? ret : count;
>> +}
>>
>> static DEVICE_ATTR_RO(name);
>> static DEVICE_ATTR_RO(choices);
>> +static DEVICE_ATTR_RW(profile);
>> +
>> static struct attribute *profile_attrs[] = {
>> &dev_attr_name.attr,
>> &dev_attr_choices.attr,
>> + &dev_attr_profile.attr,
>> NULL
>> };
>> ATTRIBUTE_GROUPS(profile);
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-06 5:46 ` Mario Limonciello
@ 2024-11-06 19:15 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:15 UTC (permalink / raw)
To: Mario Limonciello, Mario Limonciello, Hans de Goede,
Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 06.11.24 um 06:46 schrieb Mario Limonciello:
>
>
> On 11/5/24 22:10, Armin Wolf wrote:
>> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>>
>>> Reading and writing the `profile` sysfs file will use the callbacks for
>>> the platform profile handler to read or set the given profile.
>>>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> drivers/acpi/platform_profile.c | 118
>>> ++++++++++++++++++++++++++++++++
>>> 1 file changed, 118 insertions(+)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index e1b6569c4ee70..79083d0bb22e3 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -65,6 +65,78 @@ static int _get_class_choices(struct device *dev,
>>> unsigned long *choices)
>>> return 0;
>>> }
>>>
>>> +/**
>>> + * _store_class_profile - Set the profile for a class device
>>> + * @dev: The class device
>>> + * @data: The profile to set
>>> + */
>>> +static int _store_class_profile(struct device *dev, void *data)
>>> +{
>>> + enum platform_profile_option profile;
>>> + unsigned long choices;
>>> + int *i = (int *)data;
>>> + int err;
>>> +
>>> + err = _get_class_choices(dev, &choices);
>>> + if (err)
>>> + return err;
>>> +
>>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> + struct platform_profile_handler *handler;
>>> +
>>> + if (!test_bit(*i, &choices))
>>> + return -EOPNOTSUPP;
>>> +
>>> + handler = dev_get_drvdata(dev);
>>> + err = handler->profile_get(handler, &profile);
>>> + if (err)
>>> + return err;
>>> +
>>> + err = handler->profile_set(handler, *i);
>>> + if (err) {
>>> + int recover_err;
>>> +
>>> + dev_err(dev, "Failed to set profile: %d\n", err);
>>> + recover_err = handler->profile_set(handler, profile);
>>> + if (recover_err)
>>> + dev_err(dev, "Failed to reset profile: %d\n",
>>> recover_err);
>>> + }
>>
>> The whole recovery handling seems unnecessary to me. In setting the
>> platform profile fails, then
>> we should just return an error. The platform profile handler will
>> tell us the current platform
>> profile anyway.
>
> Sure, makes sense. That also means no need to capture the profile
> before setting it.
>
>>
>>> + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile");
>>> + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE);
>>
>> Please avoid sending those events when the platform profile is
>> changed through the class sysfs interface.
>>
>>> + }
>>> +
>>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>
>> Please avoid sending this event when the platform profile is changed
>> through the legacy sysfs interface.
>
> In both above cases - why?
>
> * If I change using class interface then that implicitly means that
> legacy interface changes.
> * If I change using legacy interface that implicitly means class
> interface changes too.
>
I meant that:
- if the profile is changed using the class interface then only the legacy interface should be notified
- if the profile is changed using the legacy interface then only the class interface should be notified
Thanks,
Armin Wolf
>>
>>> + return err ? err : 0;
>>> +}
>>> +
>>> +/**
>>> + * get_class_profile - Show the current profile for a class device
>>> + * @dev: The class device
>>> + * @profile: The profile to return
>>> + * Return: 0 on success, -errno on failure
>>> + */
>>> +static int get_class_profile(struct device *dev,
>>> + enum platform_profile_option *profile)
>>> +{
>>> + struct platform_profile_handler *handler;
>>> + enum platform_profile_option val;
>>> + int err;
>>> +
>>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> + handler = dev_get_drvdata(dev);
>>> + err = handler->profile_get(handler, &val);
>>> + if (err) {
>>> + pr_err("Failed to get profile for handler %s\n",
>>> handler- >name);
>>> + return err;
>>> + }
>>> + }
>>> +
>>> + if (WARN_ON(val >= PLATFORM_PROFILE_LAST))
>>> + return -EINVAL;
>>> + *profile = val;
>>> +
>>> + return 0;
>>> +}
>>>
>>> /**
>>> * name_show - Show the name of the profile handler
>>> @@ -102,12 +174,58 @@ static ssize_t choices_show(struct device *dev,
>>> return _commmon_choices_show(choices, buf);
>>> }
>>>
>>> +/**
>>> + * profile_show - Show the current profile for a class device
>>> + * @dev: The device
>>> + * @attr: The attribute
>>> + * @buf: The buffer to write to
>>> + * Return: The number of bytes written
>>> + */
>>> +static ssize_t profile_show(struct device *dev,
>>> + struct device_attribute *attr,
>>> + char *buf)
>>> +{
>>> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
>>> + int err;
>>> +
>>> + err = get_class_profile(dev, &profile);
>>> + if (err)
>>> + return err;
>>> +
>>> + return sysfs_emit(buf, "%s\n", profile_names[profile]);
>>> +}
>>> +
>>> +/**
>>> + * profile_store - Set the profile for a class device
>>> + * @dev: The device
>>> + * @attr: The attribute
>>> + * @buf: The buffer to read from
>>> + * @count: The number of bytes to read
>>> + * Return: The number of bytes read
>>> + */
>>> +static ssize_t profile_store(struct device *dev,
>>> + struct device_attribute *attr,
>>> + const char *buf, size_t count)
>>> +{
>>> + int i, ret;
>>> +
>>> + i = sysfs_match_string(profile_names, buf);
>>> + if (i < 0)
>>> + return -EINVAL;
>>> +
>>> + ret = _store_class_profile(dev, (void *)(long)&i);
>>
>> Please just pass &i.
>
> Ack.
>
>>
>> Thanks,
>> Armin Wolf
>>
>>> +
>>> + return ret ? ret : count;
>>> +}
>>>
>>> static DEVICE_ATTR_RO(name);
>>> static DEVICE_ATTR_RO(choices);
>>> +static DEVICE_ATTR_RW(profile);
>>> +
>>> static struct attribute *profile_attrs[] = {
>>> &dev_attr_name.attr,
>>> &dev_attr_choices.attr,
>>> + &dev_attr_profile.attr,
>>> NULL
>>> };
>>> ATTRIBUTE_GROUPS(profile);
>>
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile
2024-11-05 15:33 ` [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
@ 2024-11-06 19:17 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:17 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> When two profile handlers don't agree on the current profile it's ambiguous
> what to show to the legacy sysfs interface.
>
> Add a "custom" profile string that userspace will be able to distinguish
> this situation when using the legacy sysfs interface.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 1 +
> include/linux/platform_profile.h | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 8de7c8352673e..d8c2d195106c2 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -20,6 +20,7 @@ static const char * const profile_names[] = {
> [PLATFORM_PROFILE_BALANCED] = "balanced",
> [PLATFORM_PROFILE_BALANCED_PERFORMANCE] = "balanced-performance",
> [PLATFORM_PROFILE_PERFORMANCE] = "performance",
> + [PLATFORM_PROFILE_CUSTOM] = "custom",
> };
> static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
>
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index f81c3afcb7575..d2a2ab4c6cee9 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -23,6 +23,7 @@ enum platform_profile_option {
> PLATFORM_PROFILE_BALANCED,
> PLATFORM_PROFILE_BALANCED_PERFORMANCE,
> PLATFORM_PROFILE_PERFORMANCE,
> + PLATFORM_PROFILE_CUSTOM,
> PLATFORM_PROFILE_LAST, /*must always be last */
> };
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers
2024-11-05 15:33 ` [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
@ 2024-11-06 19:21 ` Armin Wolf
2024-11-06 19:33 ` Armin Wolf
0 siblings, 1 reply; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:21 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> Multiple drivers may attempt to register platform profile handlers,
> but only one may be registered and the behavior is non-deterministic
> for which one wins. It's mostly controlled by probing order.
>
> This can be problematic if one driver changes CPU settings and another
> driver notifies the EC for changing fan curves.
>
> Modify the ACPI platform profile handler to let multiple drivers
> register platform profile handlers and abstract this detail from userspace.
>
> To avoid undefined behaviors only offer profiles that are commonly
> advertised across multiple handlers.
>
> If any problems occur when changing profiles for any driver, then revert
> back to the balanced profile, which is now required.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 568485e285061..b9eb25f58a2a2 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -10,7 +10,6 @@
> #include <linux/platform_profile.h>
> #include <linux/sysfs.h>
>
> -static struct platform_profile_handler *cur_profile;
> static DEFINE_MUTEX(profile_lock);
>
> static const char * const profile_names[] = {
> @@ -368,8 +367,7 @@ static const struct attribute_group platform_profile_group = {
>
> void platform_profile_notify(void)
> {
> - if (!cur_profile)
> - return;
> + guard(mutex)(&profile_lock);
> if (!class_is_registered(&platform_profile_class))
> return;
> sysfs_notify(acpi_kobj, NULL, "platform_profile");
> @@ -428,9 +426,6 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> }
>
> guard(mutex)(&profile_lock);
> - /* We can only have one active profile */
> - if (cur_profile)
> - return -EEXIST;
>
> if (!class_is_registered(&platform_profile_class)) {
> /* class for individual handlers */
> @@ -451,9 +446,9 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> if (IS_ERR(pprof->class_dev))
> return PTR_ERR(pprof->class_dev);
> dev_set_drvdata(pprof->class_dev, pprof);
> +
> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>
> - cur_profile = pprof;
> return 0;
>
> cleanup_class:
> @@ -467,13 +462,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
> {
> guard(mutex)(&profile_lock);
>
> - cur_profile = NULL;
> -
> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>
> device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
>
> - cur_profile = NULL;
> return 0;
> }
> EXPORT_SYMBOL_GPL(platform_profile_remove);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks
2024-11-05 15:33 ` [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
@ 2024-11-06 19:30 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:30 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> As multiple platform profile handlers can now be registered, the quirks
> to avoid registering amd-pmf as a handler are no longer necessary.
> Drop them.
I love it when we can get rid of quirk tables, so:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/platform/x86/amd/pmf/Makefile | 2 +-
> drivers/platform/x86/amd/pmf/core.c | 1 -
> drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 -----------------------
> drivers/platform/x86/amd/pmf/pmf.h | 3 --
> 4 files changed, 1 insertion(+), 71 deletions(-)
> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>
> diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile
> index 7d6079b02589c..6b26e48ce8ad2 100644
> --- a/drivers/platform/x86/amd/pmf/Makefile
> +++ b/drivers/platform/x86/amd/pmf/Makefile
> @@ -7,4 +7,4 @@
> obj-$(CONFIG_AMD_PMF) += amd-pmf.o
> amd-pmf-objs := core.o acpi.o sps.o \
> auto-mode.o cnqf.o \
> - tee-if.o spc.o pmf-quirks.o
> + tee-if.o spc.o
> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
> index 47126abd13ca0..6ad00b3d472fe 100644
> --- a/drivers/platform/x86/amd/pmf/core.c
> +++ b/drivers/platform/x86/amd/pmf/core.c
> @@ -455,7 +455,6 @@ static int amd_pmf_probe(struct platform_device *pdev)
> mutex_init(&dev->lock);
> mutex_init(&dev->update_mutex);
>
> - amd_pmf_quirks_init(dev);
> apmf_acpi_init(dev);
> platform_set_drvdata(pdev, dev);
> amd_pmf_dbgfs_register(dev);
> diff --git a/drivers/platform/x86/amd/pmf/pmf-quirks.c b/drivers/platform/x86/amd/pmf/pmf-quirks.c
> deleted file mode 100644
> index 7cde5733b9cac..0000000000000
> --- a/drivers/platform/x86/amd/pmf/pmf-quirks.c
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-or-later
> -/*
> - * AMD Platform Management Framework Driver Quirks
> - *
> - * Copyright (c) 2024, Advanced Micro Devices, Inc.
> - * All Rights Reserved.
> - *
> - * Author: Mario Limonciello <mario.limonciello@amd.com>
> - */
> -
> -#include <linux/dmi.h>
> -
> -#include "pmf.h"
> -
> -struct quirk_entry {
> - u32 supported_func;
> -};
> -
> -static struct quirk_entry quirk_no_sps_bug = {
> - .supported_func = 0x4003,
> -};
> -
> -static const struct dmi_system_id fwbug_list[] = {
> - {
> - .ident = "ROG Zephyrus G14",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "GA403U"),
> - },
> - .driver_data = &quirk_no_sps_bug,
> - },
> - {
> - .ident = "ROG Ally X",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "RC72LA"),
> - },
> - .driver_data = &quirk_no_sps_bug,
> - },
> - {
> - .ident = "ASUS TUF Gaming A14",
> - .matches = {
> - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> - DMI_MATCH(DMI_PRODUCT_NAME, "FA401W"),
> - },
> - .driver_data = &quirk_no_sps_bug,
> - },
> - {}
> -};
> -
> -void amd_pmf_quirks_init(struct amd_pmf_dev *dev)
> -{
> - const struct dmi_system_id *dmi_id;
> - struct quirk_entry *quirks;
> -
> - dmi_id = dmi_first_match(fwbug_list);
> - if (!dmi_id)
> - return;
> -
> - quirks = dmi_id->driver_data;
> - if (quirks->supported_func) {
> - dev->supported_func = quirks->supported_func;
> - pr_info("Using supported funcs quirk to avoid %s platform firmware bug\n",
> - dmi_id->ident);
> - }
> -}
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 8ce8816da9c16..b89aa38434faa 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -795,7 +795,4 @@ int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq
> void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
> void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
>
> -/* Quirk infrastructure */
> -void amd_pmf_quirks_init(struct amd_pmf_dev *dev);
> -
> #endif /* PMF_H */
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers
2024-11-06 19:21 ` Armin Wolf
@ 2024-11-06 19:33 ` Armin Wolf
2024-11-06 19:34 ` Mario Limonciello
0 siblings, 1 reply; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:33 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 06.11.24 um 20:21 schrieb Armin Wolf:
> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>
>> Multiple drivers may attempt to register platform profile handlers,
>> but only one may be registered and the behavior is non-deterministic
>> for which one wins. It's mostly controlled by probing order.
>>
>> This can be problematic if one driver changes CPU settings and another
>> driver notifies the EC for changing fan curves.
>>
>> Modify the ACPI platform profile handler to let multiple drivers
>> register platform profile handlers and abstract this detail from
>> userspace.
>>
>> To avoid undefined behaviors only offer profiles that are commonly
>> advertised across multiple handlers.
>>
>> If any problems occur when changing profiles for any driver, then revert
>> back to the balanced profile, which is now required.
>
> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
>
I just noticed that the following text might need to be removed:
"If any problems occur when changing profiles for any driver, then revert
back to the balanced profile, which is now required."
Thanks,
Armin Wolf
>> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> drivers/acpi/platform_profile.c | 12 ++----------
>> 1 file changed, 2 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c
>> b/drivers/acpi/platform_profile.c
>> index 568485e285061..b9eb25f58a2a2 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -10,7 +10,6 @@
>> #include <linux/platform_profile.h>
>> #include <linux/sysfs.h>
>>
>> -static struct platform_profile_handler *cur_profile;
>> static DEFINE_MUTEX(profile_lock);
>>
>> static const char * const profile_names[] = {
>> @@ -368,8 +367,7 @@ static const struct attribute_group
>> platform_profile_group = {
>>
>> void platform_profile_notify(void)
>> {
>> - if (!cur_profile)
>> - return;
>> + guard(mutex)(&profile_lock);
>> if (!class_is_registered(&platform_profile_class))
>> return;
>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>> @@ -428,9 +426,6 @@ int platform_profile_register(struct
>> platform_profile_handler *pprof)
>> }
>>
>> guard(mutex)(&profile_lock);
>> - /* We can only have one active profile */
>> - if (cur_profile)
>> - return -EEXIST;
>>
>> if (!class_is_registered(&platform_profile_class)) {
>> /* class for individual handlers */
>> @@ -451,9 +446,9 @@ int platform_profile_register(struct
>> platform_profile_handler *pprof)
>> if (IS_ERR(pprof->class_dev))
>> return PTR_ERR(pprof->class_dev);
>> dev_set_drvdata(pprof->class_dev, pprof);
>> +
>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>
>> - cur_profile = pprof;
>> return 0;
>>
>> cleanup_class:
>> @@ -467,13 +462,10 @@ int platform_profile_remove(struct
>> platform_profile_handler *pprof)
>> {
>> guard(mutex)(&profile_lock);
>>
>> - cur_profile = NULL;
>> -
>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>
>> device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
>>
>> - cur_profile = NULL;
>> return 0;
>> }
>> EXPORT_SYMBOL_GPL(platform_profile_remove);
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers
2024-11-06 19:33 ` Armin Wolf
@ 2024-11-06 19:34 ` Mario Limonciello
0 siblings, 0 replies; 55+ messages in thread
From: Mario Limonciello @ 2024-11-06 19:34 UTC (permalink / raw)
To: Armin Wolf, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
On 11/6/2024 13:33, Armin Wolf wrote:
> Am 06.11.24 um 20:21 schrieb Armin Wolf:
>
>> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>>
>>> Multiple drivers may attempt to register platform profile handlers,
>>> but only one may be registered and the behavior is non-deterministic
>>> for which one wins. It's mostly controlled by probing order.
>>>
>>> This can be problematic if one driver changes CPU settings and another
>>> driver notifies the EC for changing fan curves.
>>>
>>> Modify the ACPI platform profile handler to let multiple drivers
>>> register platform profile handlers and abstract this detail from
>>> userspace.
>>>
>>> To avoid undefined behaviors only offer profiles that are commonly
>>> advertised across multiple handlers.
>>>
>>> If any problems occur when changing profiles for any driver, then revert
>>> back to the balanced profile, which is now required.
>>
>> Reviewed-by: Armin Wolf <W_Armin@gmx.de>
>>
> I just noticed that the following text might need to be removed:
>
> "If any problems occur when changing profiles for any driver, then revert
> back to the balanced profile, which is now required."
Good catch, thanks.
>
> Thanks,
> Armin Wolf
>
>>> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
>>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> drivers/acpi/platform_profile.c | 12 ++----------
>>> 1 file changed, 2 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c
>>> b/drivers/acpi/platform_profile.c
>>> index 568485e285061..b9eb25f58a2a2 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -10,7 +10,6 @@
>>> #include <linux/platform_profile.h>
>>> #include <linux/sysfs.h>
>>>
>>> -static struct platform_profile_handler *cur_profile;
>>> static DEFINE_MUTEX(profile_lock);
>>>
>>> static const char * const profile_names[] = {
>>> @@ -368,8 +367,7 @@ static const struct attribute_group
>>> platform_profile_group = {
>>>
>>> void platform_profile_notify(void)
>>> {
>>> - if (!cur_profile)
>>> - return;
>>> + guard(mutex)(&profile_lock);
>>> if (!class_is_registered(&platform_profile_class))
>>> return;
>>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>> @@ -428,9 +426,6 @@ int platform_profile_register(struct
>>> platform_profile_handler *pprof)
>>> }
>>>
>>> guard(mutex)(&profile_lock);
>>> - /* We can only have one active profile */
>>> - if (cur_profile)
>>> - return -EEXIST;
>>>
>>> if (!class_is_registered(&platform_profile_class)) {
>>> /* class for individual handlers */
>>> @@ -451,9 +446,9 @@ int platform_profile_register(struct
>>> platform_profile_handler *pprof)
>>> if (IS_ERR(pprof->class_dev))
>>> return PTR_ERR(pprof->class_dev);
>>> dev_set_drvdata(pprof->class_dev, pprof);
>>> +
>>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>>
>>> - cur_profile = pprof;
>>> return 0;
>>>
>>> cleanup_class:
>>> @@ -467,13 +462,10 @@ int platform_profile_remove(struct
>>> platform_profile_handler *pprof)
>>> {
>>> guard(mutex)(&profile_lock);
>>>
>>> - cur_profile = NULL;
>>> -
>>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>>
>>> device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
>>>
>>> - cur_profile = NULL;
>>> return 0;
>>> }
>>> EXPORT_SYMBOL_GPL(platform_profile_remove);
>>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device
2024-11-05 15:32 ` [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
@ 2024-11-06 19:37 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:37 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:32 schrieb Mario Limonciello:
> In order to have a device for the platform profile core to reference
> create a platform device for dell-pc.
>
> While doing this change the memory allocation for the thermal handler
> to be device managed to follow the lifecycle of that device.
>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++--------
> 1 file changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index 3cf79e55e3129..b145fedb6b710 100644
> --- a/drivers/platform/x86/dell/dell-pc.c
> +++ b/drivers/platform/x86/dell/dell-pc.c
> @@ -18,10 +18,13 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/platform_profile.h>
> +#include <linux/platform_device.h>
> #include <linux/slab.h>
>
> #include "dell-smbios.h"
>
> +static struct platform_device *platform_device;
> +
> static const struct dmi_system_id dell_device_table[] __initconst = {
> {
> .ident = "Dell Inc.",
> @@ -244,9 +247,18 @@ static int thermal_init(void)
> if (!supported_modes)
> return 0;
>
> - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL);
> - if (!thermal_handler)
> + platform_device = platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE);
> + if (!platform_device)
> return -ENOMEM;
> + ret = platform_device_add(platform_device);
Please use platform_device_register_simple() here.
Other than that:
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
> + if (ret)
> + goto cleanup_platform_device;
> +
> + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL);
> + if (!thermal_handler) {
> + ret = -ENOMEM;
> + goto cleanup_platform_device;
> + }
> thermal_handler->name = "dell-pc";
> thermal_handler->profile_get = thermal_platform_profile_get;
> thermal_handler->profile_set = thermal_platform_profile_set;
> @@ -262,20 +274,25 @@ static int thermal_init(void)
>
> /* Clean up if failed */
> ret = platform_profile_register(thermal_handler);
> - if (ret) {
> - kfree(thermal_handler);
> - thermal_handler = NULL;
> - }
> + if (ret)
> + goto cleanup_thermal_handler;
> +
> + return 0;
> +
> +cleanup_thermal_handler:
> + thermal_handler = NULL;
> +
> +cleanup_platform_device:
> + platform_device_del(platform_device);
>
> return ret;
> }
>
> static void thermal_cleanup(void)
> {
> - if (thermal_handler) {
> + if (thermal_handler)
> platform_profile_remove();
> - kfree(thermal_handler);
> - }
> + platform_device_unregister(platform_device);
> }
>
> static int __init dell_init(void)
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister
2024-11-05 15:33 ` [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
@ 2024-11-06 19:40 ` Armin Wolf
2024-11-06 19:44 ` Mario Limonciello
0 siblings, 1 reply; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:40 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> As multiple platform profile handlers may come and go, send a notification
> to userspace each time that a platform profile handler is registered or
> unregistered.
>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 79083d0bb22e3..c9917daf683cb 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -404,6 +404,7 @@ int platform_profile_register(struct platform_profile_handler *pprof)
> if (IS_ERR(pprof->class_dev))
> return PTR_ERR(pprof->class_dev);
> dev_set_drvdata(pprof->class_dev, pprof);
> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>
> cur_profile = pprof;
> return 0;
> @@ -419,7 +420,9 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
> {
> guard(mutex)(&profile_lock);
>
> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
When do we remove platform_profile_group now?
Thanks,
Armin Wolf
> + cur_profile = NULL;
> +
> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>
> device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers
2024-11-05 15:33 ` [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
@ 2024-11-06 19:41 ` Armin Wolf
2024-11-06 19:44 ` Mario Limonciello
0 siblings, 1 reply; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 19:41 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> If multiple platform profile handlers have been registered, don't allow
> switching to profiles unique to only one handler.
>
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 55 +++++++++++++++++++++++----------
> 1 file changed, 38 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index c9917daf683cb..8de7c8352673e 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -235,27 +235,48 @@ static const struct class platform_profile_class = {
> .dev_groups = profile_groups,
> };
>
> -static ssize_t platform_profile_choices_show(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +/**
> + * _aggregate_choices - Aggregate the available profile choices
> + * @dev: The device
> + * @data: The available profile choices
> + * Return: 0 on success, -errno on failure
> + */
> +static int _aggregate_choices(struct device *dev, void *data)
> {
> - int len = 0;
> - int i;
> + unsigned long *aggregate = data;
> + unsigned long choices = 0;
> + int err;
>
> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> - if (!cur_profile)
> - return -ENODEV;
> + err = _get_class_choices(dev, &choices);
> + if (err)
> + return err;
>
> - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) {
> - if (len == 0)
> - len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
> - else
> - len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
> - }
> - }
> - len += sysfs_emit_at(buf, len, "\n");
> + if (!*aggregate)
> + *aggregate = choices;
> + else
> + *aggregate &= choices;
>
> - return len;
> + return 0;
> +}
> +
> +/**
> + * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to write to
> + * Return: The number of bytes written
> + */
> +static ssize_t platform_profile_choices_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + unsigned long aggregate = 0;
> + int err;
> +
> + err = class_for_each_device(&platform_profile_class, NULL,
> + &aggregate, _aggregate_choices);
Error handling seems to be missing.
Thanks,
Armin Wolf
> +
> + return _commmon_choices_show(aggregate, buf);
> }
>
> static ssize_t platform_profile_show(struct device *dev,
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister
2024-11-06 19:40 ` Armin Wolf
@ 2024-11-06 19:44 ` Mario Limonciello
2024-11-06 20:58 ` Armin Wolf
0 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-06 19:44 UTC (permalink / raw)
To: Armin Wolf, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
On 11/6/2024 13:40, Armin Wolf wrote:
> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>
>> As multiple platform profile handlers may come and go, send a
>> notification
>> to userspace each time that a platform profile handler is registered or
>> unregistered.
>>
>> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> drivers/acpi/platform_profile.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index 79083d0bb22e3..c9917daf683cb 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -404,6 +404,7 @@ int platform_profile_register(struct
>> platform_profile_handler *pprof)
>> if (IS_ERR(pprof->class_dev))
>> return PTR_ERR(pprof->class_dev);
>> dev_set_drvdata(pprof->class_dev, pprof);
>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>
>> cur_profile = pprof;
>> return 0;
>> @@ -419,7 +420,9 @@ int platform_profile_remove(struct
>> platform_profile_handler *pprof)
>> {
>> guard(mutex)(&profile_lock);
>>
>> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
>
> When do we remove platform_profile_group now?
>
When incorporating your other feedback I noticed this was still there
and it will be removed for the next revision.
The idea will be as soon as a class registers the legacy interface is
created and will stay for the lifetime of the boot.
If all drivers are unloaded it will return -EINVAL until a new driver is
loaded.
> Thanks,
> Armin Wolf
>
>> + cur_profile = NULL;
>> +
>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>
>> device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
>>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers
2024-11-06 19:41 ` Armin Wolf
@ 2024-11-06 19:44 ` Mario Limonciello
0 siblings, 0 replies; 55+ messages in thread
From: Mario Limonciello @ 2024-11-06 19:44 UTC (permalink / raw)
To: Armin Wolf, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
On 11/6/2024 13:41, Armin Wolf wrote:
> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>
>> If multiple platform profile handlers have been registered, don't allow
>> switching to profiles unique to only one handler.
>>
>> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> drivers/acpi/platform_profile.c | 55 +++++++++++++++++++++++----------
>> 1 file changed, 38 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index c9917daf683cb..8de7c8352673e 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -235,27 +235,48 @@ static const struct class platform_profile_class
>> = {
>> .dev_groups = profile_groups,
>> };
>>
>> -static ssize_t platform_profile_choices_show(struct device *dev,
>> - struct device_attribute *attr,
>> - char *buf)
>> +/**
>> + * _aggregate_choices - Aggregate the available profile choices
>> + * @dev: The device
>> + * @data: The available profile choices
>> + * Return: 0 on success, -errno on failure
>> + */
>> +static int _aggregate_choices(struct device *dev, void *data)
>> {
>> - int len = 0;
>> - int i;
>> + unsigned long *aggregate = data;
>> + unsigned long choices = 0;
>> + int err;
>>
>> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> - if (!cur_profile)
>> - return -ENODEV;
>> + err = _get_class_choices(dev, &choices);
>> + if (err)
>> + return err;
>>
>> - for_each_set_bit(i, cur_profile->choices,
>> PLATFORM_PROFILE_LAST) {
>> - if (len == 0)
>> - len += sysfs_emit_at(buf, len, "%s", profile_names[i]);
>> - else
>> - len += sysfs_emit_at(buf, len, " %s", profile_names[i]);
>> - }
>> - }
>> - len += sysfs_emit_at(buf, len, "\n");
>> + if (!*aggregate)
>> + *aggregate = choices;
>> + else
>> + *aggregate &= choices;
>>
>> - return len;
>> + return 0;
>> +}
>> +
>> +/**
>> + * platform_profile_choices_show - Show the available profile choices
>> for legacy sysfs interface
>> + * @dev: The device
>> + * @attr: The attribute
>> + * @buf: The buffer to write to
>> + * Return: The number of bytes written
>> + */
>> +static ssize_t platform_profile_choices_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + unsigned long aggregate = 0;
>> + int err;
>> +
>> + err = class_for_each_device(&platform_profile_class, NULL,
>> + &aggregate, _aggregate_choices);
>
> Error handling seems to be missing.
>
Yup, noticed that when unloading things exploded.
Fixing in the next version.
> Thanks,
> Armin Wolf
>
>> +
>> + return _commmon_choices_show(aggregate, buf);
>> }
>>
>> static ssize_t platform_profile_show(struct device *dev,
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next
2024-11-05 15:33 ` [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
@ 2024-11-06 20:55 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 20:55 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> As multiple platform profile handlers might not all support the same
> profile, cycling to the next profile could have a different result
> depending on what handler are registered.
>
> Check what is active and supported by all handlers to decide what
> to do.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 35 ++++++++++++++++++---------------
> 1 file changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 7861fccc2e58c..568485e285061 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -378,34 +378,37 @@ EXPORT_SYMBOL_GPL(platform_profile_notify);
>
> int platform_profile_cycle(void)
> {
> + enum platform_profile_option next = PLATFORM_PROFILE_LAST;
> enum platform_profile_option profile;
> - enum platform_profile_option next;
> + unsigned long choices;
> int err;
>
> if (!class_is_registered(&platform_profile_class))
> return -ENODEV;
>
> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
Since the aggregated choices might change at any moment, we still need
some locking here.
Thanks,
Armin Wolf
> - if (!cur_profile)
> - return -ENODEV;
> + err = class_for_each_device(&platform_profile_class, NULL,
> + &profile, _aggregate_profiles);
> + if (err)
> + return err;
>
> - err = cur_profile->profile_get(cur_profile, &profile);
> - if (err)
> - return err;
> + err = class_for_each_device(&platform_profile_class, NULL,
> + &choices, _aggregate_choices);
> + if (err)
> + return err;
>
> - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
> - profile + 1);
> + next = find_next_bit_wrap(&choices,
> + PLATFORM_PROFILE_LAST,
> + profile + 1);
>
> - if (WARN_ON(next == PLATFORM_PROFILE_LAST))
> - return -EINVAL;
> + err = class_for_each_device(&platform_profile_class, NULL, &next,
> + _store_class_profile);
>
> - err = cur_profile->profile_set(cur_profile, next);
> - if (err)
> - return err;
> - }
> + if (err)
> + return err;
>
> sysfs_notify(acpi_kobj, NULL, "platform_profile");
> - return 0;
> +
> + return err;
> }
> EXPORT_SYMBOL_GPL(platform_profile_cycle);
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile
2024-11-05 15:33 ` [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
@ 2024-11-06 20:58 ` Armin Wolf
2024-11-06 21:25 ` Mario Limonciello
0 siblings, 1 reply; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 20:58 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 05.11.24 um 16:33 schrieb Mario Limonciello:
> If for any reason multiple profile handlers don't agree on the profile
> return the custom profile.
>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 84 +++++++++++++++++++++------------
> 1 file changed, 53 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index d8c2d195106c2..7861fccc2e58c 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -280,55 +280,77 @@ static ssize_t platform_profile_choices_show(struct device *dev,
> return _commmon_choices_show(aggregate, buf);
> }
>
> -static ssize_t platform_profile_show(struct device *dev,
> - struct device_attribute *attr,
> - char *buf)
> +/**
> + * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface
> + * @dev: The device
> + * @data: The profile to return
> + * Return: 0 on success, -errno on failure
> + */
> +static int _aggregate_profiles(struct device *dev, void *data)
> {
> - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
> + enum platform_profile_option *profile = data;
> + enum platform_profile_option val;
> int err;
>
> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> - if (!cur_profile)
> - return -ENODEV;
> + err = get_class_profile(dev, &val);
> + if (err)
> + return err;
>
> - err = cur_profile->profile_get(cur_profile, &profile);
> - if (err)
> - return err;
> - }
> + if (*profile != PLATFORM_PROFILE_LAST && *profile != val)
> + *profile = PLATFORM_PROFILE_CUSTOM;
> + else
> + *profile = val;
>
> - /* Check that profile is valid index */
> - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
> - return -EIO;
Please check the returned value from profile_get() first before doing
the custom platform
profile check.
> + return 0;
> +}
> +
> +/**
> + * platform_profile_show - Show the current profile for legacy sysfs interface
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to write to
> + * Return: The number of bytes written
> + */
> +static ssize_t platform_profile_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
> + int err;
> +
> + err = class_for_each_device(&platform_profile_class, NULL,
> + &profile, _aggregate_profiles);
Missing error handling.
>
> return sysfs_emit(buf, "%s\n", profile_names[profile]);
> }
>
> +/**
> + * platform_profile_store - Set the profile for legacy sysfs interface
> + * @dev: The device
> + * @attr: The attribute
> + * @buf: The buffer to read from
> + * @count: The number of bytes to read
> + * Return: The number of bytes read
> + */
> static ssize_t platform_profile_store(struct device *dev,
> - struct device_attribute *attr,
> - const char *buf, size_t count)
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> {
> - int err, i;
> + int ret;
> + int i;
>
> /* Scan for a matching profile */
> i = sysfs_match_string(profile_names, buf);
> if (i < 0)
> return -EINVAL;
> -
> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> - if (!cur_profile)
> - return -ENODEV;
> -
> - /* Check that platform supports this profile choice */
> - if (!test_bit(i, cur_profile->choices))
> - return -EOPNOTSUPP;
> -
> - err = cur_profile->profile_set(cur_profile, i);
> - if (err)
> - return err;
> + if (i == PLATFORM_PROFILE_CUSTOM) {
> + pr_warn("Custom profile not supported for legacy sysfs interface\n");
This would allow userspace applications to spam the kernel log. Please
just return -EINVAL here
and document this special case inside the interface specification.
Thanks,
Armin Wolf
> + return -EINVAL;
> }
>
> - sysfs_notify(acpi_kobj, NULL, "platform_profile");
> - return count;
> + ret = class_for_each_device(&platform_profile_class, NULL, &i, _store_class_profile);
> +
> + return ret ? ret : count;
> }
>
> static DEVICE_ATTR_RO(platform_profile_choices);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister
2024-11-06 19:44 ` Mario Limonciello
@ 2024-11-06 20:58 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 20:58 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 06.11.24 um 20:44 schrieb Mario Limonciello:
> On 11/6/2024 13:40, Armin Wolf wrote:
>> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>>
>>> As multiple platform profile handlers may come and go, send a
>>> notification
>>> to userspace each time that a platform profile handler is registered or
>>> unregistered.
>>>
>>> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
>>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> drivers/acpi/platform_profile.c | 5 ++++-
>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index 79083d0bb22e3..c9917daf683cb 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -404,6 +404,7 @@ int platform_profile_register(struct
>>> platform_profile_handler *pprof)
>>> if (IS_ERR(pprof->class_dev))
>>> return PTR_ERR(pprof->class_dev);
>>> dev_set_drvdata(pprof->class_dev, pprof);
>>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>>
>>> cur_profile = pprof;
>>> return 0;
>>> @@ -419,7 +420,9 @@ int platform_profile_remove(struct
>>> platform_profile_handler *pprof)
>>> {
>>> guard(mutex)(&profile_lock);
>>>
>>> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
>>
>> When do we remove platform_profile_group now?
>>
>
> When incorporating your other feedback I noticed this was still there
> and it will be removed for the next revision.
>
> The idea will be as soon as a class registers the legacy interface is
> created and will stay for the lifetime of the boot.
>
> If all drivers are unloaded it will return -EINVAL until a new driver
> is loaded.
And what happens when the platform profile core itself is unloaded?
Thanks,
Armin Wolf
>
>> Thanks,
>> Armin Wolf
>>
>>> + cur_profile = NULL;
>>> +
>>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>>
>>> device_destroy(&platform_profile_class, MKDEV(0, pprof->minor));
>>>
>
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers
2024-11-06 1:11 ` Mario Limonciello
@ 2024-11-06 21:04 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 21:04 UTC (permalink / raw)
To: Mario Limonciello, Mark Pearson, Hans de Goede,
Ilpo Järvinen
Cc: Rafael J. Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
open list:THINKPAD ACPI EXTRAS DRIVER, Matthew Schwartz
Am 06.11.24 um 02:11 schrieb Mario Limonciello:
> On 11/5/2024 16:47, Mark Pearson wrote:
>> Hi Mario,
>>
>> On Tue, Nov 5, 2024, at 10:32 AM, Mario Limonciello wrote:
>>> Currently there are a number of ASUS products on the market that
>>> happen to
>>> have ACPI objects for amd-pmf to bind to as well as an ACPI platform
>>> profile provided by asus-wmi.
>>>
>>> The ACPI platform profile support created by amd-pmf on these ASUS
>>> products is "Function 9" which is specifically for "BIOS or EC
>>> notification" of power slider position. This feature is actively used
>>> by some designs such as Framework 13 and Framework 16.
>>>
>>> On these ASUS designs we keep on quirking more and more of them to turn
>>> off this notification so that asus-wmi can bind.
>>>
>>> This however isn't how Windows works. "Multiple" things are
>>> notified for
>>> the power slider position. This series adjusts Linux to behave
>>> similarly.
>>>
>>> Multiple drivers can now register an ACPI platform profile and will
>>> react
>>> to set requests.
>>>
>>> To avoid chaos, only positions that are common to both drivers are
>>> accepted when the legacy /sys/firmware/acpi/platform_profile interface
>>> is used.
>>>
>>> This series also adds a new concept of a "custom" profile. This allows
>>> userspace to discover that there are multiple driver handlers that are
>>> configured differently.
>>>
>>> This series also allows dropping all of the PMF quirks from amd-pmf.
>>>
>>> v4:
>>> * Drop the list; iterate classes
>>> * Drop patches that didn't make sense without list
>>> * Cover alienware-wmi as well (recently merged to
>>> platform-x86/for-next)
>>> * Drop requirement for balanced
>>> * Rename platform-profile class members to 'profile', 'options',
>>> 'name'
>>> * Drop the name in /sys/class/platform-profile and just use ida
>>> value.
>>> IE platform-profile-0
>>>
>>> Mario Limonciello (20):
>>> ACPI: platform-profile: Add a name member to handlers
>>> platform/x86/dell: dell-pc: Create platform device
>>> ACPI: platform_profile: Add device pointer into platform profile
>>> handler
>>> ACPI: platform_profile: Add platform handler argument to
>>> platform_profile_remove()
>>> ACPI: platform_profile: Move sanity check out of the mutex
>>> ACPI: platform_profile: Move matching string for new profile out of
>>> mutex
>>> ACPI: platform_profile: Use guard(mutex) for register/unregister
>>> ACPI: platform_profile: Use `scoped_cond_guard`
>>> ACPI: platform_profile: Create class for ACPI platform profile
>>> ACPI: platform_profile: Add name attribute to class interface
>>> ACPI: platform_profile: Add choices attribute for class interface
>>> ACPI: platform_profile: Add profile attribute for class interface
>>> ACPI: platform_profile: Notify change events on register and
>>> unregister
>>> ACPI: platform_profile: Only show profiles common for all handlers
>>> ACPI: platform_profile: Add concept of a "custom" profile
>>> ACPI: platform_profile: Make sure all profile handlers agree on
>>> profile
>>> ACPI: platform_profile: Check all profile handler to calculate next
>>> ACPI: platform_profile: Allow multiple handlers
>>> platform/x86/amd: pmf: Drop all quirks
>>> Documentation: Add documentation about class interface for platform
>>> profiles
>>>
>>> .../userspace-api/sysfs-platform_profile.rst | 28 ++
>>> drivers/acpi/platform_profile.c | 446
>>> ++++++++++++++----
>>> .../surface/surface_platform_profile.c | 8 +-
>>> drivers/platform/x86/acer-wmi.c | 10 +-
>>> drivers/platform/x86/amd/pmf/Makefile | 2 +-
>>> drivers/platform/x86/amd/pmf/core.c | 1 -
>>> drivers/platform/x86/amd/pmf/pmf-quirks.c | 66 ---
>>> drivers/platform/x86/amd/pmf/pmf.h | 3 -
>>> drivers/platform/x86/amd/pmf/sps.c | 4 +-
>>> drivers/platform/x86/asus-wmi.c | 6 +-
>>> drivers/platform/x86/dell/alienware-wmi.c | 8 +-
>>> drivers/platform/x86/dell/dell-pc.c | 39 +-
>>> drivers/platform/x86/hp/hp-wmi.c | 8 +-
>>> drivers/platform/x86/ideapad-laptop.c | 4 +-
>>> .../platform/x86/inspur_platform_profile.c | 7 +-
>>> drivers/platform/x86/thinkpad_acpi.c | 4 +-
>>> include/linux/platform_profile.h | 7 +-
>>> 17 files changed, 456 insertions(+), 195 deletions(-)
>>> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>>>
>>>
>>> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
>>> --
>>> 2.43.0
>>
>> For the series - I tried it out on my T14s G6 AMD, and it all looks
>> to be working nicely and as expected.
>> The thinkpad-acpi and amd-pmf classes show up. I can tweak them
>> individually and 'custom' shows up under firmware/acpi/platform_profile.
>> I tried various combo's and didn't see any issues.
>> If you have any recommendations of things to try let me know.
>>
>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>
>> Mark
>
> Thanks for testing! The fact that Lenovo and ASUS are both doing this
> with recent laptops makes it all the stronger of a case to do it
> rather than let them race for who gets the coveted platform profile slot.
>
> If you've already tried mixing and matching combinations that's all I
> was going to suggest.
>
> I'll wait for Armin's review and then I'll respin with the tags and
> small things you and Ilpo found.
>
Looking forward to the next iteration.
Thanks,
Armin Wolf
> BTW if I missed any important feedback of yours from v3 please let me
> know. It was a lot of overhaul to switch to this way of doing things
> and a lot of it didn't make sense anymore.
>
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile
2024-11-06 20:58 ` Armin Wolf
@ 2024-11-06 21:25 ` Mario Limonciello
2024-11-06 21:31 ` Armin Wolf
0 siblings, 1 reply; 55+ messages in thread
From: Mario Limonciello @ 2024-11-06 21:25 UTC (permalink / raw)
To: Armin Wolf, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
On 11/6/2024 14:58, Armin Wolf wrote:
> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>
>> If for any reason multiple profile handlers don't agree on the profile
>> return the custom profile.
>>
>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> drivers/acpi/platform_profile.c | 84 +++++++++++++++++++++------------
>> 1 file changed, 53 insertions(+), 31 deletions(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index d8c2d195106c2..7861fccc2e58c 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -280,55 +280,77 @@ static ssize_t
>> platform_profile_choices_show(struct device *dev,
>> return _commmon_choices_show(aggregate, buf);
>> }
>>
>> -static ssize_t platform_profile_show(struct device *dev,
>> - struct device_attribute *attr,
>> - char *buf)
>> +/**
>> + * _aggregate_profiles - Aggregate the profiles for legacy sysfs
>> interface
>> + * @dev: The device
>> + * @data: The profile to return
>> + * Return: 0 on success, -errno on failure
>> + */
>> +static int _aggregate_profiles(struct device *dev, void *data)
>> {
>> - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
>> + enum platform_profile_option *profile = data;
>> + enum platform_profile_option val;
>> int err;
>>
>> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> - if (!cur_profile)
>> - return -ENODEV;
>> + err = get_class_profile(dev, &val);
>> + if (err)
>> + return err;
>>
>> - err = cur_profile->profile_get(cur_profile, &profile);
>> - if (err)
>> - return err;
>> - }
>> + if (*profile != PLATFORM_PROFILE_LAST && *profile != val)
>> + *profile = PLATFORM_PROFILE_CUSTOM;
>> + else
>> + *profile = val;
>>
>> - /* Check that profile is valid index */
>> - if (WARN_ON((profile < 0) || (profile >=
>> ARRAY_SIZE(profile_names))))
>> - return -EIO;
>
> Please check the returned value from profile_get() first before doing
> the custom platform
> profile check.
You might have missed it - that's part of get_class_profile() already.
>
>> + return 0;
>> +}
>> +
>> +/**
>> + * platform_profile_show - Show the current profile for legacy sysfs
>> interface
>> + * @dev: The device
>> + * @attr: The attribute
>> + * @buf: The buffer to write to
>> + * Return: The number of bytes written
>> + */
>> +static ssize_t platform_profile_show(struct device *dev,
>> + struct device_attribute *attr,
>> + char *buf)
>> +{
>> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
>> + int err;
>> +
>> + err = class_for_each_device(&platform_profile_class, NULL,
>> + &profile, _aggregate_profiles);
>
> Missing error handling.
>
Right, got it.
>>
>> return sysfs_emit(buf, "%s\n", profile_names[profile]);
>> }
>>
>> +/**
>> + * platform_profile_store - Set the profile for legacy sysfs interface
>> + * @dev: The device
>> + * @attr: The attribute
>> + * @buf: The buffer to read from
>> + * @count: The number of bytes to read
>> + * Return: The number of bytes read
>> + */
>> static ssize_t platform_profile_store(struct device *dev,
>> - struct device_attribute *attr,
>> - const char *buf, size_t count)
>> + struct device_attribute *attr,
>> + const char *buf, size_t count)
>> {
>> - int err, i;
>> + int ret;
>> + int i;
>>
>> /* Scan for a matching profile */
>> i = sysfs_match_string(profile_names, buf);
>> if (i < 0)
>> return -EINVAL;
>> -
>> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> - if (!cur_profile)
>> - return -ENODEV;
>> -
>> - /* Check that platform supports this profile choice */
>> - if (!test_bit(i, cur_profile->choices))
>> - return -EOPNOTSUPP;
>> -
>> - err = cur_profile->profile_set(cur_profile, i);
>> - if (err)
>> - return err;
>> + if (i == PLATFORM_PROFILE_CUSTOM) {
>> + pr_warn("Custom profile not supported for legacy sysfs
>> interface\n");
>
> This would allow userspace applications to spam the kernel log. Please
> just return -EINVAL here
> and document this special case inside the interface specification.
>
OK.
> Thanks,
> Armin Wolf
>
>> + return -EINVAL;
>> }
>>
>> - sysfs_notify(acpi_kobj, NULL, "platform_profile");
>> - return count;
>> + ret = class_for_each_device(&platform_profile_class, NULL, &i,
>> _store_class_profile);
>> +
>> + return ret ? ret : count;
>> }
>>
>> static DEVICE_ATTR_RO(platform_profile_choices);
^ permalink raw reply [flat|nested] 55+ messages in thread
* Re: [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile
2024-11-06 21:25 ` Mario Limonciello
@ 2024-11-06 21:31 ` Armin Wolf
0 siblings, 0 replies; 55+ messages in thread
From: Armin Wolf @ 2024-11-06 21:31 UTC (permalink / raw)
To: Mario Limonciello, Hans de Goede, Ilpo Järvinen
Cc: Rafael J . Wysocki, Len Brown, Maximilian Luz, Lee Chun-Yi,
Shyam Sundar S K, Corentin Chary, Luke D . Jones, Ike Panhc,
Henrique de Moraes Holschuh, Alexis Belmonte,
Uwe Kleine-König, Ai Chao, Gergo Koteles, open list,
open list:ACPI,
open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER,
open list:THINKPAD ACPI EXTRAS DRIVER, Mark Pearson,
Matthew Schwartz
Am 06.11.24 um 22:25 schrieb Mario Limonciello:
> On 11/6/2024 14:58, Armin Wolf wrote:
>> Am 05.11.24 um 16:33 schrieb Mario Limonciello:
>>
>>> If for any reason multiple profile handlers don't agree on the profile
>>> return the custom profile.
>>>
>>> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> drivers/acpi/platform_profile.c | 84
>>> +++++++++++++++++++++------------
>>> 1 file changed, 53 insertions(+), 31 deletions(-)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index d8c2d195106c2..7861fccc2e58c 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -280,55 +280,77 @@ static ssize_t
>>> platform_profile_choices_show(struct device *dev,
>>> return _commmon_choices_show(aggregate, buf);
>>> }
>>>
>>> -static ssize_t platform_profile_show(struct device *dev,
>>> - struct device_attribute *attr,
>>> - char *buf)
>>> +/**
>>> + * _aggregate_profiles - Aggregate the profiles for legacy sysfs
>>> interface
>>> + * @dev: The device
>>> + * @data: The profile to return
>>> + * Return: 0 on success, -errno on failure
>>> + */
>>> +static int _aggregate_profiles(struct device *dev, void *data)
>>> {
>>> - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
>>> + enum platform_profile_option *profile = data;
>>> + enum platform_profile_option val;
>>> int err;
>>>
>>> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> - if (!cur_profile)
>>> - return -ENODEV;
>>> + err = get_class_profile(dev, &val);
>>> + if (err)
>>> + return err;
>>>
>>> - err = cur_profile->profile_get(cur_profile, &profile);
>>> - if (err)
>>> - return err;
>>> - }
>>> + if (*profile != PLATFORM_PROFILE_LAST && *profile != val)
>>> + *profile = PLATFORM_PROFILE_CUSTOM;
>>> + else
>>> + *profile = val;
>>>
>>> - /* Check that profile is valid index */
>>> - if (WARN_ON((profile < 0) || (profile >=
>>> ARRAY_SIZE(profile_names))))
>>> - return -EIO;
>>
>> Please check the returned value from profile_get() first before doing
>> the custom platform
>> profile check.
>
> You might have missed it - that's part of get_class_profile() already.
>
You are right, my bad.
>>
>>> + return 0;
>>> +}
>>> +
>>> +/**
>>> + * platform_profile_show - Show the current profile for legacy
>>> sysfs interface
>>> + * @dev: The device
>>> + * @attr: The attribute
>>> + * @buf: The buffer to write to
>>> + * Return: The number of bytes written
>>> + */
>>> +static ssize_t platform_profile_show(struct device *dev,
>>> + struct device_attribute *attr,
>>> + char *buf)
>>> +{
>>> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
>>> + int err;
>>> +
>>> + err = class_for_each_device(&platform_profile_class, NULL,
>>> + &profile, _aggregate_profiles);
>>
>> Missing error handling.
>>
>
> Right, got it.
>
>>>
>>> return sysfs_emit(buf, "%s\n", profile_names[profile]);
>>> }
>>>
>>> +/**
>>> + * platform_profile_store - Set the profile for legacy sysfs interface
>>> + * @dev: The device
>>> + * @attr: The attribute
>>> + * @buf: The buffer to read from
>>> + * @count: The number of bytes to read
>>> + * Return: The number of bytes read
>>> + */
>>> static ssize_t platform_profile_store(struct device *dev,
>>> - struct device_attribute *attr,
>>> - const char *buf, size_t count)
>>> + struct device_attribute *attr,
>>> + const char *buf, size_t count)
>>> {
>>> - int err, i;
>>> + int ret;
>>> + int i;
>>>
>>> /* Scan for a matching profile */
>>> i = sysfs_match_string(profile_names, buf);
>>> if (i < 0)
>>> return -EINVAL;
>>> -
>>> - scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> - if (!cur_profile)
>>> - return -ENODEV;
>>> -
>>> - /* Check that platform supports this profile choice */
>>> - if (!test_bit(i, cur_profile->choices))
>>> - return -EOPNOTSUPP;
>>> -
>>> - err = cur_profile->profile_set(cur_profile, i);
>>> - if (err)
>>> - return err;
>>> + if (i == PLATFORM_PROFILE_CUSTOM) {
>>> + pr_warn("Custom profile not supported for legacy sysfs
>>> interface\n");
>>
>> This would allow userspace applications to spam the kernel log. Please
>> just return -EINVAL here
>> and document this special case inside the interface specification.
>>
> OK.
>
>> Thanks,
>> Armin Wolf
>>
>>> + return -EINVAL;
>>> }
>>>
>>> - sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>> - return count;
>>> + ret = class_for_each_device(&platform_profile_class, NULL, &i,
>>> _store_class_profile);
>>> +
>>> + return ret ? ret : count;
>>> }
>>>
>>> static DEVICE_ATTR_RO(platform_profile_choices);
>
>
^ permalink raw reply [flat|nested] 55+ messages in thread
end of thread, other threads:[~2024-11-06 21:32 UTC | newest]
Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05 15:32 [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
2024-11-05 15:32 ` [PATCH v4 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
2024-11-06 3:27 ` Armin Wolf
2024-11-05 15:32 ` [PATCH v4 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
2024-11-06 19:37 ` Armin Wolf
2024-11-05 15:32 ` [PATCH v4 03/20] ACPI: platform_profile: Add device pointer into platform profile handler Mario Limonciello
2024-11-06 3:32 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 04/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
2024-11-06 3:34 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 05/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
2024-11-06 3:35 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 06/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
2024-11-05 15:38 ` Ilpo Järvinen
2024-11-06 3:36 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 07/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
2024-11-06 3:37 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 08/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
2024-11-05 15:54 ` Ilpo Järvinen
2024-11-05 15:33 ` [PATCH v4 09/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
2024-11-06 3:53 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
2024-11-06 3:56 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
2024-11-06 1:09 ` kernel test robot
2024-11-06 4:00 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
2024-11-06 4:10 ` Armin Wolf
2024-11-06 5:46 ` Mario Limonciello
2024-11-06 19:15 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
2024-11-06 19:40 ` Armin Wolf
2024-11-06 19:44 ` Mario Limonciello
2024-11-06 20:58 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
2024-11-06 19:41 ` Armin Wolf
2024-11-06 19:44 ` Mario Limonciello
2024-11-05 15:33 ` [PATCH v4 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
2024-11-06 19:17 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
2024-11-06 20:58 ` Armin Wolf
2024-11-06 21:25 ` Mario Limonciello
2024-11-06 21:31 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
2024-11-06 20:55 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
2024-11-06 19:21 ` Armin Wolf
2024-11-06 19:33 ` Armin Wolf
2024-11-06 19:34 ` Mario Limonciello
2024-11-05 15:33 ` [PATCH v4 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
2024-11-06 19:30 ` Armin Wolf
2024-11-05 15:33 ` [PATCH v4 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
2024-11-05 22:49 ` Mark Pearson
2024-11-05 22:47 ` [PATCH v4 00/20] Add support for binding ACPI platform profile to multiple drivers Mark Pearson
2024-11-06 1:11 ` Mario Limonciello
2024-11-06 21:04 ` Armin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox