From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
<badal.nilawar@intel.com>
Subject: Re: [PATCH v11 6/6] drm/xe/hwmon: Expose power sysfs entries based on firmware support
Date: Thu, 29 May 2025 11:03:55 -0400 [thread overview]
Message-ID: <aDh3W58dudaAmK_f@intel.com> (raw)
In-Reply-To: <20250529103430.2348053-7-karthik.poosa@intel.com>
On Thu, May 29, 2025 at 04:04:30PM +0530, Karthik Poosa wrote:
> Enable hwmon sysfs entries (power_xxx) only when GPU firmware
> supports it.
> Previously, these entries were created if the MMIO register
> was present. Now, we enable based on the data in the register.
First of all, please ignore my previous comment. I had missundertood your
changes on last version of the patch 3.
>
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> ---
> drivers/gpu/drm/xe/xe_hwmon.c | 65 +++++++++++++++++++++--------------
> 1 file changed, 40 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index c57c613471c3..25a89575a629 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -296,18 +296,12 @@ static void xe_hwmon_power_max_read(struct xe_hwmon *hwmon, u32 attr, int channe
> if (hwmon->xe->info.has_mbx_power_limits) {
> xe_hwmon_pcode_read_power_limit(hwmon, attr, channel, (u32 *)®_val);
> } else {
> - rapl_limit = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
> - pkg_power_sku = xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU, channel);
> -
> /*
> - * Valid check of REG_PKG_RAPL_LIMIT is already done in xe_hwmon_power_is_visible.
> + * Valid check of these registers is already done in xe_hwmon_power_is_visible.
> * So not checking it again here.
> */
With below block gone, we could even remove the entire comment section to keep
code cleaner here. We already know that all the checks are now in the visible.
with that cleaned up:
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> - if (!xe_reg_is_valid(pkg_power_sku)) {
> - drm_warn(&xe->drm, "pkg_power_sku invalid\n");
> - *value = 0;
> - goto unlock;
> - }
> + rapl_limit = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
> + pkg_power_sku = xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU, channel);
> reg_val = xe_mmio_read32(mmio, rapl_limit);
> }
>
> @@ -652,17 +646,20 @@ static umode_t xe_hwmon_attributes_visible(struct kobject *kobj,
> int ret = 0;
> int channel = (index % 2) ? CHANNEL_PKG : CHANNEL_CARD;
> u32 power_attr = (index > 1) ? PL2_HWMON_ATTR : PL1_HWMON_ATTR;
> - u32 uval;
> + u32 uval = 0;
> + struct xe_reg rapl_limit;
> + struct xe_mmio *mmio = xe_root_tile_mmio(hwmon->xe);
>
> xe_pm_runtime_get(hwmon->xe);
>
> if (hwmon->xe->info.has_mbx_power_limits) {
> xe_hwmon_pcode_read_power_limit(hwmon, power_attr, channel, &uval);
> - ret = (uval & PWR_LIM_EN) ? attr->mode : 0;
> } else if (power_attr != PL2_HWMON_ATTR) {
> - ret = xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT,
> - channel)) ? attr->mode : 0;
> + rapl_limit = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
> + if (xe_reg_is_valid(rapl_limit))
> + uval = xe_mmio_read32(mmio, rapl_limit);
> }
> + ret = (uval & PWR_LIM_EN) ? attr->mode : 0;
>
> xe_pm_runtime_put(hwmon->xe);
>
> @@ -806,24 +803,20 @@ static umode_t
> xe_hwmon_power_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
> {
> u32 uval = 0;
> - struct xe_reg rapl_limit;
> + struct xe_reg reg;
> struct xe_mmio *mmio = xe_root_tile_mmio(hwmon->xe);
>
> switch (attr) {
> case hwmon_power_max:
> case hwmon_power_cap:
> - case hwmon_power_label:
> if (hwmon->xe->info.has_mbx_power_limits) {
> xe_hwmon_pcode_read_power_limit(hwmon, attr, channel, &uval);
> } else if (attr != PL2_HWMON_ATTR) {
> - rapl_limit = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
> - if (xe_reg_is_valid(rapl_limit))
> - uval = xe_mmio_read32(mmio, rapl_limit);
> + reg = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
> + if (xe_reg_is_valid(reg))
> + uval = xe_mmio_read32(mmio, reg);
> }
> if (uval & PWR_LIM_EN) {
> - if (attr == hwmon_power_label)
> - return 0444;
> -
> drm_info(&hwmon->xe->drm, "%s is supported on channel %d\n",
> PWR_ATTR_TO_STR(attr), channel);
> return 0664;
> @@ -832,17 +825,39 @@ xe_hwmon_power_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
> PWR_ATTR_TO_STR(attr), channel);
> return 0;
> case hwmon_power_rated_max:
> - if (hwmon->xe->info.has_mbx_power_limits)
> + if (hwmon->xe->info.has_mbx_power_limits) {
> return 0;
> - else
> - return xe_reg_is_valid(xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU,
> - channel)) ? 0444 : 0;
> + } else {
> + reg = xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU, channel);
> + if (xe_reg_is_valid(reg))
> + uval = xe_mmio_read32(mmio, reg);
> + return uval ? 0444 : 0;
> + }
> case hwmon_power_crit:
> if (channel == CHANNEL_CARD) {
> xe_hwmon_pcode_read_i1(hwmon, &uval);
> return (uval & POWER_SETUP_I1_WATTS) ? 0644 : 0;
> }
> break;
> + case hwmon_power_label:
> + if (hwmon->xe->info.has_mbx_power_limits) {
> + xe_hwmon_pcode_read_power_limit(hwmon, attr, channel, &uval);
> + } else {
> + reg = xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU, channel);
> + if (xe_reg_is_valid(reg))
> + uval = xe_mmio_read32(mmio, reg);
> +
> + if (!uval) {
> + reg = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
> + if (xe_reg_is_valid(reg))
> + uval = xe_mmio_read32(mmio, reg);
> + }
> + }
> + if ((!(uval & PWR_LIM_EN)) && channel == CHANNEL_CARD) {
> + xe_hwmon_pcode_read_i1(hwmon, &uval);
> + return (uval & POWER_SETUP_I1_WATTS) ? 0444 : 0;
> + }
> + return (uval) ? 0444 : 0;
> default:
> return 0;
> }
> --
> 2.25.1
>
next prev parent reply other threads:[~2025-05-29 15:06 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-29 10:34 [PATCH v11 0/6] drm/xe/hwmon: Add mailbox power limits, PL2, read energy from PMT Karthik Poosa
2025-05-29 10:34 ` [PATCH v11 1/6] drm/xe/hwmon: Add support to manage power limits though mailbox Karthik Poosa
2025-05-29 10:34 ` [PATCH v11 2/6] drm/xe/hwmon: Move card reactive critical power under channel card Karthik Poosa
2025-05-29 10:34 ` [PATCH v11 3/6] drm/xe/hwmon: Add support to manage PL2 though mailbox Karthik Poosa
2025-05-29 10:34 ` [PATCH v11 4/6] drm/xe/hwmon: Expose powerX_cap_interval Karthik Poosa
2025-05-29 10:34 ` [PATCH v11 5/6] drm/xe/hwmon: Read energy status from PMT Karthik Poosa
2025-05-29 10:34 ` [PATCH v11 6/6] drm/xe/hwmon: Expose power sysfs entries based on firmware support Karthik Poosa
2025-05-29 13:25 ` Rodrigo Vivi
2025-05-29 14:57 ` Poosa, Karthik
2025-05-29 15:03 ` Rodrigo Vivi [this message]
2025-05-29 10:40 ` ✓ CI.Patch_applied: success for drm/xe/hwmon: Add mailbox power limits, PL2, read energy from PMT Patchwork
2025-05-29 10:40 ` ✓ CI.checkpatch: " Patchwork
2025-05-29 10:42 ` ✓ CI.KUnit: " Patchwork
2025-05-29 10:55 ` ✓ CI.Build: " Patchwork
2025-05-29 10:58 ` ✓ CI.Hooks: " Patchwork
2025-05-29 10:59 ` ✓ CI.checksparse: " Patchwork
2025-05-29 18:21 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-30 5:31 ` ✓ CI.Patch_applied: success for drm/xe/hwmon: Add mailbox power limits, PL2, read energy from PMT (rev2) Patchwork
2025-05-30 5:31 ` ✓ CI.checkpatch: " Patchwork
2025-05-30 5:32 ` ✓ CI.KUnit: " Patchwork
2025-05-30 5:43 ` ✓ CI.Build: " Patchwork
2025-05-30 5:45 ` ✓ CI.Hooks: " Patchwork
2025-05-30 5:47 ` ✓ CI.checksparse: " Patchwork
2025-05-30 6:09 ` ✓ Xe.CI.BAT: " Patchwork
2025-05-31 0:23 ` ✓ Xe.CI.Full: " Patchwork
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=aDh3W58dudaAmK_f@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.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