Re: [PATCH] platform/x86/amd/pmf: Add support for notifying Smart PC Solution updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On 8/12/24 3:18 PM, Shyam Sundar S K wrote:
> The APMF function 14 (Notify Smart PC Solution Updates) allows the BIOS
> (AMD/OEM) to be informed about the outputs of custom Smart PC policies.
> Enhance the PMF driver to invoke APMF function 14 when these custom policy
> outputs are triggered.
> 
> Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@xxxxxxx>
> Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@xxxxxxx>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@xxxxxxx>

Thank you for your patch, I've applied this patch 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


> ---
>  drivers/platform/x86/amd/pmf/acpi.c   | 31 +++++++++++++++++++++
>  drivers/platform/x86/amd/pmf/pmf.h    | 18 ++++++++++++
>  drivers/platform/x86/amd/pmf/tee-if.c | 40 +++++++++++++++++++++++++++
>  3 files changed, 89 insertions(+)
> 
> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> index 1157ec148880..d5b496433d69 100644
> --- a/drivers/platform/x86/amd/pmf/acpi.c
> +++ b/drivers/platform/x86/amd/pmf/acpi.c
> @@ -282,6 +282,29 @@ int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx)
>  	return 0;
>  }
>  
> +static int apmf_notify_smart_pc_update(struct amd_pmf_dev *pdev, u32 val, u32 preq, u32 index)
> +{
> +	struct amd_pmf_notify_smart_pc_update args;
> +	struct acpi_buffer params;
> +	union acpi_object *info;
> +
> +	args.size = sizeof(args);
> +	args.pending_req = preq;
> +	args.custom_bios[index] = val;
> +
> +	params.length = sizeof(args);
> +	params.pointer = &args;
> +
> +	info = apmf_if_call(pdev, APMF_FUNC_NOTIFY_SMART_PC_UPDATES, &params);
> +	if (!info)
> +		return -EIO;
> +
> +	kfree(info);
> +	dev_dbg(pdev->dev, "Notify smart pc update, val: %u\n", val);
> +
> +	return 0;
> +}
> +
>  int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data)
>  {
>  	return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data));
> @@ -447,6 +470,14 @@ int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev)
>  	return 0;
>  }
>  
> +int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq, u32 idx)
> +{
> +	if (!is_apmf_func_supported(dev, APMF_FUNC_NOTIFY_SMART_PC_UPDATES))
> +		return -EINVAL;
> +
> +	return apmf_notify_smart_pc_update(dev, val, preq, idx);
> +}
> +
>  void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
>  {
>  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index 753d5662c080..9bf4326d06c3 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -35,6 +35,7 @@ struct cookie_header {
>  #define APMF_FUNC_STATIC_SLIDER_GRANULAR       9
>  #define APMF_FUNC_DYN_SLIDER_AC				11
>  #define APMF_FUNC_DYN_SLIDER_DC				12
> +#define APMF_FUNC_NOTIFY_SMART_PC_UPDATES		14
>  #define APMF_FUNC_SBIOS_HEARTBEAT_V2			16
>  
>  /* Message Definitions */
> @@ -82,7 +83,17 @@ struct cookie_header {
>  #define PMF_POLICY_STT_SKINTEMP_APU				7
>  #define PMF_POLICY_STT_SKINTEMP_HS2				8
>  #define PMF_POLICY_SYSTEM_STATE					9
> +#define PMF_POLICY_BIOS_OUTPUT_1				10
> +#define PMF_POLICY_BIOS_OUTPUT_2				11
>  #define PMF_POLICY_P3T						38
> +#define PMF_POLICY_BIOS_OUTPUT_3				57
> +#define PMF_POLICY_BIOS_OUTPUT_4				58
> +#define PMF_POLICY_BIOS_OUTPUT_5				59
> +#define PMF_POLICY_BIOS_OUTPUT_6				60
> +#define PMF_POLICY_BIOS_OUTPUT_7				61
> +#define PMF_POLICY_BIOS_OUTPUT_8				62
> +#define PMF_POLICY_BIOS_OUTPUT_9				63
> +#define PMF_POLICY_BIOS_OUTPUT_10				64
>  
>  /* TA macros */
>  #define PMF_TA_IF_VERSION_MAJOR				1
> @@ -344,6 +355,12 @@ struct os_power_slider {
>  	u8 slider_event;
>  } __packed;
>  
> +struct amd_pmf_notify_smart_pc_update {
> +	u16 size;
> +	u32 pending_req;
> +	u32 custom_bios[10];
> +} __packed;
> +
>  struct fan_table_control {
>  	bool manual;
>  	unsigned long fan_id;
> @@ -717,6 +734,7 @@ extern const struct attribute_group cnqf_feature_attribute_group;
>  int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev);
>  void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev);
>  int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev);
> +int amd_pmf_smartpc_apply_bios_output(struct amd_pmf_dev *dev, u32 val, u32 preq, u32 idx);
>  
>  /* Smart PC - TA interfaces */
>  void amd_pmf_populate_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in);
> diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
> index e246367aacee..19c27b6e4666 100644
> --- a/drivers/platform/x86/amd/pmf/tee-if.c
> +++ b/drivers/platform/x86/amd/pmf/tee-if.c
> @@ -160,6 +160,46 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
>  			dev_dbg(dev->dev, "update SYSTEM_STATE: %s\n",
>  				amd_pmf_uevent_as_str(val));
>  			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_1:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(0), 0);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_2:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(1), 1);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_3:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(2), 2);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_4:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(3), 3);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_5:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(4), 4);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_6:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(5), 5);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_7:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(6), 6);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_8:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(7), 7);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_9:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(8), 8);
> +			break;
> +
> +		case PMF_POLICY_BIOS_OUTPUT_10:
> +			amd_pmf_smartpc_apply_bios_output(dev, val, BIT(9), 9);
> +			break;
>  		}
>  	}
>  }





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux