All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com
Cc: platform-driver-x86@vger.kernel.org, Patil.Reddy@amd.com
Subject: Re: [PATCH RESEND v2 4/7] platform/x86/amd/pmf: Add support to notify sbios heart beat event
Date: Thu, 29 Feb 2024 09:24:48 -0800	[thread overview]
Message-ID: <6f3f3240-ee75-4d52-8d38-5e6d10dfa714@linux.intel.com> (raw)
In-Reply-To: <20240229105901.455467-5-Shyam-sundar.S-k@amd.com>


On 2/29/24 2:58 AM, Shyam Sundar S K wrote:
> Add support for newer revision of the heart beat notify events.
> This event is used to notify to the OEM BIOS on driver
> load/unload/suspend/resume scenarios.
>
> If OEM BIOS does not receive the heart beat event from PMF driver, OEM
> BIOS shall conclude that PMF driver is no more active and BIOS will
> update to the legacy system power thermals.
>
> Co-developed-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
> Signed-off-by: Patil Rajesh Reddy <Patil.Reddy@amd.com>
> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> ---
Looks good to me.

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>  drivers/platform/x86/amd/pmf/acpi.c | 41 +++++++++++++++++++++++++++--
>  drivers/platform/x86/amd/pmf/core.c | 10 +++++++
>  drivers/platform/x86/amd/pmf/pmf.h  | 17 ++++++++++++
>  3 files changed, 66 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c
> index 13af83b187ac..f0360eea81e6 100644
> --- a/drivers/platform/x86/amd/pmf/acpi.c
> +++ b/drivers/platform/x86/amd/pmf/acpi.c
> @@ -140,6 +140,43 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work)
>  	kfree(info);
>  }
>  
> +int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag)
> +{
> +	struct sbios_hb_event_v2 args = { };
> +	struct acpi_buffer params;
> +	union acpi_object *info;
> +
> +	args.size = sizeof(args);
> +
> +	switch (flag) {
> +	case ON_LOAD:
> +		args.load = 1;
> +		break;
> +	case ON_UNLOAD:
> +		args.unload = 1;
> +		break;
> +	case ON_SUSPEND:
> +		args.suspend = 1;
> +		break;
> +	case ON_RESUME:
> +		args.resume = 1;
> +		break;
> +	default:
> +		dev_dbg(dev->dev, "Failed to send v2 heartbeat event, flag:0x%x\n", flag);
> +		return -EINVAL;
> +	}
> +
> +	params.length = sizeof(args);
> +	params.pointer = &args;
> +
> +	info = apmf_if_call(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2, &params);
> +	if (!info)
> +		return -EIO;
> +
> +	kfree(info);
> +	return 0;
> +}
> +
>  int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx)
>  {
>  	union acpi_object *info;
> @@ -327,7 +364,7 @@ void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev)
>  {
>  	acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev);
>  
> -	if (pmf_dev->hb_interval)
> +	if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1)
>  		cancel_delayed_work_sync(&pmf_dev->heart_beat);
>  
>  	if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) &&
> @@ -351,7 +388,7 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev)
>  		goto out;
>  	}
>  
> -	if (pmf_dev->hb_interval) {
> +	if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) {
>  		/* send heartbeats only if the interval is not zero */
>  		INIT_DELAYED_WORK(&pmf_dev->heart_beat, apmf_sbios_heartbeat_notify);
>  		schedule_delayed_work(&pmf_dev->heart_beat, 0);
> diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c
> index 2230bc2b1f59..5e52eb32ab2b 100644
> --- a/drivers/platform/x86/amd/pmf/core.c
> +++ b/drivers/platform/x86/amd/pmf/core.c
> @@ -300,6 +300,9 @@ static int amd_pmf_suspend_handler(struct device *dev)
>  	if (pdev->smart_pc_enabled)
>  		cancel_delayed_work_sync(&pdev->pb_work);
>  
> +	if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
> +		amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_SUSPEND);
> +
>  	return 0;
>  }
>  
> @@ -317,6 +320,9 @@ static int amd_pmf_resume_handler(struct device *dev)
>  	if (pdev->smart_pc_enabled)
>  		schedule_delayed_work(&pdev->pb_work, msecs_to_jiffies(2000));
>  
> +	if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
> +		amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_RESUME);
> +
>  	return 0;
>  }
>  
> @@ -444,6 +450,8 @@ static int amd_pmf_probe(struct platform_device *pdev)
>  	amd_pmf_dbgfs_register(dev);
>  	amd_pmf_init_features(dev);
>  	apmf_install_handler(dev);
> +	if (is_apmf_func_supported(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
> +		amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_LOAD);
>  
>  	dev_info(dev->dev, "registered PMF device successfully\n");
>  
> @@ -455,6 +463,8 @@ static void amd_pmf_remove(struct platform_device *pdev)
>  	struct amd_pmf_dev *dev = platform_get_drvdata(pdev);
>  
>  	amd_pmf_deinit_features(dev);
> +	if (is_apmf_func_supported(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2))
> +		amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_UNLOAD);
>  	apmf_acpi_deinit(dev);
>  	amd_pmf_dbgfs_unregister(dev);
>  	mutex_destroy(&dev->lock);
> diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h
> index f11d2a348696..5cad11369697 100644
> --- a/drivers/platform/x86/amd/pmf/pmf.h
> +++ b/drivers/platform/x86/amd/pmf/pmf.h
> @@ -30,6 +30,7 @@
>  #define APMF_FUNC_STATIC_SLIDER_GRANULAR       9
>  #define APMF_FUNC_DYN_SLIDER_AC				11
>  #define APMF_FUNC_DYN_SLIDER_DC				12
> +#define APMF_FUNC_SBIOS_HEARTBEAT_V2			16
>  
>  /* Message Definitions */
>  #define SET_SPL				0x03 /* SPL: Sustained Power Limit */
> @@ -85,6 +86,21 @@
>  
>  #define PMF_IF_V1		1
>  
> +struct sbios_hb_event_v2 {
> +	u16 size;
> +	u8 load;
> +	u8 unload;
> +	u8 suspend;
> +	u8 resume;
> +} __packed;
> +
> +enum sbios_hb_v2 {
> +	ON_LOAD,
> +	ON_UNLOAD,
> +	ON_SUSPEND,
> +	ON_RESUME,
> +};
> +
>  /* AMD PMF BIOS interfaces */
>  struct apmf_verify_interface {
>  	u16 size;
> @@ -600,6 +616,7 @@ int amd_pmf_get_power_source(void);
>  int apmf_install_handler(struct amd_pmf_dev *pmf_dev);
>  int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag);
>  int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer);
> +int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag);
>  
>  /* SPS Layer */
>  int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf);

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


  reply	other threads:[~2024-02-29 17:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29 10:58 [PATCH RESEND v2 0/7] platform/x86/amd/pmf: Updates to amd-pmf Shyam Sundar S K
2024-02-29 10:58 ` [PATCH RESEND v2 1/7] platform/x86/amd/pmf: Differentiate PMF ACPI versions Shyam Sundar S K
2024-02-29 10:58 ` [PATCH RESEND v2 2/7] platform/x86/amd/pmf: Disable debugfs support for querying power thermals Shyam Sundar S K
2024-02-29 17:20   ` Kuppuswamy Sathyanarayanan
2024-02-29 10:58 ` [PATCH RESEND v2 3/7] platform/x86/amd/pmf: Add support to get sbios requests in PMF driver Shyam Sundar S K
2024-02-29 10:58 ` [PATCH RESEND v2 4/7] platform/x86/amd/pmf: Add support to notify sbios heart beat event Shyam Sundar S K
2024-02-29 17:24   ` Kuppuswamy Sathyanarayanan [this message]
2024-02-29 10:58 ` [PATCH RESEND v2 5/7] platform/x86/amd/pmf: Add support to get APTS index numbers for static slider Shyam Sundar S K
2024-03-04 13:38   ` Ilpo Järvinen
2024-02-29 10:59 ` [PATCH RESEND v2 6/7] platform/x86/amd/pmf: Add support to get sps default APTS index values Shyam Sundar S K
2024-02-29 10:59 ` [PATCH RESEND v2 7/7] platform/x86/amd/pmf: Update sps power thermals according to the platform-profiles 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=6f3f3240-ee75-4d52-8d38-5e6d10dfa714@linux.intel.com \
    --to=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=Patil.Reddy@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.