Skip to contentSkip to conversation

platform/x86/amd/pmc: Detect when STB is not available

PATCH Superseded Corey Hickey 4 participants 9 messages Oct 25, 2024 – Nov 4, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86/amd/pmc: Detect when STB is not available

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340

Additional debug shows that this happens when the calls to obtain S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return 0.

Per discussion on [email protected], this condition indicates that the STB is not available.

In order to avoid the ioremap warning, and to help the user understand the situation, catch the invalid address and print an error.

---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +5 -0
index bbb8edb62e00..72b1dfc64bf1 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	if (!phys_addr_hi && !phys_addr_low) {
+		dev_err(dev->dev, "amd_pmc: STB is not enabled on the system; disable enable_stb or contact system vendor\n");
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */
Signature · 1 line
2.45.2
maintainer
#1 lore raw
Quoted 12 lines · Corey Hickey

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340
Quoted 5 lines

Additional debug shows that this happens when the calls to obtain S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return 0.

Per discussion on [email protected], this condition indicates that the STB is not available.

If you want to refer to discussion, add it into a Link: tag. Only write the conclusion into the commit message (the part you have there after comma).

Quoted 4 lines

In order to avoid the ioremap warning, and to help the user understand the situation, catch the invalid address and print an error.

Isn't Fixes tag appropriate for this change?

Quoted 9 lines
---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +0 -0
index bbb8edb62e00..72b1dfc64bf1 100644

drivers/platform/x86/amd/pmc/pmc.c static int amd_pmc_s2d_init(struct amd_pmc_dev *dev) · line 1002

Quoted 5 lines
drivers/platform/x86/amd/pmc/pmc.c +2 -0
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	if (!phys_addr_hi && !phys_addr_low) {
+		dev_err(dev->dev, "amd_pmc: STB is not enabled on the system; disable enable_stb or contact system vendor\n");

Won't that end up duplicating the prefix if you put one into the string? The prefix is handled for you by pr_fmt() which is already provided in this file.

Signature · 1 line
 i.
Quoted 7 lines
drivers/platform/x86/amd/pmc/pmc.c +3 -0
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */
#2 lore raw
Quoted 6 lines · Ilpo Järvinen
Quoted 2 lines

Per discussion on [email protected], this condition indicates that the STB is not available.

If you want to refer to discussion, add it into a Link: tag. Only write the conclusion into the commit message (the part you have there after comma).

Thank you, I have added a Link tag to the mailing list archives.

I wanted to avoid taking credit for the claim, though--I don't have the background to claim that on my own. I have changed the wording to refer to Shyam Sundar S K, hoping that's an ok thing to do.

Quoted 6 lines
Quoted 4 lines

In order to avoid the ioremap warning, and to help the user understand the situation, catch the invalid address and print an error.

Isn't Fixes tag appropriate for this change?

Hmm... I didn't think so at first, but I guess so? I didn't do a git bisect, but I can identify that the code in question was added by 3d7d407dfb05, so I added that as a Fixes tag.

Quoted 12 lines
Quoted 12 lines
---
  drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +0 -0
index bbb8edb62e00..72b1dfc64bf1 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
  	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
  	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
Quoted 6 lines

drivers/platform/x86/amd/pmc/pmc.c static int amd_pmc_s2d_init(struct amd_pmc_dev *dev) · line 1002

Quoted 2 lines
drivers/platform/x86/amd/pmc/pmc.c +2 -0
+	if (!phys_addr_hi && !phys_addr_low) {
+		dev_err(dev->dev, "amd_pmc: STB is not enabled on the system; disable enable_stb or contact system vendor\n");

Won't that end up duplicating the prefix if you put one into the string? The prefix is handled for you by pr_fmt() which is already provided in this file.

Ah, yes, I missed that.

Thank you for your review. I will submit a patch v2 momentarily.

-Corey

#3 lore raw

PATCH v2 1/1 platform/x86/amd/pmc: Detect when STB is not available

In reply to Corey Hickey

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340

Additional debug shows that this happens when the calls to obtain S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return 0.

According to Shyam Sundar S K <[email protected]>, this condition indicates that the STB is not available.

In order to avoid the ioremap warning, and to help the user understand the situation, catch the invalid address and print an error.

Fixes 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")
---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +5 -0
index bbb8edb62e00..5669f94c3d06 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	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");
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */
Signature · 1 line
2.45.2
maintainer Acked-by on v2 1/1
#4 lore raw
Quoted 12 lines · Corey Hickey

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340
Quoted 5 lines

Additional debug shows that this happens when the calls to obtain S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return 0.

According to Shyam Sundar S K <[email protected]>, this condition indicates that the STB is not available.

No need to put my name in the commit message.

You may simply the commit message to something like this:

Further debugging reveals that this occurs when the requests for S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return a value of 0, indicating that the STB is inaccessible. To prevent the ioremap warning and provide clarity to the user, handle the invalid address and display an error message.

With this addressed

Thanks,
Shyam

Quoted 27 lines

In order to avoid the ioremap warning, and to help the user understand the situation, catch the invalid address and print an error.

Fixes 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")
---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +5 -0
index bbb8edb62e00..5669f94c3d06 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	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");
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */
#5 lore raw
Quoted 10 lines · Shyam Sundar S K

No need to put my name in the commit message.

You may simply the commit message to something like this:

Further debugging reveals that this occurs when the requests for S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return a value of 0, indicating that the STB is inaccessible. To prevent the ioremap warning and provide clarity to the user, handle the invalid address and display an error message.

Quoted 3 lines

With this addressed

Ok, thank you. I have made these changes now as patch v3.

-Corey

#6 lore raw

PATCH v3 1/1 platform/x86/amd/pmc: Detect when STB is not available

In reply to Corey Hickey

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340

Further debugging reveals that this occurs when the requests for S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return a value of 0, indicating that the STB is inaccessible. To prevent the ioremap warning and provide clarity to the user, handle the invalid address and display an error message.

Fixes 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")
---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +5 -0
index bbb8edb62e00..5669f94c3d06 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	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");
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */
Signature · 1 line
2.45.2
maintainer Reviewed-by on v3 1/1
#7 lore raw
Quoted 33 lines · Corey Hickey

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340

Further debugging reveals that this occurs when the requests for S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return a value of 0, indicating that the STB is inaccessible. To prevent the ioremap warning and provide clarity to the user, handle the invalid address and display an error message.

Fixes 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")
---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +0 -0
index bbb8edb62e00..5669f94c3d06 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);

drivers/platform/x86/amd/pmc/pmc.c static int amd_pmc_s2d_init(struct amd_pmc_dev *dev) · line 1008

Quoted 10 lines
drivers/platform/x86/amd/pmc/pmc.c +5 -0
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	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");
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */

Thanks for the update,

Signature · 1 line
 i.
#8 lore raw
In reply to Corey Hickey

Hi,

Quoted 18 lines · Corey Hickey

From: Corey Hickey <[email protected]>

Loading the amd_pmc module as:

amd_pmc enable_stb=1

...can result in the following messages in the kernel ring buffer:

    amd_pmc AMDI0009:00: SMU cmd failed. err: 0xff
    ioremap on RAM at 0x0000000000000000 - 0x0000000000ffffff
    WARNING: CPU: 10 PID: 2151 at arch/x86/mm/ioremap.c:217 __ioremap_caller+0x2cd/0x340

Further debugging reveals that this occurs when the requests for S2D_PHYS_ADDR_LOW and S2D_PHYS_ADDR_HIGH return a value of 0, indicating that the STB is inaccessible. To prevent the ioremap warning and provide clarity to the user, handle the invalid address and display an error message.

Quoted 5 lines
Fixes 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle.

Regards,

Hans

Quoted 20 lines
---
 drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +5 -0
index bbb8edb62e00..5669f94c3d06 100644
@@ -998,6 +998,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, dev->s2d_msg_id, true);
 	amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, dev->s2d_msg_id, true);
 
+	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");
+		return -EINVAL;
+	}
+
 	stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
 
 	/* Clear msg_port for other SMU operation */