Skip to content

Commit a66c198

Browse files
hghimirarodrigovivi
authored andcommitted
drm/xe/xe_gt_idle: Update handling of xe_force_wake_get return
xe_force_wake_get() now returns the reference count-incremented domain mask. If it fails for individual domains, the return value will always be 0. However, for XE_FORCEWAKE_ALL, it may return a non-zero value even in the event of failure. Update the return handling of xe_force_wake_get() to reflect this behavior, and ensure that the return value is passed as input to xe_force_wake_put(). v3 - return xe_wakeref_t instead of int in xe_force_wake_get() - xe_force_wake_put() error doesn't need to be checked. It internally WARNS on domain ack failure. v4 - Rebase fix v5 - return unsigned int for xe_force_wake_get() - Remove reudandant WARN calls. v7 - Fix commit message Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Reviewed-by: Badal Nilawar <badal.nilawar@intel.com> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241014075601.2324382-11-himal.prasad.ghimiray@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 30d1055 commit a66c198

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

drivers/gpu/drm/xe/xe_gt_idle.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void xe_gt_idle_enable_pg(struct xe_gt *gt)
101101
struct xe_gt_idle *gtidle = &gt->gtidle;
102102
struct xe_mmio *mmio = &gt->mmio;
103103
u32 vcs_mask, vecs_mask;
104+
unsigned int fw_ref;
104105
int i, j;
105106

106107
if (IS_SRIOV_VF(xe))
@@ -127,7 +128,7 @@ void xe_gt_idle_enable_pg(struct xe_gt *gt)
127128
VDN_MFXVDENC_POWERGATE_ENABLE(j));
128129
}
129130

130-
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FW_GT));
131+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
131132
if (xe->info.skip_guc_pc) {
132133
/*
133134
* GuC sets the hysteresis value when GuC PC is enabled
@@ -138,22 +139,23 @@ void xe_gt_idle_enable_pg(struct xe_gt *gt)
138139
}
139140

140141
xe_mmio_write32(mmio, POWERGATE_ENABLE, gtidle->powergate_enable);
141-
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FW_GT));
142+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
142143
}
143144

144145
void xe_gt_idle_disable_pg(struct xe_gt *gt)
145146
{
146147
struct xe_gt_idle *gtidle = &gt->gtidle;
148+
unsigned int fw_ref;
147149

148150
if (IS_SRIOV_VF(gt_to_xe(gt)))
149151
return;
150152

151153
xe_device_assert_mem_access(gt_to_xe(gt));
152154
gtidle->powergate_enable = 0;
153155

154-
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FW_GT));
156+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
155157
xe_mmio_write32(&gt->mmio, POWERGATE_ENABLE, gtidle->powergate_enable);
156-
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FW_GT));
158+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
157159
}
158160

159161
/**
@@ -172,7 +174,8 @@ int xe_gt_idle_pg_print(struct xe_gt *gt, struct drm_printer *p)
172174
enum xe_gt_idle_state state;
173175
u32 pg_enabled, pg_status = 0;
174176
u32 vcs_mask, vecs_mask;
175-
int err, n;
177+
unsigned int fw_ref;
178+
int n;
176179
/*
177180
* Media Slices
178181
*
@@ -208,14 +211,14 @@ int xe_gt_idle_pg_print(struct xe_gt *gt, struct drm_printer *p)
208211

209212
/* Do not wake the GT to read powergating status */
210213
if (state != GT_IDLE_C6) {
211-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
212-
if (err)
213-
return err;
214+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
215+
if (!fw_ref)
216+
return -ETIMEDOUT;
214217

215218
pg_enabled = xe_mmio_read32(&gt->mmio, POWERGATE_ENABLE);
216219
pg_status = xe_mmio_read32(&gt->mmio, POWERGATE_DOMAIN_STATUS);
217220

218-
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FW_GT));
221+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
219222
}
220223

221224
if (gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK) {
@@ -298,13 +301,14 @@ static void gt_idle_fini(void *arg)
298301
{
299302
struct kobject *kobj = arg;
300303
struct xe_gt *gt = kobj_to_gt(kobj->parent);
304+
unsigned int fw_ref;
301305

302306
xe_gt_idle_disable_pg(gt);
303307

304308
if (gt_to_xe(gt)->info.skip_guc_pc) {
305-
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FW_GT));
309+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
306310
xe_gt_idle_disable_c6(gt);
307-
xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
311+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
308312
}
309313

310314
sysfs_remove_files(kobj, gt_idle_attrs);

0 commit comments

Comments
 (0)