From: Gustavo Sousa <gustavo.sousa@intel.com>
To: Matt Roper <matthew.d.roper@intel.com>, <intel-xe@lists.freedesktop.org>
Cc: <matthew.d.roper@intel.com>
Subject: Re: [PATCH v2 09/30] drm/xe/guc_pc: Use scope-based cleanup
Date: Thu, 13 Nov 2025 10:00:11 -0300 [thread overview]
Message-ID: <176303881117.3698.7643196452483021515@intel.com> (raw)
In-Reply-To: <20251110232017.1475869-41-matthew.d.roper@intel.com>
Quoting Matt Roper (2025-11-10 20:20:27-03:00)
>Use scope-based cleanup for forcewake and runtime PM in the GuC PC code.
>This allows us to eliminate to goto-based cleanup and simplifies some
>other functions.
>
>Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
>---
> drivers/gpu/drm/xe/xe_guc_pc.c | 62 ++++++++++------------------------
> 1 file changed, 17 insertions(+), 45 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
>index ff22235857f8..b2e10359e019 100644
>--- a/drivers/gpu/drm/xe/xe_guc_pc.c
>+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
>@@ -511,21 +511,17 @@ u32 xe_guc_pc_get_cur_freq_fw(struct xe_guc_pc *pc)
> int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq)
> {
> struct xe_gt *gt = pc_to_gt(pc);
>- unsigned int fw_ref;
>
> /*
> * GuC SLPC plays with cur freq request when GuCRC is enabled
> * Block RC6 for a more reliable read.
> */
>- fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
>- if (!xe_force_wake_ref_has_domain(fw_ref, XE_FW_GT)) {
>- xe_force_wake_put(gt_to_fw(gt), fw_ref);
>+ CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GT);
>+ if (!xe_force_wake_ref_has_domain(fw_ref.domains, XE_FW_GT))
> return -ETIMEDOUT;
>- }
>
> *freq = get_cur_freq(gt);
>
>- xe_force_wake_put(gt_to_fw(gt), fw_ref);
> return 0;
> }
>
>@@ -1085,13 +1081,8 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc)
> */
> int xe_guc_pc_override_gucrc_mode(struct xe_guc_pc *pc, enum slpc_gucrc_mode mode)
> {
>- int ret;
>-
>- xe_pm_runtime_get(pc_to_xe(pc));
>- ret = pc_action_set_param(pc, SLPC_PARAM_PWRGATE_RC_MODE, mode);
>- xe_pm_runtime_put(pc_to_xe(pc));
>-
>- return ret;
>+ guard(xe_pm_runtime)(pc_to_xe(pc));
>+ return pc_action_set_param(pc, SLPC_PARAM_PWRGATE_RC_MODE, mode);
> }
>
> /**
>@@ -1102,13 +1093,8 @@ int xe_guc_pc_override_gucrc_mode(struct xe_guc_pc *pc, enum slpc_gucrc_mode mod
> */
> int xe_guc_pc_unset_gucrc_mode(struct xe_guc_pc *pc)
> {
>- int ret;
>-
>- xe_pm_runtime_get(pc_to_xe(pc));
>- ret = pc_action_unset_param(pc, SLPC_PARAM_PWRGATE_RC_MODE);
>- xe_pm_runtime_put(pc_to_xe(pc));
>-
>- return ret;
>+ guard(xe_pm_runtime)(pc_to_xe(pc));
>+ return pc_action_unset_param(pc, SLPC_PARAM_PWRGATE_RC_MODE);
> }
>
> static void pc_init_pcode_freq(struct xe_guc_pc *pc)
>@@ -1198,7 +1184,7 @@ int xe_guc_pc_set_power_profile(struct xe_guc_pc *pc, const char *buf)
> return -EINVAL;
>
> guard(mutex)(&pc->freq_lock);
>- xe_pm_runtime_get_noresume(pc_to_xe(pc));
>+ guard(xe_pm_runtime_noresume)(pc_to_xe(pc));
>
> ret = pc_action_set_param(pc,
> SLPC_PARAM_POWER_PROFILE,
>@@ -1209,8 +1195,6 @@ int xe_guc_pc_set_power_profile(struct xe_guc_pc *pc, const char *buf)
> else
> pc->power_profile = val;
>
>- xe_pm_runtime_put(pc_to_xe(pc));
>-
> return ret;
> }
>
>@@ -1223,17 +1207,14 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
> struct xe_device *xe = pc_to_xe(pc);
> struct xe_gt *gt = pc_to_gt(pc);
> u32 size = PAGE_ALIGN(sizeof(struct slpc_shared_data));
>- unsigned int fw_ref;
> ktime_t earlier;
> int ret;
>
> xe_gt_assert(gt, xe_device_uc_enabled(xe));
>
>- fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
>- if (!xe_force_wake_ref_has_domain(fw_ref, XE_FW_GT)) {
>- xe_force_wake_put(gt_to_fw(gt), fw_ref);
>+ CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GT);
>+ if (!xe_force_wake_ref_has_domain(fw_ref.domains, XE_FW_GT))
> return -ETIMEDOUT;
>- }
>
> if (xe->info.skip_guc_pc) {
> if (xe->info.platform != XE_PVC)
>@@ -1241,9 +1222,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
>
> /* Request max possible since dynamic freq mgmt is not enabled */
> pc_set_cur_freq(pc, UINT_MAX);
>-
>- ret = 0;
>- goto out;
>+ return 0;
> }
>
> xe_map_memset(xe, &pc->bo->vmap, 0, 0, size);
>@@ -1252,7 +1231,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
> earlier = ktime_get();
> ret = pc_action_reset(pc);
> if (ret)
>- goto out;
>+ return ret;
>
> if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
> SLPC_RESET_TIMEOUT_MS)) {
>@@ -1263,8 +1242,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
> if (wait_for_pc_state(pc, SLPC_GLOBAL_STATE_RUNNING,
> SLPC_RESET_EXTENDED_TIMEOUT_MS)) {
> xe_gt_err(gt, "GuC PC Start failed: Dynamic GT frequency control and GT sleep states are now disabled.\n");
>- ret = -EIO;
>- goto out;
>+ return -EIO;
> }
>
> xe_gt_warn(gt, "GuC PC excessive start time: %lldms",
>@@ -1273,21 +1251,20 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
>
> ret = pc_init_freqs(pc);
> if (ret)
>- goto out;
>+ return ret;
>
> ret = pc_set_mert_freq_cap(pc);
> if (ret)
>- goto out;
>+ return ret;
>
> if (xe->info.platform == XE_PVC) {
> xe_guc_pc_gucrc_disable(pc);
>- ret = 0;
>- goto out;
>+ return 0;
> }
>
> ret = pc_action_setup_gucrc(pc, GUCRC_FIRMWARE_CONTROL);
> if (ret)
>- goto out;
>+ return ret;
>
> /* Enable SLPC Optimized Strategy for compute */
> ret = pc_action_set_strategy(pc, SLPC_OPTIMIZED_STRATEGY_COMPUTE);
>@@ -1297,8 +1274,6 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
> if (unlikely(ret))
> xe_gt_err(gt, "Failed to set SLPC power profile: %pe\n", ERR_PTR(ret));
>
>-out:
>- xe_force_wake_put(gt_to_fw(gt), fw_ref);
> return ret;
> }
>
>@@ -1330,19 +1305,16 @@ static void xe_guc_pc_fini_hw(void *arg)
> {
> struct xe_guc_pc *pc = arg;
> struct xe_device *xe = pc_to_xe(pc);
>- unsigned int fw_ref;
>
> if (xe_device_wedged(xe))
> return;
>
>- fw_ref = xe_force_wake_get(gt_to_fw(pc_to_gt(pc)), XE_FORCEWAKE_ALL);
>+ CLASS(xe_force_wake, fw_ref)(gt_to_fw(pc_to_gt(pc)), XE_FORCEWAKE_ALL);
> xe_guc_pc_gucrc_disable(pc);
> XE_WARN_ON(xe_guc_pc_stop(pc));
>
> /* Bind requested freq to mert_freq_cap before unload */
> pc_set_cur_freq(pc, min(pc_max_freq_cap(pc), pc->rpe_freq));
>-
>- xe_force_wake_put(gt_to_fw(pc_to_gt(pc)), fw_ref);
> }
>
> /**
>--
>2.51.1
>
next prev parent reply other threads:[~2025-11-13 13:00 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 23:20 [PATCH v2 00/30] Scope-based forcewake and runtime PM Matt Roper
2025-11-10 23:20 ` [PATCH v2 01/30] drm/xe/forcewake: Improve kerneldoc Matt Roper
2025-11-12 14:04 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 02/30] drm/xe/eustall: Store forcewake reference in stream structure Matt Roper
2025-11-12 15:36 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 03/30] drm/xe/oa: " Matt Roper
2025-11-12 16:11 ` Gustavo Sousa
2025-11-13 17:10 ` Dixit, Ashutosh
2025-11-10 23:20 ` [PATCH v2 04/30] drm/xe/forcewake: Add scope-based cleanup for forcewake Matt Roper
2025-11-12 20:00 ` Gustavo Sousa
2025-11-12 21:01 ` Matt Roper
2025-11-12 21:16 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 05/30] drm/xe/pm: Add scope-based cleanup helper for runtime PM Matt Roper
2025-11-12 19:53 ` Michal Wajdeczko
2025-11-12 21:48 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 06/30] drm/xe/gt: Use scope-based cleanup Matt Roper
2025-11-13 12:26 ` Gustavo Sousa
2025-11-13 22:58 ` Matt Roper
2025-11-10 23:20 ` [PATCH v2 07/30] drm/xe/gt_idle: " Matt Roper
2025-11-13 12:39 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 08/30] drm/xe/guc: " Matt Roper
2025-11-13 12:46 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 09/30] drm/xe/guc_pc: " Matt Roper
2025-11-13 13:00 ` Gustavo Sousa [this message]
2025-11-10 23:20 ` [PATCH v2 10/30] drm/xe/mocs: " Matt Roper
2025-11-13 13:30 ` Gustavo Sousa
2025-11-13 23:28 ` Matt Roper
2025-11-10 23:20 ` [PATCH v2 11/30] drm/xe/pat: Use scope-based forcewake Matt Roper
2025-11-13 13:37 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 12/30] drm/xe/pxp: Use scope-based cleanup Matt Roper
2025-11-13 13:40 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 13/30] drm/xe/gsc: " Matt Roper
2025-11-13 13:46 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 14/30] drm/xe/device: " Matt Roper
2025-11-13 14:04 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 15/30] drm/xe/devcoredump: " Matt Roper
2025-11-13 14:14 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 16/30] drm/xe/display: Use scoped-cleanup Matt Roper
2025-11-13 14:25 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 17/30] drm/xe: Create scoped cleanup class for force_wake_get_any_engine() Matt Roper
2025-11-13 17:39 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 18/30] drm/xe/drm_client: Use scope-based cleanup Matt Roper
2025-11-10 23:20 ` [PATCH v2 19/30] drm/xe/gt_debugfs: " Matt Roper
2025-11-13 17:45 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 20/30] drm/xe/huc: Use scope-based forcewake Matt Roper
2025-11-13 17:46 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 21/30] drm/xe/query: " Matt Roper
2025-11-13 17:50 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 22/30] drm/xe/reg_sr: " Matt Roper
2025-11-13 17:51 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 23/30] drm/xe/vram: " Matt Roper
2025-11-10 23:57 ` [PATCH v2.1 " Matt Roper
2025-11-13 17:52 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 24/30] drm/xe/bo: Use scope-based runtime PM Matt Roper
2025-11-13 17:54 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 25/30] drm/xe/ggtt: Use scope-based runtime pm Matt Roper
2025-11-13 17:55 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 26/30] drm/xe/hwmon: Use scope-based runtime PM Matt Roper
2025-11-13 18:01 ` Gustavo Sousa
2025-11-13 18:05 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 27/30] drm/xe/sriov: " Matt Roper
2025-11-13 18:09 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 28/30] drm/xe/tests: " Matt Roper
2025-11-13 18:15 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 29/30] drm/xe/sysfs: Use scope-based runtime power management Matt Roper
2025-11-13 18:25 ` Gustavo Sousa
2025-11-10 23:20 ` [PATCH v2 30/30] drm/xe/debugfs: Use scope-based runtime PM Matt Roper
2025-11-13 18:30 ` Gustavo Sousa
2025-11-11 0:20 ` ✓ CI.KUnit: success for Scope-based forcewake and runtime PM (rev3) Patchwork
2025-11-11 0:57 ` ✓ Xe.CI.BAT: " Patchwork
2025-11-11 10:50 ` ✗ Xe.CI.Full: failure " Patchwork
2025-11-11 10:57 ` [PATCH v2 00/30] Scope-based forcewake and runtime PM Jani Nikula
2025-11-12 16:01 ` Matt Roper
2025-11-13 22:11 ` Matt Roper
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=176303881117.3698.7643196452483021515@intel.com \
--to=gustavo.sousa@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.d.roper@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