[RFC 0/3] FW guard class

Matthew Brost matthew.brost at intel.com
Mon Jun 17 17:24:24 UTC 2024


On Mon, Jun 17, 2024 at 04:34:27PM +0200, Michal Wajdeczko wrote:
> There is support for 'classes' with constructor and destructor
> semantics that can be used for any scope-based resource management,
> like device force-wake management.
> 
> Add necessary definitions explicitly, since existing macros from
> linux/cleanup.h can't deal with our specific requirements yet.
> 
> This should allow us to use:
> 
> 	scoped_guard(xe_fw, fw, XE_FW_GT)
> 		foo();
> or
> 	CLASS(xe_fw, var)(fw, XE_FW_GT);
> 
> without any concern of leaking the force-wake references.
> 
> Note: this is preliminary code as right now it's unclear how to
> correctly handle errors from the force-wake functions.
> 

I'm personally don't like this at all. IMO it obfuscate the code with
little real benefit. This is just an opinion though, others opinions may
differ from mine.

Matt

> Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
> Cc: Lucas De Marchi <lucas.demarchi at intel.com>
> 
> Michal Wajdeczko (3):
>   drm/xe: Introduce force-wake guard class
>   drm/xe: Use new FW guard in xe_mocs.c
>   drm/xe: Use new FW guard in xe_pat.c
> 
>  drivers/gpu/drm/xe/xe_force_wake.h       | 48 +++++++++++++++++++
>  drivers/gpu/drm/xe/xe_force_wake_types.h | 12 +++++
>  drivers/gpu/drm/xe/xe_mocs.c             | 12 +----
>  drivers/gpu/drm/xe/xe_pat.c              | 60 ++++++++----------------
>  4 files changed, 82 insertions(+), 50 deletions(-)
> 
> -- 
> 2.43.0
> 


More information about the Intel-xe mailing list