Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/hwmon: Use 0 to designate disabled PL1 power limit
Date: Fri, 31 Mar 2023 19:44:49 -0700	[thread overview]
Message-ID: <878rfcgw2m.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <3efd6c5d-cd3a-f562-fc61-a43e9bf003cb@linux.intel.com>

On Fri, 31 Mar 2023 03:23:33 -0700, Tvrtko Ursulin wrote:
>

Hi Tvrtko,

> > @@ -385,8 +395,22 @@ static int
> >   hwm_power_max_write(struct hwm_drvdata *ddat, long val)
> >   {
> >	struct i915_hwmon *hwmon = ddat->hwmon;
> > +	intel_wakeref_t wakeref;
> >	u32 nval;
> >   +	if (val == PL1_DISABLE) {
> > +		/* Disable PL1 limit */
> > +		hwm_locked_with_pm_intel_uncore_rmw(ddat, hwmon->rg.pkg_rapl_limit,
> > +						    PKG_PWR_LIM_1_EN, 0);
> > +
> > +		/* Verify, because PL1 limit cannot be disabled on all platforms */
>
> I think there is a race right here, since above grabbed and released the
> hwmon_lock, anyone can modify it at this point before the verification
> below. Not sure if any consequences worse than a wrong -EPERM are possible
> though.
>
> Also, is EPERM correct for something hardware does not support? We usually
> say ENODEV for such things, IIRC at least.

Changed to -ENODEV in v3.

> Anyway, race looks easily solvable by holding the existing mutex and a
> single rpm ref for the whole rmw-r cycle.

Fixed in v3, thanks for catching these.

Ashutosh

> > +		with_intel_runtime_pm(ddat->uncore->rpm, wakeref)
> > +			nval = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit);
> > +		if (nval & PKG_PWR_LIM_1_EN)
> > +			return -EPERM;
> > +		return 0;
> > +	}
> > +
> >	/* Computation in 64-bits to avoid overflow. Round to nearest. */
> >	nval = DIV_ROUND_CLOSEST_ULL((u64)val << hwmon->scl_shift_power, SF_POWER);
> >	nval = PKG_PWR_LIM_1_EN | REG_FIELD_PREP(PKG_PWR_LIM_1, nval);

      reply	other threads:[~2023-04-01  2:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  2:26 [Intel-gfx] [PATCH v2] drm/i915/hwmon: Use 0 to designate disabled PL1 power limit Ashutosh Dixit
2023-03-31  3:16 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/hwmon: Use 0 to designate disabled PL1 power limit (rev2) Patchwork
2023-03-31 10:23 ` [Intel-gfx] [PATCH v2] drm/i915/hwmon: Use 0 to designate disabled PL1 power limit Tvrtko Ursulin
2023-04-01  2:44   ` Dixit, Ashutosh [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=878rfcgw2m.wl-ashutosh.dixit@intel.com \
    --to=ashutosh.dixit@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=tvrtko.ursulin@linux.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