All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Muthusamy Ramalingam <Muthusamy.Ramalingam@amd.com>
Cc: platform-driver-x86@vger.kernel.org, Suma.Hegde@amd.com,
	 NaveenKrishna.Chatradhi@amd.com
Subject: Re: [PATCH 06/26] platform/x86/amd/hsmp: Add sdps_limit sysfs file
Date: Mon, 23 Nov 2026 13:15:20 +0200 (EET)	[thread overview]
Message-ID: <487b3b7c-c5c2-d51b-d5c0-9fed82ef604a@linux.intel.com> (raw)
In-Reply-To: <6f2d944db032009390ad2d47ef78c1d1b02e7fe5.1793602633.git.Muthusamy.Ramalingam@amd.com>

On Mon, 2 Nov 2026, Muthusamy Ramalingam wrote:

> Expose HSMP_SDPS_LIMIT as a read/write socket file on both the ACPI
> and platform drivers. For a read, set bit 31. For a write, reset bit
> 31 and store the limit in bits [30:0]. A write accepts any value that
> fits in that field. Firmware clamps it to the platform range.
> 
> Co-developed-by: Suma Hegde <Suma.Hegde@amd.com>
> Signed-off-by: Suma Hegde <Suma.Hegde@amd.com>
> Signed-off-by: Muthusamy Ramalingam <Muthusamy.Ramalingam@amd.com>
> ---
>  Documentation/arch/x86/amd_hsmp.rst   |  2 +
>  drivers/platform/x86/amd/hsmp/acpi.c  |  3 ++
>  drivers/platform/x86/amd/hsmp/plat.c  |  3 ++
>  drivers/platform/x86/amd/hsmp/sysfs.c | 67 +++++++++++++++++++++++++++
>  drivers/platform/x86/amd/hsmp/sysfs.h |  4 ++
>  5 files changed, 79 insertions(+)
> 
> diff --git a/Documentation/arch/x86/amd_hsmp.rst b/Documentation/arch/x86/amd_hsmp.rst
> index 44a7da87e5907..1fc4727b48726 100644
> --- a/Documentation/arch/x86/amd_hsmp.rst
> +++ b/Documentation/arch/x86/amd_hsmp.rst
> @@ -117,6 +117,8 @@ write-only when the platform enables only that direction of the message.
>  * socket_power: Average package power in mWatts (read only).
>  * socket_power_limit: Current socket power limit in mWatts. A write is a
>    32-bit value. Firmware clamps it to the platform range.
> +* sdps_limit: Read/write SDPS limit in mWatts. A write uses bits [30:0].
> +  Firmware clamps it to the platform range.
>  * socket_power_limit_max: Maximum socket power limit in mWatts (read only).
>  * cclk_boost_limit: Socket boost limit in MHz (write only). Accepted range
>    is 100-10000 MHz.
> diff --git a/drivers/platform/x86/amd/hsmp/acpi.c b/drivers/platform/x86/amd/hsmp/acpi.c
> index 6bbcc2f7e6a30..4c9f6c6843304 100644
> --- a/drivers/platform/x86/amd/hsmp/acpi.c
> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
> @@ -537,6 +537,8 @@ HSMP_DEV_ATTR(tdelta, HSMP_READ_TDELTA, hsmp_msg_resp32_show, 0444);
>  HSMP_DEV_ATTR_RW(socket_power_limit, HSMP_GET_SOCKET_POWER_LIMIT,
>  		 HSMP_SET_SOCKET_POWER_LIMIT,
>  		 hsmp_socket_power_limit_show, hsmp_socket_power_limit_store, 0644);
> +HSMP_DEV_ATTR_RW(sdps_limit, HSMP_SDPS_LIMIT, HSMP_SDPS_LIMIT,
> +		 hsmp_sdps_limit_show, hsmp_sdps_limit_store, 0644);
>  HSMP_DEV_ATTR_W(cclk_boost_limit, HSMP_SET_BOOST_LIMIT_SOCKET,
>  		hsmp_cclk_boost_limit_store, 0200);
>  HSMP_DEV_ATTR_RW(apb_disable, HSMP_SET_DF_PSTATE, HSMP_SET_DF_PSTATE,
> @@ -568,6 +570,7 @@ static struct attribute *hsmp_dev_attr_list[] = {
>  	&hattr_pwr_current_active_freq_limit_source.dattr.attr,
>  	&hattr_socket_power_limit_max.dattr.attr,
>  	&hattr_socket_power_limit.dattr.attr,
> +	&hattr_sdps_limit.dattr.attr,
>  	&hattr_socket_power.dattr.attr,
>  	&hattr_cclk_boost_limit.dattr.attr,
>  	&hattr_tdelta.dattr.attr,
> diff --git a/drivers/platform/x86/amd/hsmp/plat.c b/drivers/platform/x86/amd/hsmp/plat.c
> index ba8274e5bfb4a..6f4250cfc1f4a 100644
> --- a/drivers/platform/x86/amd/hsmp/plat.c
> +++ b/drivers/platform/x86/amd/hsmp/plat.c
> @@ -371,6 +371,8 @@ HSMP_DEV_ATTR_RW_X8(socket_power_limit, HSMP_GET_SOCKET_POWER_LIMIT,
>  		    HSMP_SET_SOCKET_POWER_LIMIT,
>  		    hsmp_socket_power_limit_show,
>  		    hsmp_socket_power_limit_store, 0644);
> +HSMP_DEV_ATTR_RW_X8(sdps_limit, HSMP_SDPS_LIMIT, HSMP_SDPS_LIMIT,
> +		    hsmp_sdps_limit_show, hsmp_sdps_limit_store, 0644);
>  HSMP_DEV_ATTR_X8(socket_power, HSMP_GET_SOCKET_POWER, hsmp_msg_resp32_show,
>  		 0444);
>  HSMP_DEV_ATTR_W_X8(cclk_boost_limit, HSMP_SET_BOOST_LIMIT_SOCKET,
> @@ -407,6 +409,7 @@ static struct attribute _name[] = {					       \
>  	&hattr_pwr_current_active_freq_limit_source##_sock_ind.dattr.attr,     \
>  	&hattr_socket_power_limit_max##_sock_ind.dattr.attr,		       \
>  	&hattr_socket_power_limit##_sock_ind.dattr.attr,		       \
> +	&hattr_sdps_limit##_sock_ind.dattr.attr,			       \
>  	&hattr_socket_power##_sock_ind.dattr.attr,			       \
>  	&hattr_cclk_boost_limit##_sock_ind.dattr.attr,		       \
>  	&hattr_tdelta##_sock_ind.dattr.attr,				       \
> diff --git a/drivers/platform/x86/amd/hsmp/sysfs.c b/drivers/platform/x86/amd/hsmp/sysfs.c
> index bc1b349468978..01363b0b92fd7 100644
> --- a/drivers/platform/x86/amd/hsmp/sysfs.c
> +++ b/drivers/platform/x86/amd/hsmp/sysfs.c
> @@ -629,6 +629,73 @@ ssize_t hsmp_socket_power_limit_store(struct device *dev,
>  	return count;
>  }
>  
> +/* SDPS limit show function - reads current SDPS limit */
> +ssize_t hsmp_sdps_limit_show(struct device *dev,
> +			     struct device_attribute *attr,
> +			     char *buf)
> +{
> +	struct hsmp_sys_attr *hattr = to_hsmp_sys_attr(attr);
> +	struct hsmp_message msg = {};
> +	int ret;
> +
> +	/* Set bit 31 to indicate GET operation for HSMP_SET_GET type messages */
> +	msg.msg_id = HSMP_SDPS_LIMIT;
> +	msg.sock_ind = hsmp_sysfs_sock_ind(dev, hattr);
> +	msg.num_args = 1;
> +	msg.response_sz = 1;
> +	msg.args[0] = BIT(31);  /* GET operation */

Don't we have a define for this? CHECK_GET_BIT? Though that looks
suboptimally named, its "GET_BIT", not "CHECK" except when used for 
checking, so you might want to refactor that

Get rid of comments telling what the define name already tells us (x2).

> +
> +	ret = hsmp_send_message(&msg);
> +	if (ret)
> +		return ret;
> +
> +	/* Return current SDPS limit in mWatts (bits [30:0]) */
> +	return sysfs_emit(buf, "%lu\n", msg.args[0] & GENMASK(30, 0));

Add a proper named define for this, do not extract fields with inline 
genmasks. The comment is then quite unnecessary (if something has to be 
added, put it next to the define).

> +}
> +
> +/* SDPS limit store function - sets SDPS limit */
> +ssize_t hsmp_sdps_limit_store(struct device *dev,
> +			      struct device_attribute *attr,
> +			      const char *buf, size_t count)
> +{
> +	struct hsmp_sys_attr *hattr = to_hsmp_sys_attr(attr);
> +	struct hsmp_message msg = {};
> +	unsigned long val;
> +	int ret;
> +
> +	ret = kstrtoul(buf, 10, &val);
> +	if (ret) {
> +		hsmp_err(dev, "sdps_limit", HSMP_ERR_PARSE, "unit=mW");
> +		return ret;
> +	}
> +
> +	/*
> +	 * The SDPS limit occupies bits [30:0]. Firmware clamps it to the
> +	 * platform minimum and maximum, so reject only a field overflow.
> +	 */
> +	if (val > GENMASK(30, 0)) {

FIELD_MAX(the named define from above).

> +		hsmp_err(dev, "sdps_limit", HSMP_ERR_RANGE,
> +			 "got=%lu valid=0-2147483647 unit=mW", val);

%d + FIELD_MAX(...)

> +		return -EINVAL;
> +	}
> +
> +	/* Clear bit 31 for SET operation, set SDPS limit value in bits [30:0] */

That's not what the code does, it does not clear any bits AFAICT! Do not 
state bogus claims in comments. This looks largely unnecessary comment 
after you name the field with a define.

> +	msg.msg_id = HSMP_SDPS_LIMIT;
> +	msg.sock_ind = hsmp_sysfs_sock_ind(dev, hattr);
> +	msg.num_args = 1;
> +	msg.response_sz = 1;
> +	msg.args[0] = val & GENMASK(30, 0);

FIELD_PREP()

> +
> +	ret = hsmp_send_message(&msg);
> +	if (ret) {
> +		hsmp_err(dev, "sdps_limit", HSMP_ERR_HW,
> +			 "val=%lu unit=mW rc=%d", val, ret);
> +		return ret;
> +	}
> +
> +	return count;
> +}
> +
>  static ssize_t boost_limit_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf)
>  {
>  	struct hsmp_cpu_info *cpu_info = NULL;
> diff --git a/drivers/platform/x86/amd/hsmp/sysfs.h b/drivers/platform/x86/amd/hsmp/sysfs.h
> index aae932079ab70..bf5bac77102d3 100644
> --- a/drivers/platform/x86/amd/hsmp/sysfs.h
> +++ b/drivers/platform/x86/amd/hsmp/sysfs.h
> @@ -106,6 +106,10 @@ ssize_t hsmp_socket_power_limit_show(struct device *dev,
>  ssize_t hsmp_socket_power_limit_store(struct device *dev,
>  				      struct device_attribute *attr,
>  				      const char *buf, size_t count);
> +ssize_t hsmp_sdps_limit_show(struct device *dev, struct device_attribute *attr,
> +			     char *buf);
> +ssize_t hsmp_sdps_limit_store(struct device *dev, struct device_attribute *attr,
> +			      const char *buf, size_t count);
>  
>  void hsmp_create_per_cpu_kobjects(struct device *dev, struct kobject *cpu_parent,
>  				  struct hsmp_socket *sock);
> 

-- 
 i.


  reply	other threads:[~2026-11-23 11:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  7:18 [PATCH 00/26] platform/x86/amd/hsmp: Extend socket and per-CPU sysfs Muthusamy Ramalingam
2026-11-02  7:18 ` [PATCH 01/26] platform/x86/amd/hsmp: Drop _input from socket sysfs names Muthusamy Ramalingam
2026-11-23 11:36   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 02/26] platform/x86/amd/hsmp: Rename clk_fmax and clk_fmin sysfs files Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 03/26] platform/x86/amd/hsmp: Add hsmp_err helper for parser-friendly store errors Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 04/26] platform/x86/amd/hsmp: Treat socket_power_limit as firmware-clamped Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 05/26] platform/x86/amd/hsmp: Print protocol_version as hexadecimal Muthusamy Ramalingam
2026-11-23 11:06   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 06/26] platform/x86/amd/hsmp: Add sdps_limit sysfs file Muthusamy Ramalingam
2026-11-23 11:15   ` Ilpo Järvinen [this message]
2026-11-02  7:19 ` [PATCH 07/26] platform/x86/amd/hsmp: Add df_pstate_range " Muthusamy Ramalingam
2026-11-23 11:32   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 08/26] platform/x86/amd/hsmp: Add xgmi_width " Muthusamy Ramalingam
2026-11-23 11:35   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 09/26] platform/x86/amd/hsmp: Add gmi3_link_width " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 10/26] platform/x86/amd/hsmp: Add pcie_link_rate " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 11/26] platform/x86/amd/hsmp: Add lclk DPM sysfs files Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 12/26] platform/x86/amd/hsmp: Add io_bw and xgmi_bw " Muthusamy Ramalingam
2026-11-23 11:49   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 13/26] platform/x86/amd/hsmp: Add DIMM sideband " Muthusamy Ramalingam
2026-11-23 11:51   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 14/26] platform/x86/amd/hsmp: Add per-CPU floor limit " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 15/26] platform/x86/amd/hsmp: Add metric_version sysfs file Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 16/26] platform/x86/amd/hsmp: Add enabled command sysfs files Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 17/26] platform/x86/amd/hsmp: Add DIMM power and temperature " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 18/26] platform/x86/amd/hsmp: Add SVI3 " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 19/26] platform/x86/amd/hsmp: Add cclk_floor_limit sysfs file Muthusamy Ramalingam
2026-11-23 11:56   ` Ilpo Järvinen
2026-11-02  7:19 ` [PATCH 20/26] platform/x86/amd/hsmp: Add xgmi_pstate_range " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 21/26] platform/x86/amd/hsmp: Quiet probe-time firmware status dmesg spam Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 22/26] platform/x86/amd/hsmp: Add powereff_mode sysfs file Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 23/26] platform/x86/amd/hsmp: Add svi_power " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 24/26] platform/x86/amd/hsmp: Add per-CPU ccd_power " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 25/26] platform/x86/amd/hsmp: Add per-CPU freq_limit " Muthusamy Ramalingam
2026-11-02  7:19 ` [PATCH 26/26] platform/x86/amd/hsmp: Add socket_temperature " Muthusamy Ramalingam
2026-11-23 11:59 ` [PATCH 00/26] platform/x86/amd/hsmp: Extend socket and per-CPU sysfs Ilpo Järvinen

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=487b3b7c-c5c2-d51b-d5c0-9fed82ef604a@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Muthusamy.Ramalingam@amd.com \
    --cc=NaveenKrishna.Chatradhi@amd.com \
    --cc=Suma.Hegde@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 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.