All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mallesh, Koujalagi" <mallesh.koujalagi@intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>
Cc: <rodrigo.vivi@intel.com>, <anshuman.gupta@intel.com>,
	<badal.nilawar@intel.com>, <raag.jadav@intel.com>,
	<riana.tauro@intel.com>, <sk.anirban@intel.com>,
	<soham.purkait@intel.com>, <ravi.kishore.koppuravuri@intel.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v3 1/2] drm/xe/hwmon: Improve mailbox power limit init and visibility
Date: Thu, 26 Nov 2026 11:28:47 +0530	[thread overview]
Message-ID: <25d7cc16-d09f-4802-9474-97931618441c@intel.com> (raw)
In-Reply-To: <20261126055530.1629019-2-karthik.poosa@intel.com>


On 26-11-2026 11:25 am, 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>
LGTM,
Reviewed-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
> ---
>   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 c84bcfaea98d..a068ec880819 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -831,7 +831,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))
> @@ -1432,7 +1433,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))
> @@ -1464,7 +1466,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))
> @@ -1823,6 +1826,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]) |
> @@ -1839,9 +1846,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");

  reply	other threads:[~2026-11-26  5:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  5:55 [PATCH v3 0/2] Expose power1_cap_max Karthik Poosa
2026-11-26  5:55 ` [PATCH v3 1/2] drm/xe/hwmon: Improve mailbox power limit init and visibility Karthik Poosa
2026-11-26  5:58   ` Mallesh, Koujalagi [this message]
2026-11-26  5:55 ` [PATCH v3 2/2] drm/xe/hwmon: Expose powerX_cap_max Karthik Poosa
2026-11-26  6:03 ` ✓ CI.KUnit: success for Expose power1_cap_max (rev4) Patchwork
2026-11-26  6:42 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-26 12:12 ` ✓ Xe.CI.FULL: " Patchwork
2026-11-26 18:12 ` [PATCH v3 0/2] Expose power1_cap_max Rodrigo Vivi

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=25d7cc16-d09f-4802-9474-97931618441c@intel.com \
    --to=mallesh.koujalagi@intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=ravi.kishore.koppuravuri@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@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 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.