Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>,
	Raag Jadav <raag.jadav@intel.com>,
	<intel-xe@lists.freedesktop.org>,
	"Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH v2 1/2] drm/xe: Introduce force-wake guard class
Date: Mon, 25 Nov 2024 07:11:39 -0500	[thread overview]
Message-ID: <Z0RpewnaZocMaBoX@intel.com> (raw)
In-Reply-To: <855208c6-cd7c-4e63-a865-8d970bda11df@intel.com>

On Tue, Nov 19, 2024 at 09:26:42PM +0100, Michal Wajdeczko wrote:
> 
> 
> On 19.11.2024 20:59, Lucas De Marchi wrote:
> > On Tue, Nov 19, 2024 at 09:21:17PM +0200, Raag Jadav wrote:
> >> On Tue, Nov 19, 2024 at 01:47:28PM -0500, Rodrigo Vivi wrote:
> >>> On Mon, Nov 18, 2024 at 07:45:10PM +0100, Michal Wajdeczko wrote:
> >>> > There is support for 'classes' with constructor and destructor
> >>> > semantics that can be used for any scope-based resource management,
> >>> > like our domain force-wake management.
> >>>
> >>> There is, okay...
> >>> It can be, okay...
> >>>
> >>> But why do we want?
> >>> What are the advantages?
> >>
> >> Makes error cases easier to handle + less code.
> 
> and this 'easier' is not just that as it also means that code is much
> more robust as it's the compiler job to take care of all the cleanup,
> which could be tricky when doing early exits from different paths, or
> due to late updates to the code done by someone else
> 
> >> We significantly cleaned up intel pinctrl and gpio drivers a few
> >> months ago
> >> and almost halved the footprint in some cases.
> > 
> > I'm ok with using this pattern as I already expressed before.
> > Particularly seeing other subsystems adopting it and being used well in
> > the core kernel as well.
> > 
> > Main ask here is to provide proper justification in the commit message.
> 
> there was a little more in the cover letter:
> 
> ""
> This should allow us to use:
> 
> 	CLASS(xe_fw, var)(fw, XE_FORCEWAKE_ALL);
> or
> 	guard(xe_fw)(fw, XE_FW_GT);
> or
> 	scoped_guard(xe_fw, fw, XE_FW_GT)
> 		foo();
> 
> without any concern of leaking the force-wake references.
> ""
> 
> do you want/need more?

this block here also just say 'allow to use' but fail to describe
why we should use. But the upper block started by Raav seems a good
why. Just make sure that that is in the commit message and

Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> 
> > 
> > Lucas De Marchi
> > 
> >>
> >> Raag
> >>
> >>> >
> >>> > Define xe_fw class that can be used for force-wake management.
> >>> >
> >>> > Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> >>> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> >>> > Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> >>> > Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> >>> > ---
> >>> > v2: aligned to new force-wake usage model (Michal)
> >>> > ---
> >>> >  drivers/gpu/drm/xe/xe_force_wake.h       | 12 ++++++++++++
> >>> >  drivers/gpu/drm/xe/xe_force_wake_types.h | 10 ++++++++++
> >>> >  2 files changed, 22 insertions(+)
> >>> >
> >>> > diff --git a/drivers/gpu/drm/xe/xe_force_wake.h b/drivers/gpu/drm/
> >>> xe/xe_force_wake.h
> >>> > index 0e3e84bfa51c..e46e44f7eb70 100644
> >>> > --- a/drivers/gpu/drm/xe/xe_force_wake.h
> >>> > +++ b/drivers/gpu/drm/xe/xe_force_wake.h
> >>> > @@ -6,6 +6,8 @@
> >>> >  #ifndef _XE_FORCE_WAKE_H_
> >>> >  #define _XE_FORCE_WAKE_H_
> >>> >
> >>> > +#include <linux/cleanup.h>
> >>> > +
> >>> >  #include "xe_assert.h"
> >>> >  #include "xe_force_wake_types.h"
> >>> >
> >>> > @@ -61,4 +63,14 @@ xe_force_wake_ref_has_domain(unsigned int
> >>> fw_ref, enum xe_force_wake_domains dom
> >>> >      return fw_ref & domain;
> >>> >  }
> >>> >
> >>> > +DEFINE_CLASS(xe_fw, struct xe_force_wake_guard,
> >>> > +         xe_force_wake_put(_T.fw, _T.ref),
> >>> > +         ({ (struct xe_force_wake_guard){ fw,
> >>> xe_force_wake_get(fw, domains) }; }),
> >>> > +         struct xe_force_wake *fw, enum xe_force_wake_domains
> >>> domains);
> >>> > +
> >>> > +static inline void *class_xe_fw_lock_ptr(class_xe_fw_t *_T)
> >>> > +{
> >>> > +    return _T->ref ? _T : NULL;
> >>> > +}
> >>> > +
> >>> >  #endif
> >>> > diff --git a/drivers/gpu/drm/xe/xe_force_wake_types.h b/drivers/
> >>> gpu/drm/xe/xe_force_wake_types.h
> >>> > index 899fbbcb3ea9..15456a24f707 100644
> >>> > --- a/drivers/gpu/drm/xe/xe_force_wake_types.h
> >>> > +++ b/drivers/gpu/drm/xe/xe_force_wake_types.h
> >>> > @@ -85,4 +85,14 @@ struct xe_force_wake {
> >>> >      struct xe_force_wake_domain domains[XE_FW_DOMAIN_ID_COUNT];
> >>> >  };
> >>> >
> >>> > +/**
> >>> > + * struct xe_force_wake_guard - Xe force wake guard
> >>> > + */
> >>> > +struct xe_force_wake_guard {
> >>> > +    /** @fw: force wake manager */
> >>> > +    struct xe_force_wake *fw;
> >>> > +    /** @ref: opaque reference to woken domains */
> >>> > +    unsigned int ref;
> >>> > +};
> >>> > +
> >>> >  #endif
> >>> > --
> >>> > 2.43.0
> >>> >
> 

  reply	other threads:[~2024-11-25 12:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-18 18:45 [PATCH v2 0/2] New force-wake guard class Michal Wajdeczko
2024-11-18 18:45 ` [PATCH v2 1/2] drm/xe: Introduce " Michal Wajdeczko
2024-11-19 18:47   ` Rodrigo Vivi
2024-11-19 19:21     ` Raag Jadav
2024-11-19 19:59       ` Lucas De Marchi
2024-11-19 20:26         ` Michal Wajdeczko
2024-11-25 12:11           ` Rodrigo Vivi [this message]
2024-11-25 13:53             ` Raag Jadav
2024-11-18 18:45 ` [PATCH v2 2/2] drm/xe: Use new force-wake guard class in xe_mocs.c Michal Wajdeczko
2024-11-19 20:03   ` Lucas De Marchi
2024-11-19 21:05     ` Michal Wajdeczko
2024-11-21  4:55     ` Matthew Brost
2024-11-21 20:53       ` Lucas De Marchi
2024-11-18 18:54 ` ✓ CI.Patch_applied: success for New force-wake guard class Patchwork
2024-11-18 18:55 ` ✓ CI.checkpatch: " Patchwork
2024-11-18 18:57 ` ✓ CI.KUnit: " Patchwork
2024-11-18 19:20 ` ✓ CI.Build: " Patchwork
2024-11-18 19:23 ` ✓ CI.Hooks: " Patchwork
2024-11-18 19:24 ` ✓ CI.checksparse: " Patchwork
2024-11-19  1:57 ` ✗ CI.FULL: failure " Patchwork
2024-11-19  7:29 ` ✓ CI.BAT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z0RpewnaZocMaBoX@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=raag.jadav@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox