Skip to content

Commit 9ffd6ec

Browse files
hghimirarodrigovivi
authored andcommitted
drm/xe/devcoredump: 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. Use helper xe_force_wake_ref_has_domain to verify all domains are initialized or not. 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() v5 - return unsigned int for xe_force_wake_get() v6 - use helper xe_force_wake_ref_has_domain() 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: Nirmoy Das <nirmoy.das@intel.com> Reviewed-by: Badal Nilawar <badal.nilawar@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241014075601.2324382-12-himal.prasad.ghimiray@intel.com Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent a66c198 commit 9ffd6ec

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/gpu/drm/xe/xe_devcoredump.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ static void xe_devcoredump_deferred_snap_work(struct work_struct *work)
158158
{
159159
struct xe_devcoredump_snapshot *ss = container_of(work, typeof(*ss), work);
160160
struct xe_devcoredump *coredump = container_of(ss, typeof(*coredump), snapshot);
161+
unsigned int fw_ref;
161162

162163
/* keep going if fw fails as we still want to save the memory and SW data */
163-
if (xe_force_wake_get(gt_to_fw(ss->gt), XE_FORCEWAKE_ALL))
164+
fw_ref = xe_force_wake_get(gt_to_fw(ss->gt), XE_FORCEWAKE_ALL);
165+
if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL))
164166
xe_gt_info(ss->gt, "failed to get forcewake for coredump capture\n");
165167
xe_vm_snapshot_capture_delayed(ss->vm);
166168
xe_guc_exec_queue_snapshot_capture_delayed(ss->ge);
167-
xe_force_wake_put(gt_to_fw(ss->gt), XE_FORCEWAKE_ALL);
169+
xe_force_wake_put(gt_to_fw(ss->gt), fw_ref);
168170

169171
/* Calculate devcoredump size */
170172
ss->read.size = __xe_devcoredump_read(NULL, INT_MAX, coredump);
@@ -236,8 +238,9 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
236238
u32 width_mask = (0x1 << q->width) - 1;
237239
const char *process_name = "no process";
238240

239-
int i;
241+
unsigned int fw_ref;
240242
bool cookie;
243+
int i;
241244

242245
ss->snapshot_time = ktime_get_real();
243246
ss->boot_time = ktime_get_boottime();
@@ -261,8 +264,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
261264
}
262265

263266
/* keep going if fw fails as we still want to save the memory and SW data */
264-
if (xe_force_wake_get(gt_to_fw(q->gt), XE_FORCEWAKE_ALL))
265-
xe_gt_info(ss->gt, "failed to get forcewake for coredump capture\n");
267+
fw_ref = xe_force_wake_get(gt_to_fw(q->gt), XE_FORCEWAKE_ALL);
266268

267269
ss->guc.log = xe_guc_log_snapshot_capture(&guc->log, true);
268270
ss->guc.ct = xe_guc_ct_snapshot_capture(&guc->ct, true);
@@ -274,7 +276,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
274276

275277
queue_work(system_unbound_wq, &ss->work);
276278

277-
xe_force_wake_put(gt_to_fw(q->gt), XE_FORCEWAKE_ALL);
279+
xe_force_wake_put(gt_to_fw(q->gt), fw_ref);
278280
dma_fence_end_signalling(cookie);
279281
}
280282

0 commit comments

Comments
 (0)