Skip to content

Commit 52f8cd7

Browse files
hghimirarodrigovivi
authored andcommitted
drm/xe/pat: 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. - don't use xe_assert() to report HW errors (Michal) v5 - return unsigned int from xe_force_wake_get() - remove redundant warns v7 - Fix commit message - Remove redundant header Cc: Michal Wajdeczko <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Lucas De Marchi <[email protected]> Signed-off-by: Himal Prasad Ghimiray <[email protected]> Reviewed-by: Nirmoy Das <[email protected]> Reviewed-by: Badal Nilawar <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 41cd5ce commit 52f8cd7

File tree

1 file changed

+30
-35
lines changed

1 file changed

+30
-35
lines changed

drivers/gpu/drm/xe/xe_pat.c

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,12 @@ static void program_pat_mcr(struct xe_gt *gt, const struct xe_pat_table_entry ta
182182
static void xelp_dump(struct xe_gt *gt, struct drm_printer *p)
183183
{
184184
struct xe_device *xe = gt_to_xe(gt);
185-
int i, err;
185+
unsigned int fw_ref;
186+
int i;
186187

187-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
188-
if (err)
189-
goto err_fw;
188+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
189+
if (!fw_ref)
190+
return;
190191

191192
drm_printf(p, "PAT table:\n");
192193

@@ -198,9 +199,7 @@ static void xelp_dump(struct xe_gt *gt, struct drm_printer *p)
198199
XELP_MEM_TYPE_STR_MAP[mem_type], pat);
199200
}
200201

201-
err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
202-
err_fw:
203-
xe_assert(xe, !err);
202+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
204203
}
205204

206205
static const struct xe_pat_ops xelp_pat_ops = {
@@ -211,11 +210,12 @@ static const struct xe_pat_ops xelp_pat_ops = {
211210
static void xehp_dump(struct xe_gt *gt, struct drm_printer *p)
212211
{
213212
struct xe_device *xe = gt_to_xe(gt);
214-
int i, err;
213+
unsigned int fw_ref;
214+
int i;
215215

216-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
217-
if (err)
218-
goto err_fw;
216+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
217+
if (!fw_ref)
218+
return;
219219

220220
drm_printf(p, "PAT table:\n");
221221

@@ -229,9 +229,7 @@ static void xehp_dump(struct xe_gt *gt, struct drm_printer *p)
229229
XELP_MEM_TYPE_STR_MAP[mem_type], pat);
230230
}
231231

232-
err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
233-
err_fw:
234-
xe_assert(xe, !err);
232+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
235233
}
236234

237235
static const struct xe_pat_ops xehp_pat_ops = {
@@ -242,11 +240,12 @@ static const struct xe_pat_ops xehp_pat_ops = {
242240
static void xehpc_dump(struct xe_gt *gt, struct drm_printer *p)
243241
{
244242
struct xe_device *xe = gt_to_xe(gt);
245-
int i, err;
243+
unsigned int fw_ref;
244+
int i;
246245

247-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
248-
if (err)
249-
goto err_fw;
246+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
247+
if (!fw_ref)
248+
return;
250249

251250
drm_printf(p, "PAT table:\n");
252251

@@ -258,9 +257,7 @@ static void xehpc_dump(struct xe_gt *gt, struct drm_printer *p)
258257
REG_FIELD_GET(XEHPC_CLOS_LEVEL_MASK, pat), pat);
259258
}
260259

261-
err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
262-
err_fw:
263-
xe_assert(xe, !err);
260+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
264261
}
265262

266263
static const struct xe_pat_ops xehpc_pat_ops = {
@@ -271,11 +268,12 @@ static const struct xe_pat_ops xehpc_pat_ops = {
271268
static void xelpg_dump(struct xe_gt *gt, struct drm_printer *p)
272269
{
273270
struct xe_device *xe = gt_to_xe(gt);
274-
int i, err;
271+
unsigned int fw_ref;
272+
int i;
275273

276-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
277-
if (err)
278-
goto err_fw;
274+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
275+
if (!fw_ref)
276+
return;
279277

280278
drm_printf(p, "PAT table:\n");
281279

@@ -292,9 +290,7 @@ static void xelpg_dump(struct xe_gt *gt, struct drm_printer *p)
292290
REG_FIELD_GET(XELPG_INDEX_COH_MODE_MASK, pat), pat);
293291
}
294292

295-
err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
296-
err_fw:
297-
xe_assert(xe, !err);
293+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
298294
}
299295

300296
/*
@@ -330,12 +326,13 @@ static void xe2lpm_program_pat(struct xe_gt *gt, const struct xe_pat_table_entry
330326
static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
331327
{
332328
struct xe_device *xe = gt_to_xe(gt);
333-
int i, err;
329+
unsigned int fw_ref;
334330
u32 pat;
331+
int i;
335332

336-
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
337-
if (err)
338-
goto err_fw;
333+
fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
334+
if (!fw_ref)
335+
return;
339336

340337
drm_printf(p, "PAT table:\n");
341338

@@ -374,9 +371,7 @@ static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
374371
REG_FIELD_GET(XE2_COH_MODE, pat),
375372
pat);
376373

377-
err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
378-
err_fw:
379-
xe_assert(xe, !err);
374+
xe_force_wake_put(gt_to_fw(gt), fw_ref);
380375
}
381376

382377
static const struct xe_pat_ops xe2_pat_ops = {

0 commit comments

Comments
 (0)