[PATCH v2 2/2] drm/xe: Use new force-wake guard class in xe_mocs.c

Lucas De Marchi lucas.demarchi at intel.com
Tue Nov 19 20:03:12 UTC 2024


On Mon, Nov 18, 2024 at 07:45:11PM +0100, Michal Wajdeczko wrote:
>Start using new xe_fw class to minimize risk of leaking force-wake
>references.
>
>Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
>---
>v2: rebased
>---
> drivers/gpu/drm/xe/xe_mocs.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_mocs.c b/drivers/gpu/drm/xe/xe_mocs.c
>index 54d199b5cfb2..f18aaa6595c7 100644
>--- a/drivers/gpu/drm/xe/xe_mocs.c
>+++ b/drivers/gpu/drm/xe/xe_mocs.c
>@@ -776,19 +776,15 @@ void xe_mocs_dump(struct xe_gt *gt, struct drm_printer *p)
> {
> 	struct xe_device *xe = gt_to_xe(gt);
> 	struct xe_mocs_info table;
>-	unsigned int fw_ref, flags;
>+	unsigned int flags;
>
> 	flags = get_mocs_settings(xe, &table);
>
> 	xe_pm_runtime_get_noresume(xe);
>-	fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
>-	if (!fw_ref)
>-		goto err_fw;
>
>-	table.ops->dump(&table, flags, gt, p);
>+	scoped_guard(xe_fw, gt_to_fw(gt), XE_FW_GT)
>+		table.ops->dump(&table, flags, gt, p);


afair one caveat is that you can't have a goto that jumps over guard
because of the usage of the cleanup attribute. Is that still the case or
do we have some magic convincing the compiler to do the right thing?

once we get agreement on the approach, please let's convert everything
that can be converted to scoped guard so we don't have to keep both
approaches for a long time.

Lucas De Marchi

>
>-	xe_force_wake_put(gt_to_fw(gt), fw_ref);
>-err_fw:
> 	xe_pm_runtime_put(xe);
> }
>
>-- 
>2.43.0
>


More information about the Intel-xe mailing list