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 08/26] platform/x86/amd/hsmp: Add xgmi_width sysfs file
Date: Mon, 23 Nov 2026 13:35:26 +0200 (EET)	[thread overview]
Message-ID: <69c9f6ce-7927-4ee2-ab68-0f0d3a17ead1@linux.intel.com> (raw)
In-Reply-To: <cdaa48d5e1d276de212ead62d9ddcc7316411d15.1793602633.git.Muthusamy.Ramalingam@amd.com>

On Mon, 2 Nov 2026, Muthusamy Ramalingam wrote:

> Add a read/write socket file for the xGMI link-width range on both the
> ACPI and platform drivers.
> 
> Read and write are differentiated by bit 31. Setting the bit selects a
> read, and resetting it selects a write. A read returns the minimum and
> maximum widths. A write takes "min max", with the minimum in bits
> [15:8] and the maximum in bits [7:0]. 0 is x4, 1 is x8, and 2 is x16.
> Each value is an 8-bit field. Extra arguments are rejected. Firmware
> rejects an unsupported width.
> 
> 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   |  3 +
>  drivers/platform/x86/amd/hsmp/acpi.c  |  3 +
>  drivers/platform/x86/amd/hsmp/plat.c  |  4 ++
>  drivers/platform/x86/amd/hsmp/sysfs.c | 79 +++++++++++++++++++++++++++
>  drivers/platform/x86/amd/hsmp/sysfs.h |  4 ++
>  5 files changed, 93 insertions(+)
> 
> diff --git a/Documentation/arch/x86/amd_hsmp.rst b/Documentation/arch/x86/amd_hsmp.rst
> index 694997308ffa9..134c94e71b006 100644
> --- a/Documentation/arch/x86/amd_hsmp.rst
> +++ b/Documentation/arch/x86/amd_hsmp.rst
> @@ -122,6 +122,9 @@ write-only when the platform enables only that direction of the message.
>  * df_pstate_range: Read/write DF P-state range as "min max". Each value
>    is an 8-bit field. 0 is the highest performance. Extra arguments are
>    rejected. Firmware rejects unsupported P-states.
> +* xgmi_width: Read/write xGMI link width range as "min max".
> +  0 is x4, 1 is x8, and 2 is x16. Each value is an 8-bit field.
> +  Extra arguments are rejected. Firmware rejects unsupported widths.
>  * 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 417fca04a722f..4f4170d191850 100644
> --- a/drivers/platform/x86/amd/hsmp/acpi.c
> +++ b/drivers/platform/x86/amd/hsmp/acpi.c
> @@ -541,6 +541,8 @@ HSMP_DEV_ATTR_RW(sdps_limit, HSMP_SDPS_LIMIT, HSMP_SDPS_LIMIT,
>  		 hsmp_sdps_limit_show, hsmp_sdps_limit_store, 0644);
>  HSMP_DEV_ATTR_RW(df_pstate_range, HSMP_SET_PSTATE_MAX_MIN, HSMP_SET_PSTATE_MAX_MIN,
>  		 hsmp_df_pstate_range_show, hsmp_df_pstate_range_store, 0644);
> +HSMP_DEV_ATTR_RW(xgmi_width, HSMP_SET_XGMI_LINK_WIDTH, HSMP_SET_XGMI_LINK_WIDTH,
> +		 hsmp_xgmi_width_show, hsmp_xgmi_width_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,
> @@ -574,6 +576,7 @@ static struct attribute *hsmp_dev_attr_list[] = {
>  	&hattr_socket_power_limit.dattr.attr,
>  	&hattr_sdps_limit.dattr.attr,
>  	&hattr_df_pstate_range.dattr.attr,
> +	&hattr_xgmi_width.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 3deb5480495dc..2c09a48b70471 100644
> --- a/drivers/platform/x86/amd/hsmp/plat.c
> +++ b/drivers/platform/x86/amd/hsmp/plat.c
> @@ -377,6 +377,9 @@ HSMP_DEV_ATTR_RW_X8(df_pstate_range, HSMP_SET_PSTATE_MAX_MIN,
>  		    HSMP_SET_PSTATE_MAX_MIN,
>  		    hsmp_df_pstate_range_show, hsmp_df_pstate_range_store,
>  		    0644);
> +HSMP_DEV_ATTR_RW_X8(xgmi_width, HSMP_SET_XGMI_LINK_WIDTH,
> +		    HSMP_SET_XGMI_LINK_WIDTH,
> +		    hsmp_xgmi_width_show, hsmp_xgmi_width_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,
> @@ -415,6 +418,7 @@ static struct attribute _name[] = {					       \
>  	&hattr_socket_power_limit##_sock_ind.dattr.attr,		       \
>  	&hattr_sdps_limit##_sock_ind.dattr.attr,			       \
>  	&hattr_df_pstate_range##_sock_ind.dattr.attr,			       \
> +	&hattr_xgmi_width##_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 8f10281cb97c1..4726b3dcdda3d 100644
> --- a/drivers/platform/x86/amd/hsmp/sysfs.c
> +++ b/drivers/platform/x86/amd/hsmp/sysfs.c
> @@ -812,6 +812,85 @@ ssize_t hsmp_df_pstate_range_store(struct device *dev,
>  	return count;
>  }
>  
> +/* xGMI width show function - reads current min and max link width */
> +ssize_t hsmp_xgmi_width_show(struct device *dev,
> +			     struct device_attribute *attr,
> +			     char *buf)
> +{
> +	struct hsmp_sys_attr *hattr = to_hsmp_sys_attr(attr);
> +	struct hsmp_message msg = {};

This is the correct form :-).

> +	u32 min_width, max_width;
> +	int ret;
> +
> +	/* Set bit 31 to indicate GET operation for HSMP_SET_GET type messages */

Drop.

> +	msg.msg_id = HSMP_SET_XGMI_LINK_WIDTH;
> +	msg.sock_ind = hsmp_sysfs_sock_ind(dev, hattr);
> +	msg.num_args = 1;
> +	msg.response_sz = 1;
> +	msg.args[0] = BIT(31);  /* GET operation */

You know the drill.

> +
> +	ret = hsmp_send_message(&msg);
> +	if (ret)
> +		return ret;
> +
> +	/* Extract min width[15:8] and max width[7:0] */
> +	min_width = (msg.args[0] >> 8) & 0xFF;
> +	max_width = msg.args[0] & 0xFF;

As with the other patches.

> +
> +	return sysfs_emit(buf, "%u %u\n", min_width, max_width);
> +}
> +
> +/* xGMI width store function - sets min and max link width */
> +ssize_t hsmp_xgmi_width_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 = {};
> +	u32 min_width, max_width;
> +	u32 vals[2];
> +	int ret;
> +	int got;
> +
> +	/* Parse input in format: "min_width max_width" */
> +	ret = hsmp_parse_u32_args(buf, vals, 2, 10, &got);
> +	if (ret) {
> +		hsmp_err(dev, "xgmi_width", HSMP_ERR_ARGC,
> +			 "want=2 got=%d fmt=\"min max\"", got);
> +		return -EINVAL;
> +	}
> +	min_width = vals[0];
> +	max_width = vals[1];
> +
> +	/* Min and max are 8-bit fields. Firmware rejects unsupported widths. */
> +	if (min_width > 0xFF || max_width > 0xFF) {
> +		hsmp_err(dev, "xgmi_width", HSMP_ERR_RANGE,
> +			 "min=%u max=%u valid=0-255", min_width, max_width);
> +		return -EINVAL;
> +	}
> +
> +	/* Clear bit 31 for SET operation, pack min[15:8] and max[7:0] */
> +	msg.msg_id = HSMP_SET_XGMI_LINK_WIDTH;
> +	msg.sock_ind = hsmp_sysfs_sock_ind(dev, hattr);
> +	msg.num_args = 1;
> +	msg.response_sz = 1;
> +	msg.args[0] = (min_width << 8) | max_width;

Same, the same times n in the above.

> +
> +	ret = hsmp_send_message(&msg);
> +	if (ret) {
> +		if (max_width < min_width)

Here you have this the expected way around.

Braces.

> +			hsmp_err(dev, "xgmi_width", HSMP_ERR_ORDER,
> +				 "min=%u max=%u rule=max>=min rc=%d",
> +				  min_width, max_width, ret);
> +		else
> +			hsmp_err(dev, "xgmi_width", HSMP_ERR_HW,
> +				 "min=%u max=%u rc=%d", min_width, max_width, 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 9631b9067c142..58340e0544af6 100644
> --- a/drivers/platform/x86/amd/hsmp/sysfs.h
> +++ b/drivers/platform/x86/amd/hsmp/sysfs.h
> @@ -115,6 +115,10 @@ ssize_t hsmp_df_pstate_range_show(struct device *dev,
>  ssize_t hsmp_df_pstate_range_store(struct device *dev,
>  				   struct device_attribute *attr,
>  				   const char *buf, size_t count);
> +ssize_t hsmp_xgmi_width_show(struct device *dev, struct device_attribute *attr,
> +			     char *buf);
> +ssize_t hsmp_xgmi_width_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:35 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
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 [this message]
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=69c9f6ce-7927-4ee2-ab68-0f0d3a17ead1@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.