All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>, intel-xe@lists.freedesktop.org
Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com, riana.tauro@intel.com
Subject: Re: [PATCH v4] drm/xe/hwmon: Fix xe_hwmon_power_max_write
Date: Thu, 19 Jun 2025 17:32:28 +0200	[thread overview]
Message-ID: <052cc0ccb3caee768004c07ef890f6fade3fa5c0.camel@linux.intel.com> (raw)
In-Reply-To: <20250617120030.612819-1-karthik.poosa@intel.com>

Hi, Karthik

On Tue, 2025-06-17 at 17:30 +0530, Karthik Poosa wrote:
> Prevent other bits of mailbox power limit from being overwritten with
> 0.
> This issue was due to a missing read and modify of current power
> limit,
> before setting a requested mailbox power limit, which is added in
> this
> patch.
> 
> v2:
>  - Improve commit message. (Anshuman)
> 
> v3:
>  - Rebase.
>  - Rephrase commit message. (Riana)
>  - Add read-modify-write variant of
> xe_hwmon_pcode_write_power_limit()
>    i.e. xe_hwmon_pcode_rmw_power_limit(). (Badal)
>  - Use xe_hwmon_pcode_rmw_power_limit() to set mailbox power limits.
>  - Remove xe_hwmon_pcode_write_power_limit() as all mailbox power
> limits
>    writes use xe_hwmon_pcode_rmw_power_limit() only.
> 
> v4:
>  - Use PWR_LIM in place of (PWR_LIM_EN | PWR_LIM_VAL) wherever
>    applicable. (Riana)
> 
> Fixes: 7596d839f6228 ("drm/xe/hwmon: Add support to manage power

This patch has non-trivial conflicts in drm-xe-fixes. Please help
backporting by helping resolving those:

dim update-branches
dim checkout drm-xe-fixes
dim cherry-pick 8aa7306631f0

Manually fix conflicts

git add <fixed files>
git cherry-pick --continue

Then please send me the resulting patch (do not push drm-xe-fixes).

Please let me know if you need assistance.

Thanks,
Thomas


> limits though mailbox")
> Reviewed-by: Riana Tauro <riana.tauro@intel.com>
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> ---
>  drivers/gpu/drm/xe/regs/xe_mchbar_regs.h |  1 +
>  drivers/gpu/drm/xe/xe_hwmon.c            | 50 +++++++++++-----------
> --
>  2 files changed, 24 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
> b/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
> index 5394a1373a6b..ef2bf984723f 100644
> --- a/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
> +++ b/drivers/gpu/drm/xe/regs/xe_mchbar_regs.h
> @@ -40,6 +40,7 @@
>  #define
> PCU_CR_PACKAGE_RAPL_LIMIT		XE_REG(MCHBAR_MIRROR_BASE_SNB + 0x59a0)
>  #define   PWR_LIM_VAL				REG_GENMASK(14, 0)
>  #define   PWR_LIM_EN				REG_BIT(15)
> +#define   PWR_LIM				REG_GENMASK(15, 0)
>  #define   PWR_LIM_TIME				REG_GENMASK(23, 17)
>  #define   PWR_LIM_TIME_X			REG_GENMASK(23, 22)
>  #define   PWR_LIM_TIME_Y			REG_GENMASK(21, 17)
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c
> b/drivers/gpu/drm/xe/xe_hwmon.c
> index 0d32e977537c..f08fc4377d25 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -175,8 +175,8 @@ static int xe_hwmon_pcode_read_power_limit(const
> struct xe_hwmon *hwmon, u32 att
>  	return ret;
>  }
>  
> -static int xe_hwmon_pcode_write_power_limit(const struct xe_hwmon
> *hwmon, u32 attr, u8 channel,
> -					    u32 uval)
> +static int xe_hwmon_pcode_rmw_power_limit(const struct xe_hwmon
> *hwmon, u32 attr, u8 channel,
> +					  u32 clr, u32 set)
>  {
>  	struct xe_tile *root_tile = xe_device_get_root_tile(hwmon-
> >xe);
>  	u32 val0, val1;
> @@ -195,9 +195,9 @@ static int xe_hwmon_pcode_write_power_limit(const
> struct xe_hwmon *hwmon, u32 at
>  			channel, val0, val1, ret);
>  
>  	if (attr == PL1_HWMON_ATTR)
> -		val0 = uval;
> +		val0 = (val0 & ~clr) | set;
>  	else if (attr == PL2_HWMON_ATTR)
> -		val1 = uval;
> +		val1 = (val1 & ~clr) | set;
>  	else
>  		return -EIO;
>  
> @@ -342,7 +342,7 @@ static int xe_hwmon_power_max_write(struct
> xe_hwmon *hwmon, u32 attr, int channe
>  		if (hwmon->xe->info.has_mbx_power_limits) {
>  			drm_dbg(&hwmon->xe->drm, "disabling %s on
> channel %d\n",
>  				PWR_ATTR_TO_STR(attr), channel);
> -			xe_hwmon_pcode_write_power_limit(hwmon,
> attr, channel, 0);
> +			xe_hwmon_pcode_rmw_power_limit(hwmon, attr,
> channel, PWR_LIM_EN, 0);
>  			xe_hwmon_pcode_read_power_limit(hwmon, attr,
> channel, &reg_val);
>  		} else {
>  			reg_val = xe_mmio_rmw32(mmio, rapl_limit,
> PWR_LIM_EN, 0);
> @@ -378,10 +378,9 @@ static int xe_hwmon_power_max_write(struct
> xe_hwmon *hwmon, u32 attr, int channe
>  	reg_val = PWR_LIM_EN | REG_FIELD_PREP(PWR_LIM_VAL, reg_val);
>  
>  	if (hwmon->xe->info.has_mbx_power_limits)
> -		ret = xe_hwmon_pcode_write_power_limit(hwmon, attr,
> channel, reg_val);
> +		ret = xe_hwmon_pcode_rmw_power_limit(hwmon, attr,
> channel, PWR_LIM, reg_val);
>  	else
> -		reg_val = xe_mmio_rmw32(mmio, rapl_limit, PWR_LIM_EN
> | PWR_LIM_VAL,
> -					reg_val);
> +		reg_val = xe_mmio_rmw32(mmio, rapl_limit, PWR_LIM,
> reg_val);
>  unlock:
>  	mutex_unlock(&hwmon->hwmon_lock);
>  	return ret;
> @@ -591,14 +590,11 @@ xe_hwmon_power_max_interval_store(struct device
> *dev, struct device_attribute *a
>  
>  	mutex_lock(&hwmon->hwmon_lock);
>  
> -	if (hwmon->xe->info.has_mbx_power_limits) {
> -		ret = xe_hwmon_pcode_read_power_limit(hwmon,
> power_attr, channel, (u32 *)&r);
> -		r = (r & ~PWR_LIM_TIME) | rxy;
> -		xe_hwmon_pcode_write_power_limit(hwmon, power_attr,
> channel, r);
> -	} else {
> +	if (hwmon->xe->info.has_mbx_power_limits)
> +		xe_hwmon_pcode_rmw_power_limit(hwmon, power_attr,
> channel, PWR_LIM_TIME, rxy);
> +	else
>  		r = xe_mmio_rmw32(mmio, xe_hwmon_get_reg(hwmon,
> REG_PKG_RAPL_LIMIT, channel),
>  				  PWR_LIM_TIME, rxy);
> -	}
>  
>  	mutex_unlock(&hwmon->hwmon_lock);
>  
> @@ -1217,25 +1213,25 @@ xe_hwmon_get_preregistration_info(struct
> xe_hwmon *hwmon)
>  						    &hwmon-
> >pl1_on_boot[CHANNEL_PKG]) |
>  		    xe_hwmon_pcode_read_power_limit(hwmon,
> PL2_HWMON_ATTR, CHANNEL_CARD,
>  						    &hwmon-
> >pl2_on_boot[CHANNEL_CARD]) |
> -		    xe_hwmon_pcode_read_power_limit(hwmon,
> PL1_HWMON_ATTR, CHANNEL_PKG,
> +		    xe_hwmon_pcode_read_power_limit(hwmon,
> PL2_HWMON_ATTR, CHANNEL_PKG,
>  						    &hwmon-
> >pl2_on_boot[CHANNEL_PKG])) {
>  			drm_warn(&hwmon->xe->drm,
>  				 "Failed to read power limits, check
> GPU firmware !\n");
>  		} else {
>  			drm_info(&hwmon->xe->drm, "Using mailbox
> commands for power limits\n");
>  			/* Write default limits to read from pcode
> from now on. */
> -			xe_hwmon_pcode_write_power_limit(hwmon,
> PL1_HWMON_ATTR,
> -							
> CHANNEL_CARD,
> -							 hwmon-
> >pl1_on_boot[CHANNEL_CARD]);
> -			xe_hwmon_pcode_write_power_limit(hwmon,
> PL1_HWMON_ATTR,
> -							
> CHANNEL_PKG,
> -							 hwmon-
> >pl1_on_boot[CHANNEL_PKG]);
> -			xe_hwmon_pcode_write_power_limit(hwmon,
> PL2_HWMON_ATTR,
> -							
> CHANNEL_CARD,
> -							 hwmon-
> >pl2_on_boot[CHANNEL_CARD]);
> -			xe_hwmon_pcode_write_power_limit(hwmon,
> PL2_HWMON_ATTR,
> -							
> CHANNEL_PKG,
> -							 hwmon-
> >pl2_on_boot[CHANNEL_PKG]);
> +			xe_hwmon_pcode_rmw_power_limit(hwmon,
> PL1_HWMON_ATTR,
> +						       CHANNEL_CARD,
> PWR_LIM | PWR_LIM_TIME,
> +						       hwmon-
> >pl1_on_boot[CHANNEL_CARD]);
> +			xe_hwmon_pcode_rmw_power_limit(hwmon,
> PL1_HWMON_ATTR,
> +						       CHANNEL_PKG,
> PWR_LIM | PWR_LIM_TIME,
> +						       hwmon-
> >pl1_on_boot[CHANNEL_PKG]);
> +			xe_hwmon_pcode_rmw_power_limit(hwmon,
> PL2_HWMON_ATTR,
> +						       CHANNEL_CARD,
> PWR_LIM | PWR_LIM_TIME,
> +						       hwmon-
> >pl2_on_boot[CHANNEL_CARD]);
> +			xe_hwmon_pcode_rmw_power_limit(hwmon,
> PL2_HWMON_ATTR,
> +						       CHANNEL_PKG,
> PWR_LIM | PWR_LIM_TIME,
> +						       hwmon-
> >pl2_on_boot[CHANNEL_PKG]);
>  			hwmon->scl_shift_power = PWR_UNIT;
>  			hwmon->scl_shift_energy = ENERGY_UNIT;
>  			hwmon->scl_shift_time = TIME_UNIT;


      parent reply	other threads:[~2025-06-19 15:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-17 12:00 [PATCH v4] drm/xe/hwmon: Fix xe_hwmon_power_max_write Karthik Poosa
2025-06-17 12:03 ` Nilawar, Badal
2025-06-17 12:08 ` ✓ CI.KUnit: success for drm/xe/hwmon: Fix xe_hwmon_power_max_write (rev6) Patchwork
2025-06-17 12:55 ` ✓ Xe.CI.BAT: " Patchwork
2025-06-17 19:36 ` ✗ Xe.CI.Full: failure " Patchwork
2025-06-19 15:32 ` Thomas Hellström [this message]

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=052cc0ccb3caee768004c07ef890f6fade3fa5c0.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=anshuman.gupta@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=karthik.poosa@intel.com \
    --cc=riana.tauro@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.