diff mbox series

[2/4] platform/x86/amd: pmc: Write dummy postcode into the STB DRAM

Message ID 20230125113127.3862898-3-Shyam-sundar.S-k@amd.com (mailing list archive)
State Changes Requested, archived
Headers show
Series Updates to amd_pmc driver | expand

Commit Message

Shyam Sundar S K Jan. 25, 2023, 11:31 a.m. UTC
Based on the recommendation from the PMFW team in order to get the
recent telemetry data present on the STB DRAM the driver is required
to send one dummy write to the STB buffer, so it internally triggers
the PMFW to emit the latest telemetry data in the STB DRAM region.

Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
 drivers/platform/x86/amd/pmc.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Mario Limonciello Jan. 25, 2023, 5:43 p.m. UTC | #1
[Public]



> -----Original Message-----
> From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> Sent: Wednesday, January 25, 2023 05:31
> To: hdegoede@redhat.com; markgross@kernel.org
> Cc: Goswami, Sanket <Sanket.Goswami@amd.com>; platform-driver-
> x86@vger.kernel.org; S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>
> Subject: [PATCH 2/4] platform/x86/amd: pmc: Write dummy postcode into
> the STB DRAM
> 
> Based on the recommendation from the PMFW team in order to get the
> recent telemetry data present on the STB DRAM the driver is required
> to send one dummy write to the STB buffer, so it internally triggers
> the PMFW to emit the latest telemetry data in the STB DRAM region.
> 
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
>  drivers/platform/x86/amd/pmc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/platform/x86/amd/pmc.c
> b/drivers/platform/x86/amd/pmc.c
> index 01632e6b7820..0dd9fb576f09 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -43,6 +43,7 @@
>  #define AMD_PMC_STB_S2IDLE_PREPARE	0xC6000001
>  #define AMD_PMC_STB_S2IDLE_RESTORE	0xC6000002
>  #define AMD_PMC_STB_S2IDLE_CHECK	0xC6000003
> +#define AMD_PMC_STB_DUMMY_PC		0xC6000007

Is there significance to this specific code? Any particular reason
not to pick an incremental code like 0xC6000004?

> 
>  /* STB S2D(Spill to DRAM) has different message port offset */
>  #define STB_SPILL_TO_DRAM		0xBE
> @@ -250,6 +251,11 @@ static int amd_pmc_stb_debugfs_open_v2(struct
> inode *inode, struct file *filp)
>  	u32 *buf, fsize, num_samples, stb_rdptr_offset = 0;
>  	int ret;
> 
> +	/* Write dummy postcode while reading the STB buffer */
> +	ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC);
> +	if (ret)
> +		dev_err(dev->dev, "error writing to STB: %d\n", ret);
> +
>  	buf = kzalloc(S2D_TELEMETRY_BYTES_MAX, GFP_KERNEL);
>  	if (!buf)
>  		return -ENOMEM;
> --
> 2.25.1
Shyam Sundar S K Jan. 26, 2023, 3:29 a.m. UTC | #2
On 1/25/2023 11:13 PM, Limonciello, Mario wrote:
> [Public]
> 
> 
> 
>> -----Original Message-----
>> From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
>> Sent: Wednesday, January 25, 2023 05:31
>> To: hdegoede@redhat.com; markgross@kernel.org
>> Cc: Goswami, Sanket <Sanket.Goswami@amd.com>; platform-driver-
>> x86@vger.kernel.org; S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>
>> Subject: [PATCH 2/4] platform/x86/amd: pmc: Write dummy postcode into
>> the STB DRAM
>>
>> Based on the recommendation from the PMFW team in order to get the
>> recent telemetry data present on the STB DRAM the driver is required
>> to send one dummy write to the STB buffer, so it internally triggers
>> the PMFW to emit the latest telemetry data in the STB DRAM region.
>>
>> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
>> ---
>>  drivers/platform/x86/amd/pmc.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/platform/x86/amd/pmc.c
>> b/drivers/platform/x86/amd/pmc.c
>> index 01632e6b7820..0dd9fb576f09 100644
>> --- a/drivers/platform/x86/amd/pmc.c
>> +++ b/drivers/platform/x86/amd/pmc.c
>> @@ -43,6 +43,7 @@
>>  #define AMD_PMC_STB_S2IDLE_PREPARE	0xC6000001
>>  #define AMD_PMC_STB_S2IDLE_RESTORE	0xC6000002
>>  #define AMD_PMC_STB_S2IDLE_CHECK	0xC6000003
>> +#define AMD_PMC_STB_DUMMY_PC		0xC6000007
> 
> Is there significance to this specific code? Any particular reason
> not to pick an incremental code like 0xC6000004?

Wanted to just keep in inline with Windows code atleast w.r.t to this
dummy postcode. However, if you think it does not make sense I can
change it to incremental one.

Thanks,
Shyam


> 
>>
>>  /* STB S2D(Spill to DRAM) has different message port offset */
>>  #define STB_SPILL_TO_DRAM		0xBE
>> @@ -250,6 +251,11 @@ static int amd_pmc_stb_debugfs_open_v2(struct
>> inode *inode, struct file *filp)
>>  	u32 *buf, fsize, num_samples, stb_rdptr_offset = 0;
>>  	int ret;
>>
>> +	/* Write dummy postcode while reading the STB buffer */
>> +	ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC);
>> +	if (ret)
>> +		dev_err(dev->dev, "error writing to STB: %d\n", ret);
>> +
>>  	buf = kzalloc(S2D_TELEMETRY_BYTES_MAX, GFP_KERNEL);
>>  	if (!buf)
>>  		return -ENOMEM;
>> --
>> 2.25.1
Mario Limonciello Jan. 26, 2023, 3:37 a.m. UTC | #3
On 1/25/23 21:29, Shyam Sundar S K wrote:
> 
> 
> On 1/25/2023 11:13 PM, Limonciello, Mario wrote:
>> [Public]
>>
>>
>>
>>> -----Original Message-----
>>> From: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
>>> Sent: Wednesday, January 25, 2023 05:31
>>> To: hdegoede@redhat.com; markgross@kernel.org
>>> Cc: Goswami, Sanket <Sanket.Goswami@amd.com>; platform-driver-
>>> x86@vger.kernel.org; S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>
>>> Subject: [PATCH 2/4] platform/x86/amd: pmc: Write dummy postcode into
>>> the STB DRAM
>>>
>>> Based on the recommendation from the PMFW team in order to get the
>>> recent telemetry data present on the STB DRAM the driver is required
>>> to send one dummy write to the STB buffer, so it internally triggers
>>> the PMFW to emit the latest telemetry data in the STB DRAM region.
>>>
>>> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
>>> ---
>>>   drivers/platform/x86/amd/pmc.c | 6 ++++++
>>>   1 file changed, 6 insertions(+)
>>>
>>> diff --git a/drivers/platform/x86/amd/pmc.c
>>> b/drivers/platform/x86/amd/pmc.c
>>> index 01632e6b7820..0dd9fb576f09 100644
>>> --- a/drivers/platform/x86/amd/pmc.c
>>> +++ b/drivers/platform/x86/amd/pmc.c
>>> @@ -43,6 +43,7 @@
>>>   #define AMD_PMC_STB_S2IDLE_PREPARE	0xC6000001
>>>   #define AMD_PMC_STB_S2IDLE_RESTORE	0xC6000002
>>>   #define AMD_PMC_STB_S2IDLE_CHECK	0xC6000003
>>> +#define AMD_PMC_STB_DUMMY_PC		0xC6000007
>>
>> Is there significance to this specific code? Any particular reason
>> not to pick an incremental code like 0xC6000004?
> 
> Wanted to just keep in inline with Windows code atleast w.r.t to this
> dummy postcode. However, if you think it does not make sense I can
> change it to incremental one.
> 

That's a great reason to keep it this way.  People who look at the STB 
can have familiarity on the milestones they see.

If there are other ones that are used for Windows in similar vain across 
suspend/restore as the 3 that we have today we should adjust those too.

> Thanks,
> Shyam
> 
> 
>>
>>>
>>>   /* STB S2D(Spill to DRAM) has different message port offset */
>>>   #define STB_SPILL_TO_DRAM		0xBE
>>> @@ -250,6 +251,11 @@ static int amd_pmc_stb_debugfs_open_v2(struct
>>> inode *inode, struct file *filp)
>>>   	u32 *buf, fsize, num_samples, stb_rdptr_offset = 0;
>>>   	int ret;
>>>
>>> +	/* Write dummy postcode while reading the STB buffer */
>>> +	ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC);
>>> +	if (ret)
>>> +		dev_err(dev->dev, "error writing to STB: %d\n", ret);
>>> +
>>>   	buf = kzalloc(S2D_TELEMETRY_BYTES_MAX, GFP_KERNEL);
>>>   	if (!buf)
>>>   		return -ENOMEM;
>>> --
>>> 2.25.1
Hans de Goede Jan. 30, 2023, 2:42 p.m. UTC | #4
Hi,

On 1/25/23 12:31, Shyam Sundar S K wrote:
> Based on the recommendation from the PMFW team in order to get the
> recent telemetry data present on the STB DRAM the driver is required
> to send one dummy write to the STB buffer, so it internally triggers
> the PMFW to emit the latest telemetry data in the STB DRAM region.
> 
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/platform/x86/amd/pmc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
> index 01632e6b7820..0dd9fb576f09 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -43,6 +43,7 @@
>  #define AMD_PMC_STB_S2IDLE_PREPARE	0xC6000001
>  #define AMD_PMC_STB_S2IDLE_RESTORE	0xC6000002
>  #define AMD_PMC_STB_S2IDLE_CHECK	0xC6000003
> +#define AMD_PMC_STB_DUMMY_PC		0xC6000007
>  
>  /* STB S2D(Spill to DRAM) has different message port offset */
>  #define STB_SPILL_TO_DRAM		0xBE
> @@ -250,6 +251,11 @@ static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
>  	u32 *buf, fsize, num_samples, stb_rdptr_offset = 0;
>  	int ret;
>  
> +	/* Write dummy postcode while reading the STB buffer */
> +	ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC);
> +	if (ret)
> +		dev_err(dev->dev, "error writing to STB: %d\n", ret);
> +
>  	buf = kzalloc(S2D_TELEMETRY_BYTES_MAX, GFP_KERNEL);
>  	if (!buf)
>  		return -ENOMEM;
diff mbox series

Patch

diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index 01632e6b7820..0dd9fb576f09 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -43,6 +43,7 @@ 
 #define AMD_PMC_STB_S2IDLE_PREPARE	0xC6000001
 #define AMD_PMC_STB_S2IDLE_RESTORE	0xC6000002
 #define AMD_PMC_STB_S2IDLE_CHECK	0xC6000003
+#define AMD_PMC_STB_DUMMY_PC		0xC6000007
 
 /* STB S2D(Spill to DRAM) has different message port offset */
 #define STB_SPILL_TO_DRAM		0xBE
@@ -250,6 +251,11 @@  static int amd_pmc_stb_debugfs_open_v2(struct inode *inode, struct file *filp)
 	u32 *buf, fsize, num_samples, stb_rdptr_offset = 0;
 	int ret;
 
+	/* Write dummy postcode while reading the STB buffer */
+	ret = amd_pmc_write_stb(dev, AMD_PMC_STB_DUMMY_PC);
+	if (ret)
+		dev_err(dev->dev, "error writing to STB: %d\n", ret);
+
 	buf = kzalloc(S2D_TELEMETRY_BYTES_MAX, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;