FAILED: patch "[PATCH] platform/x86/amd/pmc: Propagate SMU errors and validate S2D" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-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.1.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-buggy-snowboard-d47e@gregkh' --subject-prefix 'PATCH 6.1.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/3 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 dependency for 0225c1d637687 to Linux 6.1]
Move the existing PMC source into pmc/ and extract only the STB functions already present in this stable tree. Add the composite-module Makefile and a shared header containing the stable device structure and the declarations needed by the split. No functions or new platform support are introduced. Keep enable_stb, CPU gating and debugfs registration in their original PMC paths; omit MP2, enhanced STB dumping and newer firmware/platform helpers.
Prepare the existing S2D initializer for the target's three-way cherry-pick:
provide stb_arg.s2d_msg_id using the existing 0xBE command, query DRAM size with the existing 16 MiB default, and restore the PMC message port through a common exit. Preserve the stable zero-address rejection before mapping. The target then supplies SMU command error propagation without requiring the intervening upstream feature additions or helper functions.
Stable-dep-of: 0225c1d63768 ("platform/x86/amd/pmc: Propagate SMU errors and validate S2D address")
---
drivers/platform/x86/amd/Makefile | 3 +-
drivers/platform/x86/amd/pmc/Makefile | 4 +
drivers/platform/x86/amd/pmc/mp1_stb.c | 201 +++++++++++++++++++++++
drivers/platform/x86/amd/{ => pmc}/pmc.c | 188 +--------------------
drivers/platform/x86/amd/pmc/pmc.h | 48 ++++++
5 files changed, 257 insertions(+), 187 deletions(-)
create mode 100644 drivers/platform/x86/amd/pmc/Makefile
create mode 100644 drivers/platform/x86/amd/pmc/mp1_stb.c
rename drivers/platform/x86/amd/{ => pmc}/pmc.c (82%)
create mode 100644 drivers/platform/x86/amd/pmc/pmc.hdrivers/platform/x86/amd/Makefile +1 -2
@@ -4,8 +4,7 @@ # AMD x86 Platform-Specific Drivers # -amd-pmc-y := pmc.o -obj-$(CONFIG_AMD_PMC) += amd-pmc.o +obj-$(CONFIG_AMD_PMC) += pmc/ amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o obj-$(CONFIG_AMD_PMF) += pmf/
drivers/platform/x86/amd/pmc/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_AMD_PMC) += amd-pmc.o +amd-pmc-y := pmc.o mp1_stb.o
drivers/platform/x86/amd/pmc/mp1_stb.c new file +201 -0
201 lines not on this page · raw message
drivers/platform/x86/amd/pmc/pmc.c renamed from drivers/platform/x86/amd/pmc.c +3 -185
250 lines not on this page · raw message
drivers/platform/x86/amd/pmc/pmc.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 platform/x86/amd/pmc: Isolate STB code changes to a new file
From: Shyam Sundar S K <[email protected]>
[ Upstream commit 3279f7a6b7d42374897d3b818630602f0ff56521 ]
Since S2D (Spill to DRAM) uses different message port offsets compared to PMC message offsets for communication with PMFW, relocate the S2D macros from pmc.c to a new file, mp1_stb.c, for better code organization.
Following this change, it is logical to introduce a new structure, "struct stb_arg," to pass the message, argument, and response offset details to PMFW via the amd_pmc_send_cmd() call. Additionally, move the s2d_msg_id member from amd_pmc_dev into the new structure.
[Backport dependency for 0225c1d637687 to Linux 6.1]
The preceding STB split already provides stb_arg.s2d_msg_id and the S2D initializer context needed by the target. Extend that existing structure with message, argument and response offsets, move the S2D register macros to mp1_stb.c, and use those offsets in the PMC command and register-dump paths.
Initialize the offsets in the existing amd_pmc_s2d_init() before selecting the S2D message port. The upstream amd_is_stb_supported() helper is absent here, so do not introduce it or the unrelated newer platform, MP2 and enhanced STB debugfs code. Preserve the stable CPU gating, command ID, zero-address check and common message-port restoration. No functions are added. The unmodified target applies cleanly through a three-way apply.
Stable-dep-of: 0225c1d63768 ("platform/x86/amd/pmc: Propagate SMU errors and validate S2D address")
--- drivers/platform/x86/amd/pmc/mp1_stb.c | 8 ++++++++ drivers/platform/x86/amd/pmc/pmc.c | 21 ++++++++------------- drivers/platform/x86/amd/pmc/pmc.h | 3 +++ 3 files changed, 19 insertions(+), 13 deletions(-)
drivers/platform/x86/amd/pmc/mp1_stb.c +8 -0
@@ -31,6 +31,11 @@/* STB Spill to DRAM Message Definition */ #define STB_SPILL_TO_DRAM 0xBE +/* STB S2D(Spill to DRAM) has different message port offset */ +#define AMD_S2D_REGISTER_MESSAGE 0xA20 +#define AMD_S2D_REGISTER_RESPONSE 0xA80 +#define AMD_S2D_REGISTER_ARGUMENT 0xA88 +enum s2d_arg {S2D_TELEMETRY_SIZE =0x01 ,S2D_PHYS_ADDR_LOW ,
@@ -159,6 +164,9 @@ int amd_pmc_s2d_init(struct amd_pmc_dev *dev)int ret =0 ; dev->stb_arg.s2d_msg_id =STB_SPILL_TO_DRAM ; + dev->stb_arg.msg =AMD_S2D_REGISTER_MESSAGE ; + dev->stb_arg.arg =AMD_S2D_REGISTER_ARGUMENT ; + dev->stb_arg.resp =AMD_S2D_REGISTER_RESPONSE ;/* Spill to DRAM feature uses separate SMU message port */ dev->msg_port =MSG_PORT_S2D ;
drivers/platform/x86/amd/pmc/pmc.c +8 -13
@@ -44,11 +44,6 @@#define AMD_PMC_STB_S2IDLE_RESTORE 0xC6000002#define AMD_PMC_STB_S2IDLE_CHECK 0xC6000003 -/* STB S2D(Spill to DRAM) has different message port offset */ -#define AMD_S2D_REGISTER_MESSAGE 0xA20 -#define AMD_S2D_REGISTER_RESPONSE 0xA80 -#define AMD_S2D_REGISTER_ARGUMENT 0xA88 -/* Base address of SMU for mapping physical address to virtual address */ #define AMD_PMC_MAPPING_SIZE 0x01000#define AMD_PMC_BASE_ADDR_OFFSET 0x10000
@@ -438,10 +433,10 @@ static void amd_pmc_dump_registers(struct amd_pmc_dev *dev) {u32 value, message, argument, response; -if (dev->msg_port) { - message =AMD_S2D_REGISTER_MESSAGE ; - argument =AMD_S2D_REGISTER_ARGUMENT ; - response =AMD_S2D_REGISTER_RESPONSE ; +if (dev->msg_port ==MSG_PORT_S2D ) { + message = dev->stb_arg.msg; + argument = dev->stb_arg.arg; + response = dev->stb_arg.resp; }else { message =AMD_PMC_REGISTER_MESSAGE ; argument =AMD_PMC_REGISTER_ARGUMENT ;
@@ -465,10 +460,10 @@ int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool rmutex_lock (&dev->lock); -if (dev->msg_port) { - message =AMD_S2D_REGISTER_MESSAGE ; - argument =AMD_S2D_REGISTER_ARGUMENT ; - response =AMD_S2D_REGISTER_RESPONSE ; +if (dev->msg_port ==MSG_PORT_S2D ) { + message = dev->stb_arg.msg; + argument = dev->stb_arg.arg; + response = dev->stb_arg.resp; }else { message =AMD_PMC_REGISTER_MESSAGE ; argument =AMD_PMC_REGISTER_ARGUMENT ;
drivers/platform/x86/amd/pmc/pmc.h +3 -0
@@ -12,6 +12,9 @@ enum s2d_msg_port {struct stb_arg {u32 s2d_msg_id; +u32 msg; +u32 arg; +u32 resp; };struct amd_pmc_dev {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 platform/x86/amd/pmc: Propagate SMU errors and validate S2D address
In reply to Sasha LevinFrom: 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
@@ -171,20 +171,28 @@ int amd_pmc_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;if (!phys_addr_hi && !phys_addr_low) {dev_err (dev->dev,"STB is not enabled on the system; disable enable_stb or contact system vendor\n" );
@@ -193,14 +201,15 @@ int amd_pmc_s2d_init(struct amd_pmc_dev *dev) } 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