Skip to content

Commit 9217bd1

Browse files
superm1jwrdegoede
authored andcommitted
platform/x86/amd: pmc: Move idlemask check into amd_pmc_idlemask_read
The version check requirement for idle mask support actually only applies to RN/CZN/BRC platforms. So far no issues have happened because the PMFW version string is bigger on other supported systems. This can be reset for any new platform so move the check to only RN/CZN/BRC case. Fixes: f6045de ("platform/x86: amd-pmc: Export Idlemask values based on the APU") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://lore.kernel.org/r/20230409185348.556161-5-Shyam-sundar.S-k@amd.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 7abc361 commit 9217bd1

1 file changed

Lines changed: 33 additions & 41 deletions

File tree

  • drivers/platform/x86/amd

drivers/platform/x86/amd/pmc.c

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -342,33 +342,6 @@ static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
342342
return 0;
343343
}
344344

345-
static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
346-
struct seq_file *s)
347-
{
348-
u32 val;
349-
350-
switch (pdev->cpu_id) {
351-
case AMD_CPU_ID_CZN:
352-
val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_CZN);
353-
break;
354-
case AMD_CPU_ID_YC:
355-
case AMD_CPU_ID_CB:
356-
case AMD_CPU_ID_PS:
357-
val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_YC);
358-
break;
359-
default:
360-
return -EINVAL;
361-
}
362-
363-
if (dev)
364-
dev_dbg(pdev->dev, "SMU idlemask s0i3: 0x%x\n", val);
365-
366-
if (s)
367-
seq_printf(s, "SMU idlemask : 0x%x\n", val);
368-
369-
return 0;
370-
}
371-
372345
static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)
373346
{
374347
if (!pdev->smu_virt_addr) {
@@ -543,28 +516,47 @@ static int s0ix_stats_show(struct seq_file *s, void *unused)
543516
}
544517
DEFINE_SHOW_ATTRIBUTE(s0ix_stats);
545518

546-
static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
519+
static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
520+
struct seq_file *s)
547521
{
548-
struct amd_pmc_dev *dev = s->private;
522+
u32 val;
549523
int rc;
550524

551-
/* we haven't yet read SMU version */
552-
if (!dev->major) {
553-
rc = amd_pmc_get_smu_version(dev);
554-
if (rc)
555-
return rc;
525+
switch (pdev->cpu_id) {
526+
case AMD_CPU_ID_CZN:
527+
/* we haven't yet read SMU version */
528+
if (!pdev->major) {
529+
rc = amd_pmc_get_smu_version(pdev);
530+
if (rc)
531+
return rc;
532+
}
533+
if (pdev->major > 56 || (pdev->major >= 55 && pdev->minor >= 37))
534+
val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_CZN);
535+
else
536+
return -EINVAL;
537+
break;
538+
case AMD_CPU_ID_YC:
539+
case AMD_CPU_ID_CB:
540+
case AMD_CPU_ID_PS:
541+
val = amd_pmc_reg_read(pdev, AMD_PMC_SCRATCH_REG_YC);
542+
break;
543+
default:
544+
return -EINVAL;
556545
}
557546

558-
if (dev->major > 56 || (dev->major >= 55 && dev->minor >= 37)) {
559-
rc = amd_pmc_idlemask_read(dev, NULL, s);
560-
if (rc)
561-
return rc;
562-
} else {
563-
seq_puts(s, "Unsupported SMU version for Idlemask\n");
564-
}
547+
if (dev)
548+
dev_dbg(pdev->dev, "SMU idlemask s0i3: 0x%x\n", val);
549+
550+
if (s)
551+
seq_printf(s, "SMU idlemask : 0x%x\n", val);
565552

566553
return 0;
567554
}
555+
556+
static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
557+
{
558+
return amd_pmc_idlemask_read(s->private, NULL, s);
559+
}
568560
DEFINE_SHOW_ATTRIBUTE(amd_pmc_idlemask);
569561

570562
static void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)

0 commit comments

Comments
 (0)