mirror of
https://github.com/torvalds/linux.git
synced 2026-09-27 19:42:03 +02:00
platform/x86/amd/pmc: Fix msg_port restoration in amd_stb_debugfs_open_v2()
amd_stb_debugfs_open_v2() switches dev->msg_port to MSG_PORT_S2D to query
S2D telemetry but only restores it to MSG_PORT_PMC on one path. The early
return on the dump_custom_stb path (and the error/allocation returns) leave
the port stuck on MSG_PORT_S2D, so subsequent SMU communication - including
the s2idle prepare/restore handlers - is directed at the wrong mailbox.
Consolidate the exit path through a single label so the message port is
always restored, mirroring the fix in amd_stb_s2d_init().
Reported-by: sashiko.dev
Link: https://sashiko.dev/#/patchset/20260717162023.956346-1-mario.limonciello%40amd.com
Fixes: 2851f4f8ed ("platform/x86/amd/pmc: Define enum for S2D/PMC msg_port and add helper function")
Cc: stable@vger.kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patch.msgid.link/20260721181756.143084-3-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>
This commit is contained in:
parent
9cef693bce
commit
cbb32ff92f
|
|
@ -157,7 +157,7 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
|
|||
struct amd_pmc_dev *dev = filp->f_inode->i_private;
|
||||
u32 fsize, num_samples, val, stb_rdptr_offset = 0;
|
||||
struct amd_stb_v2_data *stb_data_arr;
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
/* Write dummy postcode while reading the STB buffer */
|
||||
ret = amd_stb_write(dev, AMD_PMC_STB_DUMMY_PC);
|
||||
|
|
@ -176,22 +176,24 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
|
|||
* the enhanced dram size. Note that we land here only for the
|
||||
* platforms that support enhanced dram size reporting.
|
||||
*/
|
||||
if (dump_custom_stb)
|
||||
return amd_stb_handle_efr(filp);
|
||||
if (dump_custom_stb) {
|
||||
ret = amd_stb_handle_efr(filp);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Get the num_samples to calculate the last push location */
|
||||
ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, dev->stb_arg.s2d_msg_id, true);
|
||||
/* Clear msg_port for other SMU operation */
|
||||
dev->msg_port = MSG_PORT_PMC;
|
||||
if (ret) {
|
||||
dev_err(dev->dev, "error: S2D_NUM_SAMPLES not supported : %d\n", ret);
|
||||
return ret;
|
||||
goto out;
|
||||
}
|
||||
|
||||
fsize = min(num_samples, S2D_TELEMETRY_BYTES_MAX);
|
||||
stb_data_arr = kmalloc_flex(*stb_data_arr, data, fsize);
|
||||
if (!stb_data_arr)
|
||||
return -ENOMEM;
|
||||
if (!stb_data_arr) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
stb_data_arr->size = fsize;
|
||||
|
||||
|
|
@ -214,7 +216,10 @@ static int amd_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
|
|||
|
||||
filp->private_data = stb_data_arr;
|
||||
|
||||
return 0;
|
||||
out:
|
||||
/* Restore the default message port for subsequent SMU operations */
|
||||
dev->msg_port = MSG_PORT_PMC;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t amd_stb_debugfs_read_v2(struct file *filp, char __user *buf, size_t size,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user