Skip to content

Commit b54147f

Browse files
superm1jwrdegoede
authored andcommitted
platform/x86/amd/pmf: Fix CnQF and auto-mode after resume
After suspend/resume cycle there is an error message and auto-mode or CnQF stops working. [ 5741.447511] amd-pmf AMDI0100:00: SMU cmd failed. err: 0xff [ 5741.447523] amd-pmf AMDI0100:00: AMD_PMF_REGISTER_RESPONSE:ff [ 5741.447527] amd-pmf AMDI0100:00: AMD_PMF_REGISTER_ARGUMENT:7 [ 5741.447531] amd-pmf AMDI0100:00: AMD_PMF_REGISTER_MESSAGE:16 [ 5741.447540] amd-pmf AMDI0100:00: [AUTO_MODE] avg power: 0 mW mode: QUIET This is because the DRAM address used for accessing metrics table needs to be refreshed after a suspend resume cycle. Add a resume callback to reset this again. Fixes: 1a409b3 ("platform/x86/amd/pmf: Get performance metrics from PMFW") Signed-off-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 362c1f2 commit b54147f

File tree

1 file changed

+25
-7
lines changed
  • drivers/platform/x86/amd/pmf

1 file changed

+25
-7
lines changed

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,29 @@ static const struct pci_device_id pmf_pci_ids[] = {
245245
{ }
246246
};
247247

248-
int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev)
248+
static void amd_pmf_set_dram_addr(struct amd_pmf_dev *dev)
249249
{
250250
u64 phys_addr;
251251
u32 hi, low;
252252

253-
INIT_DELAYED_WORK(&dev->work_buffer, amd_pmf_get_metrics);
253+
phys_addr = virt_to_phys(dev->buf);
254+
hi = phys_addr >> 32;
255+
low = phys_addr & GENMASK(31, 0);
256+
257+
amd_pmf_send_cmd(dev, SET_DRAM_ADDR_HIGH, 0, hi, NULL);
258+
amd_pmf_send_cmd(dev, SET_DRAM_ADDR_LOW, 0, low, NULL);
259+
}
254260

261+
int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev)
262+
{
255263
/* Get Metrics Table Address */
256264
dev->buf = kzalloc(sizeof(dev->m_table), GFP_KERNEL);
257265
if (!dev->buf)
258266
return -ENOMEM;
259267

260-
phys_addr = virt_to_phys(dev->buf);
261-
hi = phys_addr >> 32;
262-
low = phys_addr & GENMASK(31, 0);
268+
INIT_DELAYED_WORK(&dev->work_buffer, amd_pmf_get_metrics);
263269

264-
amd_pmf_send_cmd(dev, SET_DRAM_ADDR_HIGH, 0, hi, NULL);
265-
amd_pmf_send_cmd(dev, SET_DRAM_ADDR_LOW, 0, low, NULL);
270+
amd_pmf_set_dram_addr(dev);
266271

267272
/*
268273
* Start collecting the metrics data after a small delay
@@ -273,6 +278,18 @@ int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev)
273278
return 0;
274279
}
275280

281+
static int amd_pmf_resume_handler(struct device *dev)
282+
{
283+
struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
284+
285+
if (pdev->buf)
286+
amd_pmf_set_dram_addr(pdev);
287+
288+
return 0;
289+
}
290+
291+
static DEFINE_SIMPLE_DEV_PM_OPS(amd_pmf_pm, NULL, amd_pmf_resume_handler);
292+
276293
static void amd_pmf_init_features(struct amd_pmf_dev *dev)
277294
{
278295
int ret;
@@ -413,6 +430,7 @@ static struct platform_driver amd_pmf_driver = {
413430
.name = "amd-pmf",
414431
.acpi_match_table = amd_pmf_acpi_ids,
415432
.dev_groups = amd_pmf_driver_groups,
433+
.pm = pm_sleep_ptr(&amd_pmf_pm),
416434
},
417435
.probe = amd_pmf_probe,
418436
.remove_new = amd_pmf_remove,

0 commit comments

Comments
 (0)