Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: [RFC 3/3] drm/xe: Use new FW guard in xe_pat.c
Date: Mon, 17 Jun 2024 16:34:30 +0200	[thread overview]
Message-ID: <20240617143430.641-4-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20240617143430.641-1-michal.wajdeczko@intel.com>

Start using new FW guard to minimize risk of leaking force-wake
references.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
 drivers/gpu/drm/xe/xe_pat.c | 60 +++++++++++++------------------------
 1 file changed, 20 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_pat.c b/drivers/gpu/drm/xe/xe_pat.c
index 4ee32ee1cc88..b96395694b4b 100644
--- a/drivers/gpu/drm/xe/xe_pat.c
+++ b/drivers/gpu/drm/xe/xe_pat.c
@@ -173,12 +173,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)
 {
+	CLASS(xe_fw, guard)(gt_to_fw(gt), XE_FW_GT);
 	struct xe_device *xe = gt_to_xe(gt);
-	int i, err;
+	int i;
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-	if (err)
-		goto err_fw;
+	if (!guard.fw)
+		return;
 
 	drm_printf(p, "PAT table:\n");
 
@@ -189,10 +189,6 @@ static void xelp_dump(struct xe_gt *gt, struct drm_printer *p)
 		drm_printf(p, "PAT[%2d] = %s (%#8x)\n", i,
 			   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);
 }
 
 static const struct xe_pat_ops xelp_pat_ops = {
@@ -202,12 +198,12 @@ static const struct xe_pat_ops xelp_pat_ops = {
 
 static void xehp_dump(struct xe_gt *gt, struct drm_printer *p)
 {
+	CLASS(xe_fw, guard)(gt_to_fw(gt), XE_FW_GT);
 	struct xe_device *xe = gt_to_xe(gt);
-	int i, err;
+	int i;
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-	if (err)
-		goto err_fw;
+	if (!guard.fw)
+		return;
 
 	drm_printf(p, "PAT table:\n");
 
@@ -220,10 +216,6 @@ static void xehp_dump(struct xe_gt *gt, struct drm_printer *p)
 		drm_printf(p, "PAT[%2d] = %s (%#8x)\n", i,
 			   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);
 }
 
 static const struct xe_pat_ops xehp_pat_ops = {
@@ -233,12 +225,12 @@ static const struct xe_pat_ops xehp_pat_ops = {
 
 static void xehpc_dump(struct xe_gt *gt, struct drm_printer *p)
 {
+	CLASS(xe_fw, guard)(gt_to_fw(gt), XE_FW_GT);
 	struct xe_device *xe = gt_to_xe(gt);
-	int i, err;
+	int i;
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-	if (err)
-		goto err_fw;
+	if (!guard.fw)
+		return;
 
 	drm_printf(p, "PAT table:\n");
 
@@ -249,10 +241,6 @@ static void xehpc_dump(struct xe_gt *gt, struct drm_printer *p)
 			   REG_FIELD_GET(XELP_MEM_TYPE_MASK, pat),
 			   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);
 }
 
 static const struct xe_pat_ops xehpc_pat_ops = {
@@ -262,12 +250,12 @@ static const struct xe_pat_ops xehpc_pat_ops = {
 
 static void xelpg_dump(struct xe_gt *gt, struct drm_printer *p)
 {
+	CLASS(xe_fw, guard)(gt_to_fw(gt), XE_FW_GT);
 	struct xe_device *xe = gt_to_xe(gt);
-	int i, err;
+	int i;
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-	if (err)
-		goto err_fw;
+	if (!guard.fw)
+		return;
 
 	drm_printf(p, "PAT table:\n");
 
@@ -283,10 +271,6 @@ static void xelpg_dump(struct xe_gt *gt, struct drm_printer *p)
 			   REG_FIELD_GET(XELPG_L4_POLICY_MASK, pat),
 			   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);
 }
 
 /*
@@ -321,13 +305,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)
 {
+	CLASS(xe_fw, guard)(gt_to_fw(gt), XE_FW_GT);
 	struct xe_device *xe = gt_to_xe(gt);
-	int i, err;
+	int i;
 	u32 pat;
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
-	if (err)
-		goto err_fw;
+	if (!guard.fw)
+		return;
 
 	drm_printf(p, "PAT table:\n");
 
@@ -365,10 +349,6 @@ static void xe2_dump(struct xe_gt *gt, struct drm_printer *p)
 		   REG_FIELD_GET(XE2_L4_POLICY, pat),
 		   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);
 }
 
 static const struct xe_pat_ops xe2_pat_ops = {
-- 
2.43.0


  parent reply	other threads:[~2024-06-17 14:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 14:34 [RFC 0/3] FW guard class Michal Wajdeczko
2024-06-17 14:34 ` [RFC 1/3] drm/xe: Introduce force-wake " Michal Wajdeczko
2024-06-17 14:34 ` [RFC 2/3] drm/xe: Use new FW guard in xe_mocs.c Michal Wajdeczko
2024-06-17 14:34 ` Michal Wajdeczko [this message]
2024-06-17 14:59 ` ✓ CI.Patch_applied: success for FW guard class Patchwork
2024-06-17 15:00 ` ✗ CI.checkpatch: warning " Patchwork
2024-06-17 15:01 ` ✓ CI.KUnit: success " Patchwork
2024-06-17 15:13 ` ✓ CI.Build: " Patchwork
2024-06-17 15:15 ` ✗ CI.Hooks: failure " Patchwork
2024-06-17 15:16 ` ✓ CI.checksparse: success " Patchwork
2024-06-17 15:38 ` ✓ CI.BAT: " Patchwork
2024-06-17 17:24 ` [RFC 0/3] " Matthew Brost
2024-06-17 18:00   ` Rodrigo Vivi
2024-06-17 18:06     ` Matthew Brost
2024-06-17 19:24     ` Michal Wajdeczko
2024-06-17 23:30       ` Matthew Brost
2024-06-18  0:54         ` Lucas De Marchi
2024-06-18  1:16           ` Matthew Brost
2024-06-18 18:08             ` Michal Wajdeczko
2024-06-18 18:44               ` Matthew Brost
2024-06-18 20:26           ` Rodrigo Vivi
2024-06-19  6:40             ` Thomas Hellström
2024-06-19 18:46               ` Rodrigo Vivi
2024-06-24 16:32             ` Nirmoy Das
2024-06-18  6:39 ` ✗ CI.FULL: failure for " Patchwork

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=20240617143430.641-4-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /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