From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4E01606A322 for ; Fri, 4 Dec 2026 02:09:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e+4pQyyR Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BBD810EBA7; Fri, 4 Dec 2026 02:09:31 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id A8AB510EBB5 for ; Fri, 4 Dec 2026 02:09:25 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 64B60443B1; Fri, 4 Dec 2026 02:09:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 391531F0092C; Fri, 4 Dec 2026 02:09:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796350165; bh=z7/ZXNFeczvkya51K3rroC/ZDG/lHJjjt0v1OEveO7U=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=e+4pQyyR3aGb/vKZmbOFSrMHQhnh9Q8ytyhRDlz2trmrLWvzgsM769LwnI3Rpd34x zwFgrZFSfnlyeT1yARe/cD/YpGt8X9jpo0SKjm/lHf0yF7mtK5ecatLM4OIPvGzrBI BuMRGiUewI2uvcbd839z3U/j22G+maNA7R+VYjAdVjLOTdsl5cSUsaJzsu0FcD+zhd BPELMkwSXUFYrTIcxIBLj4Doni4R9a4TwcxeAaak+IGYMJB6Temxq+rzDcMjV/Ni0v BIA5jACn1vtNN+NQ3AmsdRn/vwadE1t5De6xho1vDfaCi/Dnj07Q/nHS2mD1AtFvM3 64LVJmdiVwMFQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 2/2] drm/xe: Add sysfs to disable RPe To: "Vinay Belgaumkar" , intel-xe@lists.freedesktop.org In-Reply-To: <20261204014137.2470389-4-vinay.belgaumkar@intel.com> References: <20261204014137.2470389-3-vinay.belgaumkar@intel.com> <20261204014137.2470389-4-vinay.belgaumkar@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 02:09:24 +0000 X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Intel-xe" X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [Medium] drm/xe: disabling RPe without min_freq update breaks GuC 70.x SLPC - [Medium] drm/xe: partial error in xe_guc_pc_restore_stashed_freq() locks mert cap - [Medium] drm/xe: removing RPe override in pc_set_min_freq() breaks min_freq sysfs ABI - [Medium] drm/xe: D3cold skips xe_guc_pc_stop(), corrupting stashed_min_freq - [Low] drm/xe: unlocked direct pc->ignore_eff_freq read in ignore_eff_freq_show() - [Low] drm/xe: missing ignore_eff_freq restore on pc_set_mert_freq_cap() error -- commit 7df33a9238986839478707b9a4d3d637a6501d51 Author: Vinay Belgaumkar drm/xe: Add sysfs to disable RPe This patch adds an ignore_eff_freq sysfs attribute to control GuC SLPC's use of efficient frequency (RPe), removes the implicit RPe override from pc_set_min_freq(), and disables RPe while stashing frequencies for the MERT frequency cap. > diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_f= req.c > index a40dd074106f3..b02a9c1fe33e1 100644 > --- a/drivers/gpu/drm/xe/xe_gt_freq.c > +++ b/drivers/gpu/drm/xe/xe_gt_freq.c > @@ -242,6 +242,40 @@ static ssize_t power_profile_store(struct kobject *k= obj, > } > static struct kobj_attribute attr_power_profile =3D __ATTR_RW(power_prof= ile); > =20 > +static ssize_t ignore_eff_freq_show(struct kobject *kobj, > + struct kobj_attribute *attr, > + char *buff) > +{ > + struct device *dev =3D kobj_to_dev(kobj); > + struct xe_guc_pc *pc =3D dev_to_pc(dev); > + > + return sysfs_emit(buff, "%u\n", pc->ignore_eff_freq); > +} [Severity: Low] Is this an unlocked data race on pc->ignore_eff_freq? xe_guc_pc_set_ignore_eff_freq() updates pc->ignore_eff_freq under pc->freq_lock, whereas ignore_eff_freq_show() performs a plain unlocked read that can race with concurrent sysfs writes. Every other callback in xe_gt_freq.c also reads struct xe_guc_pc through a xe_guc_pc_*() helper rather than accessing fields directly, and xe_guc_pc_set_ignore_eff_freq() takes u32 even though pc->ignore_eff_freq is a bool. Adding a locked xe_guc_pc_get_ignore_eff_freq() accessor and switching the parameter to bool would clean up all three. [ ... ] > diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_p= c.c > index cc1869e6bcbef..bda0dde9c19f2 100644 > --- a/drivers/gpu/drm/xe/xe_guc_pc.c > +++ b/drivers/gpu/drm/xe/xe_guc_pc.c [ ... ] > @@ -358,13 +373,6 @@ static int pc_set_min_freq(struct xe_guc_pc *pc, u32= freq) > if (!pc_freq_in_range(pc, freq)) > return -EINVAL; > =20 > - /* > - * GuC policy is to elevate minimum frequency to the efficient levels > - * Our goal is to have the admin choices respected. > - */ > - pc_action_set_param(pc, SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY, > - freq < xe_guc_pc_get_rpe_freq(pc)); > - > return pc_action_set_param(pc, > SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ, > freq); [Severity: Medium] Does removing the SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY update here break the existing freq0/min_freq sysfs ABI for values below rpe_freq? Since commit dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs"), writing min_freq < rpe_freq disabled RPe so admin minimum and fixed-frequency (max_freq <=3D min_freq) requests below rpe_freq took effec= t. With pc->ignore_eff_freq defaulting to false, existing tools writing a lower min_freq now get a successful write return while GuC keeps the effective minimum pinned at rpe_freq. DOC: Xe GT Frequency Management in drivers/gpu/drm/xe/xe_gt_freq.c is also not updated to document ignore_eff_freq or note that max <=3D min no longer acts as a fixed-frequency request below rpe_freq by default. > @@ -615,7 +623,10 @@ static int xe_guc_pc_get_min_freq_locked(struct xe_g= uc_pc *pc, u32 *freq) > =20 > /* In the middle of a temporary freq cap, return stashed or min freq */ > if (pc->mert_freq_cap_active) { > - *freq =3D pc->user_requested_min ?: pc->stashed_min_freq; > + u32 min =3D pc->user_requested_min ?: pc->stashed_min_freq; > + > + /* Return what GuC would report based on ignore_eff_freq */ > + *freq =3D !pc->ignore_eff_freq ? max(min, xe_guc_pc_get_rpe_freq(pc)) = : min; > return 0; > } [Severity: Medium] Can this synthetic RPe elevation corrupt pc->stashed_min_freq across a D3cold runtime suspend/resume cycle? If xe_guc_pc_restore_stashed_freq() fails on a platform with Wa_22019338487, callers such as xe_device_probe() and do_gt_restart() ignore the error from xe_gt_sanitize_freq() and leave pc->mert_freq_cap_active true. On D3cold runtime suspend, xe_pm_runtime_suspend() calls xe_gt_suspend() directly without calling xe_guc_pc_stop(), so pc->mert_freq_cap_active is still true when resume reaches pc_set_mert_freq_cap(). pc_set_mert_freq_cap() then calls xe_guc_pc_get_min_freq_locked() to stash the underlying minimum, which hits this branch instead of querying GuC and overwrites pc->stashed_min_freq with the RPe-elevated value. Once xe_guc_pc_restore_stashed_freq() programs that stashed value as GuC's global minimum, setting ignore_eff_freq to 1 can no longer lower min_freq below RPe. Clearing pc->mert_freq_cap_active in pc_init_freqs() (or calling xe_guc_pc_stop() during D3cold suspend) would avoid this. [ ... ] > @@ -1103,12 +1123,23 @@ void xe_guc_pc_remove_flush_freq_limit(struct xe_= guc_pc *pc) > static int pc_set_mert_freq_cap(struct xe_guc_pc *pc) > { > int ret; > + u32 mert_freq_cap; > =20 > if (!XE_GT_WA(pc_to_gt(pc), 22019338487)) > return 0; > =20 > guard(mutex)(&pc->freq_lock); > =20 > + /* > + * Disable the RPe floor so the min queried below reflects the real > + * underlying minimum (RPn or user_requested_min) instead of a value > + * GuC may have elevated to RPe. This stays disabled until > + * xe_guc_pc_restore_stashed_freq() reinstates it. > + */ > + ret =3D pc_set_ignore_eff_freq(pc, 1); > + if (ret) > + return ret; > + > /* > * Get updated min/max and stash them. > */ > @@ -1121,7 +1152,9 @@ static int pc_set_mert_freq_cap(struct xe_guc_pc *p= c) > /* > * Ensure min and max are bound by MERT_FREQ_CAP until driver loads. > */ > - ret =3D pc_set_min_freq(pc, min(xe_guc_pc_get_rpe_freq(pc), pc_max_freq= _cap(pc))); > + mert_freq_cap =3D min(xe_guc_pc_get_rpe_freq(pc), pc_max_freq_cap(pc)); > + > + ret =3D pc_set_min_freq(pc, mert_freq_cap); > if (!ret) > ret =3D pc_set_max_freq(pc, min(pc->rp0_freq, pc_max_freq_cap(pc))); [Severity: Low] If querying or programming the frequencies fails after pc_set_ignore_eff_freq(pc, 1), does this leave GuC with RPe disabled while pc->ignore_eff_freq stays false? Because pc->mert_freq_cap_active remains false on error, xe_guc_pc_restore_stashed_freq() will not reinstate the saved setting. On non-fatal resume paths such as xe_device_resume() (when !flr) or a canceled D3cold runtime suspend in xe_pci_runtime_suspend(), pc_init_freqs() has already set pc->freq_ready =3D true, leaving the device live with sysfs reporting ignore_eff_freq as 0 while GuC ignores RPe. Restoring pc_set_ignore_eff_freq(pc, pc->ignore_eff_freq) on the error path would keep them in sync. > @@ -1153,9 +1186,11 @@ int xe_guc_pc_restore_stashed_freq(struct xe_guc_p= c *pc) > =20 > /* Apply any user min/max request made while the cap was active, else t= he stash. */ > ret =3D pc_set_max_freq(pc, pc->user_requested_max ?: pc->stashed_max_f= req); > - > if (!ret) > ret =3D pc_set_min_freq(pc, pc->user_requested_min ?: pc->stashed_min_= freq); > + /* Restore ignore_eff_freq override from pc_set_mert_freq_cap(). */ > + if (!ret) > + ret =3D pc_set_ignore_eff_freq(pc, pc->ignore_eff_freq); > if (!ret) > pc->mert_freq_cap_active =3D false; [Severity: Medium] If pc_set_ignore_eff_freq() (or pc_set_min_freq()) fails after pc_set_max_freq() succeeds, does pc->mert_freq_cap_active stay stuck true? Every caller invokes xe_guc_pc_restore_stashed_freq() via xe_gt_sanitize_freq() (xe_device_probe(), gsc_work(), and do_gt_restart()) and discards the return value without retrying. While pc->mert_freq_cap_active remains stuck true, subsequent sysfs writes to min_freq, max_freq, and ignore_eff_freq silently skip GuC updates and return success, while min_freq and max_freq reads return cached values instead of querying GuC. [ ... ] > @@ -1211,6 +1251,32 @@ static int pc_action_set_strategy(struct xe_guc_pc= *pc, u32 val) > return ret; > } > =20 > +int xe_guc_pc_set_ignore_eff_freq(struct xe_guc_pc *pc, u32 val) > +{ > + int ret =3D 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 ignore_eff_freq =3D=3D 0, GuC elevates min_freq to RPe when > + * enabled, and resets it back to the previously set min when > + * disabled (ignore_eff_freq =3D=3D 1), so no explicit set_min_freq > + * request is needed here. > + */ > + ret =3D pc_set_ignore_eff_freq(pc, val); > + } > + > + if (!ret) > + pc->ignore_eff_freq =3D val; > + > + return ret; > +} [Severity: Medium] Does setting SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY to 1 without also sending SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ actually lower GuC's minimum frequency on GuC 70.x firmware? Commit 28e671114fb0 ("drm/i915/guc/slpc: Restore efficient freq earlier") noted that GuC does not bring min_freq back down to RPn on its own when SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY is set to 1, so i915 follows it with an explicit min frequency update: drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c:intel_guc_slpc_set_ignore_eff_f= req() { ... /* Set min to RPn when we disable efficient freq */ if (val) ret =3D slpc_set_param(slpc, SLPC_PARAM_GLOBAL_MIN_GT_UNSLICE_FREQ_MHZ, slpc->min_freq); ... } Because xe loads the same i915/*_guc_70.bin firmware family without requiring a newer minor version (full_ver_required is false in xe_uc_fw_check_version_requirements()), relying on GuC to lower min_freq automatically can leave min_freq stuck at RPe here, after GT reset/resume in pc_init_freqs() (which restores ignore_eff_freq after pc_adjust_requested_freq()), and when pc_adjust_freq_bounds() or pc_set_mert_freq_cap() queries the underlying minimum right after disabling RPe. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204014137.2470= 389-3-vinay.belgaumkar@intel.com?part=3D2