Skip to content

Commit 6888347

Browse files
superm1ij-intel
authored andcommitted
ACPI: platform_profile: Allow multiple handlers
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 <[email protected]> Tested-by: Matthew Schwartz <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Reviewed-by: Armin Wolf <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 37a6853 commit 6888347

File tree

1 file changed

+0
-11
lines changed

1 file changed

+0
-11
lines changed

drivers/acpi/platform_profile.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/platform_profile.h>
1111
#include <linux/sysfs.h>
1212

13-
static struct platform_profile_handler *cur_profile;
1413
static DEFINE_MUTEX(profile_lock);
1514

1615
static const char * const profile_names[] = {
@@ -410,8 +409,6 @@ static const struct attribute_group platform_profile_group = {
410409

411410
void platform_profile_notify(struct platform_profile_handler *pprof)
412411
{
413-
if (!cur_profile)
414-
return;
415412
scoped_cond_guard(mutex_intr, return, &profile_lock) {
416413
_notify_class_profile(pprof->class_dev, NULL);
417414
}
@@ -474,9 +471,6 @@ int platform_profile_register(struct platform_profile_handler *pprof)
474471
}
475472

476473
guard(mutex)(&profile_lock);
477-
/* We can only have one active profile */
478-
if (cur_profile)
479-
return -EEXIST;
480474

481475
/* create class interface for individual handler */
482476
pprof->minor = ida_alloc(&platform_profile_ida, GFP_KERNEL);
@@ -492,16 +486,13 @@ int platform_profile_register(struct platform_profile_handler *pprof)
492486

493487
sysfs_notify(acpi_kobj, NULL, "platform_profile");
494488

495-
cur_profile = pprof;
496-
497489
err = sysfs_update_group(acpi_kobj, &platform_profile_group);
498490
if (err)
499491
goto cleanup_cur;
500492

501493
return 0;
502494

503495
cleanup_cur:
504-
cur_profile = NULL;
505496
device_unregister(pprof->class_dev);
506497

507498
cleanup_ida:
@@ -516,8 +507,6 @@ int platform_profile_remove(struct platform_profile_handler *pprof)
516507
int id;
517508
guard(mutex)(&profile_lock);
518509

519-
cur_profile = NULL;
520-
521510
id = pprof->minor;
522511
device_unregister(pprof->class_dev);
523512
ida_free(&platform_profile_ida, id);

0 commit comments

Comments
 (0)