From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: rafael@kernel.org
Cc: "Len Brown" <lenb@kernel.org>, "Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Maximilian Luz" <luzmaximilian@gmail.com>,
"Shyam Sundar S K" <Shyam-sundar.S-k@amd.com>,
"Mark Pearson" <mpearson-lenovo@squebb.ca>,
"Derek J. Clark" <derekjohn.clark@gmail.com>,
"Daniel Lezcano" <daniel.lezcano@kernel.org>,
"Zhang Rui" <rui.zhang@intel.com>,
"Lukasz Luba" <lukasz.luba@arm.com>,
"Jai Luthra" <jai.luthra@ideasonboard.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Armin Wolf" <W_Armin@gmx.de>, "Jack Wu" <jackbb_wu@compal.com>,
"Mario Limonciello (AMD)" <superm1@kernel.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-pm@vger.kernel.org,
platform-driver-x86@vger.kernel.org
Subject: [PATCH v1 3/4] platform profile: Add firmware-neutral aggregate sysfs interface
Date: Wed, 14 Oct 2026 15:24:46 +0200 [thread overview]
Message-ID: <20261014132500.3817549-4-daniel.lezcano@oss.qualcomm.com> (raw)
In-Reply-To: <20261014132500.3817549-1-daniel.lezcano@oss.qualcomm.com>
The per-provider class interface is firmware-independent, but system-
wide profile selection is only exposed under /sys/firmware/acpi.
Add /sys/kernel/platform_profile/{choices,profile}, sharing the existing
aggregate callbacks and semantics with the legacy interface. Keep
attributes hidden until a provider is registered and remove them after
the last provider.
Notify both aggregate frontends on profile changes. Also notify the
provider class device on a direct profile write, matching its documented
POLLPRI ABI. Restore aggregate visibility after a failed registration.
Assisted-by: OpenCode:gpt-6.1-sol
Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
---
drivers/platform/profile/core.c | 60 +++++++++++++++++++++++++++++----
1 file changed, 53 insertions(+), 7 deletions(-)
diff --git a/drivers/platform/profile/core.c b/drivers/platform/profile/core.c
index f18fd96b942c..507b96bdfdb1 100644
--- a/drivers/platform/profile/core.c
+++ b/drivers/platform/profile/core.c
@@ -26,9 +26,11 @@ static DEFINE_MUTEX(profile_lock);
static DEFINE_MUTEX(profile_registration_lock);
static LIST_HEAD(profile_handlers);
static struct kobject *compat_kobj;
+static struct kobject *profile_kobj;
static void profile_notify(void)
{
+ sysfs_notify(profile_kobj, NULL, "profile");
if (compat_kobj)
sysfs_notify(compat_kobj, NULL, "platform_profile");
}
@@ -250,6 +252,7 @@ static ssize_t profile_store(struct device *dev,
ret = _store_class_profile(dev, &index);
if (ret)
return ret;
+ _notify_class_profile(dev, NULL);
}
profile_notify();
@@ -324,7 +327,7 @@ static int _remove_hidden_choices(struct device *dev, void *arg)
}
/**
- * platform_profile_choices_show - Show the available profile choices for legacy sysfs interface
+ * platform_profile_choices_show - Show the aggregate profile choices
* @kobj: The kobject
* @attr: The attribute
* @buf: The buffer to write to
@@ -360,7 +363,7 @@ static ssize_t platform_profile_choices_show(struct kobject *kobj,
}
/**
- * _aggregate_profiles - Aggregate the profiles for legacy sysfs interface
+ * _aggregate_profiles - Aggregate the profiles across providers
* @dev: The device
* @data: The profile to return
*
@@ -385,7 +388,7 @@ static int _aggregate_profiles(struct device *dev, void *data)
}
/**
- * _store_and_notify - Store and notify a class from legacy sysfs interface
+ * _store_and_notify - Store and notify a provider from an aggregate write
* @dev: The device
* @data: The profile to return
*
@@ -403,7 +406,7 @@ static int _store_and_notify(struct device *dev, void *data)
}
/**
- * platform_profile_show - Show the current profile for legacy sysfs interface
+ * platform_profile_show - Show the current aggregate profile
* @kobj: The kobject
* @attr: The attribute
* @buf: The buffer to write to
@@ -431,7 +434,7 @@ static ssize_t platform_profile_show(struct kobject *kobj,
}
/**
- * platform_profile_store - Set the profile for legacy sysfs interface
+ * platform_profile_store - Set the profile across all providers
* @kobj: The kobject
* @attr: The attribute
* @buf: The buffer to read from
@@ -493,8 +496,30 @@ static const struct attribute_group platform_profile_group = {
.is_visible = profile_class_is_visible,
};
+static struct kobj_attribute aggregate_choices =
+ __ATTR(choices, 0444, platform_profile_choices_show, NULL);
+static struct kobj_attribute aggregate_profile =
+ __ATTR(profile, 0644, platform_profile_show, platform_profile_store);
+
+static struct attribute *aggregate_attrs[] = {
+ &aggregate_choices.attr,
+ &aggregate_profile.attr,
+ NULL
+};
+
+static const struct attribute_group aggregate_group = {
+ .attrs = aggregate_attrs,
+ .is_visible = profile_class_is_visible,
+};
+
static int profile_update(void)
{
+ int err;
+
+ err = sysfs_update_group(profile_kobj, &aggregate_group);
+ if (err)
+ return err;
+
if (compat_kobj)
return sysfs_update_group(compat_kobj, &platform_profile_group);
@@ -502,7 +527,7 @@ static int profile_update(void)
}
/**
- * platform_profile_notify - Notify class device and legacy sysfs interface
+ * platform_profile_notify - Notify the provider and aggregate sysfs interfaces
* @dev: The class device
*/
void platform_profile_notify(struct device *dev)
@@ -643,6 +668,7 @@ struct device *platform_profile_register(struct device *dev, const char *name,
cleanup_cur:
scoped_guard(mutex, &profile_lock)
list_del(&to_pprof_handler(ppdev)->node);
+ profile_update();
device_unregister(ppdev);
cleanup_ida:
@@ -726,15 +752,33 @@ static int __init platform_profile_init(void)
if (err)
return err;
+ profile_kobj = kobject_create_and_add("platform_profile", kernel_kobj);
+ if (!profile_kobj) {
+ err = -ENOMEM;
+ goto unregister_class;
+ }
+
+ err = sysfs_create_group(profile_kobj, &aggregate_group);
+ if (err)
+ goto put_kobj;
+
compat_kobj = platform_profile_compat_kobj();
if (compat_kobj) {
err = sysfs_create_group(compat_kobj, &platform_profile_group);
if (err) {
kobject_put(compat_kobj);
- class_unregister(&platform_profile_class);
+ goto remove_group;
}
}
+ return 0;
+
+remove_group:
+ sysfs_remove_group(profile_kobj, &aggregate_group);
+put_kobj:
+ kobject_put(profile_kobj);
+unregister_class:
+ class_unregister(&platform_profile_class);
return err;
}
@@ -744,6 +788,8 @@ static void __exit platform_profile_exit(void)
sysfs_remove_group(compat_kobj, &platform_profile_group);
kobject_put(compat_kobj);
}
+ sysfs_remove_group(profile_kobj, &aggregate_group);
+ kobject_put(profile_kobj);
class_unregister(&platform_profile_class);
}
subsys_initcall_sync(platform_profile_init);
--
2.43.0
next prev parent reply other threads:[~2026-10-14 13:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 13:24 [PATCH v1 0/4] Make platform profiles firmware independent Daniel Lezcano
2026-10-14 13:24 ` [PATCH v1 1/4] platform profile: Separate handler locking from sysfs lifetime Daniel Lezcano
2026-10-14 13:24 ` [PATCH v1 2/4] platform profile: Extract the core from ACPI Daniel Lezcano
2026-10-14 13:24 ` Daniel Lezcano [this message]
2026-10-14 13:24 ` [PATCH v1 4/4] platform profile: Document firmware-independent profile selection Daniel Lezcano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261014132500.3817549-4-daniel.lezcano@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=W_Armin@gmx.de \
--cc=corbet@lwn.net \
--cc=daniel.lezcano@kernel.org \
--cc=derekjohn.clark@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jackbb_wu@compal.com \
--cc=jai.luthra@ideasonboard.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=luzmaximilian@gmail.com \
--cc=mpearson-lenovo@squebb.ca \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=skhan@linuxfoundation.org \
--cc=superm1@kernel.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox