Skip to content

Commit f21bf62

Browse files
Shyam Sundar S Kjwrdegoede
authored andcommitted
platform/x86/amd/pmf: Fix to update SPS thermals when power supply change
Every power mode of static power slider has its own AC and DC power settings. When the power source changes from AC to DC, corresponding DC thermals were not updated from PMF config store and this leads the system to always run on AC power settings. Fix it by registering with power_supply notifier and apply DC settings upon getting notified by the power_supply handler. Fixes: da5ce22 ("platform/x86/amd/pmf: Add support for PMF core layer") Suggested-by: Patil Rajesh Reddy <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 635f79b commit f21bf62

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

drivers/platform/x86/amd/pmf/core.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ static bool force_load;
5858
module_param(force_load, bool, 0444);
5959
MODULE_PARM_DESC(force_load, "Force load this driver on supported older platforms (experimental)");
6060

61+
static int amd_pmf_pwr_src_notify_call(struct notifier_block *nb, unsigned long event, void *data)
62+
{
63+
struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);
64+
65+
if (event != PSY_EVENT_PROP_CHANGED)
66+
return NOTIFY_OK;
67+
68+
if (is_apmf_func_supported(pmf, APMF_FUNC_AUTO_MODE) ||
69+
is_apmf_func_supported(pmf, APMF_FUNC_DYN_SLIDER_DC) ||
70+
is_apmf_func_supported(pmf, APMF_FUNC_DYN_SLIDER_AC)) {
71+
if ((pmf->amt_enabled || pmf->cnqf_enabled) && is_pprof_balanced(pmf))
72+
return NOTIFY_DONE;
73+
}
74+
75+
amd_pmf_set_sps_power_limits(pmf);
76+
77+
return NOTIFY_OK;
78+
}
79+
6180
static int current_power_limits_show(struct seq_file *seq, void *unused)
6281
{
6382
struct amd_pmf_dev *dev = seq->private;
@@ -372,6 +391,9 @@ static int amd_pmf_probe(struct platform_device *pdev)
372391
apmf_install_handler(dev);
373392
amd_pmf_dbgfs_register(dev);
374393

394+
dev->pwr_src_notifier.notifier_call = amd_pmf_pwr_src_notify_call;
395+
power_supply_reg_notifier(&dev->pwr_src_notifier);
396+
375397
mutex_init(&dev->lock);
376398
mutex_init(&dev->update_mutex);
377399
dev_info(dev->dev, "registered PMF device successfully\n");
@@ -383,6 +405,7 @@ static int amd_pmf_remove(struct platform_device *pdev)
383405
{
384406
struct amd_pmf_dev *dev = platform_get_drvdata(pdev);
385407

408+
power_supply_unreg_notifier(&dev->pwr_src_notifier);
386409
mutex_destroy(&dev->lock);
387410
mutex_destroy(&dev->update_mutex);
388411
amd_pmf_deinit_features(dev);

drivers/platform/x86/amd/pmf/pmf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ struct amd_pmf_dev {
169169
struct mutex update_mutex; /* protects race between ACPI handler and metrics thread */
170170
bool cnqf_enabled;
171171
bool cnqf_supported;
172+
struct notifier_block pwr_src_notifier;
172173
};
173174

174175
struct apmf_sps_prop_granular {

0 commit comments

Comments
 (0)