History log of /linux-master/drivers/acpi/platform_profile.c
Revision Date Author Comments
# b25d5a1c 16-Aug-2021 Hans de Goede <hdegoede@redhat.com>

ACPI: platform-profile: call sysfs_notify() from platform_profile_store()

Drivers like thinkpad_acpi and ideapad_laptop call the
platform_profile_notify() helper when the profile is changed by hardware
(the embedded-controller/EC) in response to an EC handled hotkey.

This allows userspace to monitor for such changes by polling for POLLPRI
on the platform_profile sysfs file. But the profile can also be changed
underneath a userspace program monitoring it by anonther userspace program
storing a new value.

Add a sysfs_notify() call to platform_profile_store(), so that userspace
programs monitoring for changes also get notified in this case.

Also update the documentation to document that POLLPRI polling can be
used to watch for changes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 6c0b5e3f 11-Feb-2021 Maximilian Luz <luzmaximilian@gmail.com>

ACPI: platform: Add balanced-performance platform profile

Some devices, including most Microsoft Surface devices, have a platform
profile somewhere inbetween balanced and performance. More specifically,
adding this profile allows the following mapping on Surface devices:

Vendor Name Platform Profile
------------------------------------------
Battery Saver low-power
Recommended balanced
Better Performance balanced-performance
Best Performance performance

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 041142d7 25-Jan-2021 Hans de Goede <hdegoede@redhat.com>

ACPI: platform-profile: Fix possible deadlock in platform_profile_remove()

After a rmmod thinkpad_acpi, lockdep pointed out this possible deadlock:

Our _show and _store sysfs attr functions get called with the kn->active
lock held for the sysfs attr and then take the profile_lock.
sysfs_remove_group() also takes the kn->active lock for the sysfs attr,
so if we call it with the profile_lock held, then we get an ABBA deadlock.

platform_profile_remove() must only be called by drivers which have
first *successfully* called platform_profile_register(). Anything else
is a driver bug. So the check for cur_profile being set before calling
sysfs_remove_group() is not necessary and it can be dropped.

It is safe to call sysfs_remove_group() without holding the profile_lock
since the attr-group group cannot be re-added until after we clear
cur_profile.

Change platform_profile_remove() to only hold the profile_lock while
clearing the cur_profile, fixing the deadlock.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 84f9017c 24-Jan-2021 Jiaxun Yang <jiaxun.yang@flygoat.com>

ACPI: platform-profile: Introduce object pointers to callbacks

Add an object pointer to handler callbacks to avoid the need for
drivers to have a global variable to get to their driver-data
struct.

Link: https://lore.kernel.org/linux-acpi/6a29f338-d9e4-150c-81dd-2ffb54f5bc35@redhat.com/
Link: https://lore.kernel.org/r/20210114073429.176462-3-jiaxun.yang@flygoat.com
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# 9d56653d 24-Jan-2021 Jiaxun Yang <jiaxun.yang@flygoat.com>

ACPI: platform-profile: Drop const qualifier for cur_profile

Drop the const qualifier from the static global cur_profile
pointer declaration.

This is a preparation patch for passing the cur_profile pointer as
parameter to the profile_get() and profile_set() callbacks so that
drivers dynamically allocating their driver-data struct, with their
platform_profile_handler struct embedded, can use this pointer to
get to their driver-data.

Note this also requires dropping the const from the pprof
platform_profile_register() function argument. Dropping this
const is not a problem, non of the queued up consumers of
platform_profile_register() actually pass in a const pointer.

Link: https://lore.kernel.org/linux-acpi/5e7a4d87-52ef-e487-9cc2-8e7094beaa08@redhat.com/
Link: https://lore.kernel.org/r/20210114073429.176462-2-jiaxun.yang@flygoat.com
Suggested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
[ hdegoede@redhat.com: Also remove const from platform_profile_register() ]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>


# a2ff95e0 29-Dec-2020 Mark Pearson <markpearson@lenovo.com>

ACPI: platform: Add platform profile support

This is the initial implementation of the platform-profile feature.
It provides the details discussed and outlined in the
sysfs-platform_profile document.

Many modern systems have the ability to modify the operating profile to
control aspects like fan speed, temperature and power levels. This
module provides a common sysfs interface that platform modules can register
against to control their individual profile options.

Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
[ rjw: Use full words in enum values names ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>