From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Vinay Belgaumkar <vinay.belgaumkar@intel.com>,
Badal Nilawar <badal.nilawar@intel.com>,
"Stuart Summers" <stuart.summers@intel.com>
Subject: Re: [PATCH v4 2/3] drm/xe/xe_guc_pc: Lock once to update stashed frequencies
Date: Mon, 16 Jun 2025 10:29:02 -0400 [thread overview]
Message-ID: <aFAqLjeXkkL5rNGP@intel.com> (raw)
In-Reply-To: <20250615-wa-22019338487-v4-2-704830697cbc@intel.com>
On Sun, Jun 15, 2025 at 11:17:35PM -0700, Lucas De Marchi wrote:
> pc_set_mert_freq_cap() currently lock()/unlock() the mutex multiple times
> to stash the current frequencies. It's not a problem since
> xe_guc_pc_restore_stashed_freq() is guaranteed to be called only later
> in the init sequence. However, now that we have _locked() variants for
> this functions, use them and avoid potential issues when called from
> other places or using the same pattern.
>
> While at it, prefer and early return for the WA check to reduce
> indentation.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_pc.c | 39 ++++++++++++++++++++-------------------
> 1 file changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index 53aaf937d4bec..d449eb0e3e8af 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
> @@ -891,27 +891,28 @@ static int pc_adjust_requested_freq(struct xe_guc_pc *pc)
>
> static int pc_set_mert_freq_cap(struct xe_guc_pc *pc)
> {
> - int ret = 0;
> + int ret;
>
> - if (XE_WA(pc_to_gt(pc), 22019338487)) {
> - /*
> - * Get updated min/max and stash them.
> - */
> - ret = xe_guc_pc_get_min_freq(pc, &pc->stashed_min_freq);
> - if (!ret)
> - ret = xe_guc_pc_get_max_freq(pc, &pc->stashed_max_freq);
> - if (ret)
> - return ret;
> + if (!XE_WA(pc_to_gt(pc), 22019338487))
> + return 0;
>
> - /*
> - * Ensure min and max are bound by MERT_FREQ_CAP until driver loads.
> - */
> - mutex_lock(&pc->freq_lock);
> - ret = pc_set_min_freq(pc, min(pc->rpe_freq, pc_max_freq_cap(pc)));
> - if (!ret)
> - ret = pc_set_max_freq(pc, min(pc->rp0_freq, pc_max_freq_cap(pc)));
> - mutex_unlock(&pc->freq_lock);
> - }
> + guard(mutex)(&pc->freq_lock);
> +
> + /*
> + * Get updated min/max and stash them.
> + */
> + ret = xe_guc_pc_get_min_freq_locked(pc, &pc->stashed_min_freq);
> + if (!ret)
> + ret = xe_guc_pc_get_max_freq_locked(pc, &pc->stashed_max_freq);
> + if (ret)
> + return ret;
> +
> + /*
> + * Ensure min and max are bound by MERT_FREQ_CAP until driver loads.
> + */
> + ret = pc_set_min_freq(pc, min(pc->rpe_freq, pc_max_freq_cap(pc)));
> + if (!ret)
> + ret = pc_set_max_freq(pc, min(pc->rp0_freq, pc_max_freq_cap(pc)));
>
> return ret;
> }
>
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-06-16 14:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 6:17 [PATCH v4 0/3] drm/xe: Update Wa_22019338487 Lucas De Marchi
2025-06-16 6:17 ` [PATCH v4 1/3] drm/xe/guc_pc: Add _locked variant for min/max freq Lucas De Marchi
2025-06-16 14:26 ` Rodrigo Vivi
2025-06-16 6:17 ` [PATCH v4 2/3] drm/xe/xe_guc_pc: Lock once to update stashed frequencies Lucas De Marchi
2025-06-16 14:29 ` Rodrigo Vivi [this message]
2025-06-16 6:17 ` [PATCH v4 3/3] drm/xe/bmg: Update Wa_22019338487 Lucas De Marchi
2025-06-16 14:37 ` Rodrigo Vivi
2025-06-16 15:38 ` Lucas De Marchi
2025-06-16 20:35 ` Rodrigo Vivi
2025-06-16 21:21 ` Lucas De Marchi
2025-06-16 6:24 ` ✗ CI.checkpatch: warning for drm/xe: " Patchwork
2025-06-16 6:25 ` ✓ CI.KUnit: success " Patchwork
2025-06-16 7:06 ` ✓ Xe.CI.BAT: " Patchwork
2025-06-16 16:32 ` ✗ Xe.CI.Full: failure " 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=aFAqLjeXkkL5rNGP@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=stuart.summers@intel.com \
--cc=vinay.belgaumkar@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