Skip to contentSkip to conversation

platform/x86: amd-pmc: Move SMU logging setup out of init

PATCH In review Mario Limonciello 2 participants 5 messages Apr 11, 2022 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 platform/x86: amd-pmc: Move SMU logging setup out of init

SMU logging is setup when the device is probed currently.

In analyzing boot performance it was observed that amd_pmc_probe is taking ~116800us on startup on an OEM platform. This is longer than expected, and is caused by enabling SMU logging at startup.

As the SMU logging is only needed for debugging, initialize it only upon use. This decreases the time for amd_pmc_probe to ~28800us.

---
v1->v2:
* Drop extra check for dev->active_ips as already validated in get_metrics_table
* Add tag

 drivers/platform/x86/amd-pmc.c | 47 ++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 19 deletions(-)
drivers/platform/x86/amd-pmc.c +28 -19
index e9d0dbbb2887..103ba0729b2a 100644
@@ -162,6 +162,7 @@ static struct amd_pmc_dev pmc;
 static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret);
 static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
 static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
+static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev);
 
 static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int reg_offset)
 {
@@ -319,6 +320,13 @@ static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
 
 static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)
 {
+	if (!pdev->smu_virt_addr) {
+		int ret = amd_pmc_setup_smu_logging(pdev);
+
+		if (ret)
+			return ret;
+	}
+
 	if (pdev->cpu_id == AMD_CPU_ID_PCO)
 		return -ENODEV;
 	memcpy_fromio(table, pdev->smu_virt_addr, sizeof(struct smu_metrics));
@@ -447,25 +455,32 @@ static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)
 
 static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
 {
-	u32 phys_addr_low, phys_addr_hi;
-	u64 smu_phys_addr;
-
-	if (dev->cpu_id == AMD_CPU_ID_PCO)
+	if (dev->cpu_id == AMD_CPU_ID_PCO) {
+		dev_warn_once(dev->dev, "SMU debugging info not supported on this platform\n");
 		return -EINVAL;
+	}
 
 	/* Get Active devices list from SMU */
-	amd_pmc_send_cmd(dev, 0, &dev->active_ips, SMU_MSG_GET_SUP_CONSTRAINTS, 1);
+	if (!dev->active_ips)
+		amd_pmc_send_cmd(dev, 0, &dev->active_ips, SMU_MSG_GET_SUP_CONSTRAINTS, 1);
 
 	/* Get dram address */
-	amd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, 1);
-	amd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, 1);
-	smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
-
-	dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr, sizeof(struct smu_metrics));
-	if (!dev->smu_virt_addr)
-		return -ENOMEM;
+	if (!dev->smu_virt_addr) {
+		u32 phys_addr_low, phys_addr_hi;
+		u64 smu_phys_addr;
+
+		amd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, 1);
+		amd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, 1);
+		smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
+
+		dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,
+						  sizeof(struct smu_metrics));
+		if (!dev->smu_virt_addr)
+			return -ENOMEM;
+	}
 
 	/* Start the logging */
+	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, 0);
 	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, 0);
 
 	return 0;
@@ -634,8 +649,7 @@ static void amd_pmc_s2idle_prepare(void)
 	u32 arg = 1;
 
 	/* Reset and Start SMU logging - to monitor the s0i3 stats */
-	amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_RESET, 0);
-	amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_START, 0);
+	amd_pmc_setup_smu_logging(pdev);
 
 	/* Activate CZN specific RTC functionality */
 	if (pdev->cpu_id == AMD_CPU_ID_CZN) {
@@ -846,11 +860,6 @@ static int amd_pmc_probe(struct platform_device *pdev)
 		goto err_pci_dev_put;
 	}
 
-	/* Use SMU to get the s0i3 debug stats */
-	err = amd_pmc_setup_smu_logging(dev);
-	if (err)
-		dev_err(dev->dev, "SMU debugging info not supported on this platform\n");
-
 	if (enable_stb && dev->cpu_id == AMD_CPU_ID_YC) {
 		err = amd_pmc_s2d_init(dev);
 		if (err)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/3 platform/x86: amd-pmc: Move FCH init to first use

FCH address is accessed only when looking at s0ix stats.

As this is unnecessary for initialization, move it ito the first time stats are accessed from sysfs. This descrease startup time by about 200us.

---
v1->v2:
* Add tag

 drivers/platform/x86/amd-pmc.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/platform/x86/amd-pmc.c +12 -11
index 103ba0729b2a..1f68a3cb1973 100644
@@ -383,6 +383,17 @@ static int s0ix_stats_show(struct seq_file *s, void *unused)
 	struct amd_pmc_dev *dev = s->private;
 	u64 entry_time, exit_time, residency;
 
+	/* Use FCH registers to get the S0ix stats */
+	if (!dev->fch_virt_addr) {
+		u32 base_addr_lo = FCH_BASE_PHY_ADDR_LOW;
+		u32 base_addr_hi = FCH_BASE_PHY_ADDR_HIGH;
+		u64 fch_phys_addr = ((u64)base_addr_hi << 32 | base_addr_lo);
+
+		dev->fch_virt_addr = devm_ioremap(dev->dev, fch_phys_addr, FCH_SSC_MAPPING_SIZE);
+		if (!dev->fch_virt_addr)
+			return -ENOMEM;
+	}
+
 	entry_time = ioread32(dev->fch_virt_addr + FCH_S0I3_ENTRY_TIME_H_OFFSET);
 	entry_time = entry_time << 32 | ioread32(dev->fch_virt_addr + FCH_S0I3_ENTRY_TIME_L_OFFSET);
 
@@ -796,7 +807,7 @@ static int amd_pmc_probe(struct platform_device *pdev)
 	struct amd_pmc_dev *dev = &pmc;
 	struct pci_dev *rdev;
 	u32 base_addr_lo, base_addr_hi;
-	u64 base_addr, fch_phys_addr;
+	u64 base_addr;
 	int err;
 	u32 val;
 
@@ -850,16 +861,6 @@ static int amd_pmc_probe(struct platform_device *pdev)
 
 	mutex_init(&dev->lock);
 
-	/* Use FCH registers to get the S0ix stats */
-	base_addr_lo = FCH_BASE_PHY_ADDR_LOW;
-	base_addr_hi = FCH_BASE_PHY_ADDR_HIGH;
-	fch_phys_addr = ((u64)base_addr_hi << 32 | base_addr_lo);
-	dev->fch_virt_addr = devm_ioremap(dev->dev, fch_phys_addr, FCH_SSC_MAPPING_SIZE);
-	if (!dev->fch_virt_addr) {
-		err = -ENOMEM;
-		goto err_pci_dev_put;
-	}
-
 	if (enable_stb && dev->cpu_id == AMD_CPU_ID_YC) {
 		err = amd_pmc_s2d_init(dev);
 		if (err)
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 3/3 platform/x86: amd-pmc: Avoid reading SMU version at probe time

In reply to Mario Limonciello

Currently the SMU version only used to determine whether the SMU supports reading the idle mask. To speed up startup, move it to the first time the idle mask is read.

This decreases the startup time from ~28500us to 100us.

---
v1->v2:
* Add tag

 drivers/platform/x86/amd-pmc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/platform/x86/amd-pmc.c +7 -1
index 1f68a3cb1973..be781b4e2ce3 100644
@@ -418,6 +418,13 @@ static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
 	struct amd_pmc_dev *dev = s->private;
 	int rc;
 
+	/* we haven't yet read SMU version */
+	if (!dev->major) {
+		rc = amd_pmc_get_smu_version(dev);
+		if (rc)
+			return rc;
+	}
+
 	if (dev->major > 56 || (dev->major >= 55 && dev->minor >= 37)) {
 		rc = amd_pmc_idlemask_read(dev, NULL, s);
 		if (rc)
@@ -867,7 +874,6 @@ static int amd_pmc_probe(struct platform_device *pdev)
 			return err;
 	}
 
-	amd_pmc_get_smu_version(dev);
 	platform_set_drvdata(pdev, dev);
 	err = acpi_register_lps0_dev(&amd_pmc_s2idle_dev_ops);
 	if (err)
Signature · 1 line
2.34.1
#3 lore raw
In reply to Mario Limonciello

Hi Mario,

Quoted 9 lines · Mario Limonciello

SMU logging is setup when the device is probed currently.

In analyzing boot performance it was observed that amd_pmc_probe is taking ~116800us on startup on an OEM platform. This is longer than expected, and is caused by enabling SMU logging at startup.

As the SMU logging is only needed for debugging, initialize it only upon use. This decreases the time for amd_pmc_probe to ~28800us.

Quoted 6 lines

---
v1->v2:
* Drop extra check for dev->active_ips as already validated in get_metrics_table
* Add tag

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

Note I had to resolve some trivial conflicts manually because your base did not include the "platform/x86: amd-pmc: Fix compilation without CONFIG_SUSPEND" patch (1), please double check the results.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

1) To avoid this in the future please use the:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
branch as base in the future.

Quoted 97 lines
 drivers/platform/x86/amd-pmc.c | 47 ++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 19 deletions(-)
drivers/platform/x86/amd-pmc.c +28 -19
index e9d0dbbb2887..103ba0729b2a 100644
@@ -162,6 +162,7 @@ static struct amd_pmc_dev pmc;
 static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret);
 static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
 static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
+static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev);
 
 static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int reg_offset)
 {
@@ -319,6 +320,13 @@ static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,
 
 static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics *table)
 {
+	if (!pdev->smu_virt_addr) {
+		int ret = amd_pmc_setup_smu_logging(pdev);
+
+		if (ret)
+			return ret;
+	}
+
 	if (pdev->cpu_id == AMD_CPU_ID_PCO)
 		return -ENODEV;
 	memcpy_fromio(table, pdev->smu_virt_addr, sizeof(struct smu_metrics));
@@ -447,25 +455,32 @@ static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)
 
 static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
 {
-	u32 phys_addr_low, phys_addr_hi;
-	u64 smu_phys_addr;
-
-	if (dev->cpu_id == AMD_CPU_ID_PCO)
+	if (dev->cpu_id == AMD_CPU_ID_PCO) {
+		dev_warn_once(dev->dev, "SMU debugging info not supported on this platform\n");
 		return -EINVAL;
+	}
 
 	/* Get Active devices list from SMU */
-	amd_pmc_send_cmd(dev, 0, &dev->active_ips, SMU_MSG_GET_SUP_CONSTRAINTS, 1);
+	if (!dev->active_ips)
+		amd_pmc_send_cmd(dev, 0, &dev->active_ips, SMU_MSG_GET_SUP_CONSTRAINTS, 1);
 
 	/* Get dram address */
-	amd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, 1);
-	amd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, 1);
-	smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
-
-	dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr, sizeof(struct smu_metrics));
-	if (!dev->smu_virt_addr)
-		return -ENOMEM;
+	if (!dev->smu_virt_addr) {
+		u32 phys_addr_low, phys_addr_hi;
+		u64 smu_phys_addr;
+
+		amd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, 1);
+		amd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, 1);
+		smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
+
+		dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,
+						  sizeof(struct smu_metrics));
+		if (!dev->smu_virt_addr)
+			return -ENOMEM;
+	}
 
 	/* Start the logging */
+	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, 0);
 	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, 0);
 
 	return 0;
@@ -634,8 +649,7 @@ static void amd_pmc_s2idle_prepare(void)
 	u32 arg = 1;
 
 	/* Reset and Start SMU logging - to monitor the s0i3 stats */
-	amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_RESET, 0);
-	amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_START, 0);
+	amd_pmc_setup_smu_logging(pdev);
 
 	/* Activate CZN specific RTC functionality */
 	if (pdev->cpu_id == AMD_CPU_ID_CZN) {
@@ -846,11 +860,6 @@ static int amd_pmc_probe(struct platform_device *pdev)
 		goto err_pci_dev_put;
 	}
 
-	/* Use SMU to get the s0i3 debug stats */
-	err = amd_pmc_setup_smu_logging(dev);
-	if (err)
-		dev_err(dev->dev, "SMU debugging info not supported on this platform\n");
-
 	if (enable_stb && dev->cpu_id == AMD_CPU_ID_YC) {
 		err = amd_pmc_s2d_init(dev);
 		if (err)
#4 lore raw

[AMD Official Use Only]

Quoted 43 lines

-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Monday, April 11, 2022 09:56
To: Limonciello, Mario <[email protected]>; Mark Gross <[email protected]>; open list:X86 PLATFORM DRIVERS <platform-driver- [email protected]>
Cc: S-k, Shyam-sundar <[email protected]>; Goswami, Sanket <[email protected]>; [email protected]
Subject: Re: [PATCH v2 1/3] platform/x86: amd-pmc: Move SMU logging setup out of init

Hi Mario,

Quoted 6 lines · Mario Limonciello

SMU logging is setup when the device is probed currently.

In analyzing boot performance it was observed that amd_pmc_probe is taking ~116800us on startup on an OEM platform. This is longer than expected, and is caused by enabling SMU logging at startup.

Quoted 8 lines

As the SMU logging is only needed for debugging, initialize it only upon use. This decreases the time for amd_pmc_probe to ~28800us.

---
v1->v2:
* Drop extra check for dev->active_ips as already validated in

get_metrics_table

Quoted 1 line

* Add tag

Thank you for your patch-series, I've applied the series to my review-hans branch:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fpdx86%2Fplatform-drivers- x86.git%2Flog%2F%3Fh%3Dreview- hans&amp;data=04%7C01%7Cmario.limonciello%40amd.com%7Ca66415c73ed 04611830c08da1bcb69d7%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C637852857715985040%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata =hZkKrgZOzSgTIUe%2BGJK7wGpq%2BoCgB6j9SH%2BUT2rok9M%3D&amp;reser ved=0

Quoted 3 lines

Note I had to resolve some trivial conflicts manually because your base did not include the "platform/x86: amd-pmc: Fix compilation without CONFIG_SUSPEND" patch (1), please double check the results.

Ah thanks. I had done it relative to platform-x86/for-next (as of b49f72e7f96d4ed147447428f2ae5b4cea598ca7), didn't realize it wasn't yet applied there until you said this.

Quoted 143 lines

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

1) To avoid this in the future please use the:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fpdx86%2Fplatform-drivers- x86.git%2Flog%2F%3Fh%3Dreview- hans&amp;data=04%7C01%7Cmario.limonciello%40amd.com%7Ca66415c73ed 04611830c08da1bcb69d7%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0 %7C637852857715985040%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata =hZkKrgZOzSgTIUe%2BGJK7wGpq%2BoCgB6j9SH%2BUT2rok9M%3D&amp;reser ved=0
branch as base in the future.

drivers/platform/x86/amd-

Quoted 5 lines
 drivers/platform/x86/amd-pmc.c | 47 ++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 19 deletions(-)
drivers/platform/x86/amd- renamed from drivers/platform/x86/amd-pmc.c +0 -0

pmc.c

drivers/platform/x86/amd-pmc.c static struct amd_pmc_dev pmc; · line 162

Quoted 5 lines

index e9d0dbbb2887..103ba0729b2a 100644

drivers/platform/x86/amd-pmc.c +0 -0
@@ -162,6 +162,7 @@ static struct amd_pmc_dev pmc;
 static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data,

u8 msg, bool ret);

drivers/platform/x86/amd-pmc.c static struct amd_pmc_dev pmc;

Quoted 5 lines
drivers/platform/x86/amd-pmc.c +1 -0
 static int amd_pmc_write_stb(struct amd_pmc_dev *dev, u32 data);
 static int amd_pmc_read_stb(struct amd_pmc_dev *dev, u32 *buf);
+static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev);
 
 static inline u32 amd_pmc_reg_read(struct amd_pmc_dev *dev, int

reg_offset)

drivers/platform/x86/amd-pmc.c static int amd_pmc_idlemask_read(struct

Quoted 2 lines
drivers/platform/x86/amd-pmc.c +0 -0
 {
@@ -319,6 +320,13 @@ static int amd_pmc_idlemask_read(struct

amd_pmc_dev *pdev, struct device *dev,

drivers/platform/x86/amd-pmc.c static int amd_pmc_idlemask_read(struct · line 320

Quoted 2 lines
drivers/platform/x86/amd-pmc.c +0 -0
 static int get_metrics_table(struct amd_pmc_dev *pdev, struct smu_metrics

*table)

drivers/platform/x86/amd-pmc.c static int amd_pmc_idlemask_read(struct amd_pmc_dev *pdev, struct device *dev,

Quoted 11 lines
drivers/platform/x86/amd-pmc.c +7 -0
 {
+	if (!pdev->smu_virt_addr) {
+		int ret = amd_pmc_setup_smu_logging(pdev);
+
+		if (ret)
+			return ret;
+	}
+
 	if (pdev->cpu_id == AMD_CPU_ID_PCO)
 		return -ENODEV;
 	memcpy_fromio(table, pdev->smu_virt_addr, sizeof(struct

smu_metrics));

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct

Quoted 1 line
drivers/platform/x86/amd-pmc.c +0 -0
@@ -447,25 +455,32 @@ static inline void amd_pmc_dbgfs_unregister(struct

amd_pmc_dev *dev)

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)

Quoted 9 lines
drivers/platform/x86/amd-pmc.c +2 -4
 static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
 {
-	u32 phys_addr_low, phys_addr_hi;
-	u64 smu_phys_addr;
-
-	if (dev->cpu_id == AMD_CPU_ID_PCO)
+	if (dev->cpu_id == AMD_CPU_ID_PCO) {
+		dev_warn_once(dev->dev, "SMU debugging info not supported

on this platform\n");

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)

Quoted 5 lines
drivers/platform/x86/amd-pmc.c +1 -1
 		return -EINVAL;
+	}
 
 	/* Get Active devices list from SMU */
-	amd_pmc_send_cmd(dev, 0, &dev->active_ips,

SMU_MSG_GET_SUP_CONSTRAINTS, 1);

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct · line 464

Quoted 2 lines
drivers/platform/x86/amd-pmc.c +2 -0
+	if (!dev->active_ips)
+		amd_pmc_send_cmd(dev, 0, &dev->active_ips,

SMU_MSG_GET_SUP_CONSTRAINTS, 1);

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct · line 458

Quoted 3 lines
drivers/platform/x86/amd-pmc.c +0 -1
 	/* Get dram address */
-	amd_pmc_send_cmd(dev, 0, &phys_addr_low,

SMU_MSG_LOG_GETDRAM_ADDR_LO, 1);

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct · line 459

Quoted 1 line
drivers/platform/x86/amd-pmc.c +0 -1
-	amd_pmc_send_cmd(dev, 0, &phys_addr_hi,

SMU_MSG_LOG_GETDRAM_ADDR_HI, 1);

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)

Quoted 3 lines
drivers/platform/x86/amd-pmc.c +0 -3
-	smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
-
-	dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,

sizeof(struct smu_metrics));

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)

Quoted 7 lines
drivers/platform/x86/amd-pmc.c +5 -2
-	if (!dev->smu_virt_addr)
-		return -ENOMEM;
+	if (!dev->smu_virt_addr) {
+		u32 phys_addr_low, phys_addr_hi;
+		u64 smu_phys_addr;
+
+		amd_pmc_send_cmd(dev, 0, &phys_addr_low,

SMU_MSG_LOG_GETDRAM_ADDR_LO, 1);

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct · line 471

Quoted 1 line
drivers/platform/x86/amd-pmc.c +1 -0
+		amd_pmc_send_cmd(dev, 0, &phys_addr_hi,

SMU_MSG_LOG_GETDRAM_ADDR_HI, 1);

drivers/platform/x86/amd-pmc.c static inline void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)

Quoted 3 lines
drivers/platform/x86/amd-pmc.c +3 -0
+		smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
+
+		dev->smu_virt_addr = devm_ioremap(dev->dev,

smu_phys_addr,

drivers/platform/x86/amd-pmc.c static int amd_pmc_probe(struct platform_device

Quoted 21 lines
drivers/platform/x86/amd-pmc.c +6 -2
+						  sizeof(struct smu_metrics));
+		if (!dev->smu_virt_addr)
+			return -ENOMEM;
+	}
 
 	/* Start the logging */
+	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, 0);
 	amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, 0);
 
 	return 0;
@@ -634,8 +649,7 @@ static void amd_pmc_s2idle_prepare(void)
 	u32 arg = 1;
 
 	/* Reset and Start SMU logging - to monitor the s0i3 stats */
-	amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_RESET, 0);
-	amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_START, 0);
+	amd_pmc_setup_smu_logging(pdev);
 
 	/* Activate CZN specific RTC functionality */
 	if (pdev->cpu_id == AMD_CPU_ID_CZN) {
@@ -846,11 +860,6 @@ static int amd_pmc_probe(struct platform_device

*pdev)

drivers/platform/x86/amd-pmc.c static int amd_pmc_probe(struct platform_device *pdev)

Quoted 7 lines
drivers/platform/x86/amd-pmc.c +0 -4
 		goto err_pci_dev_put;
 	}
 
-	/* Use SMU to get the s0i3 debug stats */
-	err = amd_pmc_setup_smu_logging(dev);
-	if (err)
-		dev_err(dev->dev, "SMU debugging info not supported on this

platform\n");

Quoted 4 lines
drivers/platform/x86/amd-pmc.c +0 -1
-
 	if (enable_stb && dev->cpu_id == AMD_CPU_ID_YC) {
 		err = amd_pmc_s2d_init(dev);
 		if (err)