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

From: Mark Hasemeyer
Date: Fri Oct 27 2023 - 17:29:27 EST


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/a3ee6577-d521-6d18-0a15-2f97d6f8ac3a@xxxxxxx/
Fixes: be8325fb3d8c ("platform/x86/amd: pmc: Get STB DRAM size from PMFW")
Cc: stable@xxxxxxxxxxxxxxx # 6.5.x

Signed-off-by: Mark Hasemeyer <markhas@xxxxxxxxxxxx>
---

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