Skip to content

Commit 69e76c5

Browse files
Shyam Sundar S Kjwrdegoede
authored andcommitted
platform/x86/amd/pmf: Add facility to dump TA inputs
PMF driver sends constant inputs to TA which its gets via the other subsystems in the kernel. To debug certain TA issues knowing what inputs being sent to TA becomes critical. Add debug facility to the driver which can isolate Smart PC and TA related issues. Also, make source_as_str() as non-static function as this helper is required outside of sps.c file. Reviewed-by: Mario Limonciello <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Shyam Sundar S K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Hans de Goede <[email protected]>
1 parent 4984dbb commit 69e76c5

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ bool is_pprof_balanced(struct amd_pmf_dev *pmf);
602602
int amd_pmf_power_slider_update_event(struct amd_pmf_dev *dev);
603603
const char *amd_pmf_source_as_str(unsigned int state);
604604

605+
const char *amd_pmf_source_as_str(unsigned int state);
605606

606607
int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
607608
int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf);
@@ -632,4 +633,6 @@ int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev);
632633

633634
/* Smart PC - TA interfaces */
634635
void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
636+
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
637+
635638
#endif /* PMF_H */

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,42 @@
1414
#include <linux/units.h>
1515
#include "pmf.h"
1616

17+
#ifdef CONFIG_AMD_PMF_DEBUG
18+
static const char *ta_slider_as_str(unsigned int state)
19+
{
20+
switch (state) {
21+
case TA_BEST_PERFORMANCE:
22+
return "PERFORMANCE";
23+
case TA_BETTER_PERFORMANCE:
24+
return "BALANCED";
25+
case TA_BEST_BATTERY:
26+
return "POWER_SAVER";
27+
default:
28+
return "Unknown TA Slider State";
29+
}
30+
}
31+
32+
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
33+
{
34+
dev_dbg(dev->dev, "==== TA inputs START ====\n");
35+
dev_dbg(dev->dev, "Slider State: %s\n", ta_slider_as_str(in->ev_info.power_slider));
36+
dev_dbg(dev->dev, "Power Source: %s\n", amd_pmf_source_as_str(in->ev_info.power_source));
37+
dev_dbg(dev->dev, "Battery Percentage: %u\n", in->ev_info.bat_percentage);
38+
dev_dbg(dev->dev, "Designed Battery Capacity: %u\n", in->ev_info.bat_design);
39+
dev_dbg(dev->dev, "Fully Charged Capacity: %u\n", in->ev_info.full_charge_capacity);
40+
dev_dbg(dev->dev, "Drain Rate: %d\n", in->ev_info.drain_rate);
41+
dev_dbg(dev->dev, "Socket Power: %u\n", in->ev_info.socket_power);
42+
dev_dbg(dev->dev, "Skin Temperature: %u\n", in->ev_info.skin_temperature);
43+
dev_dbg(dev->dev, "Avg C0 Residency: %u\n", in->ev_info.avg_c0residency);
44+
dev_dbg(dev->dev, "Max C0 Residency: %u\n", in->ev_info.max_c0residency);
45+
dev_dbg(dev->dev, "GFX Busy: %u\n", in->ev_info.gfx_busy);
46+
dev_dbg(dev->dev, "LID State: %s\n", in->ev_info.lid_state ? "close" : "open");
47+
dev_dbg(dev->dev, "==== TA inputs END ====\n");
48+
}
49+
#else
50+
void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in) {}
51+
#endif
52+
1753
static void amd_pmf_get_smu_info(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
1854
{
1955
u16 max, avg = 0;

drivers/platform/x86/amd/pmf/tee-if.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ static int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
182182
}
183183

184184
if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) {
185+
amd_pmf_dump_ta_inputs(dev, in);
185186
dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count,
186187
ta_sm->pmf_result);
187188
amd_pmf_apply_policies(dev, out);

0 commit comments

Comments
 (0)