X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	platform-driver-x86@vger.kernel.org,  Patil.Reddy@amd.com,
	mario.limonciello@amd.com, Yijun.Shen@dell.com,
	 Sanket Goswami <Sanket.Goswami@amd.com>
Subject: Re: [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism
Date: Mon, 30 Jun 2025 16:16:04 +0300 (EEST)	[thread overview]
Message-ID: <e165a766-ff44-f29a-5b10-4f88b07b7cd6@linux.intel.com> (raw)
In-Reply-To: <20250617071413.3906284-3-Shyam-sundar.S-k@amd.com>

On Tue, 17 Jun 2025, Shyam Sundar S K wrote:

> Originally, the 'amd_pmf_get_custom_bios_inputs()' function was written
> under the assumption that the BIOS would only send a single pending
> request for the driver to process. However, following OEM enablement, it
> became clear that multiple pending requests for custom BIOS inputs might
> be sent at the same time, a scenario that the current code logic does not
> support when it comes to handling multiple custom BIOS inputs.
> 
> To address this, the code logic needs to be improved to not only manage
> multiple simultaneous custom BIOS inputs but also to ensure it is scalable
> for future additional inputs.
> 
> Cc: Patil Rajesh Reddy <Patil.Reddy@amd.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/pmf/pmf.h | 12 ++++++------
>  drivers/platform/x86/amd/pmf/spc.c | 15 ++++++---------
>  2 files changed, 12 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 1a5a8d70c360..696b170255e0 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -623,14 +623,14 @@ enum ta_slider {
>  	TA_MAX,
>  };
>  
> -enum apmf_smartpc_custom_bios_inputs {
> -	APMF_SMARTPC_CUSTOM_BIOS_INPUT1,
> -	APMF_SMARTPC_CUSTOM_BIOS_INPUT2,
> +struct amd_pmf_pb_bitmap {
> +	const char *name;
> +	u32 bit_mask;
>  };
>  
> -enum apmf_preq_smartpc {
> -	NOTIFY_CUSTOM_BIOS_INPUT1 = 5,
> -	NOTIFY_CUSTOM_BIOS_INPUT2,
> +static const struct amd_pmf_pb_bitmap custom_bios_inputs[] __used = {
> +	{"NOTIFY_CUSTOM_BIOS_INPUT1",     BIT(5)},
> +	{"NOTIFY_CUSTOM_BIOS_INPUT2",     BIT(6)},
>  };
>  
>  enum platform_type {
> diff --git a/drivers/platform/x86/amd/pmf/spc.c b/drivers/platform/x86/amd/pmf/spc.c
> index 1d90f9382024..e72c11aba31d 100644
> --- a/drivers/platform/x86/amd/pmf/spc.c
> +++ b/drivers/platform/x86/amd/pmf/spc.c
> @@ -101,18 +101,15 @@ void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *
>  static void amd_pmf_get_custom_bios_inputs(struct amd_pmf_dev *pdev,
>  					   struct ta_pmf_enact_table *in)
>  {
> +	u32 *bios_inputs[] = {&in->ev_info.bios_input1, &in->ev_info.bios_input2};
> +	int i;
> +
>  	if (!pdev->req.pending_req)
>  		return;
>  
> -	switch (pdev->req.pending_req) {
> -	case BIT(NOTIFY_CUSTOM_BIOS_INPUT1):
> -		in->ev_info.bios_input1 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT1];
> -		break;
> -	case BIT(NOTIFY_CUSTOM_BIOS_INPUT2):
> -		in->ev_info.bios_input2 = pdev->req.custom_policy[APMF_SMARTPC_CUSTOM_BIOS_INPUT2];
> -		break;
> -	default:
> -		dev_dbg(pdev->dev, "Invalid preq for BIOS input: 0x%x\n", pdev->req.pending_req);
> +	for (i = 0; i < ARRAY_SIZE(custom_bios_inputs); i++) {
> +		if (pdev->req.pending_req & custom_bios_inputs[i].bit_mask)
> +			*bios_inputs[i] = pdev->req.custom_policy[i];

Hi,

After seeing this version, I think there's better way to solve the 
discontinous layout problem.

Could you instead add a helper amd_pmf_set_ta_bios_input() or something 
along those lines. With that, you don't need to add that local array at 
all. I'd also convert bios_input1/2 to array so both are arrays (I 
understand you cannot change the layout and merge the arrays). The 
helper can then pick which of the arrays it should set to based on the 
index.

And briefly mention in the helper's function comment, that we need to do 
this because the layout does not have continuous area for bios inputs.

That seems simpler approach than this local array approach.

-- 
 i.


  reply	other threads:[~2025-06-30 13:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17  7:14 [PATCH v2 0/9] Enhancements to PMF Driver for Improved Custom BIOS Input Handling Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 1/9] platform/x86/amd/pmf: Add support for adjusting PMF PPT and PPT APU thresholds Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 2/9] platform/x86/amd/pmf: Fix the custom bios input handling mechanism Shyam Sundar S K
2025-06-30 13:16   ` Ilpo Järvinen [this message]
2025-07-23  6:48     ` Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 3/9] platform/x86/amd/pmf: Extend custom BIOS inputs for more policies Shyam Sundar S K
2025-06-30 13:18   ` Ilpo Järvinen
2025-06-17  7:14 ` [PATCH v2 4/9] platform/x86/amd/pmf: Update ta_pmf_action structure member Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 5/9] platform/x86/amd/pmf: Add helper to verify BIOS input notifications are enable/disable Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 6/9] platform/x86/amd/pmf: Add custom BIOS input support for AMD_CPU_ID_PS Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 7/9] platform/x86/amd/pmf: Preserve custom BIOS inputs for evaluating the policies Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 8/9] platform/x86/amd/pmf: Call enact function sooner to process early pending requests Shyam Sundar S K
2025-06-17  7:14 ` [PATCH v2 9/9] platform/x86/amd/pmf: Add debug logs for pending requests and custom BIOS inputs Shyam Sundar S K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e165a766-ff44-f29a-5b10-4f88b07b7cd6@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Patil.Reddy@amd.com \
    --cc=Sanket.Goswami@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=Yijun.Shen@dell.com \
    --cc=hdegoede@redhat.com \
    --cc=mario.limonciello@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox