[PATCH 7/9] drm/xe: Use xe_force_wake_tryget when possible

Nirmoy Das nirmoy.das at intel.com
Tue Jun 4 11:02:23 UTC 2024


xe_force_wake_get() increments the domain ref regardless of success
or failure so call xe_force_wake_tryget() to ensure xe_force_wake_put
is called even on failure to keep ref count value accurate.

Signed-off-by: Nirmoy Das <nirmoy.das at intel.com>
---
 drivers/gpu/drm/xe/xe_device.c | 4 ++--
 drivers/gpu/drm/xe/xe_guc.c    | 2 +-
 drivers/gpu/drm/xe/xe_guc_pc.c | 6 +++---
 drivers/gpu/drm/xe/xe_huc.c    | 2 +-
 drivers/gpu/drm/xe/xe_query.c  | 2 +-
 drivers/gpu/drm/xe/xe_vram.c   | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 94dbfe5cf19c..0ff57b3dd0c1 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -527,7 +527,7 @@ static int xe_device_set_has_flat_ccs(struct  xe_device *xe)
 
 	struct xe_gt *gt = xe_root_mmio_gt(xe);
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+	err = xe_force_wake_tryget(gt_to_fw(gt), XE_FW_GT);
 	if (err)
 		return err;
 
@@ -756,7 +756,7 @@ void xe_device_td_flush(struct xe_device *xe)
 		if (xe_gt_is_media_type(gt))
 			continue;
 
-		if (xe_force_wake_get(gt_to_fw(gt), XE_FW_GT))
+		if (xe_force_wake_tryget(gt_to_fw(gt), XE_FW_GT))
 			return;
 
 		xe_mmio_write32(gt, XE2_TDF_CTRL, TRANSIENT_FLUSH_REQUEST);
diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 086a048876ba..728a20aa0700 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -1137,7 +1137,7 @@ void xe_guc_print_info(struct xe_guc *guc, struct drm_printer *p)
 
 	xe_uc_fw_print(&guc->fw, p);
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+	err = xe_force_wake_tryget(gt_to_fw(gt), XE_FW_GT);
 	if (err)
 		return;
 
diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
index ab207a11ac0f..09962634e519 100644
--- a/drivers/gpu/drm/xe/xe_guc_pc.c
+++ b/drivers/gpu/drm/xe/xe_guc_pc.c
@@ -394,7 +394,7 @@ int xe_guc_pc_get_cur_freq(struct xe_guc_pc *pc, u32 *freq)
 	 * GuC SLPC plays with cur freq request when GuCRC is enabled
 	 * Block RC6 for a more reliable read.
 	 */
-	ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
+	ret = xe_force_wake_tryget(gt_to_fw(gt), XE_FORCEWAKE_ALL);
 	if (ret)
 		return ret;
 
@@ -762,7 +762,7 @@ int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc)
 	if (ret)
 		return ret;
 
-	ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
+	ret = xe_force_wake_tryget(gt_to_fw(gt), XE_FORCEWAKE_ALL);
 	if (ret)
 		return ret;
 
@@ -823,7 +823,7 @@ int xe_guc_pc_start(struct xe_guc_pc *pc)
 
 	xe_gt_assert(gt, xe_device_uc_enabled(xe));
 
-	ret = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
+	ret = xe_force_wake_tryget(gt_to_fw(gt), XE_FORCEWAKE_ALL);
 	if (ret)
 		return ret;
 
diff --git a/drivers/gpu/drm/xe/xe_huc.c b/drivers/gpu/drm/xe/xe_huc.c
index b039ff49341b..1d300eea97da 100644
--- a/drivers/gpu/drm/xe/xe_huc.c
+++ b/drivers/gpu/drm/xe/xe_huc.c
@@ -310,7 +310,7 @@ void xe_huc_print_info(struct xe_huc *huc, struct drm_printer *p)
 	if (!xe_uc_fw_is_enabled(&huc->fw))
 		return;
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+	err = xe_force_wake_tryget(gt_to_fw(gt), XE_FW_GT);
 	if (err)
 		return;
 
diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
index 995effcb904b..55253b0e6490 100644
--- a/drivers/gpu/drm/xe/xe_query.c
+++ b/drivers/gpu/drm/xe/xe_query.c
@@ -149,7 +149,7 @@ query_engine_cycles(struct xe_device *xe,
 	if (!hwe)
 		return -EINVAL;
 
-	if (xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL))
+	if (xe_force_wake_tryget(gt_to_fw(gt), XE_FORCEWAKE_ALL))
 		return -EIO;
 
 	__read_timestamps(gt,
diff --git a/drivers/gpu/drm/xe/xe_vram.c b/drivers/gpu/drm/xe/xe_vram.c
index 5bcd59190353..5cf8ac8025ef 100644
--- a/drivers/gpu/drm/xe/xe_vram.c
+++ b/drivers/gpu/drm/xe/xe_vram.c
@@ -238,7 +238,7 @@ static int tile_vram_size(struct xe_tile *tile, u64 *vram_size,
 		return 0;
 	}
 
-	err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
+	err = xe_force_wake_tryget(gt_to_fw(gt), XE_FW_GT);
 	if (err)
 		return err;
 
-- 
2.42.0



More information about the Intel-xe mailing list