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 37F64606A322 for ; Fri, 4 Dec 2026 01:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VcuL0dV4 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F081310E485; Fri, 4 Dec 2026 01:41:58 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30D6010E485 for ; Fri, 4 Dec 2026 01:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796348513; x=1827884513; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DYbj69Lqsa+IVPz7fYhjRSb76w1rWHLpbF4IjpjttQY=; b=VcuL0dV4sdyqes74WbnH7uP8iC1Hm66EpWcyPwoCCrN0Gd6Z0yZhJETP X7J4oajmiFvUT6Hk2x1delDWMU4xtY/2hFjzIEA5TmyV5MCb+tFLa3H2f mxwjlLjHwDE4jNlFVL/pFWbMmIRFHWRMCzr+Hfxqfd/QPVpbGN28fNplL fq7/EE8JJJ3Adlbe/jFqC/DFF7N85nqjvTixi3CKxXsRzLb1VoIOD4RV5 utb1lA+YBc0WmSRTepnZSajSK3k8Ba8d69HnAQxJrul/odfLdrx1MgPrq m7PDAxLceQr29D7J6pzPGxbc1mz4mD0LepAJzys2IfqNfYVN15nlj7LKY A==; X-CSE-ConnectionGUID: vTW1rhGyRBe21P4qYYEcQg== X-CSE-MsgGUID: Gs39GMFQRB2Z61hpnwW5OA== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5335152" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5335152" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 17:41:52 -0800 X-CSE-ConnectionGUID: ziHkN+CjRPq6TJllSI10CQ== X-CSE-MsgGUID: hJ48JpVKTC6poMLuRumS6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="13990557" Received: from vbelgaum-desk1.fm.intel.com ([10.121.64.203]) by orviesa007.jf.intel.com with ESMTP; 03 Dec 2026 17:41:52 -0800 From: Vinay Belgaumkar To: intel-xe@lists.freedesktop.org Cc: Vinay Belgaumkar , Rodrigo Vivi , Sk Anirban Subject: [PATCH v8 2/2] drm/xe: Add sysfs to disable RPe Date: Thu, 3 Dec 2026 17:41:38 -0800 Message-ID: <20261204014137.2470389-4-vinay.belgaumkar@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204014137.2470389-3-vinay.belgaumkar@intel.com> References: <20261204014137.2470389-3-vinay.belgaumkar@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Sender: "Intel-xe" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT 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 When SLPC is initialized, GuC sets the GT min freq to RPe(efficient) by default. This frequency is desgined for optimal perf/power ratio. However, certain use cases may want to run at lower frequencies. This sysfs allows user to disable use of default RPe behavior. Efficient frequency will now be controlled by this interface alone. Setting min_freq < efficient will not disable RPe. When RPe is enabled, GuC raises min to RPe and lowers it back when disabled. Update pc_set_mert_freq_cap() to now disable RPe before stashing min freq. This ensures we are saving the real min freq instead of the elevated one. $ cat /sys/class/drm/card0/device/tile0/gt1/freq0/ignore_eff_freq 0 v2: Address Sashiko comments. v3: Disable RPe before stashing freq before mert cap (Sashiko) v4: Disable RPe inside pc_adjust_freq_bounds (Sashiko), make use_rpe a bool (Anirban) v5: Restore use_rpe while under pc->freq_lock(Sashiko) v6: Fix bug in pc_init_freqs (Sashiko) v7: During mert_cap return the correct min (Sashiko) v8: Rename use_rpe to ignore_eff_freq (Rodrigo) Cc: Rodrigo Vivi Cc: Sk Anirban Signed-off-by: Vinay Belgaumkar --- drivers/gpu/drm/xe/xe_gt_freq.c | 35 +++++++++++ drivers/gpu/drm/xe/xe_guc_pc.c | 87 ++++++++++++++++++++++++---- drivers/gpu/drm/xe/xe_guc_pc.h | 1 + drivers/gpu/drm/xe/xe_guc_pc_types.h | 2 + 4 files changed, 115 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt_freq.c b/drivers/gpu/drm/xe/xe_gt_freq.c index a40dd074106f..b02a9c1fe33e 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 *kobj, } static struct kobj_attribute attr_power_profile = __ATTR_RW(power_profile); +static ssize_t ignore_eff_freq_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buff) +{ + struct device *dev = kobj_to_dev(kobj); + struct xe_guc_pc *pc = dev_to_pc(dev); + + return sysfs_emit(buff, "%u\n", pc->ignore_eff_freq); +} + +static ssize_t ignore_eff_freq_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buff, size_t count) +{ + struct device *dev = kobj_to_dev(kobj); + struct xe_guc_pc *pc = dev_to_pc(dev); + int err; + u32 val; + + err = kstrtou32(buff, 0, &val); + if (err) + return err; + + if (val > 1) + return -EINVAL; + + guard(xe_pm_runtime)(dev_to_xe(dev)); + err = xe_guc_pc_set_ignore_eff_freq(pc, val); + + return err ?: count; +} + +static struct kobj_attribute attr_ignore_eff_freq = __ATTR_RW(ignore_eff_freq); + static const struct attribute *freq_attrs[] = { &attr_act_freq.attr, &attr_cur_freq.attr, @@ -252,6 +286,7 @@ static const struct attribute *freq_attrs[] = { &attr_min_freq.attr, &attr_max_freq.attr, &attr_power_profile.attr, + &attr_ignore_eff_freq.attr, NULL }; diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c index cc1869e6bcbe..bda0dde9c19f 100644 --- a/drivers/gpu/drm/xe/xe_guc_pc.c +++ b/drivers/gpu/drm/xe/xe_guc_pc.c @@ -344,6 +344,21 @@ static void pc_set_cur_freq(struct xe_guc_pc *pc, u32 freq) pc_set_manual_rp_ctrl(pc, false); } +static int pc_set_ignore_eff_freq(struct xe_guc_pc *pc, u32 val) +{ + struct xe_gt *gt = pc_to_gt(pc); + int ret; + + xe_device_assert_mem_access(pc_to_xe(pc)); + + ret = pc_action_set_param(pc, SLPC_PARAM_IGNORE_EFFICIENT_FREQUENCY, val); + if (ret) + xe_gt_err_once(gt, "Failed to set ignore_eff_freq to %u, %pe\n", + val, ERR_PTR(ret)); + + return ret; +} + static bool pc_freq_in_range(struct xe_guc_pc *pc, u32 freq) { /* @@ -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; - /* - * 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); @@ -615,7 +623,10 @@ static int xe_guc_pc_get_min_freq_locked(struct xe_guc_pc *pc, u32 *freq) /* In the middle of a temporary freq cap, return stashed or min freq */ if (pc->mert_freq_cap_active) { - *freq = pc->user_requested_min ?: pc->stashed_min_freq; + u32 min = pc->user_requested_min ?: pc->stashed_min_freq; + + /* Return what GuC would report based on ignore_eff_freq */ + *freq = !pc->ignore_eff_freq ? max(min, xe_guc_pc_get_rpe_freq(pc)) : min; return 0; } @@ -947,6 +958,15 @@ static int pc_adjust_freq_bounds(struct xe_guc_pc *pc) lockdep_assert_held(&pc->freq_lock); + /* + * GuC enables RPe by default during SLPC reset, regardless of + * ignore_eff_freq. Disable it so min_freq below reflects the true GT + * min freq. + */ + ret = pc_set_ignore_eff_freq(pc, 1); + if (ret) + goto out; + ret = pc_action_query_task_state(pc); if (ret) goto out; @@ -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; if (!XE_GT_WA(pc_to_gt(pc), 22019338487)) return 0; guard(mutex)(&pc->freq_lock); + /* + * 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 = 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 *pc) /* * Ensure min and max are bound by MERT_FREQ_CAP until driver loads. */ - ret = pc_set_min_freq(pc, min(xe_guc_pc_get_rpe_freq(pc), pc_max_freq_cap(pc))); + mert_freq_cap = min(xe_guc_pc_get_rpe_freq(pc), pc_max_freq_cap(pc)); + + ret = pc_set_min_freq(pc, mert_freq_cap); if (!ret) ret = pc_set_max_freq(pc, min(pc->rp0_freq, pc_max_freq_cap(pc))); @@ -1153,9 +1186,11 @@ int xe_guc_pc_restore_stashed_freq(struct xe_guc_pc *pc) /* Apply any user min/max request made while the cap was active, else the stash. */ ret = pc_set_max_freq(pc, pc->user_requested_max ?: pc->stashed_max_freq); - if (!ret) ret = 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 = pc_set_ignore_eff_freq(pc, pc->ignore_eff_freq); if (!ret) pc->mert_freq_cap_active = false; @@ -1189,6 +1224,11 @@ static int pc_init_freqs(struct xe_guc_pc *pc) pc_init_pcode_freq(pc); + /* Restore ignore_eff_freq */ + ret = pc_set_ignore_eff_freq(pc, pc->ignore_eff_freq); + if (ret) + goto out; + /* * The frequencies are really ready for use only after the user * requested ones got restored. @@ -1211,6 +1251,32 @@ static int pc_action_set_strategy(struct xe_guc_pc *pc, u32 val) return ret; } +int xe_guc_pc_set_ignore_eff_freq(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 ignore_eff_freq == 0, GuC elevates min_freq to RPe when + * enabled, and resets it back to the previously set min when + * disabled (ignore_eff_freq == 1), so no explicit set_min_freq + * request is needed here. + */ + ret = pc_set_ignore_eff_freq(pc, val); + } + + if (!ret) + pc->ignore_eff_freq = val; + + return ret; +} + static const char *power_profile_to_string(struct xe_guc_pc *pc) { switch (pc->power_profile) { @@ -1447,6 +1513,7 @@ int xe_guc_pc_init(struct xe_guc_pc *pc) pc->bo = bo; pc->power_profile = SLPC_POWER_PROFILE_BASE; + pc->ignore_eff_freq = false; return devm_add_action_or_reset(xe->drm.dev, xe_guc_pc_fini_hw, pc); } diff --git a/drivers/gpu/drm/xe/xe_guc_pc.h b/drivers/gpu/drm/xe/xe_guc_pc.h index 1025a2b15f5f..4638465b8c74 100644 --- a/drivers/gpu/drm/xe/xe_guc_pc.h +++ b/drivers/gpu/drm/xe/xe_guc_pc.h @@ -31,6 +31,7 @@ int xe_guc_pc_get_max_freq(struct xe_guc_pc *pc, u32 *freq); int xe_guc_pc_set_max_freq(struct xe_guc_pc *pc, u32 freq); int xe_guc_pc_set_power_profile(struct xe_guc_pc *pc, const char *buf); void xe_guc_pc_get_power_profile(struct xe_guc_pc *pc, char *profile); +int xe_guc_pc_set_ignore_eff_freq(struct xe_guc_pc *pc, u32 val); enum xe_gt_idle_state xe_guc_pc_c_status(struct xe_guc_pc *pc); u64 xe_guc_pc_rc6_residency(struct xe_guc_pc *pc); diff --git a/drivers/gpu/drm/xe/xe_guc_pc_types.h b/drivers/gpu/drm/xe/xe_guc_pc_types.h index 9a6ea2904e33..71b13183e951 100644 --- a/drivers/gpu/drm/xe/xe_guc_pc_types.h +++ b/drivers/gpu/drm/xe/xe_guc_pc_types.h @@ -37,6 +37,8 @@ struct xe_guc_pc { u32 power_profile; /** @mert_freq_cap_active: Wa_22019338487 min/max cap is currently in force */ bool mert_freq_cap_active; + /** @ignore_eff_freq: Tell GuC to ignore efficient frequency (RPe) */ + bool ignore_eff_freq; }; #endif /* _XE_GUC_PC_TYPES_H_ */ -- 2.53.0