drm/xe/pat: Update handling of xe_force_wake_get return
authorHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Mon, 14 Oct 2024 07:55:54 +0000 (13:25 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 17 Oct 2024 14:17:09 +0000 (10:17 -0400)
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 <michal.wajdeczko@intel.com>
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-20-himal.prasad.ghimiray@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_pat.c

index b164738181739658cb24ee7273d86b306503042c..30fdbdb9341e894621857eab55443008285dcdc9 100644 (file)
@@ -182,11 +182,12 @@ static void program_pat_mcr(struct xe_gt *gt, const struct xe_pat_table_entry ta
 static void xelp_dump(struct xe_gt *gt, struct drm_printer *p)
 {
        struct xe_device *xe = gt_to_xe(gt);
-       int i, err;
+       unsigned int fw_ref;
+       int i;
 
-       err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-       if (err)
-               goto err_fw;
+       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (!fw_ref)
+               return;
 
        drm_printf(p, "PAT table:\n");
 
@@ -198,9 +199,7 @@ static void xelp_dump(struct xe_gt *gt, struct drm_printer *p)
                           XELP_MEM_TYPE_STR_MAP[mem_type], pat);
        }
 
-       err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
-err_fw:
-       xe_assert(xe, !err);
+       xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
 
 static const struct xe_pat_ops xelp_pat_ops = {
@@ -211,11 +210,12 @@ static const struct xe_pat_ops xelp_pat_ops = {
 static void xehp_dump(struct xe_gt *gt, struct drm_printer *p)
 {
        struct xe_device *xe = gt_to_xe(gt);
-       int i, err;
+       unsigned int fw_ref;
+       int i;
 
-       err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-       if (err)
-               goto err_fw;
+       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (!fw_ref)
+               return;
 
        drm_printf(p, "PAT table:\n");
 
@@ -229,9 +229,7 @@ static void xehp_dump(struct xe_gt *gt, struct drm_printer *p)
                           XELP_MEM_TYPE_STR_MAP[mem_type], pat);
        }
 
-       err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
-err_fw:
-       xe_assert(xe, !err);
+       xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
 
 static const struct xe_pat_ops xehp_pat_ops = {
@@ -242,11 +240,12 @@ static const struct xe_pat_ops xehp_pat_ops = {
 static void xehpc_dump(struct xe_gt *gt, struct drm_printer *p)
 {
        struct xe_device *xe = gt_to_xe(gt);
-       int i, err;
+       unsigned int fw_ref;
+       int i;
 
-       err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-       if (err)
-               goto err_fw;
+       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (!fw_ref)
+               return;
 
        drm_printf(p, "PAT table:\n");
 
@@ -258,9 +257,7 @@ static void xehpc_dump(struct xe_gt *gt, struct drm_printer *p)
                           REG_FIELD_GET(XEHPC_CLOS_LEVEL_MASK, pat), pat);
        }
 
-       err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
-err_fw:
-       xe_assert(xe, !err);
+       xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
 
 static const struct xe_pat_ops xehpc_pat_ops = {
@@ -271,11 +268,12 @@ static const struct xe_pat_ops xehpc_pat_ops = {
 static void xelpg_dump(struct xe_gt *gt, struct drm_printer *p)
 {
        struct xe_device *xe = gt_to_xe(gt);
-       int i, err;
+       unsigned int fw_ref;
+       int i;
 
-       err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-       if (err)
-               goto err_fw;
+       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (!fw_ref)
+               return;
 
        drm_printf(p, "PAT table:\n");
 
@@ -292,9 +290,7 @@ static void xelpg_dump(struct xe_gt *gt, struct drm_printer *p)
                           REG_FIELD_GET(XELPG_INDEX_COH_MODE_MASK, pat), pat);
        }
 
-       err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
-err_fw:
-       xe_assert(xe, !err);
+       xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
 
 /*
@@ -330,12 +326,13 @@ static void xe2lpm_program_pat(struct xe_gt *gt, const struct xe_pat_table_entry
 static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
 {
        struct xe_device *xe = gt_to_xe(gt);
-       int i, err;
+       unsigned int fw_ref;
        u32 pat;
+       int i;
 
-       err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-       if (err)
-               goto err_fw;
+       fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+       if (!fw_ref)
+               return;
 
        drm_printf(p, "PAT table:\n");
 
@@ -374,9 +371,7 @@ static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
                   REG_FIELD_GET(XE2_COH_MODE, pat),
                   pat);
 
-       err = xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
-err_fw:
-       xe_assert(xe, !err);
+       xe_force_wake_put(gt_to_fw(gt), fw_ref);
 }
 
 static const struct xe_pat_ops xe2_pat_ops = {