Commit bedad003 authored by Matt Roper's avatar Matt Roper
Browse files

drm/xe/gt_debugfs: Use scope-based cleanup



Use scope-based cleanup for forcewake and runtime PM to simplify the
debugfs code slightly.

Reviewed-by: default avatarGustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-45-matthew.d.roper@intel.com


Signed-off-by: default avatarMatt Roper <matthew.d.roper@intel.com>
parent 062a6b83
Loading
Loading
Loading
Loading
+8 −21
Original line number Diff line number Diff line
@@ -105,35 +105,24 @@ int xe_gt_debugfs_show_with_rpm(struct seq_file *m, void *data)
	struct drm_info_node *node = m->private;
	struct xe_gt *gt = node_to_gt(node);
	struct xe_device *xe = gt_to_xe(gt);
	int ret;

	xe_pm_runtime_get(xe);
	ret = xe_gt_debugfs_simple_show(m, data);
	xe_pm_runtime_put(xe);

	return ret;
	guard(xe_pm_runtime)(xe);
	return xe_gt_debugfs_simple_show(m, data);
}

static int hw_engines(struct xe_gt *gt, struct drm_printer *p)
{
	struct xe_hw_engine *hwe;
	enum xe_hw_engine_id id;
	unsigned int fw_ref;
	int ret = 0;

	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
	if (!xe_force_wake_ref_has_domain(fw_ref, XE_FORCEWAKE_ALL)) {
		ret = -ETIMEDOUT;
		goto fw_put;
	}
	CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FORCEWAKE_ALL);
	if (!xe_force_wake_ref_has_domain(fw_ref.domains, XE_FORCEWAKE_ALL))
		return -ETIMEDOUT;

	for_each_hw_engine(hwe, gt, id)
		xe_hw_engine_print(hwe, p);

fw_put:
	xe_force_wake_put(gt_to_fw(gt), fw_ref);

	return ret;
	return 0;
}

static int steering(struct xe_gt *gt, struct drm_printer *p)
@@ -269,9 +258,8 @@ static void force_reset(struct xe_gt *gt)
{
	struct xe_device *xe = gt_to_xe(gt);

	xe_pm_runtime_get(xe);
	guard(xe_pm_runtime)(xe);
	xe_gt_reset_async(gt);
	xe_pm_runtime_put(xe);
}

static ssize_t force_reset_write(struct file *file,
@@ -297,9 +285,8 @@ static void force_reset_sync(struct xe_gt *gt)
{
	struct xe_device *xe = gt_to_xe(gt);

	xe_pm_runtime_get(xe);
	guard(xe_pm_runtime)(xe);
	xe_gt_reset(gt);
	xe_pm_runtime_put(xe);
}

static ssize_t force_reset_sync_write(struct file *file,