From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Francois Dugast <francois.dugast@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>,
intel-xe@lists.freedesktop.org, lucas.demarchi@intel.com,
matthew.brost@intel.com, matthew.auld@intel.com,
anshuman.gupta@intel.com
Subject: Re: [PATCH 1/7] drm/xe: Fix xe_pm_runtime_get_if_active return
Date: Mon, 06 May 2024 15:23:06 +0200 [thread overview]
Message-ID: <6e948aa47bce90caf8a3f7f692a1e36296833edb.camel@linux.intel.com> (raw)
In-Reply-To: <ZjjX_5L5P7JR2vgH@fdugast-desk>
Hi, Francois,
On Mon, 2024-05-06 at 15:15 +0200, Francois Dugast wrote:
> On Mon, May 06, 2024 at 01:47:56PM +0200, Thomas Hellström wrote:
> > On Fri, 2024-05-03 at 15:13 -0400, Rodrigo Vivi wrote:
> > > Current callers of this function are already taking the result
> > > to a boolean and using in an if. It might be a problem because
> > > current function might return negative error codes on failure,
> > > without increasing the reference counter.
> > >
> > > In this scenario we could end up with extra 'put' call ending
> > > in unbalanced scenarios.
> > >
> > > Let's fix it, while aligning with the current xe_pm_get_if_in_use
> > > style.
> > >
> > > Cc: Francois Dugast <francois.dugast@intel.com>
> > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > ---
> > > drivers/gpu/drm/xe/xe_pm.c | 8 ++++----
> > > drivers/gpu/drm/xe/xe_pm.h | 2 +-
> > > 2 files changed, 5 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_pm.c
> > > b/drivers/gpu/drm/xe/xe_pm.c
> > > index c1831106ea4b..eca977d1e1cb 100644
> > > --- a/drivers/gpu/drm/xe/xe_pm.c
> > > +++ b/drivers/gpu/drm/xe/xe_pm.c
> > > @@ -505,12 +505,12 @@ int xe_pm_runtime_get_ioctl(struct
> > > xe_device
> > > *xe)
> > > * xe_pm_runtime_get_if_active - Get a runtime_pm reference if
> > > device active
> > > * @xe: xe device instance
> > > *
> > > - * Returns: Any number greater than or equal to 0 for success,
> > > negative error
> > > - * code otherwise.
> > > + * Returns: True if device is awake (regardless the previous
> > > number
> > > of references)
> > Nit: Athough both "Returns:" and "Return:" work, the latter seems
> > to be
> > the preferred.
>
> Hi Thomas,
>
> This is indeed what grep shows for Xe (for DRM it is less obvious).
> The
> doc mentions "Returns" in Documentation/gpu/introduction.rst, should
> we
> update it?
I've tried to use https://docs.kernel.org/doc-guide/kernel-doc.html as
a reference, which uses "Return", so I've been trying to enforce that
for xe reviews.
/Thomas
>
> Francois
>
> >
> > Otherwise LGTM.
> > Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> >
> >
> >
> > > + * and a new reference was taken, false otherwise.
> > > */
> > > -int xe_pm_runtime_get_if_active(struct xe_device *xe)
> > > +bool xe_pm_runtime_get_if_active(struct xe_device *xe)
> > > {
> > > - return pm_runtime_get_if_active(xe->drm.dev);
> > > + return pm_runtime_get_if_active(xe->drm.dev) > 0;
> > > }
> > >
> > > /**
> > > diff --git a/drivers/gpu/drm/xe/xe_pm.h
> > > b/drivers/gpu/drm/xe/xe_pm.h
> > > index 18b0613fe57b..f694005db278 100644
> > > --- a/drivers/gpu/drm/xe/xe_pm.h
> > > +++ b/drivers/gpu/drm/xe/xe_pm.h
> > > @@ -29,7 +29,7 @@ int xe_pm_runtime_resume(struct xe_device *xe);
> > > void xe_pm_runtime_get(struct xe_device *xe);
> > > int xe_pm_runtime_get_ioctl(struct xe_device *xe);
> > > void xe_pm_runtime_put(struct xe_device *xe);
> > > -int xe_pm_runtime_get_if_active(struct xe_device *xe);
> > > +bool xe_pm_runtime_get_if_active(struct xe_device *xe);
> > > bool xe_pm_runtime_get_if_in_use(struct xe_device *xe);
> > > void xe_pm_runtime_get_noresume(struct xe_device *xe);
> > > bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
> >
next prev parent reply other threads:[~2024-05-06 13:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 19:13 [PATCH 0/7] Unlock deeper package-C states (PC-10) and D3Cold Rodrigo Vivi
2024-05-03 19:13 ` [PATCH 1/7] drm/xe: Fix xe_pm_runtime_get_if_active return Rodrigo Vivi
2024-05-06 11:47 ` Thomas Hellström
2024-05-06 13:15 ` Francois Dugast
2024-05-06 13:23 ` Thomas Hellström [this message]
2024-05-03 19:13 ` [PATCH 2/7] drm/xe: Fix xe_pm_runtime_get_if_in_use documentation Rodrigo Vivi
2024-05-06 11:49 ` Thomas Hellström
2024-05-03 19:13 ` [PATCH 3/7] drm/xe: Relax runtime pm protection during execution Rodrigo Vivi
2024-05-06 11:57 ` Thomas Hellström
2024-05-03 19:13 ` [PATCH 4/7] drm/xe: Relax runtime pm protection around VM Rodrigo Vivi
2024-05-06 12:30 ` Thomas Hellström
2024-05-06 14:23 ` Rodrigo Vivi
2024-05-07 18:19 ` Matthew Brost
2024-05-09 11:48 ` Gupta, Anshuman
2024-05-09 19:41 ` Rodrigo Vivi
2024-05-03 19:13 ` [PATCH 5/7] drm/xe: Prepare display for D3Cold Rodrigo Vivi
2024-05-03 19:13 ` [PATCH 6/7] drm/xe: Stop checking for power_lost on D3Cold Rodrigo Vivi
2024-05-07 10:35 ` Gupta, Anshuman
2024-05-03 19:13 ` [PATCH 7/7] drm/xe: Enable D3Cold on 'low' VRAM utilization Rodrigo Vivi
2024-05-09 11:51 ` Gupta, Anshuman
2024-05-03 20:34 ` ✓ CI.Patch_applied: success for Unlock deeper package-C states (PC-10) and D3Cold Patchwork
2024-05-03 20:34 ` ✓ CI.checkpatch: " Patchwork
2024-05-03 20:35 ` ✓ CI.KUnit: " Patchwork
2024-05-03 20:47 ` ✓ CI.Build: " Patchwork
2024-05-03 20:49 ` ✓ CI.Hooks: " Patchwork
2024-05-03 20:51 ` ✓ CI.checksparse: " Patchwork
2024-05-03 21:31 ` ✓ CI.BAT: " Patchwork
2024-05-04 0:18 ` ✗ CI.FULL: failure " Patchwork
2024-05-06 19:09 ` Rodrigo Vivi
2024-05-09 10:21 ` [PATCH 0/7] " Francois Dugast
-- strict thread matches above, loose matches on Subject: below --
2024-05-08 20:07 [PATCH 1/7] drm/xe: Fix xe_pm_runtime_get_if_active return Rodrigo Vivi
2024-05-09 19:16 Rodrigo Vivi
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=6e948aa47bce90caf8a3f7f692a1e36296833edb.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=anshuman.gupta@intel.com \
--cc=francois.dugast@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@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