Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vinay Belgaumkar" <vinay.belgaumkar@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 2/2] drm/xe: Add sysfs to disable RPe
Date: Thu, 19 Nov 2026 22:50:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-224160@kernel.org> (raw)
In-Reply-To: <20261119222958.1239889-4-vinay.belgaumkar@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe: unlocked pc_set_ignore_eff_freq() call in
  xe_guc_pc_start()
--

commit 92347c09642635b15512f302b19f351ec5e6cc4f
Author: Vinay Belgaumkar <vinay.belgaumkar@intel.com>

drm/xe: Add sysfs to disable RPe

This commit adds a per-GT use_rpe sysfs attribute to control SLPC
efficient frequency behavior independently of min_freq and disables RPe
before querying min_freq during frequency bounds setup and MERT frequency
capping.

> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index ea47b0ded83a4..0f98e8e48c577 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c

[ ... ]

> @@ -1192,6 +1224,31 @@ static int pc_action_set_strategy(struct xe_guc_pc *pc, u32 val)
>  	return ret;
>  }
>  
> +int xe_guc_pc_set_use_rpe(struct xe_guc_pc *pc, u32 val)
> +{
> +	int ret = 0;
> +
> +	guard(mutex)(&pc->freq_lock);
> +
> +	/* Might be in the middle of a gt reset */
> +	if (!pc->freq_ready)
> +		return -EAGAIN;
> +
> +	if (!pc->mert_freq_cap_active) {
> +		/*
> +		 * If use_rpe == 1, ignore_eff_freq = false. GuC elevates min_freq to
> +		 * RPe when enabled, and resets it back to the previously set min
> +		 * when disabled, so no explicit set_min_freq request is needed here.
> +		 */
> +		ret = pc_set_ignore_eff_freq(pc, !val);
> +	}
> +
> +	if (!ret)
> +		pc->use_rpe = val;
> +
> +	return ret;
> +}
> +
>  static const char *power_profile_to_string(struct xe_guc_pc *pc)
>  {
>  	switch (pc->power_profile) {
> @@ -1344,6 +1401,10 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
>  	if (ret)
>  		return ret;
>  
> +	ret = pc_set_ignore_eff_freq(pc, !pc->use_rpe);
> +	if (unlikely(ret))
> +		return ret;
> +
>  	ret = pc_set_mert_freq_cap(pc);
>  	if (ret)
>  		return ret;

[Severity: Medium]
Can calling pc_set_ignore_eff_freq(pc, !pc->use_rpe) outside pc->freq_lock
after pc_init_freqs() has already set pc->freq_ready = true race with
sysfs accesses?

Inside pc_init_freqs(), pc_adjust_freq_bounds() forces ignore_eff_freq to
1 under pc->freq_lock, and pc_init_freqs() then sets pc->freq_ready = true
and unlocks pc->freq_lock before pc->use_rpe is applied here:

CPU0                              CPU1
xe_guc_pc_start()
  pc_init_freqs()
    mutex_lock(&pc->freq_lock)
    pc_adjust_freq_bounds()
      pc_set_ignore_eff_freq(pc, 1)
    ...
    pc->freq_ready = true
    mutex_unlock(&pc->freq_lock)
  !pc->use_rpe (reads old value)
                                  use_rpe_store()
                                    xe_guc_pc_set_use_rpe()
                                      mutex_lock(&pc->freq_lock)
                                      pc_set_ignore_eff_freq(pc, !val)
                                      pc->use_rpe = val
                                      mutex_unlock(&pc->freq_lock)
  pc_set_ignore_eff_freq(pc, old) <-- overwrites GuC state with stale value

This leaves SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY in GuC out of sync with
pc->use_rpe.

In that same window between pc_init_freqs() dropping pc->freq_lock and
pc_set_ignore_eff_freq(pc, !pc->use_rpe) completing, a concurrent
min_freq_show() sees pc->freq_ready == true while ignore_eff_freq is still
1 from pc_adjust_freq_bounds() and reports the un-elevated min_freq even
when pc->use_rpe is true.  Also, if pc_set_ignore_eff_freq() or
pc_set_mert_freq_cap() fails here, xe_guc_pc_start() returns an error with
pc->freq_ready left set to true, and on Wa_22019338487 platforms this
briefly re-enables RPe right before pc_set_mert_freq_cap() disables it
again.

Could pc_set_ignore_eff_freq(pc, !pc->use_rpe) be moved inside
pc_init_freqs() under pc->freq_lock before pc->freq_ready is set (or
skipped when pc_set_mert_freq_cap() will keep RPe disabled)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119222958.1239889-3-vinay.belgaumkar@intel.com?part=2

  reply	other threads:[~2026-11-19 22:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 22:29 [PATCH v4 1/2] drm/xe: Disallow freq changes while mert cap is active Vinay Belgaumkar
2026-11-19 22:30 ` [PATCH v4 2/2] drm/xe: Add sysfs to disable RPe Vinay Belgaumkar
2026-11-19 22:50   ` sashiko-bot [this message]
2026-11-19 22:57 ` [PATCH v4 1/2] drm/xe: Disallow freq changes while mert cap is active sashiko-bot

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=sashiko-outbox-224160@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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