* [PATCH v5 1/4] platform/x86/amd: pmc: Pass true/false to bool argument
2023-05-25 14:19 [PATCH v5 0/4] Updates to AMD PMC driver Shyam Sundar S K
@ 2023-05-25 14:19 ` Shyam Sundar S K
2023-05-25 14:19 ` [PATCH v5 2/4] platform/x86/amd: pmc: Get STB DRAM size from PMFW Shyam Sundar S K
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Shyam Sundar S K @ 2023-05-25 14:19 UTC (permalink / raw)
To: hdegoede, markgross
Cc: Sanket.Goswami, mario.limonciello, platform-driver-x86,
Shyam Sundar S K, Ilpo Järvinen
Pass true/false to the bool argument of the amd_pmc_send_cmd() function,
instead of 1/0 to match the function signature.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmc.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index 427905714f79..f28c295b47dd 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -261,7 +261,7 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
dev->msg_port = 1;
/* Get the num_samples to calculate the last push location */
- ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, STB_SPILL_TO_DRAM, 1);
+ ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, STB_SPILL_TO_DRAM, true);
/* Clear msg_port for other SMU operation */
dev->msg_port = 0;
if (ret) {
@@ -317,15 +317,15 @@ static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
/* Get Active devices list from SMU */
if (!dev->active_ips)
- amd_pmc_send_cmd(dev, 0, &dev->active_ips, SMU_MSG_GET_SUP_CONSTRAINTS, 1);
+ amd_pmc_send_cmd(dev, 0, &dev->active_ips, SMU_MSG_GET_SUP_CONSTRAINTS, true);
/* Get dram address */
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);
+ amd_pmc_send_cmd(dev, 0, &phys_addr_low, SMU_MSG_LOG_GETDRAM_ADDR_LO, true);
+ amd_pmc_send_cmd(dev, 0, &phys_addr_hi, SMU_MSG_LOG_GETDRAM_ADDR_HI, true);
smu_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
dev->smu_virt_addr = devm_ioremap(dev->dev, smu_phys_addr,
@@ -335,8 +335,8 @@ static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
}
/* 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);
+ amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_RESET, false);
+ amd_pmc_send_cmd(dev, 0, NULL, SMU_MSG_LOG_START, false);
return 0;
}
@@ -377,7 +377,7 @@ static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
if (dev->cpu_id == AMD_CPU_ID_PCO)
return -ENODEV;
- rc = amd_pmc_send_cmd(dev, 0, &val, SMU_MSG_GETSMUVERSION, 1);
+ rc = amd_pmc_send_cmd(dev, 0, &val, SMU_MSG_GETSMUVERSION, true);
if (rc)
return rc;
@@ -794,7 +794,7 @@ static void amd_pmc_s2idle_prepare(void)
}
msg = amd_pmc_get_os_hint(pdev);
- rc = amd_pmc_send_cmd(pdev, arg, NULL, msg, 0);
+ rc = amd_pmc_send_cmd(pdev, arg, NULL, msg, false);
if (rc) {
dev_err(pdev->dev, "suspend failed: %d\n", rc);
return;
@@ -829,7 +829,7 @@ static int amd_pmc_dump_data(struct amd_pmc_dev *pdev)
if (pdev->cpu_id == AMD_CPU_ID_PCO)
return -ENODEV;
- return amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_DUMP_DATA, 0);
+ return amd_pmc_send_cmd(pdev, 0, NULL, SMU_MSG_LOG_DUMP_DATA, false);
}
static void amd_pmc_s2idle_restore(void)
@@ -839,7 +839,7 @@ static void amd_pmc_s2idle_restore(void)
u8 msg;
msg = amd_pmc_get_os_hint(pdev);
- rc = amd_pmc_send_cmd(pdev, 0, NULL, msg, 0);
+ rc = amd_pmc_send_cmd(pdev, 0, NULL, msg, false);
if (rc)
dev_err(pdev->dev, "resume failed: %d\n", rc);
@@ -899,13 +899,13 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
/* Spill to DRAM feature uses separate SMU message port */
dev->msg_port = 1;
- amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, STB_SPILL_TO_DRAM, 1);
+ amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, STB_SPILL_TO_DRAM, true);
if (size != S2D_TELEMETRY_BYTES_MAX)
return -EIO;
/* Get STB DRAM address */
- amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, STB_SPILL_TO_DRAM, 1);
- amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, STB_SPILL_TO_DRAM, 1);
+ amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, STB_SPILL_TO_DRAM, true);
+ amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, STB_SPILL_TO_DRAM, true);
stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v5 2/4] platform/x86/amd: pmc: Get STB DRAM size from PMFW
2023-05-25 14:19 [PATCH v5 0/4] Updates to AMD PMC driver Shyam Sundar S K
2023-05-25 14:19 ` [PATCH v5 1/4] platform/x86/amd: pmc: Pass true/false to bool argument Shyam Sundar S K
@ 2023-05-25 14:19 ` Shyam Sundar S K
2023-05-25 14:19 ` [PATCH v5 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id Shyam Sundar S K
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Shyam Sundar S K @ 2023-05-25 14:19 UTC (permalink / raw)
To: hdegoede, markgross
Cc: Sanket.Goswami, mario.limonciello, platform-driver-x86,
Shyam Sundar S K, Ilpo Järvinen
Recent PMFW's have support for querying the STB DRAM size. Add this
support to the driver.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmc.c | 37 +++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index f28c295b47dd..e2439fda5c02 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -115,6 +115,7 @@ enum s2d_arg {
S2D_PHYS_ADDR_LOW,
S2D_PHYS_ADDR_HIGH,
S2D_NUM_SAMPLES,
+ S2D_DRAM_SIZE,
};
struct amd_pmc_bit_map {
@@ -147,6 +148,7 @@ struct amd_pmc_dev {
u32 base_addr;
u32 cpu_id;
u32 active_ips;
+ u32 dram_size;
/* SMU version information */
u8 smu_program;
u8 major;
@@ -890,11 +892,39 @@ static const struct pci_device_id pmc_pci_ids[] = {
{ }
};
+static int amd_pmc_get_dram_size(struct amd_pmc_dev *dev)
+{
+ int ret;
+
+ switch (dev->cpu_id) {
+ case AMD_CPU_ID_YC:
+ if (!(dev->major > 90 || (dev->major == 90 && dev->minor > 39))) {
+ ret = -EINVAL;
+ goto err_dram_size;
+ }
+ break;
+ default:
+ ret = -EINVAL;
+ goto err_dram_size;
+ }
+
+ ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, STB_SPILL_TO_DRAM, true);
+ if (ret || !dev->dram_size)
+ goto err_dram_size;
+
+ return 0;
+
+err_dram_size:
+ dev_err(dev->dev, "DRAM size command not supported for this platform\n");
+ return ret;
+}
+
static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
{
u32 phys_addr_low, phys_addr_hi;
u64 stb_phys_addr;
u32 size = 0;
+ int ret;
/* Spill to DRAM feature uses separate SMU message port */
dev->msg_port = 1;
@@ -903,6 +933,11 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
if (size != S2D_TELEMETRY_BYTES_MAX)
return -EIO;
+ /* Get DRAM size */
+ ret = amd_pmc_get_dram_size(dev);
+ if (ret)
+ dev->dram_size = S2D_TELEMETRY_DRAMBYTES_MAX;
+
/* Get STB DRAM address */
amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, STB_SPILL_TO_DRAM, true);
amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, STB_SPILL_TO_DRAM, true);
@@ -912,7 +947,7 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
/* Clear msg_port for other SMU operation */
dev->msg_port = 0;
- dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, S2D_TELEMETRY_DRAMBYTES_MAX);
+ dev->stb_virt_addr = devm_ioremap(dev->dev, stb_phys_addr, dev->dram_size);
if (!dev->stb_virt_addr)
return -ENOMEM;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH v5 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id
2023-05-25 14:19 [PATCH v5 0/4] Updates to AMD PMC driver Shyam Sundar S K
2023-05-25 14:19 ` [PATCH v5 1/4] platform/x86/amd: pmc: Pass true/false to bool argument Shyam Sundar S K
2023-05-25 14:19 ` [PATCH v5 2/4] platform/x86/amd: pmc: Get STB DRAM size from PMFW Shyam Sundar S K
@ 2023-05-25 14:19 ` Shyam Sundar S K
2023-05-26 9:32 ` Ilpo Järvinen
2023-05-25 14:19 ` [PATCH v5 4/4] platform/x86/amd: pmc: Update metrics table info for Pink Sardine Shyam Sundar S K
` (2 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Shyam Sundar S K @ 2023-05-25 14:19 UTC (permalink / raw)
To: hdegoede, markgross
Cc: Sanket.Goswami, mario.limonciello, platform-driver-x86,
Shyam Sundar S K
Add a helper routine to check the underlying cpu id, that can be used
across the PMC driver to remove the duplicate code.
Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmc.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index e2439fda5c02..c2f03cdc9ca9 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -564,6 +564,18 @@ static void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)
debugfs_remove_recursive(dev->dbgfs_dir);
}
+static bool amd_pmc_is_stb_supported(struct amd_pmc_dev *dev)
+{
+ switch (dev->cpu_id) {
+ case AMD_CPU_ID_YC:
+ case AMD_CPU_ID_CB:
+ case AMD_CPU_ID_PS:
+ return true;
+ default:
+ return false;
+ }
+}
+
static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
{
dev->dbgfs_dir = debugfs_create_dir("amd_pmc", NULL);
@@ -575,8 +587,7 @@ static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
&amd_pmc_idlemask_fops);
/* Enable STB only when the module_param is set */
if (enable_stb) {
- if (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB ||
- dev->cpu_id == AMD_CPU_ID_PS)
+ if (amd_pmc_is_stb_supported(dev))
debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
&amd_pmc_stb_debugfs_fops_v2);
else
@@ -1036,7 +1047,7 @@ static int amd_pmc_probe(struct platform_device *pdev)
mutex_init(&dev->lock);
- if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB)) {
+ if (enable_stb && amd_pmc_is_stb_supported(dev)) {
err = amd_pmc_s2d_init(dev);
if (err)
goto err_pci_dev_put;
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v5 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id
2023-05-25 14:19 ` [PATCH v5 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id Shyam Sundar S K
@ 2023-05-26 9:32 ` Ilpo Järvinen
0 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-05-26 9:32 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: hdegoede, markgross, Sanket.Goswami, mario.limonciello,
platform-driver-x86
[-- Attachment #1: Type: text/plain, Size: 2039 bytes --]
On Thu, 25 May 2023, Shyam Sundar S K wrote:
> Add a helper routine to check the underlying cpu id, that can be used
> across the PMC driver to remove the duplicate code.
>
> Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
> drivers/platform/x86/amd/pmc.c | 17 ++++++++++++++---
> 1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
> index e2439fda5c02..c2f03cdc9ca9 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -564,6 +564,18 @@ static void amd_pmc_dbgfs_unregister(struct amd_pmc_dev *dev)
> debugfs_remove_recursive(dev->dbgfs_dir);
> }
>
> +static bool amd_pmc_is_stb_supported(struct amd_pmc_dev *dev)
> +{
> + switch (dev->cpu_id) {
> + case AMD_CPU_ID_YC:
> + case AMD_CPU_ID_CB:
> + case AMD_CPU_ID_PS:
> + return true;
> + default:
> + return false;
> + }
> +}
> +
> static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
> {
> dev->dbgfs_dir = debugfs_create_dir("amd_pmc", NULL);
> @@ -575,8 +587,7 @@ static void amd_pmc_dbgfs_register(struct amd_pmc_dev *dev)
> &amd_pmc_idlemask_fops);
> /* Enable STB only when the module_param is set */
> if (enable_stb) {
> - if (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB ||
> - dev->cpu_id == AMD_CPU_ID_PS)
> + if (amd_pmc_is_stb_supported(dev))
> debugfs_create_file("stb_read", 0644, dev->dbgfs_dir, dev,
> &amd_pmc_stb_debugfs_fops_v2);
> else
> @@ -1036,7 +1047,7 @@ static int amd_pmc_probe(struct platform_device *pdev)
>
> mutex_init(&dev->lock);
>
> - if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB)) {
> + if (enable_stb && amd_pmc_is_stb_supported(dev)) {
> err = amd_pmc_s2d_init(dev);
> if (err)
> goto err_pci_dev_put;
>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
--
i.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 4/4] platform/x86/amd: pmc: Update metrics table info for Pink Sardine
2023-05-25 14:19 [PATCH v5 0/4] Updates to AMD PMC driver Shyam Sundar S K
` (2 preceding siblings ...)
2023-05-25 14:19 ` [PATCH v5 3/4] platform/x86/amd: pmc: Add helper function to check the cpu id Shyam Sundar S K
@ 2023-05-25 14:19 ` Shyam Sundar S K
2023-05-26 9:38 ` Ilpo Järvinen
2023-05-25 14:24 ` [PATCH v5 0/4] Updates to AMD PMC driver Limonciello, Mario
2023-05-30 9:09 ` Hans de Goede
5 siblings, 1 reply; 9+ messages in thread
From: Shyam Sundar S K @ 2023-05-25 14:19 UTC (permalink / raw)
To: hdegoede, markgross
Cc: Sanket.Goswami, mario.limonciello, platform-driver-x86,
Shyam Sundar S K
Starting from Pink Sardine, number of IP blocks were added to the SoC
and the PMFW has the ability to give debug stats on each the IP blocks
after a S0ix cycle within part of the SMU metrics table.
To differentiate this change, the 's2d_msg_id' is also changed. Add these
new capabilities to the driver.
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
drivers/platform/x86/amd/pmc.c | 53 ++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index c2f03cdc9ca9..f7bda8a64c95 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -45,7 +45,6 @@
#define AMD_PMC_STB_DUMMY_PC 0xC6000007
/* STB S2D(Spill to DRAM) has different message port offset */
-#define STB_SPILL_TO_DRAM 0xBE
#define AMD_S2D_REGISTER_MESSAGE 0xA20
#define AMD_S2D_REGISTER_RESPONSE 0xA80
#define AMD_S2D_REGISTER_ARGUMENT 0xA88
@@ -99,7 +98,6 @@
#define PMC_MSG_DELAY_MIN_US 50
#define RESPONSE_REGISTER_LOOP_MAX 20000
-#define SOC_SUBSYSTEM_IP_MAX 12
#define DELAY_MIN_US 2000
#define DELAY_MAX_US 3000
#define FIFO_SIZE 4096
@@ -133,9 +131,18 @@ static const struct amd_pmc_bit_map soc15_ip_blk[] = {
{"ISP", BIT(6)},
{"NBIO", BIT(7)},
{"DF", BIT(8)},
- {"USB0", BIT(9)},
- {"USB1", BIT(10)},
+ {"USB3_0", BIT(9)},
+ {"USB3_1", BIT(10)},
{"LAPIC", BIT(11)},
+ {"USB3_2", BIT(12)},
+ {"USB3_3", BIT(13)},
+ {"USB3_4", BIT(14)},
+ {"USB4_0", BIT(15)},
+ {"USB4_1", BIT(16)},
+ {"MPM", BIT(17)},
+ {"JPEG", BIT(18)},
+ {"IPU", BIT(19)},
+ {"UMSCH", BIT(20)},
{}
};
@@ -149,6 +156,8 @@ struct amd_pmc_dev {
u32 cpu_id;
u32 active_ips;
u32 dram_size;
+ u32 num_ips;
+ u32 s2d_msg_id;
/* SMU version information */
u8 smu_program;
u8 major;
@@ -196,8 +205,8 @@ struct smu_metrics {
u64 timein_s0i3_totaltime;
u64 timein_swdrips_lastcapture;
u64 timein_swdrips_totaltime;
- u64 timecondition_notmet_lastcapture[SOC_SUBSYSTEM_IP_MAX];
- u64 timecondition_notmet_totaltime[SOC_SUBSYSTEM_IP_MAX];
+ u64 timecondition_notmet_lastcapture[32];
+ u64 timecondition_notmet_totaltime[32];
} __packed;
static int amd_pmc_stb_debugfs_open(struct inode *inode, struct file *filp)
@@ -263,7 +272,7 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
dev->msg_port = 1;
/* Get the num_samples to calculate the last push location */
- ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, STB_SPILL_TO_DRAM, true);
+ ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, dev->s2d_msg_id, true);
/* Clear msg_port for other SMU operation */
dev->msg_port = 0;
if (ret) {
@@ -310,6 +319,23 @@ static const struct file_operations amd_pmc_stb_debugfs_fops_v2 = {
.release = amd_pmc_stb_debugfs_release_v2,
};
+static void amd_pmc_get_ip_info(struct amd_pmc_dev *dev)
+{
+ switch (dev->cpu_id) {
+ case AMD_CPU_ID_PCO:
+ case AMD_CPU_ID_RN:
+ case AMD_CPU_ID_YC:
+ case AMD_CPU_ID_CB:
+ dev->num_ips = 12;
+ dev->s2d_msg_id = 0xBE;
+ break;
+ case AMD_CPU_ID_PS:
+ dev->num_ips = 21;
+ dev->s2d_msg_id = 0x85;
+ break;
+ }
+}
+
static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
{
if (dev->cpu_id == AMD_CPU_ID_PCO) {
@@ -471,7 +497,7 @@ static int smu_fw_info_show(struct seq_file *s, void *unused)
table.timeto_resume_to_os_lastcapture);
seq_puts(s, "\n=== Active time (in us) ===\n");
- for (idx = 0 ; idx < SOC_SUBSYSTEM_IP_MAX ; idx++) {
+ for (idx = 0 ; idx < dev->num_ips ; idx++) {
if (soc15_ip_blk[idx].bit_mask & dev->active_ips)
seq_printf(s, "%-8s : %lld\n", soc15_ip_blk[idx].name,
table.timecondition_notmet_lastcapture[idx]);
@@ -919,7 +945,7 @@ static int amd_pmc_get_dram_size(struct amd_pmc_dev *dev)
goto err_dram_size;
}
- ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, STB_SPILL_TO_DRAM, true);
+ ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, dev->s2d_msg_id, true);
if (ret || !dev->dram_size)
goto err_dram_size;
@@ -940,7 +966,10 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
/* Spill to DRAM feature uses separate SMU message port */
dev->msg_port = 1;
- amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, STB_SPILL_TO_DRAM, true);
+ /* Get num of IP blocks within the SoC */
+ amd_pmc_get_ip_info(dev);
+
+ amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, dev->s2d_msg_id, true);
if (size != S2D_TELEMETRY_BYTES_MAX)
return -EIO;
@@ -950,8 +979,8 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
dev->dram_size = S2D_TELEMETRY_DRAMBYTES_MAX;
/* Get STB DRAM address */
- amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, STB_SPILL_TO_DRAM, true);
- amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, STB_SPILL_TO_DRAM, true);
+ 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);
stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH v5 4/4] platform/x86/amd: pmc: Update metrics table info for Pink Sardine
2023-05-25 14:19 ` [PATCH v5 4/4] platform/x86/amd: pmc: Update metrics table info for Pink Sardine Shyam Sundar S K
@ 2023-05-26 9:38 ` Ilpo Järvinen
0 siblings, 0 replies; 9+ messages in thread
From: Ilpo Järvinen @ 2023-05-26 9:38 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: hdegoede, markgross, Sanket.Goswami, mario.limonciello,
platform-driver-x86
[-- Attachment #1: Type: text/plain, Size: 5865 bytes --]
On Thu, 25 May 2023, Shyam Sundar S K wrote:
> Starting from Pink Sardine, number of IP blocks were added to the SoC
> and the PMFW has the ability to give debug stats on each the IP blocks
> after a S0ix cycle within part of the SMU metrics table.
>
> To differentiate this change, the 's2d_msg_id' is also changed.
This sounds a bit vague. I'd have simply said:
Pink Sardine also has different s2d message id.
...but consider replacing "s2d message id" with "Spill to DRAM message
port offset" if that's correct way to say things. I picked up that
wording from the comment in one of the contexts below, perhaps that
comment should no longer be there as the relevant define now got removed?
> Add these new capabilities to the driver.
>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
The code change itself looks fine.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
> drivers/platform/x86/amd/pmc.c | 53 ++++++++++++++++++++++++++--------
> 1 file changed, 41 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
> index c2f03cdc9ca9..f7bda8a64c95 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -45,7 +45,6 @@
> #define AMD_PMC_STB_DUMMY_PC 0xC6000007
>
> /* STB S2D(Spill to DRAM) has different message port offset */
> -#define STB_SPILL_TO_DRAM 0xBE
> #define AMD_S2D_REGISTER_MESSAGE 0xA20
> #define AMD_S2D_REGISTER_RESPONSE 0xA80
> #define AMD_S2D_REGISTER_ARGUMENT 0xA88
> @@ -99,7 +98,6 @@
> #define PMC_MSG_DELAY_MIN_US 50
> #define RESPONSE_REGISTER_LOOP_MAX 20000
>
> -#define SOC_SUBSYSTEM_IP_MAX 12
> #define DELAY_MIN_US 2000
> #define DELAY_MAX_US 3000
> #define FIFO_SIZE 4096
> @@ -133,9 +131,18 @@ static const struct amd_pmc_bit_map soc15_ip_blk[] = {
> {"ISP", BIT(6)},
> {"NBIO", BIT(7)},
> {"DF", BIT(8)},
> - {"USB0", BIT(9)},
> - {"USB1", BIT(10)},
> + {"USB3_0", BIT(9)},
> + {"USB3_1", BIT(10)},
> {"LAPIC", BIT(11)},
> + {"USB3_2", BIT(12)},
> + {"USB3_3", BIT(13)},
> + {"USB3_4", BIT(14)},
> + {"USB4_0", BIT(15)},
> + {"USB4_1", BIT(16)},
> + {"MPM", BIT(17)},
> + {"JPEG", BIT(18)},
> + {"IPU", BIT(19)},
> + {"UMSCH", BIT(20)},
> {}
> };
>
> @@ -149,6 +156,8 @@ struct amd_pmc_dev {
> u32 cpu_id;
> u32 active_ips;
> u32 dram_size;
> + u32 num_ips;
> + u32 s2d_msg_id;
> /* SMU version information */
> u8 smu_program;
> u8 major;
> @@ -196,8 +205,8 @@ struct smu_metrics {
> u64 timein_s0i3_totaltime;
> u64 timein_swdrips_lastcapture;
> u64 timein_swdrips_totaltime;
> - u64 timecondition_notmet_lastcapture[SOC_SUBSYSTEM_IP_MAX];
> - u64 timecondition_notmet_totaltime[SOC_SUBSYSTEM_IP_MAX];
> + u64 timecondition_notmet_lastcapture[32];
> + u64 timecondition_notmet_totaltime[32];
> } __packed;
>
> static int amd_pmc_stb_debugfs_open(struct inode *inode, struct file *filp)
> @@ -263,7 +272,7 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
> dev->msg_port = 1;
>
> /* Get the num_samples to calculate the last push location */
> - ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, STB_SPILL_TO_DRAM, true);
> + ret = amd_pmc_send_cmd(dev, S2D_NUM_SAMPLES, &num_samples, dev->s2d_msg_id, true);
> /* Clear msg_port for other SMU operation */
> dev->msg_port = 0;
> if (ret) {
> @@ -310,6 +319,23 @@ static const struct file_operations amd_pmc_stb_debugfs_fops_v2 = {
> .release = amd_pmc_stb_debugfs_release_v2,
> };
>
> +static void amd_pmc_get_ip_info(struct amd_pmc_dev *dev)
> +{
> + switch (dev->cpu_id) {
> + case AMD_CPU_ID_PCO:
> + case AMD_CPU_ID_RN:
> + case AMD_CPU_ID_YC:
> + case AMD_CPU_ID_CB:
> + dev->num_ips = 12;
> + dev->s2d_msg_id = 0xBE;
> + break;
> + case AMD_CPU_ID_PS:
> + dev->num_ips = 21;
> + dev->s2d_msg_id = 0x85;
> + break;
> + }
> +}
> +
> static int amd_pmc_setup_smu_logging(struct amd_pmc_dev *dev)
> {
> if (dev->cpu_id == AMD_CPU_ID_PCO) {
> @@ -471,7 +497,7 @@ static int smu_fw_info_show(struct seq_file *s, void *unused)
> table.timeto_resume_to_os_lastcapture);
>
> seq_puts(s, "\n=== Active time (in us) ===\n");
> - for (idx = 0 ; idx < SOC_SUBSYSTEM_IP_MAX ; idx++) {
> + for (idx = 0 ; idx < dev->num_ips ; idx++) {
> if (soc15_ip_blk[idx].bit_mask & dev->active_ips)
> seq_printf(s, "%-8s : %lld\n", soc15_ip_blk[idx].name,
> table.timecondition_notmet_lastcapture[idx]);
> @@ -919,7 +945,7 @@ static int amd_pmc_get_dram_size(struct amd_pmc_dev *dev)
> goto err_dram_size;
> }
>
> - ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, STB_SPILL_TO_DRAM, true);
> + ret = amd_pmc_send_cmd(dev, S2D_DRAM_SIZE, &dev->dram_size, dev->s2d_msg_id, true);
> if (ret || !dev->dram_size)
> goto err_dram_size;
>
> @@ -940,7 +966,10 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
> /* Spill to DRAM feature uses separate SMU message port */
> dev->msg_port = 1;
>
> - amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, STB_SPILL_TO_DRAM, true);
> + /* Get num of IP blocks within the SoC */
> + amd_pmc_get_ip_info(dev);
> +
> + amd_pmc_send_cmd(dev, S2D_TELEMETRY_SIZE, &size, dev->s2d_msg_id, true);
> if (size != S2D_TELEMETRY_BYTES_MAX)
> return -EIO;
>
> @@ -950,8 +979,8 @@ static int amd_pmc_s2d_init(struct amd_pmc_dev *dev)
> dev->dram_size = S2D_TELEMETRY_DRAMBYTES_MAX;
>
> /* Get STB DRAM address */
> - amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_LOW, &phys_addr_low, STB_SPILL_TO_DRAM, true);
> - amd_pmc_send_cmd(dev, S2D_PHYS_ADDR_HIGH, &phys_addr_hi, STB_SPILL_TO_DRAM, true);
> + 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);
>
> stb_phys_addr = ((u64)phys_addr_hi << 32 | phys_addr_low);
>
>
--
i.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v5 0/4] Updates to AMD PMC driver
2023-05-25 14:19 [PATCH v5 0/4] Updates to AMD PMC driver Shyam Sundar S K
` (3 preceding siblings ...)
2023-05-25 14:19 ` [PATCH v5 4/4] platform/x86/amd: pmc: Update metrics table info for Pink Sardine Shyam Sundar S K
@ 2023-05-25 14:24 ` Limonciello, Mario
2023-05-30 9:09 ` Hans de Goede
5 siblings, 0 replies; 9+ messages in thread
From: Limonciello, Mario @ 2023-05-25 14:24 UTC (permalink / raw)
To: S-k, Shyam-sundar, hdegoede@redhat.com, markgross@kernel.org
Cc: Goswami, Sanket, platform-driver-x86@vger.kernel.org
[AMD Official Use Only - General]
> -----Original Message-----
> From: S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>
> Sent: Thursday, May 25, 2023 9:19 AM
> To: hdegoede@redhat.com; markgross@kernel.org
> Cc: Goswami, Sanket <Sanket.Goswami@amd.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>; platform-driver-x86@vger.kernel.org; S-k,
> Shyam-sundar <Shyam-sundar.S-k@amd.com>
> Subject: [PATCH v5 0/4] Updates to AMD PMC driver
>
> Series includes fixes and feature updates to the PMC driver.
> Series has been split into 4 patches to incorporate the review
> remarks from v2.
>
> v5:
> - Change amd_pmc_is_cpu_supported() to amd_pmc_is_stb_supported()
>
> v4:
> - Based on review-hans branch
> - Address review remarks from Ilpo on the commit-msg and function names
>
> v3:
> - Based on review-hans branch
> - Pass true/false instead of 1/0 the amd_pmc_send_cmd()
> - Add helper for supported cpu id check as suggested by Ilpo.
>
> v2:
> - Based on review-hans branch
> - Add a switch for cpu-id check based on feedback from Mario.
>
> Shyam Sundar S K (4):
> platform/x86/amd: pmc: Pass true/false to bool argument
> platform/x86/amd: pmc: Get STB DRAM size from PMFW
> platform/x86/amd: pmc: Add helper function to check the cpu id
> platform/x86/amd: pmc: Update metrics table info for Pink Sardine
>
> drivers/platform/x86/amd/pmc.c | 123 ++++++++++++++++++++++++++---
> ----
> 1 file changed, 99 insertions(+), 24 deletions(-)
>
> --
> 2.25.1
For the series:
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH v5 0/4] Updates to AMD PMC driver
2023-05-25 14:19 [PATCH v5 0/4] Updates to AMD PMC driver Shyam Sundar S K
` (4 preceding siblings ...)
2023-05-25 14:24 ` [PATCH v5 0/4] Updates to AMD PMC driver Limonciello, Mario
@ 2023-05-30 9:09 ` Hans de Goede
5 siblings, 0 replies; 9+ messages in thread
From: Hans de Goede @ 2023-05-30 9:09 UTC (permalink / raw)
To: Shyam Sundar S K, markgross
Cc: Sanket.Goswami, mario.limonciello, platform-driver-x86
Hi,
On 5/25/23 16:19, Shyam Sundar S K wrote:
> Series includes fixes and feature updates to the PMC driver.
> Series has been split into 4 patches to incorporate the review
> remarks from v2.
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 it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
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
> v5:
> - Change amd_pmc_is_cpu_supported() to amd_pmc_is_stb_supported()
>
> v4:
> - Based on review-hans branch
> - Address review remarks from Ilpo on the commit-msg and function names
>
> v3:
> - Based on review-hans branch
> - Pass true/false instead of 1/0 the amd_pmc_send_cmd()
> - Add helper for supported cpu id check as suggested by Ilpo.
>
> v2:
> - Based on review-hans branch
> - Add a switch for cpu-id check based on feedback from Mario.
>
> Shyam Sundar S K (4):
> platform/x86/amd: pmc: Pass true/false to bool argument
> platform/x86/amd: pmc: Get STB DRAM size from PMFW
> platform/x86/amd: pmc: Add helper function to check the cpu id
> platform/x86/amd: pmc: Update metrics table info for Pink Sardine
>
> drivers/platform/x86/amd/pmc.c | 123 ++++++++++++++++++++++++++-------
> 1 file changed, 99 insertions(+), 24 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread