* [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers
@ 2024-11-07 6:02 Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
` (20 more replies)
0 siblings, 21 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
---
v5:
* Adjust mutex handling
* Add missing error handling
* Drop dev member
* Add cleanup handling for module unload
* Fix crash on accessing legacy files after all drivers unloaded
Mario Limonciello (20):
ACPI: platform-profile: Add a name member to handlers
platform/x86/dell: dell-pc: Create platform device
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: Unregister class and sysfs group on module
unload
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
.../ABI/testing/sysfs-platform_profile | 5 +
.../userspace-api/sysfs-platform_profile.rst | 28 +
drivers/acpi/platform_profile.c | 494 ++++++++++++++----
.../surface/surface_platform_profile.c | 7 +-
drivers/platform/x86/acer-wmi.c | 5 +-
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 | 3 +-
drivers/platform/x86/asus-wmi.c | 5 +-
drivers/platform/x86/dell/alienware-wmi.c | 3 +-
drivers/platform/x86/dell/dell-pc.c | 35 +-
drivers/platform/x86/hp/hp-wmi.c | 3 +-
drivers/platform/x86/ideapad-laptop.c | 3 +-
.../platform/x86/inspur_platform_profile.c | 6 +-
drivers/platform/x86/thinkpad_acpi.c | 3 +-
include/linux/platform_profile.h | 6 +-
18 files changed, 488 insertions(+), 190 deletions(-)
delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
--
2.43.0
^ permalink raw reply [flat|nested] 42+ messages in thread
* [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
` (19 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
In order to prepare for allowing multiple handlers, introduce
a name field that can be used to distinguish between different
handlers.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
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>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* pick up tag
---
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);
--
2.43.0
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:07 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 03/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
` (18 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
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: Armin Wolf <W_Armin@gmx.de>
Tested-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>
---
v5:
* use platform_device_register_simple()
---
drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++--------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
index 3cf79e55e3129..0cd9b26572b61 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,15 @@ 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_register_simple("dell-pc", -1, NULL, 0);
+ if (!platform_device)
return -ENOMEM;
+
+ 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 +271,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_unregister(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] 42+ messages in thread
* [PATCH v5 03/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove()
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 04/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
` (17 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
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: Mark Pearson <mpearson-lenovo@squebb.ca>
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>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Add tag
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 d2f7fd7743a13..c24744da20916 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -205,7 +205,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 61aa488a80eb5..1c9e37b1f4761 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.profile_get = ssam_platform_profile_get;
@@ -227,7 +228,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 53fbc9b4d3df7..71761d4220c26 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -2546,7 +2546,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:
@@ -2569,7 +2569,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 e2d0cc92c4396..cfa88c0c9e594 100644
--- a/drivers/platform/x86/amd/pmf/sps.c
+++ b/drivers/platform/x86/amd/pmf/sps.c
@@ -425,5 +425,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 c7c104c65a85a..f5f8cda7fd19c 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -4885,7 +4885,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);
@@ -4912,7 +4912,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 ac0038afd98fa..e7f97eb24a014 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -1064,7 +1064,7 @@ static int create_thermal_profile(void)
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 0cd9b26572b61..b1ada199e7978 100644
--- a/drivers/platform/x86/dell/dell-pc.c
+++ b/drivers/platform/x86/dell/dell-pc.c
@@ -288,7 +288,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 26cac73caf2b9..bb8771d8b5cd8 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -1692,7 +1692,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 1f94c14c3b832..50819ac919e87 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -1135,7 +1135,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 03da2c8cf6789..d8fd59b826f3a 100644
--- a/drivers/platform/x86/inspur_platform_profile.c
+++ b/drivers/platform/x86/inspur_platform_profile.c
@@ -190,7 +190,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 c8c316b8507a5..619a4db74e5f3 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -10637,7 +10637,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 6fa988e417428..58279b76d740e 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -36,7 +36,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] 42+ messages in thread
* [PATCH v5 04/20] ACPI: platform_profile: Move sanity check out of the mutex
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (2 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 03/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 05/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
` (16 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
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: Mark Pearson <mpearson-lenovo@squebb.ca>
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>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Add tag
---
drivers/acpi/platform_profile.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index c24744da20916..ce3aa1361721e 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -179,6 +179,13 @@ 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;
+ }
+
mutex_lock(&profile_lock);
/* We can only have one active profile */
if (cur_profile) {
@@ -186,13 +193,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] 42+ messages in thread
* [PATCH v5 05/20] ACPI: platform_profile: Move matching string for new profile out of mutex
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (3 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 04/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 06/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
` (15 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
Holding the mutex is not necessary while scanning the string passed into
platform_profile_store().
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
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 ce3aa1361721e..fbdf3cdf1141d 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] 42+ messages in thread
* [PATCH v5 06/20] ACPI: platform_profile: Use guard(mutex) for register/unregister
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (4 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 05/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 07/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
` (14 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
guard(mutex) can be used to automatically release mutexes when going
out of scope.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
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>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
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 fbdf3cdf1141d..548eb99253958 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -184,32 +184,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] 42+ messages in thread
* [PATCH v5 07/20] ACPI: platform_profile: Use `scoped_cond_guard`
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (5 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 06/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
` (13 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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. While changing, move the sysfs notification
used in platform_profile_store() outside of mutex scope.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
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 | 114 ++++++++++++--------------------
1 file changed, 44 insertions(+), 70 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 548eb99253958..0450bdae7c88b 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] 42+ messages in thread
* [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (6 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 07/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:16 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload Mario Limonciello
` (12 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Use ida instead of idr
* Use device_unregister instead of device_destroy()
* MKDEV (0, 0)
---
drivers/acpi/platform_profile.c | 50 +++++++++++++++++++++++++++++---
include/linux/platform_profile.h | 2 ++
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 0450bdae7c88b..652034b71ee9b 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_IDA(platform_profile_ida);
+
+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;
@@ -163,20 +175,50 @@ 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 = ida_alloc(&platform_profile_ida, GFP_KERNEL);
+ pprof->class_dev = device_create(&platform_profile_class, NULL,
+ MKDEV(0, 0), NULL, "platform-profile-%d",
+ pprof->minor);
+ if (IS_ERR(pprof->class_dev)) {
+ err = PTR_ERR(pprof->class_dev);
+ goto cleanup_ida;
+ }
+ dev_set_drvdata(pprof->class_dev, pprof);
cur_profile = pprof;
return 0;
+
+cleanup_ida:
+ ida_free(&platform_profile_ida, pprof->minor);
+
+cleanup_class:
+ class_unregister(&platform_profile_class);
+
+ return err;
}
EXPORT_SYMBOL_GPL(platform_profile_register);
int platform_profile_remove(struct platform_profile_handler *pprof)
{
+ int id;
guard(mutex)(&profile_lock);
- sysfs_remove_group(acpi_kobj, &platform_profile_group);
+ id = pprof->minor;
+ device_unregister(pprof->class_dev);
+ ida_free(&platform_profile_ida, id);
+
cur_profile = NULL;
return 0;
}
diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
index 58279b76d740e..d92a035e6ba6a 100644
--- a/include/linux/platform_profile.h
+++ b/include/linux/platform_profile.h
@@ -28,6 +28,8 @@ enum platform_profile_option {
struct platform_profile_handler {
const char *name;
+ 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] 42+ messages in thread
* [PATCH v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (7 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:21 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
` (11 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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 and sysfs group are no longer needed when the platform profile
core is a module and unloaded.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/acpi/platform_profile.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 652034b71ee9b..9caf070f77f6a 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -224,6 +224,13 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
}
EXPORT_SYMBOL_GPL(platform_profile_remove);
+static void __exit platform_profile_exit(void)
+{
+ class_unregister(&platform_profile_class);
+ sysfs_remove_group(acpi_kobj, &platform_profile_group);
+}
+module_exit(platform_profile_exit);
+
MODULE_AUTHOR("Mark Pearson <markpearson@lenovo.com>");
MODULE_DESCRIPTION("ACPI platform profile sysfs interface");
MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH v5 10/20] ACPI: platform_profile: Add name attribute to class interface
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (8 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:23 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
` (10 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Drop newline
* Add mutex for sysfs access
---
drivers/acpi/platform_profile.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 9caf070f77f6a..f605c2bd35c68 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -25,8 +25,35 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
static DEFINE_IDA(platform_profile_ida);
+/**
+ * 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)
+{
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ struct platform_profile_handler *handler = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%s\n", handler->name);
+ }
+ return -ERESTARTSYS;
+}
+
+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] 42+ messages in thread
* [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (9 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:28 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
` (9 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Fix kdoc
* Add tag
* Fix whitespace
* Adjust mutex use
---
drivers/acpi/platform_profile.c | 65 +++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index f605c2bd35c68..5e0bb91c5f451 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
static DEFINE_IDA(platform_profile_ida);
+/**
+ * _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
+ * @choices: Pointer to return the available profile choices
+ * Return: The available profile choices
+ */
+static int _get_class_choices(struct device *dev, unsigned long *choices)
+{
+ struct platform_profile_handler *handler;
+ int i;
+
+ lockdep_assert_held(&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
@@ -44,9 +84,34 @@ static ssize_t name_show(struct device *dev,
return -ERESTARTSYS;
}
+/**
+ * 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;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ 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] 42+ messages in thread
* [PATCH v5 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (10 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:34 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
` (8 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Drop recovery flow
* Don't get profile before setting (not needed)
* Simplify casting for call to _store_class_profile()
* Only notify legacy interface of changes
* Adjust mutex use
---
drivers/acpi/platform_profile.c | 110 ++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 5e0bb91c5f451..35e0e8f666072 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -65,6 +65,62 @@ 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)
+{
+ struct platform_profile_handler *handler;
+ unsigned long choices;
+ int *i = (int *)data;
+ int err;
+
+ err = _get_class_choices(dev, &choices);
+ if (err)
+ return err;
+
+ lockdep_assert_held(&profile_lock);
+ if (!test_bit(*i, &choices))
+ return -EOPNOTSUPP;
+
+ handler = dev_get_drvdata(dev);
+ err = handler->profile_set(handler, *i);
+ if (err)
+ return err;
+
+ 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;
+
+ lockdep_assert_held(&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
* @dev: The device
@@ -106,12 +162,66 @@ 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;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ 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;
+
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
+ ret = _store_class_profile(dev, &i);
+ if (ret)
+ return ret;
+ }
+
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
+
+ return 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] 42+ messages in thread
* [PATCH v5 13/20] ACPI: platform_profile: Notify change events on register and unregister
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (11 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
` (7 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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: Mark Pearson <mpearson-lenovo@squebb.ca>
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 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 35e0e8f666072..510e1435d3980 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -399,6 +399,8 @@ int platform_profile_register(struct platform_profile_handler *pprof)
}
dev_set_drvdata(pprof->class_dev, pprof);
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
+
cur_profile = pprof;
return 0;
@@ -421,6 +423,8 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
device_unregister(pprof->class_dev);
ida_free(&platform_profile_ida, id);
+ sysfs_notify(acpi_kobj, NULL, "platform_profile");
+
cur_profile = NULL;
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH v5 14/20] ACPI: platform_profile: Only show profiles common for all handlers
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (12 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
` (6 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* adjust mutex use
---
drivers/acpi/platform_profile.c | 59 ++++++++++++++++++++++++---------
1 file changed, 44 insertions(+), 15 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 510e1435d3980..2ae0437623abb 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -231,27 +231,56 @@ static const struct class platform_profile_class = {
.dev_groups = profile_groups,
};
+/**
+ * _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)
+{
+ unsigned long *aggregate = data;
+ unsigned long choices = 0;
+ int err;
+
+ err = _get_class_choices(dev, &choices);
+ if (err)
+ return err;
+
+ if (!*aggregate)
+ *aggregate = choices;
+ else
+ *aggregate &= choices;
+
+ 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)
+ struct device_attribute *attr,
+ char *buf)
{
- int len = 0;
- int i;
+ unsigned long aggregate = 0;
+ int err;
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]);
- }
+ err = class_for_each_device(&platform_profile_class, NULL,
+ &aggregate, _aggregate_choices);
+ if (err)
+ return err;
}
- len += sysfs_emit_at(buf, len, "\n");
- return len;
+ /* no profile handler registered any more */
+ if (!aggregate)
+ return -EINVAL;
+
+ return _commmon_choices_show(aggregate, buf);
}
static ssize_t platform_profile_show(struct device *dev,
--
2.43.0
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH v5 15/20] ACPI: platform_profile: Add concept of a "custom" profile
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (13 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
` (5 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
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>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
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 2ae0437623abb..b6f3388b4eef9 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 d92a035e6ba6a..07807c93fde74 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] 42+ messages in thread
* [PATCH v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (14 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:53 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
` (4 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Notify class profile of change to legacy interface
* Don't show warning when writing custom string, document in last patch
instead.
* Adjust mutex use
---
drivers/acpi/platform_profile.c | 101 ++++++++++++++++++++++++--------
1 file changed, 76 insertions(+), 25 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index b6f3388b4eef9..7f302ac4d3779 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -94,6 +94,22 @@ static int _store_class_profile(struct device *dev, void *data)
return err ? err : 0;
}
+/**
+ * _notify_class_profile - Notify the class device of a profile change
+ * @dev: The class device
+ * @data: Unused
+ */
+static int _notify_class_profile(struct device *dev, void *data)
+{
+ struct platform_profile_handler *handler = dev_get_drvdata(dev);
+
+ lockdep_assert_held(&profile_lock);
+ sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile");
+ kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE);
+
+ return 0;
+}
+
/**
* get_class_profile - Show the current profile for a class device
* @dev: The class device
@@ -284,54 +300,89 @@ static ssize_t platform_profile_choices_show(struct device *dev,
return _commmon_choices_show(aggregate, 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 = data;
+ enum platform_profile_option val;
+ int err;
+
+ err = get_class_profile(dev, &val);
+ if (err)
+ return err;
+
+ if (*profile != PLATFORM_PROFILE_LAST && *profile != val)
+ *profile = PLATFORM_PROFILE_CUSTOM;
+ else
+ *profile = val;
+
+ 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)
+ struct device_attribute *attr,
+ char *buf)
{
- enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
+ enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
int err;
scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
- if (!cur_profile)
- return -ENODEV;
-
- err = cur_profile->profile_get(cur_profile, &profile);
+ err = class_for_each_device(&platform_profile_class, NULL,
+ &profile, _aggregate_profiles);
if (err)
return err;
}
- /* Check that profile is valid index */
- if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
- return -EIO;
+ /* no profile handler registered any more */
+ if (profile == PLATFORM_PROFILE_LAST)
+ return -EINVAL;
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)
+ if (i < 0 || PLATFORM_PROFILE_CUSTOM)
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;
+ ret = class_for_each_device(&platform_profile_class, NULL, &i,
+ _store_class_profile);
+ if (ret)
+ return ret;
+ ret = class_for_each_device(&platform_profile_class, NULL, NULL,
+ _notify_class_profile);
+ if (ret)
+ return ret;
}
- sysfs_notify(acpi_kobj, NULL, "platform_profile");
return count;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (15 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 8:58 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
` (3 subsequent siblings)
20 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Adjust mutex use
---
drivers/acpi/platform_profile.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 7f302ac4d3779..2c466f2d16b42 100644
--- a/drivers/acpi/platform_profile.c
+++ b/drivers/acpi/platform_profile.c
@@ -411,34 +411,39 @@ 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);
+ 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,
+ 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;
}
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] 42+ messages in thread
* [PATCH v5 18/20] ACPI: platform_profile: Allow multiple handlers
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (16 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
` (2 subsequent siblings)
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
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 the
drivers that were already changed remain changed and the legacy sysfs
handler will report 'custom'.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* reword commit message
---
drivers/acpi/platform_profile.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
index 2c466f2d16b42..63ef192f1a07c 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[] = {
@@ -401,8 +400,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");
@@ -459,9 +457,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 */
@@ -487,7 +482,6 @@ int platform_profile_register(struct platform_profile_handler *pprof)
sysfs_notify(acpi_kobj, NULL, "platform_profile");
- cur_profile = pprof;
return 0;
cleanup_ida:
@@ -511,7 +505,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
sysfs_notify(acpi_kobj, NULL, "platform_profile");
- cur_profile = NULL;
return 0;
}
EXPORT_SYMBOL_GPL(platform_profile_remove);
--
2.43.0
^ permalink raw reply related [flat|nested] 42+ messages in thread
* [PATCH v5 19/20] platform/x86/amd: pmf: Drop all quirks
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (17 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
2024-11-07 9:06 ` [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Armin Wolf
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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, Armin Wolf
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.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
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] 42+ messages in thread
* [PATCH v5 20/20] Documentation: Add documentation about class interface for platform profiles
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (18 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
@ 2024-11-07 6:02 ` Mario Limonciello
2024-11-07 9:06 ` [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Armin Wolf
20 siblings, 0 replies; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 6:02 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.
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v5:
* Fix some typos
---
.../ABI/testing/sysfs-platform_profile | 5 ++++
.../userspace-api/sysfs-platform_profile.rst | 28 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile
index baf1d125f9f83..125324ab53a96 100644
--- a/Documentation/ABI/testing/sysfs-platform_profile
+++ b/Documentation/ABI/testing/sysfs-platform_profile
@@ -33,3 +33,8 @@ Description: Reading this file gives the current selected profile for this
source such as e.g. a hotkey triggered profile change handled
either directly by the embedded-controller or fully handled
inside the kernel.
+
+ This file may also emit the string 'custom' to indicate
+ that multiple platform profiles drivers are in use but
+ have different values. This string can not be written to
+ this interface and is solely for informational purposes.
diff --git a/Documentation/userspace-api/sysfs-platform_profile.rst b/Documentation/userspace-api/sysfs-platform_profile.rst
index 4fccde2e45639..b746c30432753 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
+common 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 differs 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] 42+ messages in thread
* Re: [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device
2024-11-07 6:02 ` [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
@ 2024-11-07 8:07 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8:07 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 07.11.24 um 07:02 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: Armin Wolf <W_Armin@gmx.de>
> Tested-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>
> ---
> v5:
> * use platform_device_register_simple()
> ---
> drivers/platform/x86/dell/dell-pc.c | 32 +++++++++++++++++++++--------
> 1 file changed, 23 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c
> index 3cf79e55e3129..0cd9b26572b61 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,15 @@ 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_register_simple("dell-pc", -1, NULL, 0);
Please keep using PLATFORM_DEVID_NONE here.
Thanks,
Armin Wolf
> + if (!platform_device)
> return -ENOMEM;
> +
> + 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 +271,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_unregister(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] 42+ messages in thread
* Re: [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile
2024-11-07 6:02 ` [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
@ 2024-11-07 8:16 ` Armin Wolf
2024-11-07 21:09 ` Mario Limonciello
0 siblings, 1 reply; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8:16 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 07.11.24 um 07:02 schrieb Mario Limonciello:
> When registering a platform profile handler create a class device
> that will allow changing a single platform profile handler.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v5:
> * Use ida instead of idr
> * Use device_unregister instead of device_destroy()
> * MKDEV (0, 0)
> ---
> drivers/acpi/platform_profile.c | 50 +++++++++++++++++++++++++++++---
> include/linux/platform_profile.h | 2 ++
> 2 files changed, 48 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 0450bdae7c88b..652034b71ee9b 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_IDA(platform_profile_ida);
> +
> +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;
> @@ -163,20 +175,50 @@ 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 = ida_alloc(&platform_profile_ida, GFP_KERNEL);
Missing error handling.
> + pprof->class_dev = device_create(&platform_profile_class, NULL,
> + MKDEV(0, 0), NULL, "platform-profile-%d",
> + pprof->minor);
Two things:
1. Please allow drivers to pass in their struct device so the resulting class device
has a parent device. This would allow userspace applications to determine which device
handles which platform profile device. This parameter is optional and can be NULL.
2. Please use the fourth argument of device_create() instead of dev_set_drvdata().
Thanks,
Armin Wolf
> + if (IS_ERR(pprof->class_dev)) {
> + err = PTR_ERR(pprof->class_dev);
> + goto cleanup_ida;
> + }
> + dev_set_drvdata(pprof->class_dev, pprof);
>
> cur_profile = pprof;
> return 0;
> +
> +cleanup_ida:
> + ida_free(&platform_profile_ida, pprof->minor);
> +
> +cleanup_class:
> + class_unregister(&platform_profile_class);
> +
> + return err;
> }
> EXPORT_SYMBOL_GPL(platform_profile_register);
>
> int platform_profile_remove(struct platform_profile_handler *pprof)
> {
> + int id;
> guard(mutex)(&profile_lock);
>
> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
> + id = pprof->minor;
> + device_unregister(pprof->class_dev);
> + ida_free(&platform_profile_ida, id);
> +
> cur_profile = NULL;
> return 0;
> }
> diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h
> index 58279b76d740e..d92a035e6ba6a 100644
> --- a/include/linux/platform_profile.h
> +++ b/include/linux/platform_profile.h
> @@ -28,6 +28,8 @@ enum platform_profile_option {
>
> struct platform_profile_handler {
> const char *name;
> + 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] 42+ messages in thread
* Re: [PATCH v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload
2024-11-07 6:02 ` [PATCH v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload Mario Limonciello
@ 2024-11-07 8:21 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8: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 07.11.24 um 07:02 schrieb Mario Limonciello:
> The class and sysfs group are no longer needed when the platform profile
> core is a module and unloaded.
>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> drivers/acpi/platform_profile.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 652034b71ee9b..9caf070f77f6a 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -224,6 +224,13 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
> }
> EXPORT_SYMBOL_GPL(platform_profile_remove);
>
> +static void __exit platform_profile_exit(void)
> +{
> + class_unregister(&platform_profile_class);
> + sysfs_remove_group(acpi_kobj, &platform_profile_group);
This will crash should the class still not exist.
I suggest you register the class and the legacy sysfs group during module initialization, and
add a is_visible() callback to the legacy sysfs group. Then you can use sysfs_update_group() to
update the visibility of the sysfs files when platform profiles come and go.
Also please squash this patch with the patch introducing the class infrastructure.
Thanks,
Armin Wolf
> +}
> +module_exit(platform_profile_exit);
> +
> MODULE_AUTHOR("Mark Pearson <markpearson@lenovo.com>");
> MODULE_DESCRIPTION("ACPI platform profile sysfs interface");
> MODULE_LICENSE("GPL");
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 10/20] ACPI: platform_profile: Add name attribute to class interface
2024-11-07 6:02 ` [PATCH v5 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
@ 2024-11-07 8:23 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8:23 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 07.11.24 um 07:02 schrieb Mario Limonciello:
> The name attribute shows the name of the associated platform profile
> handler.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v5:
> * Drop newline
> * Add mutex for sysfs access
> ---
> drivers/acpi/platform_profile.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 9caf070f77f6a..f605c2bd35c68 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -25,8 +25,35 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
>
> static DEFINE_IDA(platform_profile_ida);
>
> +/**
> + * 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)
> +{
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + struct platform_profile_handler *handler = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%s\n", handler->name);
> + }
> + return -ERESTARTSYS;
Is the mutex really necessary here? The name remains static across the lifetime of the platform profile.
Thanks,
Armin Wolf
> +}
> +
> +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] 42+ messages in thread
* Re: [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-07 6:02 ` [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
@ 2024-11-07 8:28 ` Armin Wolf
2024-11-07 22:09 ` Mario Limonciello
0 siblings, 1 reply; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8:28 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 07.11.24 um 07:02 schrieb Mario Limonciello:
> The `choices` file will show all possible choices that a given platform
> profile handler can support.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v5:
> * Fix kdoc
> * Add tag
> * Fix whitespace
> * Adjust mutex use
> ---
> drivers/acpi/platform_profile.c | 65 +++++++++++++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index f605c2bd35c68..5e0bb91c5f451 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST);
>
> static DEFINE_IDA(platform_profile_ida);
>
> +/**
> + * _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
> + * @choices: Pointer to return the available profile choices
> + * Return: The available profile choices
> + */
> +static int _get_class_choices(struct device *dev, unsigned long *choices)
> +{
> + struct platform_profile_handler *handler;
> + int i;
> +
> + lockdep_assert_held(&profile_lock);
> + handler = dev_get_drvdata(dev);
> + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
> + *choices |= BIT(i);
Maybe just copying the bitmask would be enough here? In this case we could also drop
this function as well.
> +
> + return 0;
> +}
> +
> /**
> * name_show - Show the name of the profile handler
> * @dev: The device
> @@ -44,9 +84,34 @@ static ssize_t name_show(struct device *dev,
> return -ERESTARTSYS;
> }
>
> +/**
> + * 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;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + err = _get_class_choices(dev, &choices);
> + if (err)
> + return err;
> + }
Please directly use the choices field here, no need for a mutex since the choices are static
across the lifetime of the platform profile.
Thanks,
Armin Wolf
> +
> + 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] 42+ messages in thread
* Re: [PATCH v5 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-07 6:02 ` [PATCH v5 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
@ 2024-11-07 8:34 ` Armin Wolf
2024-11-07 21:41 ` Mario Limonciello
0 siblings, 1 reply; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8: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 07.11.24 um 07:02 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.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v5:
> * Drop recovery flow
> * Don't get profile before setting (not needed)
> * Simplify casting for call to _store_class_profile()
> * Only notify legacy interface of changes
> * Adjust mutex use
> ---
> drivers/acpi/platform_profile.c | 110 ++++++++++++++++++++++++++++++++
> 1 file changed, 110 insertions(+)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 5e0bb91c5f451..35e0e8f666072 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -65,6 +65,62 @@ 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)
> +{
> + struct platform_profile_handler *handler;
> + unsigned long choices;
> + int *i = (int *)data;
> + int err;
> +
> + err = _get_class_choices(dev, &choices);
> + if (err)
> + return err;
> +
> + lockdep_assert_held(&profile_lock);
> + if (!test_bit(*i, &choices))
> + return -EOPNOTSUPP;
> +
> + handler = dev_get_drvdata(dev);
> + err = handler->profile_set(handler, *i);
> + if (err)
> + return err;
> +
> + return err ? err : 0;
Please just return 0 here.
> +}
> +
> +/**
> + * 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;
> +
> + lockdep_assert_held(&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
> * @dev: The device
> @@ -106,12 +162,66 @@ 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;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + err = get_class_profile(dev, &profile);
> + if (err)
> + return err;
> + }
> +
> + return sysfs_emit(buf, "%s\n", profile_names[profile]);
AFAIK we do not need to take the mutex here, since querying the current platform profile
should not change any state.
Thanks,
Armin Wolf
> +}
> +
> +/**
> + * 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;
> +
> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> + ret = _store_class_profile(dev, &i);
> + if (ret)
> + return ret;
> + }
> +
> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
> +
> + return 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] 42+ messages in thread
* Re: [PATCH v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile
2024-11-07 6:02 ` [PATCH v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
@ 2024-11-07 8:53 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8: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 07.11.24 um 07:02 schrieb Mario Limonciello:
> If for any reason multiple profile handlers don't agree on the profile
> return the custom profile.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v5:
> * Notify class profile of change to legacy interface
> * Don't show warning when writing custom string, document in last patch
> instead.
> * Adjust mutex use
> ---
> drivers/acpi/platform_profile.c | 101 ++++++++++++++++++++++++--------
> 1 file changed, 76 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index b6f3388b4eef9..7f302ac4d3779 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -94,6 +94,22 @@ static int _store_class_profile(struct device *dev, void *data)
> return err ? err : 0;
> }
>
> +/**
> + * _notify_class_profile - Notify the class device of a profile change
> + * @dev: The class device
> + * @data: Unused
> + */
> +static int _notify_class_profile(struct device *dev, void *data)
> +{
> + struct platform_profile_handler *handler = dev_get_drvdata(dev);
> +
> + lockdep_assert_held(&profile_lock);
> + sysfs_notify(&handler->class_dev->kobj, NULL, "platform_profile");
> + kobject_uevent(&handler->class_dev->kobj, KOBJ_CHANGE);
> +
> + return 0;
> +}
> +
> /**
> * get_class_profile - Show the current profile for a class device
> * @dev: The class device
> @@ -284,54 +300,89 @@ static ssize_t platform_profile_choices_show(struct device *dev,
> return _commmon_choices_show(aggregate, 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 = data;
> + enum platform_profile_option val;
> + int err;
> +
> + err = get_class_profile(dev, &val);
> + if (err)
> + return err;
> +
> + if (*profile != PLATFORM_PROFILE_LAST && *profile != val)
> + *profile = PLATFORM_PROFILE_CUSTOM;
> + else
> + *profile = val;
> +
> + 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)
> + struct device_attribute *attr,
> + char *buf)
> {
> - enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED;
> + enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
> int err;
>
> scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
> - if (!cur_profile)
> - return -ENODEV;
> -
> - err = cur_profile->profile_get(cur_profile, &profile);
> + err = class_for_each_device(&platform_profile_class, NULL,
> + &profile, _aggregate_profiles);
> if (err)
> return err;
> }
>
> - /* Check that profile is valid index */
> - if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names))))
> - return -EIO;
> + /* no profile handler registered any more */
> + if (profile == PLATFORM_PROFILE_LAST)
> + return -EINVAL;
>
> 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)
> + if (i < 0 || PLATFORM_PROFILE_CUSTOM)
This condition looks a bit weird.
> 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;
> + ret = class_for_each_device(&platform_profile_class, NULL, &i,
> + _store_class_profile);
> + if (ret)
> + return ret;
> + ret = class_for_each_device(&platform_profile_class, NULL, NULL,
> + _notify_class_profile);
Please rework _store_class_profile() and _notify_class_profile() into:
- platform_profile_store(struct platform_profile_handler,enumplatform_profile_option option),
which is called by profile_store() while holding profile_lock.
- platform_profile_class_store(struct device *dev, void *data), which is used with class_for_each_device()
and internally calls platform_profile_store() and issues an notification on the "profile" (not "platform_profile"!)
class attribute and an uevent.
This allows you to avoid having to iterate through all platform profile handlers twice.
Thanks,
Armin Wolf
> + if (ret)
> + return ret;
> }
>
> - sysfs_notify(acpi_kobj, NULL, "platform_profile");
> return count;
> }
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next
2024-11-07 6:02 ` [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
@ 2024-11-07 8:58 ` Armin Wolf
2024-11-07 22:05 ` Mario Limonciello
0 siblings, 1 reply; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 8: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 07.11.24 um 07:02 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.
>
> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v5:
> * Adjust mutex use
> ---
> drivers/acpi/platform_profile.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index 7f302ac4d3779..2c466f2d16b42 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -411,34 +411,39 @@ 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);
> + 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,
> + next = find_next_bit_wrap(&choices,
> + PLATFORM_PROFILE_LAST,
> profile + 1);
Could it be that this would lead to be "custom" profile being selected under some conditions?
Also _aggregate_profiles() expects profile to be initialized with PLATFORM_PROFILE_LAST.
Thanks,
Armin Wolf
>
> - 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;
> }
>
> sysfs_notify(acpi_kobj, NULL, "platform_profile");
> - return 0;
> +
> + return err;
> }
> EXPORT_SYMBOL_GPL(platform_profile_cycle);
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
` (19 preceding siblings ...)
2024-11-07 6:02 ` [PATCH v5 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
@ 2024-11-07 9:06 ` Armin Wolf
2024-11-07 21:45 ` Mario Limonciello
20 siblings, 1 reply; 42+ messages in thread
From: Armin Wolf @ 2024-11-07 9:06 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 07.11.24 um 07:02 schrieb 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.
Thank you for this patch series. The overall design seems good to me, but i think
you forgot to extend platform_profile_notify().
Thanks,
Armin Wolf
> ---
> v5:
> * Adjust mutex handling
> * Add missing error handling
> * Drop dev member
> * Add cleanup handling for module unload
> * Fix crash on accessing legacy files after all drivers unloaded
>
> Mario Limonciello (20):
> ACPI: platform-profile: Add a name member to handlers
> platform/x86/dell: dell-pc: Create platform device
> 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: Unregister class and sysfs group on module
> unload
> 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
>
> .../ABI/testing/sysfs-platform_profile | 5 +
> .../userspace-api/sysfs-platform_profile.rst | 28 +
> drivers/acpi/platform_profile.c | 494 ++++++++++++++----
> .../surface/surface_platform_profile.c | 7 +-
> drivers/platform/x86/acer-wmi.c | 5 +-
> 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 | 3 +-
> drivers/platform/x86/asus-wmi.c | 5 +-
> drivers/platform/x86/dell/alienware-wmi.c | 3 +-
> drivers/platform/x86/dell/dell-pc.c | 35 +-
> drivers/platform/x86/hp/hp-wmi.c | 3 +-
> drivers/platform/x86/ideapad-laptop.c | 3 +-
> .../platform/x86/inspur_platform_profile.c | 6 +-
> drivers/platform/x86/thinkpad_acpi.c | 3 +-
> include/linux/platform_profile.h | 6 +-
> 18 files changed, 488 insertions(+), 190 deletions(-)
> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>
>
> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile
2024-11-07 8:16 ` Armin Wolf
@ 2024-11-07 21:09 ` Mario Limonciello
2024-11-08 17:34 ` Armin Wolf
0 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 21:09 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/7/2024 02:16, Armin Wolf wrote:
> Am 07.11.24 um 07:02 schrieb Mario Limonciello:
>
>> When registering a platform profile handler create a class device
>> that will allow changing a single platform profile handler.
>>
>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> v5:
>> * Use ida instead of idr
>> * Use device_unregister instead of device_destroy()
>> * MKDEV (0, 0)
>> ---
>> drivers/acpi/platform_profile.c | 50 +++++++++++++++++++++++++++++---
>> include/linux/platform_profile.h | 2 ++
>> 2 files changed, 48 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index 0450bdae7c88b..652034b71ee9b 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_IDA(platform_profile_ida);
>> +
>> +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;
>> @@ -163,20 +175,50 @@ 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 = ida_alloc(&platform_profile_ida, GFP_KERNEL);
>
> Missing error handling.
Ack.
>
>> + pprof->class_dev = device_create(&platform_profile_class, NULL,
>> + MKDEV(0, 0), NULL, "platform-profile-%d",
>> + pprof->minor);
>
> Two things:
>
> 1. Please allow drivers to pass in their struct device so the resulting
> class device
> has a parent device. This would allow userspace applications to
> determine which device
> handles which platform profile device. This parameter is optional and
> can be NULL.
>
I previously did this indirectly by letting them set it in the
"struct platform_profile_handler *pprof" and then used that value.
You had said that wasn't necessary so I dropped that patch. I would
rather go back to including that then having another argument to
platform_profile_register().
> 2. Please use the fourth argument of device_create() instead of
> dev_set_drvdata().
OK.
>
> Thanks,
> Armin Wolf
>
>> + if (IS_ERR(pprof->class_dev)) {
>> + err = PTR_ERR(pprof->class_dev);
>> + goto cleanup_ida;
>> + }
>> + dev_set_drvdata(pprof->class_dev, pprof);
>>
>> cur_profile = pprof;
>> return 0;
>> +
>> +cleanup_ida:
>> + ida_free(&platform_profile_ida, pprof->minor);
>> +
>> +cleanup_class:
>> + class_unregister(&platform_profile_class);
>> +
>> + return err;
>> }
>> EXPORT_SYMBOL_GPL(platform_profile_register);
>>
>> int platform_profile_remove(struct platform_profile_handler *pprof)
>> {
>> + int id;
>> guard(mutex)(&profile_lock);
>>
>> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
>> + id = pprof->minor;
>> + device_unregister(pprof->class_dev);
>> + ida_free(&platform_profile_ida, id);
>> +
>> cur_profile = NULL;
>> return 0;
>> }
>> diff --git a/include/linux/platform_profile.h b/include/linux/
>> platform_profile.h
>> index 58279b76d740e..d92a035e6ba6a 100644
>> --- a/include/linux/platform_profile.h
>> +++ b/include/linux/platform_profile.h
>> @@ -28,6 +28,8 @@ enum platform_profile_option {
>>
>> struct platform_profile_handler {
>> const char *name;
>> + 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] 42+ messages in thread
* Re: [PATCH v5 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-07 8:34 ` Armin Wolf
@ 2024-11-07 21:41 ` Mario Limonciello
2024-11-08 18:00 ` Armin Wolf
0 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 21:41 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/7/2024 02:34, Armin Wolf wrote:
> Am 07.11.24 um 07:02 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.
>>
>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> v5:
>> * Drop recovery flow
>> * Don't get profile before setting (not needed)
>> * Simplify casting for call to _store_class_profile()
>> * Only notify legacy interface of changes
>> * Adjust mutex use
>> ---
>> drivers/acpi/platform_profile.c | 110 ++++++++++++++++++++++++++++++++
>> 1 file changed, 110 insertions(+)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index 5e0bb91c5f451..35e0e8f666072 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -65,6 +65,62 @@ 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)
>> +{
>> + struct platform_profile_handler *handler;
>> + unsigned long choices;
>> + int *i = (int *)data;
>> + int err;
>> +
>> + err = _get_class_choices(dev, &choices);
>> + if (err)
>> + return err;
>> +
>> + lockdep_assert_held(&profile_lock);
>> + if (!test_bit(*i, &choices))
>> + return -EOPNOTSUPP;
>> +
>> + handler = dev_get_drvdata(dev);
>> + err = handler->profile_set(handler, *i);
>> + if (err)
>> + return err;
>> +
>> + return err ? err : 0;
>
> Please just return 0 here.
>
>> +}
>> +
>> +/**
>> + * 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;
>> +
>> + lockdep_assert_held(&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
>> * @dev: The device
>> @@ -106,12 +162,66 @@ 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;
>> +
>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> + err = get_class_profile(dev, &profile);
>> + if (err)
>> + return err;
>> + }
>> +
>> + return sysfs_emit(buf, "%s\n", profile_names[profile]);
>
> AFAIK we do not need to take the mutex here, since querying the current
> platform profile
> should not change any state.
I think it's still needed, in case someone attempts to unload the driver
at the same time as it's being read. It's not static information
because it needs to use the function pointer into the driver to get it.
This will protect from that occurring.
That's the same reason I was thinking name needed protection too.
>
> Thanks,
> Armin Wolf
>
>> +}
>> +
>> +/**
>> + * 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;
>> +
>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> + ret = _store_class_profile(dev, &i);
>> + if (ret)
>> + return ret;
>> + }
>> +
>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>> +
>> + return 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] 42+ messages in thread
* Re: [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers
2024-11-07 9:06 ` [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Armin Wolf
@ 2024-11-07 21:45 ` Mario Limonciello
2024-11-08 18:13 ` Armin Wolf
0 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 21:45 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/7/2024 03:06, Armin Wolf wrote:
> Am 07.11.24 um 07:02 schrieb 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.
>
> Thank you for this patch series. The overall design seems good to me,
> but i think
> you forgot to extend platform_profile_notify().
What did you have in mind? platform_profile_notify() is called from
drivers and just used to notify the legacy sysfs in the event of a change.
Were you thinking it also needs to notify the class device perhaps?
>
> Thanks,
> Armin Wolf
>
>> ---
>> v5:
>> * Adjust mutex handling
>> * Add missing error handling
>> * Drop dev member
>> * Add cleanup handling for module unload
>> * Fix crash on accessing legacy files after all drivers unloaded
>>
>> Mario Limonciello (20):
>> ACPI: platform-profile: Add a name member to handlers
>> platform/x86/dell: dell-pc: Create platform device
>> 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: Unregister class and sysfs group on module
>> unload
>> 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
>>
>> .../ABI/testing/sysfs-platform_profile | 5 +
>> .../userspace-api/sysfs-platform_profile.rst | 28 +
>> drivers/acpi/platform_profile.c | 494 ++++++++++++++----
>> .../surface/surface_platform_profile.c | 7 +-
>> drivers/platform/x86/acer-wmi.c | 5 +-
>> 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 | 3 +-
>> drivers/platform/x86/asus-wmi.c | 5 +-
>> drivers/platform/x86/dell/alienware-wmi.c | 3 +-
>> drivers/platform/x86/dell/dell-pc.c | 35 +-
>> drivers/platform/x86/hp/hp-wmi.c | 3 +-
>> drivers/platform/x86/ideapad-laptop.c | 3 +-
>> .../platform/x86/inspur_platform_profile.c | 6 +-
>> drivers/platform/x86/thinkpad_acpi.c | 3 +-
>> include/linux/platform_profile.h | 6 +-
>> 18 files changed, 488 insertions(+), 190 deletions(-)
>> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>>
>>
>> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next
2024-11-07 8:58 ` Armin Wolf
@ 2024-11-07 22:05 ` Mario Limonciello
2024-11-08 18:10 ` Armin Wolf
0 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 22:05 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/7/2024 02:58, Armin Wolf wrote:
> Am 07.11.24 um 07:02 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.
>>
>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> v5:
>> * Adjust mutex use
>> ---
>> drivers/acpi/platform_profile.c | 23 ++++++++++++++---------
>> 1 file changed, 14 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index 7f302ac4d3779..2c466f2d16b42 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -411,34 +411,39 @@ 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);
>> + 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,
>> + next = find_next_bit_wrap(&choices,
>> + PLATFORM_PROFILE_LAST,
>> profile + 1);
>
> Could it be that this would lead to be "custom" profile being selected
> under some conditions?
Yeah, you're right. If all drivers supported custom then this could
happen. I'll clear custom like this:
choices &= ~BIT(PLATFORM_PROFILE_CUSTOM);
> Also _aggregate_profiles() expects profile to be initialized with
> PLATFORM_PROFILE_LAST.
Will correct initialization in platform_profile_cycle() to this.
enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
But this also raises a good point. If _aggregate_profiles() returns
custom then this should be an error because next profile is undefined.
So I'll catch that like this.
err = class_for_each_device()
if (err)
return err;
if (profile == PLATFORM_PROFILE_CUSTOM)
return -EINVAL;
>
> Thanks,
> Armin Wolf
>
>>
>> - 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;
>> }
>>
>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>> - return 0;
>> +
>> + return err;
>> }
>> EXPORT_SYMBOL_GPL(platform_profile_cycle);
>>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-07 8:28 ` Armin Wolf
@ 2024-11-07 22:09 ` Mario Limonciello
2024-11-08 18:06 ` Armin Wolf
0 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-07 22:09 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/7/2024 02:28, Armin Wolf wrote:
> Am 07.11.24 um 07:02 schrieb Mario Limonciello:
>
>> The `choices` file will show all possible choices that a given platform
>> profile handler can support.
>>
>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> v5:
>> * Fix kdoc
>> * Add tag
>> * Fix whitespace
>> * Adjust mutex use
>> ---
>> drivers/acpi/platform_profile.c | 65 +++++++++++++++++++++++++++++++++
>> 1 file changed, 65 insertions(+)
>>
>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>> platform_profile.c
>> index f605c2bd35c68..5e0bb91c5f451 100644
>> --- a/drivers/acpi/platform_profile.c
>> +++ b/drivers/acpi/platform_profile.c
>> @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) ==
>> PLATFORM_PROFILE_LAST);
>>
>> static DEFINE_IDA(platform_profile_ida);
>>
>> +/**
>> + * _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
>> + * @choices: Pointer to return the available profile choices
>> + * Return: The available profile choices
>> + */
>> +static int _get_class_choices(struct device *dev, unsigned long
>> *choices)
>> +{
>> + struct platform_profile_handler *handler;
>> + int i;
>> +
>> + lockdep_assert_held(&profile_lock);
>> + handler = dev_get_drvdata(dev);
>> + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
>> + *choices |= BIT(i);
>
> Maybe just copying the bitmask would be enough here? In this case we
> could also drop
> this function as well.
Right now this could work, but choices and the use of it has gone
through great lengths to ensure that once there are too many profiles it
automatically becomes a bigger variable.
unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
So I would rather keep this as is.
>
>> +
>> + return 0;
>> +}
>> +
>> /**
>> * name_show - Show the name of the profile handler
>> * @dev: The device
>> @@ -44,9 +84,34 @@ static ssize_t name_show(struct device *dev,
>> return -ERESTARTSYS;
>> }
>>
>> +/**
>> + * 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;
>> +
>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) {
>> + err = _get_class_choices(dev, &choices);
>> + if (err)
>> + return err;
>> + }
>
> Please directly use the choices field here, no need for a mutex since
> the choices are static
> across the lifetime of the platform profile.
But similarly to my other message, the class could be unregistered and
this needs to be protected.
>
> Thanks,
> Armin Wolf
>
>> +
>> + 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] 42+ messages in thread
* Re: [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile
2024-11-07 21:09 ` Mario Limonciello
@ 2024-11-08 17:34 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-08 17: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 07.11.24 um 22:09 schrieb Mario Limonciello:
> On 11/7/2024 02:16, Armin Wolf wrote:
>> Am 07.11.24 um 07:02 schrieb Mario Limonciello:
>>
>>> When registering a platform profile handler create a class device
>>> that will allow changing a single platform profile handler.
>>>
>>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> v5:
>>> * Use ida instead of idr
>>> * Use device_unregister instead of device_destroy()
>>> * MKDEV (0, 0)
>>> ---
>>> drivers/acpi/platform_profile.c | 50
>>> +++++++++++++++++++++++++++++---
>>> include/linux/platform_profile.h | 2 ++
>>> 2 files changed, 48 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index 0450bdae7c88b..652034b71ee9b 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_IDA(platform_profile_ida);
>>> +
>>> +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;
>>> @@ -163,20 +175,50 @@ 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 = ida_alloc(&platform_profile_ida, GFP_KERNEL);
>>
>> Missing error handling.
>
> Ack.
>
>>
>>> + pprof->class_dev = device_create(&platform_profile_class, NULL,
>>> + MKDEV(0, 0), NULL, "platform-profile-%d",
>>> + pprof->minor);
>>
>> Two things:
>>
>> 1. Please allow drivers to pass in their struct device so the
>> resulting class device
>> has a parent device. This would allow userspace applications to
>> determine which device
>> handles which platform profile device. This parameter is optional and
>> can be NULL.
>>
>
> I previously did this indirectly by letting them set it in the
> "struct platform_profile_handler *pprof" and then used that value.
>
> You had said that wasn't necessary so I dropped that patch. I would
> rather go back to including that then having another argument to
> platform_profile_register().
>
I meant that requiring "dev" to be set is not necessary. Having a "dev" field inside struct platform_profile_handler is fine.
Thanks,
Armin Wolf
>> 2. Please use the fourth argument of device_create() instead of
>> dev_set_drvdata().
>
> OK.
>
>>
>> Thanks,
>> Armin Wolf
>>
>>> + if (IS_ERR(pprof->class_dev)) {
>>> + err = PTR_ERR(pprof->class_dev);
>>> + goto cleanup_ida;
>>> + }
>>> + dev_set_drvdata(pprof->class_dev, pprof);
>>>
>>> cur_profile = pprof;
>>> return 0;
>>> +
>>> +cleanup_ida:
>>> + ida_free(&platform_profile_ida, pprof->minor);
>>> +
>>> +cleanup_class:
>>> + class_unregister(&platform_profile_class);
>>> +
>>> + return err;
>>> }
>>> EXPORT_SYMBOL_GPL(platform_profile_register);
>>>
>>> int platform_profile_remove(struct platform_profile_handler *pprof)
>>> {
>>> + int id;
>>> guard(mutex)(&profile_lock);
>>>
>>> - sysfs_remove_group(acpi_kobj, &platform_profile_group);
>>> + id = pprof->minor;
>>> + device_unregister(pprof->class_dev);
>>> + ida_free(&platform_profile_ida, id);
>>> +
>>> cur_profile = NULL;
>>> return 0;
>>> }
>>> diff --git a/include/linux/platform_profile.h b/include/linux/
>>> platform_profile.h
>>> index 58279b76d740e..d92a035e6ba6a 100644
>>> --- a/include/linux/platform_profile.h
>>> +++ b/include/linux/platform_profile.h
>>> @@ -28,6 +28,8 @@ enum platform_profile_option {
>>>
>>> struct platform_profile_handler {
>>> const char *name;
>>> + 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] 42+ messages in thread
* Re: [PATCH v5 12/20] ACPI: platform_profile: Add profile attribute for class interface
2024-11-07 21:41 ` Mario Limonciello
@ 2024-11-08 18:00 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-08 18: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 07.11.24 um 22:41 schrieb Mario Limonciello:
> On 11/7/2024 02:34, Armin Wolf wrote:
>> Am 07.11.24 um 07:02 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.
>>>
>>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> v5:
>>> * Drop recovery flow
>>> * Don't get profile before setting (not needed)
>>> * Simplify casting for call to _store_class_profile()
>>> * Only notify legacy interface of changes
>>> * Adjust mutex use
>>> ---
>>> drivers/acpi/platform_profile.c | 110
>>> ++++++++++++++++++++++++++++++++
>>> 1 file changed, 110 insertions(+)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index 5e0bb91c5f451..35e0e8f666072 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -65,6 +65,62 @@ 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)
>>> +{
>>> + struct platform_profile_handler *handler;
>>> + unsigned long choices;
>>> + int *i = (int *)data;
>>> + int err;
>>> +
>>> + err = _get_class_choices(dev, &choices);
>>> + if (err)
>>> + return err;
>>> +
>>> + lockdep_assert_held(&profile_lock);
>>> + if (!test_bit(*i, &choices))
>>> + return -EOPNOTSUPP;
>>> +
>>> + handler = dev_get_drvdata(dev);
>>> + err = handler->profile_set(handler, *i);
>>> + if (err)
>>> + return err;
>>> +
>>> + return err ? err : 0;
>>
>> Please just return 0 here.
>>
>>> +}
>>> +
>>> +/**
>>> + * 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;
>>> +
>>> + lockdep_assert_held(&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
>>> * @dev: The device
>>> @@ -106,12 +162,66 @@ 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;
>>> +
>>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> + err = get_class_profile(dev, &profile);
>>> + if (err)
>>> + return err;
>>> + }
>>> +
>>> + return sysfs_emit(buf, "%s\n", profile_names[profile]);
>>
>> AFAIK we do not need to take the mutex here, since querying the
>> current platform profile
>> should not change any state.
>
> I think it's still needed, in case someone attempts to unload the driver
> at the same time as it's being read. It's not static information
> because it needs to use the function pointer into the driver to get it.
>
> This will protect from that occurring.
>
> That's the same reason I was thinking name needed protection too.
>
I see, good point.
Thanks,
Armin Wolf
>>
>> Thanks,
>> Armin Wolf
>>
>>> +}
>>> +
>>> +/**
>>> + * 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;
>>> +
>>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> + ret = _store_class_profile(dev, &i);
>>> + if (ret)
>>> + return ret;
>>> + }
>>> +
>>> + sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>> +
>>> + return 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] 42+ messages in thread
* Re: [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-07 22:09 ` Mario Limonciello
@ 2024-11-08 18:06 ` Armin Wolf
2024-11-08 19:25 ` Mario Limonciello
0 siblings, 1 reply; 42+ messages in thread
From: Armin Wolf @ 2024-11-08 18:06 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 07.11.24 um 23:09 schrieb Mario Limonciello:
> On 11/7/2024 02:28, Armin Wolf wrote:
>> Am 07.11.24 um 07:02 schrieb Mario Limonciello:
>>
>>> The `choices` file will show all possible choices that a given platform
>>> profile handler can support.
>>>
>>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> v5:
>>> * Fix kdoc
>>> * Add tag
>>> * Fix whitespace
>>> * Adjust mutex use
>>> ---
>>> drivers/acpi/platform_profile.c | 65
>>> +++++++++++++++++++++++++++++++++
>>> 1 file changed, 65 insertions(+)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index f605c2bd35c68..5e0bb91c5f451 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) ==
>>> PLATFORM_PROFILE_LAST);
>>>
>>> static DEFINE_IDA(platform_profile_ida);
>>>
>>> +/**
>>> + * _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
>>> + * @choices: Pointer to return the available profile choices
>>> + * Return: The available profile choices
>>> + */
>>> +static int _get_class_choices(struct device *dev, unsigned long
>>> *choices)
>>> +{
>>> + struct platform_profile_handler *handler;
>>> + int i;
>>> +
>>> + lockdep_assert_held(&profile_lock);
>>> + handler = dev_get_drvdata(dev);
>>> + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
>>> + *choices |= BIT(i);
>>
>> Maybe just copying the bitmask would be enough here? In this case we
>> could also drop
>> this function as well.
>
> Right now this could work, but choices and the use of it has gone
> through great lengths to ensure that once there are too many profiles
> it automatically becomes a bigger variable.
>
> unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
>
> So I would rather keep this as is.
>
I think users of this function can do the locking themself and instead use the functions from bitmap.h. Because _get_class_choices() will break once "choices" becomes bigger.
Thanks,
Armin Wolf
>>
>>> +
>>> + return 0;
>>> +}
>>> +
>>> /**
>>> * name_show - Show the name of the profile handler
>>> * @dev: The device
>>> @@ -44,9 +84,34 @@ static ssize_t name_show(struct device *dev,
>>> return -ERESTARTSYS;
>>> }
>>>
>>> +/**
>>> + * 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;
>>> +
>>> + scoped_cond_guard(mutex_intr, return -ERESTARTSYS,
>>> &profile_lock) {
>>> + err = _get_class_choices(dev, &choices);
>>> + if (err)
>>> + return err;
>>> + }
>>
>> Please directly use the choices field here, no need for a mutex since
>> the choices are static
>> across the lifetime of the platform profile.
>
> But similarly to my other message, the class could be unregistered and
> this needs to be protected.
>
>>
>> Thanks,
>> Armin Wolf
>>
>>> +
>>> + 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] 42+ messages in thread
* Re: [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next
2024-11-07 22:05 ` Mario Limonciello
@ 2024-11-08 18:10 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-08 18: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 07.11.24 um 23:05 schrieb Mario Limonciello:
> On 11/7/2024 02:58, Armin Wolf wrote:
>> Am 07.11.24 um 07:02 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.
>>>
>>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>> v5:
>>> * Adjust mutex use
>>> ---
>>> drivers/acpi/platform_profile.c | 23 ++++++++++++++---------
>>> 1 file changed, 14 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>> platform_profile.c
>>> index 7f302ac4d3779..2c466f2d16b42 100644
>>> --- a/drivers/acpi/platform_profile.c
>>> +++ b/drivers/acpi/platform_profile.c
>>> @@ -411,34 +411,39 @@ 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);
>>> + 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,
>>> + next = find_next_bit_wrap(&choices,
>>> + PLATFORM_PROFILE_LAST,
>>> profile + 1);
>>
>> Could it be that this would lead to be "custom" profile being
>> selected under some conditions?
>
> Yeah, you're right. If all drivers supported custom then this could
> happen. I'll clear custom like this:
>
> choices &= ~BIT(PLATFORM_PROFILE_CUSTOM);
>
Sound good to me.
>> Also _aggregate_profiles() expects profile to be initialized with
>> PLATFORM_PROFILE_LAST.
>
> Will correct initialization in platform_profile_cycle() to this.
>
> enum platform_profile_option profile = PLATFORM_PROFILE_LAST;
>
> But this also raises a good point. If _aggregate_profiles() returns
> custom then this should be an error because next profile is undefined.
> So I'll catch that like this.
> err = class_for_each_device()
> if (err)
> return err;
> if (profile == PLATFORM_PROFILE_CUSTOM)
> return -EINVAL;
Good point, please also check if profile == PLATFORM_PROFILE_LAST in case no platform profile handlers are currently installed.
Thanks,
Armin Wol
>>
>> Thanks,
>> Armin Wolf
>>
>>>
>>> - 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;
>>> }
>>>
>>> sysfs_notify(acpi_kobj, NULL, "platform_profile");
>>> - return 0;
>>> +
>>> + return err;
>>> }
>>> EXPORT_SYMBOL_GPL(platform_profile_cycle);
>>>
>
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers
2024-11-07 21:45 ` Mario Limonciello
@ 2024-11-08 18:13 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-08 18:13 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 07.11.24 um 22:45 schrieb Mario Limonciello:
> On 11/7/2024 03:06, Armin Wolf wrote:
>> Am 07.11.24 um 07:02 schrieb 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.
>>
>> Thank you for this patch series. The overall design seems good to me,
>> but i think
>> you forgot to extend platform_profile_notify().
>
> What did you have in mind? platform_profile_notify() is called from
> drivers and just used to notify the legacy sysfs in the event of a
> change.
>
> Were you thinking it also needs to notify the class device perhaps?
>
If platform_profile_notify() only notifies the legacy sysfs interface, then userspace applications are forced to continue using the legacy sysfs interface
for receiving notifications.
Thanks,
Armin Wolf
>>
>> Thanks,
>> Armin Wolf
>>
>>> ---
>>> v5:
>>> * Adjust mutex handling
>>> * Add missing error handling
>>> * Drop dev member
>>> * Add cleanup handling for module unload
>>> * Fix crash on accessing legacy files after all drivers unloaded
>>>
>>> Mario Limonciello (20):
>>> ACPI: platform-profile: Add a name member to handlers
>>> platform/x86/dell: dell-pc: Create platform device
>>> 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: Unregister class and sysfs group on module
>>> unload
>>> 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
>>>
>>> .../ABI/testing/sysfs-platform_profile | 5 +
>>> .../userspace-api/sysfs-platform_profile.rst | 28 +
>>> drivers/acpi/platform_profile.c | 494
>>> ++++++++++++++----
>>> .../surface/surface_platform_profile.c | 7 +-
>>> drivers/platform/x86/acer-wmi.c | 5 +-
>>> 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 | 3 +-
>>> drivers/platform/x86/asus-wmi.c | 5 +-
>>> drivers/platform/x86/dell/alienware-wmi.c | 3 +-
>>> drivers/platform/x86/dell/dell-pc.c | 35 +-
>>> drivers/platform/x86/hp/hp-wmi.c | 3 +-
>>> drivers/platform/x86/ideapad-laptop.c | 3 +-
>>> .../platform/x86/inspur_platform_profile.c | 6 +-
>>> drivers/platform/x86/thinkpad_acpi.c | 3 +-
>>> include/linux/platform_profile.h | 6 +-
>>> 18 files changed, 488 insertions(+), 190 deletions(-)
>>> delete mode 100644 drivers/platform/x86/amd/pmf/pmf-quirks.c
>>>
>>>
>>> base-commit: d68cb6023356af3bd3193983ad4ec03954a0b3e2
>
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-08 18:06 ` Armin Wolf
@ 2024-11-08 19:25 ` Mario Limonciello
2024-11-08 19:44 ` Armin Wolf
0 siblings, 1 reply; 42+ messages in thread
From: Mario Limonciello @ 2024-11-08 19: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/8/2024 12:06, Armin Wolf wrote:
> Am 07.11.24 um 23:09 schrieb Mario Limonciello:
>
>> On 11/7/2024 02:28, Armin Wolf wrote:
>>> Am 07.11.24 um 07:02 schrieb Mario Limonciello:
>>>
>>>> The `choices` file will show all possible choices that a given platform
>>>> profile handler can support.
>>>>
>>>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>> ---
>>>> v5:
>>>> * Fix kdoc
>>>> * Add tag
>>>> * Fix whitespace
>>>> * Adjust mutex use
>>>> ---
>>>> drivers/acpi/platform_profile.c | 65
>>>> +++++++++++++++++++++++++++++++++
>>>> 1 file changed, 65 insertions(+)
>>>>
>>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>>> platform_profile.c
>>>> index f605c2bd35c68..5e0bb91c5f451 100644
>>>> --- a/drivers/acpi/platform_profile.c
>>>> +++ b/drivers/acpi/platform_profile.c
>>>> @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) ==
>>>> PLATFORM_PROFILE_LAST);
>>>>
>>>> static DEFINE_IDA(platform_profile_ida);
>>>>
>>>> +/**
>>>> + * _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
>>>> + * @choices: Pointer to return the available profile choices
>>>> + * Return: The available profile choices
>>>> + */
>>>> +static int _get_class_choices(struct device *dev, unsigned long
>>>> *choices)
>>>> +{
>>>> + struct platform_profile_handler *handler;
>>>> + int i;
>>>> +
>>>> + lockdep_assert_held(&profile_lock);
>>>> + handler = dev_get_drvdata(dev);
>>>> + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
>>>> + *choices |= BIT(i);
>>>
>>> Maybe just copying the bitmask would be enough here? In this case we
>>> could also drop
>>> this function as well.
>>
>> Right now this could work, but choices and the use of it has gone
>> through great lengths to ensure that once there are too many profiles
>> it automatically becomes a bigger variable.
>>
>> unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
>>
>> So I would rather keep this as is.
>>
> I think users of this function can do the locking themself and instead
> use the functions from bitmap.h. Because _get_class_choices() will break
> once "choices" becomes bigger.
>
I am thinking it's better to just switch explicitly to an 'unsigned
long' and add a static check that all profiles fit. If ever they don't
fit, the code can be overhauled at that point.
And yes _get_class_choices can go away then, and this is a lot simpler.
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for class interface
2024-11-08 19:25 ` Mario Limonciello
@ 2024-11-08 19:44 ` Armin Wolf
0 siblings, 0 replies; 42+ messages in thread
From: Armin Wolf @ 2024-11-08 19:44 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 08.11.24 um 20:25 schrieb Mario Limonciello:
> On 11/8/2024 12:06, Armin Wolf wrote:
>> Am 07.11.24 um 23:09 schrieb Mario Limonciello:
>>
>>> On 11/7/2024 02:28, Armin Wolf wrote:
>>>> Am 07.11.24 um 07:02 schrieb Mario Limonciello:
>>>>
>>>>> The `choices` file will show all possible choices that a given
>>>>> platform
>>>>> profile handler can support.
>>>>>
>>>>> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>> ---
>>>>> v5:
>>>>> * Fix kdoc
>>>>> * Add tag
>>>>> * Fix whitespace
>>>>> * Adjust mutex use
>>>>> ---
>>>>> drivers/acpi/platform_profile.c | 65
>>>>> +++++++++++++++++++++++++++++++++
>>>>> 1 file changed, 65 insertions(+)
>>>>>
>>>>> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/
>>>>> platform_profile.c
>>>>> index f605c2bd35c68..5e0bb91c5f451 100644
>>>>> --- a/drivers/acpi/platform_profile.c
>>>>> +++ b/drivers/acpi/platform_profile.c
>>>>> @@ -25,6 +25,46 @@ static_assert(ARRAY_SIZE(profile_names) ==
>>>>> PLATFORM_PROFILE_LAST);
>>>>>
>>>>> static DEFINE_IDA(platform_profile_ida);
>>>>>
>>>>> +/**
>>>>> + * _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
>>>>> + * @choices: Pointer to return the available profile choices
>>>>> + * Return: The available profile choices
>>>>> + */
>>>>> +static int _get_class_choices(struct device *dev, unsigned long
>>>>> *choices)
>>>>> +{
>>>>> + struct platform_profile_handler *handler;
>>>>> + int i;
>>>>> +
>>>>> + lockdep_assert_held(&profile_lock);
>>>>> + handler = dev_get_drvdata(dev);
>>>>> + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST)
>>>>> + *choices |= BIT(i);
>>>>
>>>> Maybe just copying the bitmask would be enough here? In this case we
>>>> could also drop
>>>> this function as well.
>>>
>>> Right now this could work, but choices and the use of it has gone
>>> through great lengths to ensure that once there are too many profiles
>>> it automatically becomes a bigger variable.
>>>
>>> unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)];
>>>
>>> So I would rather keep this as is.
>>>
>> I think users of this function can do the locking themself and
>> instead use the functions from bitmap.h. Because _get_class_choices()
>> will break once "choices" becomes bigger.
>>
>
> I am thinking it's better to just switch explicitly to an 'unsigned
> long' and add a static check that all profiles fit. If ever they
> don't fit, the code can be overhauled at that point.
>
> And yes _get_class_choices can go away then, and this is a lot simpler.
Ok.
^ permalink raw reply [flat|nested] 42+ messages in thread
end of thread, other threads:[~2024-11-08 19:45 UTC | newest]
Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 6:02 [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 01/20] ACPI: platform-profile: Add a name member to handlers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 02/20] platform/x86/dell: dell-pc: Create platform device Mario Limonciello
2024-11-07 8:07 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 03/20] ACPI: platform_profile: Add platform handler argument to platform_profile_remove() Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 04/20] ACPI: platform_profile: Move sanity check out of the mutex Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 05/20] ACPI: platform_profile: Move matching string for new profile out of mutex Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 06/20] ACPI: platform_profile: Use guard(mutex) for register/unregister Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 07/20] ACPI: platform_profile: Use `scoped_cond_guard` Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 08/20] ACPI: platform_profile: Create class for ACPI platform profile Mario Limonciello
2024-11-07 8:16 ` Armin Wolf
2024-11-07 21:09 ` Mario Limonciello
2024-11-08 17:34 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 09/20] ACPI: platform_profile: Unregister class and sysfs group on module unload Mario Limonciello
2024-11-07 8:21 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 10/20] ACPI: platform_profile: Add name attribute to class interface Mario Limonciello
2024-11-07 8:23 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 11/20] ACPI: platform_profile: Add choices attribute for " Mario Limonciello
2024-11-07 8:28 ` Armin Wolf
2024-11-07 22:09 ` Mario Limonciello
2024-11-08 18:06 ` Armin Wolf
2024-11-08 19:25 ` Mario Limonciello
2024-11-08 19:44 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 12/20] ACPI: platform_profile: Add profile " Mario Limonciello
2024-11-07 8:34 ` Armin Wolf
2024-11-07 21:41 ` Mario Limonciello
2024-11-08 18:00 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 13/20] ACPI: platform_profile: Notify change events on register and unregister Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 14/20] ACPI: platform_profile: Only show profiles common for all handlers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 15/20] ACPI: platform_profile: Add concept of a "custom" profile Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 16/20] ACPI: platform_profile: Make sure all profile handlers agree on profile Mario Limonciello
2024-11-07 8:53 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 17/20] ACPI: platform_profile: Check all profile handler to calculate next Mario Limonciello
2024-11-07 8:58 ` Armin Wolf
2024-11-07 22:05 ` Mario Limonciello
2024-11-08 18:10 ` Armin Wolf
2024-11-07 6:02 ` [PATCH v5 18/20] ACPI: platform_profile: Allow multiple handlers Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 19/20] platform/x86/amd: pmf: Drop all quirks Mario Limonciello
2024-11-07 6:02 ` [PATCH v5 20/20] Documentation: Add documentation about class interface for platform profiles Mario Limonciello
2024-11-07 9:06 ` [PATCH v5 00/20] Add support for binding ACPI platform profile to multiple drivers Armin Wolf
2024-11-07 21:45 ` Mario Limonciello
2024-11-08 18:13 ` Armin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox