diff options
author | Shyam Sundar S K <Shyam-sundar.S-k@amd.com> | 2022-08-02 20:41:42 +0530 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2022-08-15 13:23:38 +0200 |
commit | 4dc491c898fb47406423547da4d1e1ef8ff36b3e (patch) | |
tree | c110753538d5b11b06870d94e454493e2350a778 /drivers | |
parent | 4c71ae4144746eb467f6aaab0ff83e306f11d6af (diff) |
platform/x86/amd/pmf: Add debugfs information
Add debugfs support to the PMF driver so that using this interface the
live counters from the PMFW can be queried to see if the power parameters
are getting set properly when a certain power mode change happens.
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-5-Shyam-sundar.S-k@amd.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/amd/pmf/core.c | 36 | ||||
-rw-r--r-- | drivers/platform/x86/amd/pmf/pmf.h | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index a70ab6c9608a..032d9dc5e09f 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -8,6 +8,7 @@ * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> */ +#include <linux/debugfs.h> #include <linux/iopoll.h> #include <linux/module.h> #include <linux/pci.h> @@ -46,6 +47,39 @@ #define DELAY_MIN_US 2000 #define DELAY_MAX_US 3000 +static int current_power_limits_show(struct seq_file *seq, void *unused) +{ + struct amd_pmf_dev *dev = seq->private; + struct amd_pmf_static_slider_granular table; + int mode, src = 0; + + mode = amd_pmf_get_pprof_modes(dev); + src = amd_pmf_get_power_source(); + amd_pmf_update_slider(dev, SLIDER_OP_GET, mode, &table); + seq_printf(seq, "spl:%u fppt:%u sppt:%u sppt_apu_only:%u stt_min:%u stt[APU]:%u stt[HS2]: %u\n", + table.prop[src][mode].spl, + table.prop[src][mode].fppt, + table.prop[src][mode].sppt, + table.prop[src][mode].sppt_apu_only, + table.prop[src][mode].stt_min, + table.prop[src][mode].stt_skin_temp[STT_TEMP_APU], + table.prop[src][mode].stt_skin_temp[STT_TEMP_HS2]); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(current_power_limits); + +static void amd_pmf_dbgfs_unregister(struct amd_pmf_dev *dev) +{ + debugfs_remove_recursive(dev->dbgfs_dir); +} + +static void amd_pmf_dbgfs_register(struct amd_pmf_dev *dev) +{ + dev->dbgfs_dir = debugfs_create_dir("amd_pmf", NULL); + debugfs_create_file("current_power_limits", 0644, dev->dbgfs_dir, dev, + ¤t_power_limits_fops); +} + int amd_pmf_get_power_source(void) { if (power_supply_is_system_supplied() > 0) @@ -231,6 +265,7 @@ static int amd_pmf_probe(struct platform_device *pdev) apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_init_features(dev); + amd_pmf_dbgfs_register(dev); mutex_init(&dev->lock); dev_info(dev->dev, "registered PMF device successfully\n"); @@ -244,6 +279,7 @@ static int amd_pmf_remove(struct platform_device *pdev) mutex_destroy(&dev->lock); amd_pmf_deinit_features(dev); + amd_pmf_dbgfs_unregister(dev); kfree(dev->buf); return 0; } diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index fa3ea103b54a..8b25fd19e473 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -90,6 +90,7 @@ struct amd_pmf_dev { u32 supported_func; enum platform_profile_option current_profile; struct platform_profile_handler pprof; + struct dentry *dbgfs_dir; }; struct apmf_sps_prop_granular { |