Kurt Borja
07f531b395
ACPI: platform_profile: Remove platform_profile_handler from exported symbols
...
In order to protect the platform_profile_handler from API consumers,
allocate it in platform_profile_register() and modify it's signature
accordingly.
Remove the platform_profile_handler from all consumer drivers and
replace them with a pointer to the class device, which is
now returned from platform_profile_register().
Replace *pprof with a pointer to the class device in the rest of
exported symbols.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Kurt Borja <kuurtb@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Link: https://lore.kernel.org/r/20250116002721.75592-16-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2025-01-17 19:15:59 +02:00
Kurt Borja
3e6d0bf3b9
platform/x86: amd: pmf: sps: Use devm_platform_profile_register()
...
Replace platform_profile_register() with it's device managed version.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Kurt Borja <kuurtb@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Link: https://lore.kernel.org/r/20250116002721.75592-9-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2025-01-16 17:26:35 +02:00
Kurt Borja
58d5629dc8
ACPI: platform_profile: Add probe to platform_profile_ops
...
Add a `probe` callback to platform_profile_ops, which lets drivers
initialize the choices member manually. This is a step towards
unexposing the struct platform_profile_handler from the consumer
drivers.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Kurt Borja <kuurtb@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Link: https://lore.kernel.org/r/20250116002721.75592-6-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2025-01-16 17:26:30 +02:00
Kurt Borja
b5ca1a4488
ACPI: platform_profile: Add ops member to handlers
...
Replace *profile_get and *profile_set members with a general *ops
member.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Kurt Borja <kuurtb@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Link: https://lore.kernel.org/r/20250116002721.75592-5-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2025-01-16 17:26:28 +02:00
Kurt Borja
cf3ea098dd
ACPI: platform_profile: Remove platform_profile_handler from callbacks
...
Devices can now set drvdata to the class device, thus passing the
platform_profile_handler to callbacks is unnecessary. Instead pass the
class device.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Kurt Borja <kuurtb@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Link: https://lore.kernel.org/r/20250116002721.75592-4-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2025-01-16 17:26:26 +02:00
Kurt Borja
249c576f0f
ACPI: platform_profile: Let drivers set drvdata to the class device
...
Add *drvdata to platform_profile_register() signature and assign it to
the class device.
While at it, pass specific driver state as drvdata to replace uses of
container_of() with dev_get_drvdata().
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Kurt Borja <kuurtb@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Link: https://lore.kernel.org/r/20250116002721.75592-3-kuurtb@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2025-01-16 17:26:25 +02:00
Mario Limonciello
9b3bb37b44
ACPI: platform_profile: Add platform handler argument to platform_profile_remove()
...
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 >
Link: https://lore.kernel.org/r/20241206031918.1537-5-mario.limonciello@amd.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2024-12-10 19:17:51 +02:00
Mario Limonciello
6f5e63ddc3
ACPI: platform_profile: Add device pointer into platform profile handler
...
In order to let platform profile handlers manage platform profile
for their driver the core code will need a pointer to the device.
Add this to the structure and use it in the trivial driver cases.
Reviewed-by: Armin Wolf <W_Armin@gmx.de >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com >
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca >
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com >
Link: https://lore.kernel.org/r/20241206031918.1537-4-mario.limonciello@amd.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2024-12-10 19:17:49 +02:00
Mario Limonciello
549de562d7
ACPI: platform-profile: Add a name member to handlers
...
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 >
Link: https://lore.kernel.org/r/20241206031918.1537-2-mario.limonciello@amd.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2024-12-10 19:17:45 +02:00
Shyam Sundar S K
8362e862fb
platform/x86/amd/pmf: Update sps power thermals according to the platform-profiles
...
Update power thermals according to the platform-profiles selected by the
user.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20240306114415.3267603-8-Shyam-sundar.S-k@amd.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2024-03-12 12:48:34 +02:00
Shyam Sundar S K
3eecb434d7
platform/x86/amd/pmf: Add support to get sps default APTS index values
...
During the driver probe, the default cache values for the static slider
would be obtained by evaluating the APTS method. Add support to use
these values as the thermal settings to be updated on the system based
on the changing platform-profiles.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20240306114415.3267603-7-Shyam-sundar.S-k@amd.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2024-03-12 12:48:32 +02:00
Shyam Sundar S K
48d38f5692
platform/x86/amd/pmf: Add support to get APTS index numbers for static slider
...
APMF spec has a newer section called the APTS (AMD Performance and
Thermal State) information, where each slider/power mode is associated
with an index number.
Add support to get these indices for the Static Slider.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20240306114415.3267603-6-Shyam-sundar.S-k@amd.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
2024-03-12 12:48:30 +02:00
Shyam Sundar S K
4984dbb607
platform/x86/amd/pmf: Make source_as_str() as non-static
...
Add amd_pmf prefix to source_as_str() function, so that the function name
does not look generic. As this is a helper function make it as non-static
so that it can be reused across multiple PMF features.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20231212014705.2017474-10-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-12-18 12:47:46 +01:00
Yang Li
785c00993d
platform/x86/amd/pmf: Fix unsigned comparison with less than zero
...
The return value from the call to amd_pmf_get_pprof_modes() is int.
However, the return value is being assigned to an unsigned char
variable 'mode', so making 'mode' an int.
silence the warning:
./drivers/platform/x86/amd/pmf/sps.c:183:5-9: WARNING: Unsigned expression compared with zero: mode < 0
Reported-by: Abaci Robot <abaci@linux.alibaba.com >
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5995
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com >
Link: https://lore.kernel.org/r/20230727014315.51375-1-yang.lee@linux.alibaba.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-07-31 16:01:58 +02:00
Shyam Sundar S K
33c9ab5b49
platform/x86/amd/pmf: Notify OS power slider update
...
APMF fn8 can notify EC about the OS slider position change. Add this
capability to the PMF driver so that it can call the APMF fn8 based on
the changes in the Platform profile events.
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com >
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20230714144435.1239776-2-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-07-25 14:31:25 +02:00
Shyam Sundar S K
506ed33d07
platform/x86/amd/pmf: Fix compiler warnings in static slider
...
This patch fixes warnings with -Wmissing-prototypes:
warning: no previous prototype for 'source_as_str' [-Wmissing-prototypes]
warning: no previous prototype for 'slider_as_str' [-Wmissing-prototypes]
Fixes: a82ebb3d80 ("platform/x86/amd/pmf: Add PMF acpi debug support")
Reported-by: kernel test robot <lkp@intel.com >
Closes: https://lore.kernel.org/oe-kbuild-all/202305160220.REQc5T2y-lkp@intel.com/
Suggested-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com >
Link: https://lore.kernel.org/r/20230516074531.2885235-1-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-05-16 10:36:55 +02:00
Shyam Sundar S K
a82ebb3d80
platform/x86/amd/pmf: Add PMF acpi debug support
...
PMF driver maintains an internal config store for each PMF feature
after the feature init happens. Having a debug mechanism to triage
in-field issues w.r.t to mode switch not happening based on the OEM
fed values via the ACPI method to PMF driver is becoming the need of
the hour. Add support to get more ACPI debug spew guarded by a CONFIG.
Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Link: https://lore.kernel.org/r/20230510144751.66601-1-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-05-15 15:17:31 +02:00
Shyam Sundar S K
635f79bc73
platform/x86/amd/pmf: Fix to update SPS default pprof thermals
...
By design PMF static slider will be set to BALANCED during
init, but updating to corresponding thermal values from
the PMF config store was missed, leading to improper settings
getting propagated to PMFW.
Fixes: 4c71ae4144 ("platform/x86/amd/pmf: Add support SPS PMF feature")
Suggested-by: Patil Rajesh Reddy <Patil.Reddy@amd.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Link: https://lore.kernel.org/r/20230125095936.3292883-5-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-01-30 14:30:57 +01:00
Shyam Sundar S K
16909aa8c9
platform/x86/amd/pmf: Add helper routine to check pprof is balanced
...
Add helper routine to check if the current platform profile
is balanced mode and remove duplicate code occurrences.
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Link: https://lore.kernel.org/r/20230125095936.3292883-3-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-01-30 14:30:57 +01:00
Shyam Sundar S K
c5258d39fc
platform/x86/amd/pmf: Add helper routine to update SPS thermals
...
Add helper routine to update the static slider information
and remove the duplicate code occurrences after this change.
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com >
Link: https://lore.kernel.org/r/20230125095936.3292883-2-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2023-01-30 14:30:57 +01:00
Shyam Sundar S K
ea522b8061
platform/x86/amd/pmf: Fix clang unused variable warning
...
variable 'mode' is used uninitialized whenever switch default is taken
in sps.c which leads to the following clang warning.
drivers/platform/x86/amd/pmf/sps.c:96:2: error: variable 'mode' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
default:
^~~~~~~
drivers/platform/x86/amd/pmf/sps.c:101:9: note: uninitialized use occurs here
return mode;
^~~~
drivers/platform/x86/amd/pmf/sps.c:84:9: note: initialize the variable 'mode' to silence this warning
u8 mode;
^
= '\0'
1 error generated.
Fix it by returning -EOPNOTSUPP in default case and also change the return
type of the function amd_pmf_get_pprof_modes() to keep it similar like
other drivers which implement platform_profile.
Fixes: 4c71ae4144 ("platform/x86/amd/pmf: Add support SPS PMF feature")
Reported-by: Nathan Chancellor <nathan@kernel.org >
Reviewed-by: Nathan Chancellor <nathan@kernel.org >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20220822062917.4061503-1-Shyam-sundar.S-k@amd.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2022-08-24 10:35:54 +02:00
Shyam Sundar S K
4c71ae4144
platform/x86/amd/pmf: Add support SPS PMF feature
...
SPS (a.k.a. Static Power Slider) gives a feel of Windows performance
power slider for the Linux users, where the user selects a certain
mode (like "balanced", "low-power" or "performance") and the thermals
associated with each selected mode gets applied from the silicon
side via the mailboxes defined through PMFW.
PMF driver hooks to platform_profile by reading the PMF ACPI fn9 to
see if the support is being advertised by ACPI interface.
If supported, the PMF driver reacts to platform_profile selection choices
made by the user and adjust the system thermal behavior.
Reviewed-by: Hans de Goede <hdegoede@redhat.com >
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com >
Link: https://lore.kernel.org/r/20220802151149.2123699-4-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com >
2022-08-15 13:23:38 +02:00