From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: Asad Kamal <asad.kamal@amd.com>, amd-gfx@lists.freedesktop.org
Cc: hawking.zhang@amd.com, le.ma@amd.com, shiwu.zhang@amd.com,
alexander.deucher@amd.com, KevinYang.Wang@amd.com
Subject: Re: [PATCH v2 2/4] drm/amd/pm: Add sysfs node for ubb power
Date: Thu, 13 Nov 2025 12:00:33 +0530 [thread overview]
Message-ID: <0bd34547-e444-4037-a46c-0ff2975813d5@amd.com> (raw)
In-Reply-To: <20251112152815.203110-2-asad.kamal@amd.com>
On 11/12/2025 8:58 PM, Asad Kamal wrote:
> Add sysfs node to expose ubb power limit for smu_v13_0_12
>
> v2: Update sysfs node name to baseboard_power & baseboard_power_limit to
> make it consistent with other node names (Lijo)
>
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
> .../gpu/drm/amd/include/kgd_pp_interface.h | 2 +
> drivers/gpu/drm/amd/pm/amdgpu_pm.c | 65 ++++++++++++++++++-
> 2 files changed, 65 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
> index 2366e68262e6..92477120c28d 100644
> --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
> +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
> @@ -166,6 +166,8 @@ enum amd_pp_sensors {
> AMDGPU_PP_SENSOR_NODEPOWER,
> AMDGPU_PP_SENSOR_GPPTRESIDENCY,
> AMDGPU_PP_SENSOR_MAXNODEPOWERLIMIT,
> + AMDGPU_PP_SENSOR_UBB_POWER,
> + AMDGPU_PP_SENSOR_UBB_POWER_LIMIT,
> };
>
> enum amd_pp_task {
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index d9e37fd6e186..1efa08771361 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -2082,9 +2082,10 @@ static int pp_dpm_clk_default_attr_update(struct amdgpu_device *adev, struct amd
> * for user application to monitor various board reated attributes.
> *
> * The amdgpu driver provides a sysfs API for reporting board attributes. Presently,
> - * seven types of attributes are reported. Baseboard temperature and
> + * nine types of attributes are reported. Baseboard temperature and
> * gpu board temperature are reported as binary files. Npm status, current node power limit,
> - * max node power limit, node power and global ppt residency is reported as ASCII text file.
> + * max node power limit, node power, global ppt residency, baseboard_power, baseboard_power_limit
> + * is reported as ASCII text file.
> *
> * * .. code-block:: console
> *
> @@ -2101,6 +2102,10 @@ static int pp_dpm_clk_default_attr_update(struct amdgpu_device *adev, struct amd
> * hexdump /sys/bus/pci/devices/.../board/node_power
> *
> * hexdump /sys/bus/pci/devices/.../board/global_ppt_resid
> + *
> + * hexdump /sys/bus/pci/devices/.../board/baseboard_power
> + *
> + * hexdump /sys/bus/pci/devices/.../board/baseboard_power_limit
> */
>
> /**
> @@ -2295,6 +2300,52 @@ static ssize_t amdgpu_show_max_node_power_limit(struct device *dev,
> return sysfs_emit(buf, "%u\n", max_nplimit);
> }
>
> +/**
> + * DOC: baseboard_power
> + *
> + * The amdgpu driver provides a sysfs API for retrieving current ubb power.
> + * The file baseboard_power is used for this.
> + */
Please also update the unit for both (W/kW/mW etc.).
Thanks,
Lijo
> +static ssize_t amdgpu_show_baseboard_power(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct drm_device *ddev = dev_get_drvdata(dev);
> + struct amdgpu_device *adev = drm_to_adev(ddev);
> + u32 ubbpower;
> + int r;
> +
> + /* get the node power */
> + r = amdgpu_pm_get_sensor_generic(adev, AMDGPU_PP_SENSOR_UBB_POWER,
> + (void *)&ubbpower);
> + if (r)
> + return r;
> +
> + return sysfs_emit(buf, "%u\n", ubbpower);
> +}
> +
> +/**
> + * DOC: baseboard_power_limit
> + *
> + * The amdgpu driver provides a sysfs API for retrieving threshold ubb power.
> + * The file baseboard_power_limit is used for this.
> + */
> +static ssize_t amdgpu_show_baseboard_power_limit(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct drm_device *ddev = dev_get_drvdata(dev);
> + struct amdgpu_device *adev = drm_to_adev(ddev);
> + u32 ubbpowerlimit;
> + int r;
> +
> + /* get the node power */
> + r = amdgpu_pm_get_sensor_generic(adev, AMDGPU_PP_SENSOR_UBB_POWER_LIMIT,
> + (void *)&ubbpowerlimit);
> + if (r)
> + return r;
> +
> + return sysfs_emit(buf, "%u\n", ubbpowerlimit);
> +}
> +
> static DEVICE_ATTR(baseboard_temp, 0444, amdgpu_get_baseboard_temp_metrics, NULL);
> static DEVICE_ATTR(gpuboard_temp, 0444, amdgpu_get_gpuboard_temp_metrics, NULL);
> static DEVICE_ATTR(cur_node_power_limit, 0444, amdgpu_show_cur_node_power_limit, NULL);
> @@ -2302,6 +2353,8 @@ static DEVICE_ATTR(node_power, 0444, amdgpu_show_node_power, NULL);
> static DEVICE_ATTR(global_ppt_resid, 0444, amdgpu_show_global_ppt_resid, NULL);
> static DEVICE_ATTR(max_node_power_limit, 0444, amdgpu_show_max_node_power_limit, NULL);
> static DEVICE_ATTR(npm_status, 0444, amdgpu_show_npm_status, NULL);
> +static DEVICE_ATTR(baseboard_power, 0444, amdgpu_show_baseboard_power, NULL);
> +static DEVICE_ATTR(baseboard_power_limit, 0444, amdgpu_show_baseboard_power_limit, NULL);
>
> static struct attribute *board_attrs[] = {
> &dev_attr_baseboard_temp.attr,
> @@ -4748,6 +4801,14 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev)
> sysfs_add_file_to_group(&adev->dev->kobj, &dev_attr_npm_status.attr,
> amdgpu_board_attr_group.name);
> }
> + if (amdgpu_pm_get_sensor_generic(adev, AMDGPU_PP_SENSOR_UBB_POWER_LIMIT,
> + (void *)&tmp) != -EOPNOTSUPP) {
> + sysfs_add_file_to_group(&adev->dev->kobj,
> + &dev_attr_baseboard_power_limit.attr,
> + amdgpu_board_attr_group.name);
> + sysfs_add_file_to_group(&adev->dev->kobj, &dev_attr_baseboard_power.attr,
> + amdgpu_board_attr_group.name);
> + }
> }
>
> adev->pm.sysfs_initialized = true;
next prev parent reply other threads:[~2025-11-13 6:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 15:28 [PATCH v2 1/4] drm/amd/pm: Update pmfw headers for smu_v13_0_12 Asad Kamal
2025-11-12 15:28 ` [PATCH v2 2/4] drm/amd/pm: Add sysfs node for ubb power Asad Kamal
2025-11-13 6:30 ` Lazar, Lijo [this message]
2025-11-12 15:28 ` [PATCH v2 3/4] drm/amd/pm: Fetch ubb power for smu_v13_0_12 Asad Kamal
2025-11-12 15:28 ` [PATCH v2 4/4] drm/amd/pm: Enable system power caps " Asad Kamal
2025-11-13 6:32 ` Lazar, Lijo
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=0bd34547-e444-4037-a46c-0ff2975813d5@amd.com \
--to=lijo.lazar@amd.com \
--cc=KevinYang.Wang@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=asad.kamal@amd.com \
--cc=hawking.zhang@amd.com \
--cc=le.ma@amd.com \
--cc=shiwu.zhang@amd.com \
/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