Skip to content

drm/xe: Convert xe_force_wake calls to guard helpers.

Maarten Lankhorst dri-devel intel-xe lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8header/cleanup.h: Add _init_args to DEFINE_LOCK_GUARD_1(_COND)include/linux/cleanup.h+19 -110 replies
2/8drm/xe/gt: Unify xe_hw_fence_irq_finish() calls.drivers/gpu/drm/xe/xe_gt.c+14 -171 reply
3/8drm/xe: Add scoped guards for xe_force_wakedrivers/gpu/drm/xe/xe_force_wake.c drivers/gpu/drm/xe/xe_force_wake.h+66 -04 replies
4/8drm/xe: Add xe_force_wake_get_alldrivers/gpu/drm/xe/xe_force_wake.c drivers/gpu/drm/xe/xe_force_wake.h+77 -350 replies
5/8drm/xe/coredump: Use guard helpers for xe_force_wake.drivers/gpu/drm/xe/xe_devcoredump.c+17 -191 reply
6/8drm/xe/gsc: Use guard helper for xe_gsc_print_info.drivers/gpu/drm/xe/xe_gsc.c+8 -140 replies
7/8drm/xe/vram: Use xe_force_wake guard helperdrivers/gpu/drm/xe/xe_vram.c+20 -250 replies
8/8drm/xe/gt: Convert to xe_force_wake guard helpersdrivers/gpu/drm/xe/xe_gt.c+74 -1420 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH-resent-to-correct-ml 0/8] drm/xe: Convert xe_force_wake calls to guard helpers.

Ignore my previous series please, it should have been sent to intel-xe, was sent to intel-gfx.

Instead of all this repetition of

{
	unsigned fw_ref;

	fw_ref = xe_force_wake_get(fw, domain);
	if (!xe_force_wake_ref_has_domain(..))
		return -ETIMEDOUT;

	...

out:

	xe_force_wake_put(fw_ref);
	return ret;
}

I thought I would look at how to replace it with the guard helpers. It is easy, but it required some minor fixes to make DEFINE_LOCK_GUARD_1 work with extra init arguments.

So I changed the function signature slightly to make the first optional argument a struct member (current behavior), and any additional argument goes to the init call.

This replaces the previous code with

{
	scoped_cond_guard(xe_force_wake_get, return -ETIMEDOUT, fw, domain) {
		....

		return ret;
	}
}

I' ve thought also of playing with this:

{
	CLASS(xe_force_wake_get, fw_ref)(fw, domain);
	if (!fw_ref.lock))
		return -ETIMEDOUT;

	...
	return ret;
}

I'm just fearing that the scoped_cond_guard makes it imposssible to get this wrong, while in the second example it's not clear that it can fail, and that you have to check.

Let me know what you think!
Feedback welcome for the header change as well, should probably go into the locking tree..

Cc Ingo Molnar <[email protected]>
Cc David Lechner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Will Deacon <[email protected]>
Cc Waiman Long <[email protected]>
Cc Boqun Feng <[email protected]>

Maarten Lankhorst (8):
header/cleanup.h: Add _init_args to DEFINE_LOCK_GUARD_1(_COND) drm/xe/gt: Unify xe_hw_fence_irq_finish() calls. drm/xe: Add scoped guards for xe_force_wake
drm/xe: Add xe_force_wake_get_all
drm/xe/coredump: Use guard helpers for xe_force_wake. drm/xe/gsc: Use guard helper for xe_gsc_print_info. drm/xe/vram: Use xe_force_wake guard helper drm/xe/gt: Convert to xe_force_wake guard helpers

 drivers/gpu/drm/xe/xe_devcoredump.c |  36 ++---
 drivers/gpu/drm/xe/xe_force_wake.c  | 161 ++++++++++++++----
 drivers/gpu/drm/xe/xe_force_wake.h  |  17 ++
 drivers/gpu/drm/xe/xe_gsc.c         |  22 +--
 drivers/gpu/drm/xe/xe_gt.c          | 243 ++++++++++------------------
 drivers/gpu/drm/xe/xe_vram.c        |  45 +++---
 include/linux/cleanup.h             |  30 ++--
 7 files changed, 293 insertions(+), 261 deletions(-)
Signature · 1 line
2.47.1