[RFC 2/2] drm/xe: Use new PM guard in xe_gt_debugfs.c
Michal Wajdeczko
michal.wajdeczko at intel.com
Mon Jun 17 14:01:20 UTC 2024
Start using new PM guard to minimize risk of leaking PM references.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
drivers/gpu/drm/xe/xe_gt_debugfs.c | 91 +++++++++++-------------------
1 file changed, 34 insertions(+), 57 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
index 5e7fd937917a..6973953a709c 100644
--- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
@@ -88,39 +88,31 @@ static int hw_engines(struct xe_gt *gt, struct drm_printer *p)
struct xe_hw_engine *hwe;
enum xe_hw_engine_id id;
int err;
+ CLASS(xe_pm, guard)(xe);
- xe_pm_runtime_get(xe);
err = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
- if (err) {
- xe_pm_runtime_put(xe);
+ if (err)
return err;
- }
for_each_hw_engine(hwe, gt, id)
xe_hw_engine_print(hwe, p);
err = xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
- xe_pm_runtime_put(xe);
- if (err)
- return err;
-
- return 0;
+ return err;
}
static int force_reset(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_gt_reset_async(gt);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_gt_reset_async(gt);
return 0;
}
static int force_reset_sync(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_gt_reset_async(gt);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_gt_reset_async(gt);
flush_work(>->reset.worker);
@@ -131,39 +123,35 @@ static int sa_info(struct xe_gt *gt, struct drm_printer *p)
{
struct xe_tile *tile = gt_to_tile(gt);
- xe_pm_runtime_get(gt_to_xe(gt));
- drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,
- tile->mem.kernel_bb_pool->gpu_addr);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ drm_suballoc_dump_debug_info(&tile->mem.kernel_bb_pool->base, p,
+ tile->mem.kernel_bb_pool->gpu_addr);
return 0;
}
static int topology(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_gt_topology_dump(gt, p);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_gt_topology_dump(gt, p);
return 0;
}
static int steering(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_gt_mcr_steering_dump(gt, p);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_gt_mcr_steering_dump(gt, p);
return 0;
}
static int ggtt(struct xe_gt *gt, struct drm_printer *p)
{
- int ret;
+ int ret = -EIO;
- xe_pm_runtime_get(gt_to_xe(gt));
- ret = xe_ggtt_dump(gt_to_tile(gt)->mem.ggtt, p);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ ret = xe_ggtt_dump(gt_to_tile(gt)->mem.ggtt, p);
return ret;
}
@@ -172,8 +160,7 @@ static int register_save_restore(struct xe_gt *gt, struct drm_printer *p)
{
struct xe_hw_engine *hwe;
enum xe_hw_engine_id id;
-
- xe_pm_runtime_get(gt_to_xe(gt));
+ CLASS(xe_pm, var)(gt_to_xe(gt));
xe_reg_sr_dump(>->reg_sr, p);
drm_printf(p, "\n");
@@ -192,79 +179,69 @@ static int register_save_restore(struct xe_gt *gt, struct drm_printer *p)
for_each_hw_engine(hwe, gt, id)
xe_reg_whitelist_dump(&hwe->reg_whitelist, p);
- xe_pm_runtime_put(gt_to_xe(gt));
-
return 0;
}
static int workarounds(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_wa_dump(gt, p);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_wa_dump(gt, p);
return 0;
}
static int pat(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_pat_dump(gt, p);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_pat_dump(gt, p);
return 0;
}
static int mocs(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_mocs_dump(gt, p);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_mocs_dump(gt, p);
return 0;
}
static int rcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_RENDER);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_RENDER);
return 0;
}
static int ccs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COMPUTE);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COMPUTE);
return 0;
}
static int bcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COPY);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_COPY);
return 0;
}
static int vcs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_DECODE);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_DECODE);
return 0;
}
static int vecs_default_lrc(struct xe_gt *gt, struct drm_printer *p)
{
- xe_pm_runtime_get(gt_to_xe(gt));
- xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_ENHANCE);
- xe_pm_runtime_put(gt_to_xe(gt));
+ scoped_guard(xe_pm, gt_to_xe(gt))
+ xe_lrc_dump_default(p, gt, XE_ENGINE_CLASS_VIDEO_ENHANCE);
return 0;
}
--
2.43.0
More information about the Intel-xe
mailing list