From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 1/3] drm/i915/hwmon: Get mutex and rpm ref just once in hwm_power_max_write
Date: Fri, 7 Apr 2023 07:08:46 -0400 [thread overview]
Message-ID: <ZC/5vngItjNcBnxL@intel.com> (raw)
In-Reply-To: <20230406044522.3108359-2-ashutosh.dixit@intel.com>
On Wed, Apr 05, 2023 at 09:45:20PM -0700, Ashutosh Dixit wrote:
> In preparation for follow-on patches, refactor hwm_power_max_write to take
> hwmon_lock and runtime pm wakeref at start of the function and release them
> at the end, therefore acquiring these just once each.
>
> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/i915/i915_hwmon.c | 28 +++++++++++++++-------------
> 1 file changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_hwmon.c b/drivers/gpu/drm/i915/i915_hwmon.c
> index 8e7dccc8d3a0e..7f44e809ca155 100644
> --- a/drivers/gpu/drm/i915/i915_hwmon.c
> +++ b/drivers/gpu/drm/i915/i915_hwmon.c
> @@ -396,31 +396,33 @@ hwm_power_max_write(struct hwm_drvdata *ddat, long val)
> {
> struct i915_hwmon *hwmon = ddat->hwmon;
> intel_wakeref_t wakeref;
> + int ret = 0;
> u32 nval;
>
> + mutex_lock(&hwmon->hwmon_lock);
> + wakeref = intel_runtime_pm_get(ddat->uncore->rpm);
> +
> /* Disable PL1 limit and verify, because the limit cannot be disabled on all platforms */
> if (val == PL1_DISABLE) {
> - mutex_lock(&hwmon->hwmon_lock);
> - with_intel_runtime_pm(ddat->uncore->rpm, wakeref) {
> - intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit,
> - PKG_PWR_LIM_1_EN, 0);
> - nval = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit);
> - }
> - mutex_unlock(&hwmon->hwmon_lock);
> + intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit,
> + PKG_PWR_LIM_1_EN, 0);
> + nval = intel_uncore_read(ddat->uncore, hwmon->rg.pkg_rapl_limit);
>
> if (nval & PKG_PWR_LIM_1_EN)
> - return -ENODEV;
> - return 0;
> + ret = -ENODEV;
> + goto exit;
> }
>
> /* 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);
>
> - hwm_locked_with_pm_intel_uncore_rmw(ddat, hwmon->rg.pkg_rapl_limit,
> - PKG_PWR_LIM_1_EN | PKG_PWR_LIM_1,
> - nval);
> - return 0;
> + intel_uncore_rmw(ddat->uncore, hwmon->rg.pkg_rapl_limit,
> + PKG_PWR_LIM_1_EN | PKG_PWR_LIM_1, nval);
> +exit:
> + intel_runtime_pm_put(ddat->uncore->rpm, wakeref);
> + mutex_unlock(&hwmon->hwmon_lock);
> + return ret;
> }
>
> static int
> --
> 2.38.0
>
next prev parent reply other threads:[~2023-04-07 11:08 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 4:45 [Intel-gfx] [PATCH v4 0/3] drm/i915/guc: Disable PL1 power limit when loading GuC firmware Ashutosh Dixit
2023-04-06 4:45 ` [Intel-gfx] [PATCH 1/3] drm/i915/hwmon: Get mutex and rpm ref just once in hwm_power_max_write Ashutosh Dixit
2023-04-07 11:08 ` Rodrigo Vivi [this message]
2023-04-06 4:45 ` [Intel-gfx] [PATCH 2/3] drm/i915/guc: Disable PL1 power limit when loading GuC firmware Ashutosh Dixit
2023-04-06 9:16 ` kernel test robot
2023-04-07 11:08 ` Rodrigo Vivi
2023-04-10 22:17 ` Dixit, Ashutosh
2023-04-06 4:45 ` [Intel-gfx] [PATCH 3/3] drm/i915/hwmon: Block waiting for GuC reset to complete Ashutosh Dixit
2023-04-07 11:04 ` Rodrigo Vivi
2023-04-10 22:40 ` Dixit, Ashutosh
2023-04-06 5:15 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/guc: Disable PL1 power limit when loading GuC firmware Patchwork
2023-04-06 5:32 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-04-06 17:42 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-04-10 22:35 [Intel-gfx] [PATCH 0/3] " Ashutosh Dixit
2023-04-10 22:35 ` [Intel-gfx] [PATCH 1/3] drm/i915/hwmon: Get mutex and rpm ref just once in hwm_power_max_write Ashutosh Dixit
2023-04-20 16:40 [Intel-gfx] [PATCH v6 0/3] drm/i915/guc: Disable PL1 power limit when loading GuC firmware Ashutosh Dixit
2023-04-20 16:40 ` [Intel-gfx] [PATCH 1/3] drm/i915/hwmon: Get mutex and rpm ref just once in hwm_power_max_write Ashutosh Dixit
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=ZC/5vngItjNcBnxL@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=ashutosh.dixit@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/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