summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Limonciello <mario.limonciello@amd.com>2026-07-21 13:17:54 -0500
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2026-07-27 14:42:22 +0300
commit34d145254ca655ead49d00025981f2f5b200a62f (patch)
tree70c8e42106decb5862599bad3c2095bb485a5b4a
parent0225c1d637687b03726f00ac65b6def843d2c464 (diff)
downloadlinux-next-34d145254ca655ead49d00025981f2f5b200a62f.tar.gz
linux-next-34d145254ca655ead49d00025981f2f5b200a62f.zip
platform/x86/amd/pmc: Only expose stb_read after telemetry buffer is mapped
amd_stb_s2d_init() creates the v2 "stb_read" debugfs node before mapping the telemetry buffer into dev->stb_virt_addr, leaving a window during probe where a read faults on a NULL dev->stb_virt_addr in amd_stb_debugfs_open_v2()/amd_stb_handle_efr(). This becomes trivial to hit once a failed STB init no longer aborts probe (next patch), which leaves the node registered with a NULL buffer. Create it only after dev->stb_virt_addr is mapped. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://patch.msgid.link/20260721181756.143084-5-mario.limonciello@amd.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
-rw-r--r--drivers/platform/x86/amd/pmc/mp1_stb.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/platform/x86/amd/pmc/mp1_stb.c b/drivers/platform/x86/amd/pmc/mp1_stb.c
index 1ec0e599df7f..8a33e75b71c3 100644
--- a/drivers/platform/x86/amd/pmc/mp1_stb.c
+++ b/drivers/platform/x86/amd/pmc/mp1_stb.c
@@ -299,10 +299,7 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)
if (!enable_stb)
return 0;
- if (amd_is_stb_supported(dev)) {
- debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
- &amd_stb_debugfs_fops_v2);
- } else {
+ if (!amd_is_stb_supported(dev)) {
debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
&amd_stb_debugfs_fops);
return 0;
@@ -342,8 +339,18 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)
}
dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, dev->dram_size);
- if (!dev->stb_virt_addr)
+ if (!dev->stb_virt_addr) {
ret = -ENOMEM;
+ goto out;
+ }
+
+ /*
+ * Only expose stb_read once the buffer is mapped; otherwise a read
+ * faults on a NULL dev->stb_virt_addr, now that a failed STB init no
+ * longer aborts probe.
+ */
+ debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
+ &amd_stb_debugfs_fops_v2);
out:
/* Restore the default message port for subsequent SMU operations */