Skip to content

Commit b6ffe4d

Browse files
Perry Yuanbp3tk0v
authored andcommitted
platform/x86: hfi: Init per-cpu scores for each class
Initialize per CPU score `amd_hfi_ipcc_scores` which store energy score and performance score data for each class. Classic and dense cores are ranked according to those values as energy efficiency capability or performance capability. OS scheduler will pick cores from the ranking list on each class ID for the thread which provide the class id got from hardware feedback interface. Signed-off-by: Perry Yuan <[email protected]> Co-developed-by: Mario Limonciello <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Acked-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/[email protected]
1 parent d4e95ea commit b6ffe4d

File tree

1 file changed

+29
-0
lines changed
  • drivers/platform/x86/amd/hfi

1 file changed

+29
-0
lines changed

drivers/platform/x86/amd/hfi/hfi.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,31 @@ static int amd_hfi_alloc_class_data(struct platform_device *pdev)
228228
return 0;
229229
}
230230

231+
static int amd_set_hfi_ipcc_score(struct amd_hfi_cpuinfo *hfi_cpuinfo, int cpu)
232+
{
233+
for (int i = 0; i < hfi_cpuinfo->nr_class; i++)
234+
WRITE_ONCE(hfi_cpuinfo->ipcc_scores[i],
235+
hfi_cpuinfo->amd_hfi_classes[i].perf);
236+
237+
return 0;
238+
}
239+
240+
static int update_hfi_ipcc_scores(void)
241+
{
242+
int cpu;
243+
int ret;
244+
245+
for_each_possible_cpu(cpu) {
246+
struct amd_hfi_cpuinfo *hfi_cpuinfo = per_cpu_ptr(&amd_hfi_cpuinfo, cpu);
247+
248+
ret = amd_set_hfi_ipcc_score(hfi_cpuinfo, cpu);
249+
if (ret)
250+
return ret;
251+
}
252+
253+
return 0;
254+
}
255+
231256
static int amd_hfi_metadata_parser(struct platform_device *pdev,
232257
struct amd_hfi_data *amd_hfi_data)
233258
{
@@ -310,6 +335,10 @@ static int amd_hfi_probe(struct platform_device *pdev)
310335
if (ret)
311336
return ret;
312337

338+
ret = update_hfi_ipcc_scores();
339+
if (ret)
340+
return ret;
341+
313342
return 0;
314343
}
315344

0 commit comments

Comments
 (0)