2023-10-27 21:30:57

by Mark Hasemeyer

[permalink] [raw]
Subject: [PATCH v1] platform/x86/amd/pmc: Get smu version before reading dram size

Calls to amd_pmc_get_dram_size can fail because the function assumes smu
version information has already been read when it hasn't. The smu
version is lazily read as opposed to being read at probe because it is
slow and increases boot time.

Read the smu version information if it has not been read yet.

Link: https://lore.kernel.org/all/[email protected]/
Fixes: be8325fb3d8c ("platform/x86/amd: pmc: Get STB DRAM size from PMFW")
Cc: [email protected] # 6.5.x

Signed-off-by: Mark Hasemeyer <[email protected]>
---

drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
index cd6ac04c1468..f668eddbc5d5 100644
--- a/drivers/platform/x86/amd/pmc/pmc.c
+++ b/drivers/platform/x86/amd/pmc/pmc.c
@@ -970,6 +970,11 @@ static int amd_pmc_get_dram_size(struct amd_pmc_dev *dev)

switch (dev->cpu_id) {
case AMD_CPU_ID_YC:
+ if (!dev->major) {
+ ret = amd_pmc_get_smu_version(dev);
+ if (ret)
+ goto err_dram_size;
+ }
if (!(dev->major > 90 || (dev->major == 90 && dev->minor > 39))) {
ret = -EINVAL;
goto err_dram_size;
--
2.42.0.820.g83a721a137-goog


2023-10-30 09:24:46

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v1] platform/x86/amd/pmc: Get smu version before reading dram size

On Fri, 27 Oct 2023, Mark Hasemeyer wrote:

> Calls to amd_pmc_get_dram_size can fail because the function assumes smu

Always use () after function names, thank you.

> version information has already been read when it hasn't. The smu
> version is lazily read as opposed to being read at probe because it is
> slow and increases boot time.
>
> Read the smu version information if it has not been read yet.
>
> Link: https://lore.kernel.org/all/[email protected]/
> Fixes: be8325fb3d8c ("platform/x86/amd: pmc: Get STB DRAM size from PMFW")
> Cc: [email protected] # 6.5.x
>
> Signed-off-by: Mark Hasemeyer <[email protected]>
> ---
>
> drivers/platform/x86/amd/pmc/pmc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c
> index cd6ac04c1468..f668eddbc5d5 100644
> --- a/drivers/platform/x86/amd/pmc/pmc.c
> +++ b/drivers/platform/x86/amd/pmc/pmc.c
> @@ -970,6 +970,11 @@ static int amd_pmc_get_dram_size(struct amd_pmc_dev *dev)
>
> switch (dev->cpu_id) {
> case AMD_CPU_ID_YC:
> + if (!dev->major) {
> + ret = amd_pmc_get_smu_version(dev);
> + if (ret)
> + goto err_dram_size;
> + }
> if (!(dev->major > 90 || (dev->major == 90 && dev->minor > 39))) {
> ret = -EINVAL;
> goto err_dram_size;
>

Hi,

Thank you for your patch. This has already come up but no acceptable patch
has emerged since. Please see this thread for what needs to be done if you
want to provide one (or maybe Shyam already has one which has just not
been sent out yet):

https://lore.kernel.org/platform-driver-x86/[email protected]/

(Since this dram size is on an init path that always needs SMU version,
the SMU version can just be called by the init unconditonally rather than
adding more of this lazy initialization everywhere).


--
i.

2023-10-30 16:10:06

by Mark Hasemeyer

[permalink] [raw]
Subject: Re: [PATCH v1] platform/x86/amd/pmc: Get smu version before reading dram size

> Hi,
>
> Thank you for your patch. This has already come up but no acceptable patch
> has emerged since. Please see this thread for what needs to be done if you
> want to provide one (or maybe Shyam already has one which has just not
> been sent out yet):
>
> https://lore.kernel.org/platform-driver-x86/[email protected]/
>
> (Since this dram size is on an init path that always needs SMU version,
> the SMU version can just be called by the init unconditonally rather than
> adding more of this lazy initialization everywhere).

Thanks for pointing me to that thread. I think Shyam/AMD can come up
with a better long term solution, but it may be worth pushing this
patch through for a couple reasons:
1. Probing of the driver currently fails on STB enabled systems with a
Mendocino SoC. A slower boot time is better than the driver failing to
load IMO.
2. This patch only affects Mendocino SoCs, and was a suggested
solution from Mario in the thread you mentioned.

That said, I can also just disable STB for now...

2023-10-30 16:18:05

by Mario Limonciello

[permalink] [raw]
Subject: Re: [PATCH v1] platform/x86/amd/pmc: Get smu version before reading dram size

On 10/30/2023 11:09, Mark Hasemeyer wrote:
>> Hi,
>>
>> Thank you for your patch. This has already come up but no acceptable patch
>> has emerged since. Please see this thread for what needs to be done if you
>> want to provide one (or maybe Shyam already has one which has just not
>> been sent out yet):
>>
>> https://lore.kernel.org/platform-driver-x86/[email protected]/
>>
>> (Since this dram size is on an init path that always needs SMU version,
>> the SMU version can just be called by the init unconditonally rather than
>> adding more of this lazy initialization everywhere).
>
> Thanks for pointing me to that thread. I think Shyam/AMD can come up
> with a better long term solution, but it may be worth pushing this
> patch through for a couple reasons:
> 1. Probing of the driver currently fails on STB enabled systems with a
> Mendocino SoC. A slower boot time is better than the driver failing to
> load IMO.
> 2. This patch only affects Mendocino SoCs, and was a suggested
> solution from Mario in the thread you mentioned.
>
> That said, I can also just disable STB for now...

It's debugfs. The vast majority of people won't need to access it even
if STB is turned on by default. It should only really be needed in
error cases.

So how about if the STB init is pushed into the lazy init path as well?
You can make the files at probe, and then check in their first access if
init was done.

2023-10-31 07:55:10

by Shyam Sundar S K

[permalink] [raw]
Subject: Re: [PATCH v1] platform/x86/amd/pmc: Get smu version before reading dram size

Hi Mark, Ilpo,

On 10/30/2023 9:39 PM, Mark Hasemeyer wrote:
>> Hi,
>>
>> Thank you for your patch. This has already come up but no acceptable patch
>> has emerged since. Please see this thread for what needs to be done if you
>> want to provide one (or maybe Shyam already has one which has just not
>> been sent out yet):

Yes. Was talking to FW team before I respin.

>>
>> https://lore.kernel.org/platform-driver-x86/[email protected]/
>>
>> (Since this dram size is on an init path that always needs SMU version,
>> the SMU version can just be called by the init unconditonally rather than
>> adding more of this lazy initialization everywhere).
>
> Thanks for pointing me to that thread. I think Shyam/AMD can come up
> with a better long term solution, but it may be worth pushing this
> patch through for a couple reasons:
> 1. Probing of the driver currently fails on STB enabled systems with a
> Mendocino SoC. A slower boot time is better than the driver failing to
> load IMO.
> 2. This patch only affects Mendocino SoCs, and was a suggested
> solution from Mario in the thread you mentioned.
>

I have a patch in place that should address the problem you are
mentioning. I will send that out next Monday after some tests.

Thanks,
Shyam

> That said, I can also just disable STB for now...

2023-10-31 15:21:29

by Mark Hasemeyer

[permalink] [raw]
Subject: Re: [PATCH v1] platform/x86/amd/pmc: Get smu version before reading dram size

> I have a patch in place that should address the problem you are
> mentioning. I will send that out next Monday after some tests.

Great, thanks Shyam! I'll hold off on pushing a patch implementing
what Mario suggested.