FAILED: patch "[PATCH] platform/x86/amd/pmc: Propagate SMU errors and validate S2D" failed to apply to 6.6-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 0225c1d637687b03726f00ac65b6def843d2c464
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090317-retool-chivalry-dde5@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0225c1d637687b03726f00ac65b6def843d2c464 Mon Sep 17 00:00:00 2001
From: Mario Limonciello <[email protected]>
Date: Tue, 21 Jul 2026 13:17:53 -0500
Subject: [PATCH] platform/x86/amd/pmc: Propagate SMU errors and validate S2D
address
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
amd_stb_s2d_init() discards the return value of several S2D SMU commands. When the SMU refuses a command (e.g. "SMU cmd failed. err: 0xff") the failure is only noticed indirectly - if at all - and reported as -EIO, masking the real error.
More seriously, the S2D_PHYS_ADDR_LOW/HIGH return values are ignored, so on failure phys_addr_low/hi are left uninitialised and the assembled address is passed straight to devm_ioremap(). When the SMU leaves them at zero this maps physical address 0 and trips the ioremap-on-RAM warning:
amd_pmc AMDI000B:00: SMU cmd failed. err: 0xff ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
WARNING: CPU: 13 PID: 4592 at arch/x86/mm/ioremap.c:...
Check the return value of each SMU command and propagate it, and reject a zero physical address before calling devm_ioremap().
drivers/platform/x86/amd/pmc/mp1_stb.c +20 -11
@@ -311,30 +311,39 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)/* Spill to DRAM feature uses separate SMU message port */ dev->msg_port =MSG_PORT_S2D ; -amd_pmc_send_cmd (dev,S2D_TELEMETRY_SIZE , &size, dev->stb_arg.s2d_msg_id, true); + ret =amd_pmc_send_cmd (dev,S2D_TELEMETRY_SIZE , &size, dev->stb_arg.s2d_msg_id, true); +if (ret) + goto out;if (size !=S2D_TELEMETRY_BYTES_MAX ) { ret = -EIO ; goto out; } -/* Get DRAM size */ - ret =amd_pmc_send_cmd (dev,S2D_DRAM_SIZE , &dev->dram_size, dev->stb_arg.s2d_msg_id, true); -if (ret || !dev->dram_size) +/* Get DRAM size; fall back to the default if the query fails */ +if (amd_pmc_send_cmd (dev,S2D_DRAM_SIZE , &dev->dram_size, dev->stb_arg.s2d_msg_id, true) || + !dev->dram_size) dev->dram_size =S2D_TELEMETRY_DRAMBYTES_MAX ;/* Get STB DRAM address */ -amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_LOW , &phys_addr_low, dev->stb_arg.s2d_msg_id, true); -amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_HIGH , &phys_addr_hi, dev->stb_arg.s2d_msg_id, true); + ret =amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_LOW , &phys_addr_low, + dev->stb_arg.s2d_msg_id, true); +if (ret) + goto out; + ret =amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_HIGH , &phys_addr_hi, + dev->stb_arg.s2d_msg_id, true); +if (ret) + goto out; stb_phys_addr = ((u64 )phys_addr_hi <<32 | phys_addr_low); - - dev->stb_virt_addr =devm_ioremap (dev->dev, stb_phys_addr, dev->dram_size); -if (!dev->stb_virt_addr) { - ret = -ENOMEM ; +if (!stb_phys_addr) { +dev_err (dev->dev,"S2D phys addr query returned invalid address\n" ); + ret = -ENXIO ; goto out; } - ret =0 ; + dev->stb_virt_addr =devm_ioremap (dev->dev, stb_phys_addr, dev->dram_size); +if (!dev->stb_virt_addr) + ret = -ENOMEM ; out:/* Restore the default message port for subsequent SMU operations */
Sasha Levin
maintainerPATCH 1/2 platform/x86/amd/pmc: Move STB functionality to a new file for better code organization
From: Shyam Sundar S K <[email protected]>
[ Upstream commit 0e914063ddd135407c0550b77a6f5bf779bf8384 ]
As the SoC evolves with each generation, the dynamics between the PMC and STB layers within the PMC driver are becoming increasingly complex, making it challenging to manage both in a single file and maintain code readability.
Additionally, during silicon bringup, the PMC functionality is often enabled first, with STB functionality added later. This can lead to missed updates in the driver, potentially causing issues.
To address these challenges, it's beneficial to move all STB-related changes to a separate file. This approach will better accommodate newer SoCs, provide improved flexibility for desktop variants, and facilitate the collection of additional debug information through STB mechanisms.
Also the additional checks for entering s2d_init have been moved from the PMC probe to amd_pmc_s2d_init(). This adjustment makes more sense following the transfer of code to the separate mp1_stb.c file.
Backport adaptation for Linux 6.6:
Move only the existing S2D initialization routine to mp1_stb.c, renamed to amd_stb_s2d_init. Keep the existing STB debugfs implementation, module parameters, supported CPUs and suspend workarounds in pmc.c. Do not import the newer custom-buffer helper, allocation changes or platform support. No functions are added; the initializer is moved and renamed.
Retain IP-count/message-ID setup in the existing probe path before S2D initialization. Share the S2D command definitions, use the stb_arg.s2d_msg_id layout and named message ports expected by the target, and restore the PMC message port through a common exit path. Only the existing command sender and relocated initializer need cross-file declarations.
As in the upstream dependency, omit the old zero-address check from the relocated initializer. Target 0225c1d637687b03726f00ac65b6def843d2c464 applies unchanged and supplies command-error propagation and zero-address rejection before ioremap. This dependency prepares that target's exact patch context.
Stable-dep-of: 0225c1d63768 ("platform/x86/amd/pmc: Propagate SMU errors and validate S2D address")
--- drivers/platform/x86/amd/pmc/Makefile | 2 +- drivers/platform/x86/amd/pmc/mp1_stb.c | 58 +++++++++++++++++++++ drivers/platform/x86/amd/pmc/pmc.c | 72 ++++---------------------- drivers/platform/x86/amd/pmc/pmc.h | 27 +++++++++- 4 files changed, 93 insertions(+), 66 deletions(-) create mode 100644 drivers/platform/x86/amd/pmc/mp1_stb.c
drivers/platform/x86/amd/pmc/Makefile +1 -1
@@ -4,5 +4,5 @@ # AMD Power Management Controller Driver # -amd-pmc-objs := pmc.o pmc-quirks.o +amd-pmc-objs := pmc.o pmc-quirks.o mp1_stb.o obj-$(CONFIG_AMD_PMC) += amd-pmc.o
drivers/platform/x86/amd/pmc/mp1_stb.c new file +58 -0
58 lines not on this page · raw message
drivers/platform/x86/amd/pmc/pmc.c +9 -63
126 lines not on this page · raw message
drivers/platform/x86/amd/pmc/pmc.h +25 -2
@@ -14,18 +14,38 @@#include <linux/types.h> #include <linux/mutex.h> +/* STB Spill to DRAM Parameters */ +#define S2D_TELEMETRY_BYTES_MAX 0x100000 + +enum s2d_arg { +S2D_TELEMETRY_SIZE =0x01 , +S2D_PHYS_ADDR_LOW , +S2D_PHYS_ADDR_HIGH , +S2D_NUM_SAMPLES , +S2D_DRAM_SIZE , +}; + +enum s2d_msg_port { +MSG_PORT_PMC , +MSG_PORT_S2D , +}; + +struct stb_arg { +u32 s2d_msg_id; +}; +struct amd_pmc_dev {void __iomem *regbase;void __iomem *smu_virt_addr;void __iomem *stb_virt_addr;void __iomem *fch_virt_addr; -bool msg_port; +enum s2d_msg_port msg_port;u32 base_addr;u32 cpu_id;u32 active_ips;u32 dram_size;u32 num_ips; -u32 s2d_msg_id; +struct stb_arg stb_arg;/* SMU version information */ u8 smu_program;u8 major;
@@ -56,4 +76,7 @@ void amd_pmc_quirks_init(struct amd_pmc_dev *dev);#define AMD_CPU_ID_SP 0x14A4#define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507 +int amd_stb_s2d_init (struct amd_pmc_dev *dev); +int amd_pmc_send_cmd (struct amd_pmc_dev *dev,u32 arg,u32 *data,u8 msg,bool ret); +#endif /* PMC_H */
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 platform/x86/amd/pmc: Propagate SMU errors and validate S2D address
From: Mario Limonciello <[email protected]>
[ Upstream commit 0225c1d637687b03726f00ac65b6def843d2c464 ]
amd_stb_s2d_init() discards the return value of several S2D SMU commands. When the SMU refuses a command (e.g. "SMU cmd failed. err: 0xff") the failure is only noticed indirectly - if at all - and reported as -EIO, masking the real error.
More seriously, the S2D_PHYS_ADDR_LOW/HIGH return values are ignored, so on failure phys_addr_low/hi are left uninitialised and the assembled address is passed straight to devm_ioremap(). When the SMU leaves them at zero this maps physical address 0 and trips the ioremap-on-RAM warning:
amd_pmc AMDI000B:00: SMU cmd failed. err: 0xff ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
WARNING: CPU: 13 PID: 4592 at arch/x86/mm/ioremap.c:...
Check the return value of each SMU command and propagate it, and reject a zero physical address before calling devm_ioremap().
--- drivers/platform/x86/amd/pmc/mp1_stb.c | 31 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/platform/x86/amd/pmc/mp1_stb.c +20 -11
@@ -26,30 +26,39 @@ int amd_stb_s2d_init(struct amd_pmc_dev *dev)/* Spill to DRAM feature uses separate SMU message port */ dev->msg_port =MSG_PORT_S2D ; -amd_pmc_send_cmd (dev,S2D_TELEMETRY_SIZE , &size, dev->stb_arg.s2d_msg_id, true); + ret =amd_pmc_send_cmd (dev,S2D_TELEMETRY_SIZE , &size, dev->stb_arg.s2d_msg_id, true); +if (ret) + goto out;if (size !=S2D_TELEMETRY_BYTES_MAX ) { ret = -EIO ; goto out; } -/* Get DRAM size */ - ret =amd_pmc_send_cmd (dev,S2D_DRAM_SIZE , &dev->dram_size, dev->stb_arg.s2d_msg_id, true); -if (ret || !dev->dram_size) +/* Get DRAM size; fall back to the default if the query fails */ +if (amd_pmc_send_cmd (dev,S2D_DRAM_SIZE , &dev->dram_size, dev->stb_arg.s2d_msg_id, true) || + !dev->dram_size) dev->dram_size =S2D_TELEMETRY_DRAMBYTES_MAX ;/* Get STB DRAM address */ -amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_LOW , &phys_addr_low, dev->stb_arg.s2d_msg_id, true); -amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_HIGH , &phys_addr_hi, dev->stb_arg.s2d_msg_id, true); + ret =amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_LOW , &phys_addr_low, + dev->stb_arg.s2d_msg_id, true); +if (ret) + goto out; + ret =amd_pmc_send_cmd (dev,S2D_PHYS_ADDR_HIGH , &phys_addr_hi, + dev->stb_arg.s2d_msg_id, true); +if (ret) + goto out; stb_phys_addr = ((u64 )phys_addr_hi <<32 | phys_addr_low); - - dev->stb_virt_addr =devm_ioremap (dev->dev, stb_phys_addr, dev->dram_size); -if (!dev->stb_virt_addr) { - ret = -ENOMEM ; +if (!stb_phys_addr) { +dev_err (dev->dev,"S2D phys addr query returned invalid address\n" ); + ret = -ENXIO ; goto out; } - ret =0 ; + dev->stb_virt_addr =devm_ioremap (dev->dev, stb_phys_addr, dev->dram_size); +if (!dev->stb_virt_addr) + ret = -ENOMEM ; out:/* Restore the default message port for subsequent SMU operations */
Signature · 1 line
2.53.0