Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
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>, <raag.jadav@intel.com>,
	<riana.tauro@intel.com>, <sk.anirban@intel.com>,
	<mallesh.koujalagi@intel.com>, <soham.purkait@intel.com>,
	<ravi.kishore.koppuravuri@intel.com>
Subject: Re: [PATCH v3 2/2] drm/xe/hwmon: Improve mailbox power limit init and visibility
Date: Wed, 25 Nov 2026 12:02:55 -0500	[thread overview]
Message-ID: <awcUv79JuIdn2AkI@intel.com> (raw)
In-Reply-To: <20261123170259.394360-3-karthik.poosa@intel.com>

On Mon, Nov 23, 2026 at 10:32:59PM +0530, Karthik Poosa wrote:
> On platforms with mailbox power limits, a failed boot-time power limit
> read causes two issues:
> 
> - The power, energy and time shifts are only set if all reads succeed.
>   Otherwise they stay 0, while the other reads still fill pl1_on_boot[]
>   and pl2_on_boot[], so power values are reported 8x too high. Since
>   mailbox units are fixed, set them before the reads.
> 
> - Writes to power_max and power_cap are clamped to the boot limits, but
>   visibility comes from a separate pcode read. A channel whose boot read
>   failed (limit 0) can still be visible, and any write sets a 0 limit.
>   Base visibility on the boot limits instead.
> 
> Fixes: 7596d839f622 ("drm/xe/hwmon: Add support to manage power limits though mailbox")
> Fixes: c713b9a23c73 ("drm/xe/hwmon: Add support to manage PL2 though mailbox")
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

but please make this the first patch since it is fixes and the other patch
depend on the units being set, and address Mallesh's nit request on the other
one and resend for CI.

Thanks,
Rodrigo.

> ---
> v2:
>  - Use pl1_on_boot[] and pl2_on_boot[] for interval visibility in
>    xe_hwmon_attributes_visible() and for hwmon_power_label visibility in
>    xe_hwmon_power_is_visible(). (Sashiko)
> 
>  drivers/gpu/drm/xe/xe_hwmon.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 8b848470d5e5..10c88af956e7 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -825,7 +825,8 @@ static umode_t xe_hwmon_attributes_visible(struct kobject *kobj,
>  	struct xe_mmio *mmio = xe_root_tile_mmio(hwmon->xe);
>  
>  	if (hwmon->xe->info.has_mbx_power_limits) {
> -		xe_hwmon_pcode_read_power_limit(hwmon, power_attr, channel, &uval);
> +		uval = power_attr == PL1_HWMON_ATTR ? hwmon->pl1_on_boot[channel] :
> +						      hwmon->pl2_on_boot[channel];
>  	} else if (power_attr != PL2_HWMON_ATTR) {
>  		rapl_limit = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
>  		if (xe_reg_is_valid(rapl_limit))
> @@ -1429,7 +1430,8 @@ xe_hwmon_power_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
>  	case hwmon_power_max:
>  	case hwmon_power_cap:
>  		if (hwmon->xe->info.has_mbx_power_limits) {
> -			xe_hwmon_pcode_read_power_limit(hwmon, attr, channel, &uval);
> +			uval = attr == hwmon_power_max ? hwmon->pl1_on_boot[channel] :
> +						   hwmon->pl2_on_boot[channel];
>  		} else if (attr != PL2_HWMON_ATTR) {
>  			reg = xe_hwmon_get_reg(hwmon, REG_PKG_RAPL_LIMIT, channel);
>  			if (xe_reg_is_valid(reg))
> @@ -1461,7 +1463,8 @@ xe_hwmon_power_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel)
>  		break;
>  	case hwmon_power_label:
>  		if (hwmon->xe->info.has_mbx_power_limits) {
> -			xe_hwmon_pcode_read_power_limit(hwmon, attr, channel, &uval);
> +			uval = (hwmon->pl1_on_boot[channel] | hwmon->pl2_on_boot[channel]) &
> +			       PWR_LIM_EN;
>  		} else {
>  			reg = xe_hwmon_get_reg(hwmon, REG_PKG_POWER_SKU, channel);
>  			if (xe_reg_is_valid(reg))
> @@ -1824,6 +1827,10 @@ xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon)
>  	struct xe_reg pkg_power_sku_unit;
>  
>  	if (hwmon->xe->info.has_mbx_power_limits) {
> +		/* Mailbox units are fixed; set them even if the limit reads below fail. */
> +		hwmon->scl_shift_power = PWR_UNIT;
> +		hwmon->scl_shift_energy = ENERGY_UNIT;
> +		hwmon->scl_shift_time = TIME_UNIT;
>  		/* Check if GPU firmware support mailbox power limits commands. */
>  		if (xe_hwmon_pcode_read_power_limit(hwmon, PL1_HWMON_ATTR, CHANNEL_CARD,
>  						    &hwmon->pl1_on_boot[CHANNEL_CARD]) |
> @@ -1840,9 +1847,6 @@ xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon)
>  			/* Write default limits to read from pcode from now on. */
>  			if (xe_hwmon_pcode_set_default_power_limits(hwmon))
>  				drm_warn(&hwmon->xe->drm, "Failed to set default power limits\n");
> -			hwmon->scl_shift_power = PWR_UNIT;
> -			hwmon->scl_shift_energy = ENERGY_UNIT;
> -			hwmon->scl_shift_time = TIME_UNIT;
>  		}
>  	} else {
>  		drm_info(&hwmon->xe->drm, "Using register for power limits\n");
> -- 
> 2.34.1
> 

  reply	other threads:[~2026-11-25 18:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 17:02 [PATCH v2 0/2] Expose power1_cap_max Karthik Poosa
2026-11-23 17:02 ` [PATCH v3 1/2] drm/xe/hwmon: Expose powerX_cap_max Karthik Poosa
2026-11-24 12:25   ` Mallesh, Koujalagi
2026-11-23 17:02 ` [PATCH v3 2/2] drm/xe/hwmon: Improve mailbox power limit init and visibility Karthik Poosa
2026-11-25 17:02   ` Rodrigo Vivi [this message]
2026-11-23 17:14 ` ✗ CI.KUnit: failure for Expose power1_cap_max (rev2) 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=awcUv79JuIdn2AkI@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 \
    --cc=mallesh.koujalagi@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=ravi.kishore.koppuravuri@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=sk.anirban@intel.com \
    --cc=soham.purkait@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