All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Lukas Wunner <lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
Cc: Archit Taneja <architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
	David Airlie <airlied-cv59FeDIM0c@public.gmane.org>,
	nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Maarten Lankhorst
	<maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	Ben Skeggs <bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v2 2/3] drm/nouveau: Fix runtime PM leak in nv50_disp_atomic_commit()
Date: Tue, 17 Jul 2018 13:31:24 +0300	[thread overview]
Message-ID: <20180717103124.GO5565@intel.com> (raw)
In-Reply-To: <20180717073352.GA17459-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>

On Tue, Jul 17, 2018 at 09:33:52AM +0200, Lukas Wunner wrote:
> On Thu, Jul 12, 2018 at 01:02:53PM -0400, Lyude Paul wrote:
> > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > @@ -1878,7 +1878,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,
> >  		nv50_disp_atomic_commit_tail(state);
> >  
> >  	drm_for_each_crtc(crtc, dev) {
> > -		if (crtc->state->enable) {
> > +		if (crtc->state->active) {
> >  			if (!drm->have_disp_power_ref) {
> >  				drm->have_disp_power_ref = true;
> >  				return 0;
> 
> Somewhat tangential comment on this older patch, since you
> continue to dig around in the runtime PM area:
> 
> Whenever a crtc is activated or deactivated in nouveau, we iterate
> over all crtcs and acquire a runtime PM if a crtc is active and
> previously there was no active one, or we drop a ref if none is
> active and previously there was an active one.
> 
> For a while now I've been thinking that it would be more straightforward
> to acquire a ref whenever a crtc is activated and drop one when a crtc
> is deactivated, i.e. hold one ref for every active crtc.  That way the
> have_disp_power_ref variable as well as the iteration logic could be
> removed, leading to a simplification.  Just a suggestion anyway.

The current code looks somewhat busted anyway. First problem is that
it's accessing crtc->state without the appropriate locks held (unless
something always pulls in all crtcs to every commit?). Second issue
is that the rpm_put() is called without waiting for nonblocking commits
to have finished so it looks like you can currentlly remove the power
before the hardware has been properly shut down.

-- 
Ville Syrjälä
Intel
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: Lyude Paul <lyude@redhat.com>,
	nouveau@lists.freedesktop.org,
	Archit Taneja <architt@codeaurora.org>,
	David Airlie <airlied@linux.ie>,
	dri-devel@lists.freedesktop.org,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	linux-kernel@vger.kernel.org, Ben Skeggs <bskeggs@redhat.com>
Subject: Re: [Nouveau] [PATCH v2 2/3] drm/nouveau: Fix runtime PM leak in nv50_disp_atomic_commit()
Date: Tue, 17 Jul 2018 13:31:24 +0300	[thread overview]
Message-ID: <20180717103124.GO5565@intel.com> (raw)
In-Reply-To: <20180717073352.GA17459@wunner.de>

On Tue, Jul 17, 2018 at 09:33:52AM +0200, Lukas Wunner wrote:
> On Thu, Jul 12, 2018 at 01:02:53PM -0400, Lyude Paul wrote:
> > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > @@ -1878,7 +1878,7 @@ nv50_disp_atomic_commit(struct drm_device *dev,
> >  		nv50_disp_atomic_commit_tail(state);
> >  
> >  	drm_for_each_crtc(crtc, dev) {
> > -		if (crtc->state->enable) {
> > +		if (crtc->state->active) {
> >  			if (!drm->have_disp_power_ref) {
> >  				drm->have_disp_power_ref = true;
> >  				return 0;
> 
> Somewhat tangential comment on this older patch, since you
> continue to dig around in the runtime PM area:
> 
> Whenever a crtc is activated or deactivated in nouveau, we iterate
> over all crtcs and acquire a runtime PM if a crtc is active and
> previously there was no active one, or we drop a ref if none is
> active and previously there was an active one.
> 
> For a while now I've been thinking that it would be more straightforward
> to acquire a ref whenever a crtc is activated and drop one when a crtc
> is deactivated, i.e. hold one ref for every active crtc.  That way the
> have_disp_power_ref variable as well as the iteration logic could be
> removed, leading to a simplification.  Just a suggestion anyway.

The current code looks somewhat busted anyway. First problem is that
it's accessing crtc->state without the appropriate locks held (unless
something always pulls in all crtcs to every commit?). Second issue
is that the rpm_put() is called without waiting for nonblocking commits
to have finished so it looks like you can currentlly remove the power
before the hardware has been properly shut down.

-- 
Ville Syrjälä
Intel

  parent reply	other threads:[~2018-07-17 10:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-12 17:02 [PATCH v2 0/3] drm/nouveau: Fix runtime PM leaks Lyude Paul
     [not found] ` <20180712170256.13018-1-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-07-12 17:02   ` [PATCH v2 1/3] drm/nouveau: Fix runtime PM leak in drm_open() Lyude Paul
2018-07-12 17:02     ` Lyude Paul
2018-07-12 17:02 ` [PATCH v2 2/3] drm/nouveau: Fix runtime PM leak in nv50_disp_atomic_commit() Lyude Paul
2018-07-12 17:02   ` Lyude Paul
2018-07-17  7:33   ` [Nouveau] " Lukas Wunner
2018-07-17  7:33     ` Lukas Wunner
     [not found]     ` <20180717073352.GA17459-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2018-07-17 10:31       ` Ville Syrjälä [this message]
2018-07-17 10:31         ` Ville Syrjälä
2018-07-12 17:02 ` [PATCH v2 3/3] drm/nouveau: Remove bogus crtc check in pmops_runtime_idle Lyude Paul
     [not found]   ` <20180712170256.13018-4-lyude-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-07-12 17:17     ` Daniel Vetter
2018-07-12 17:17       ` Daniel Vetter

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=20180717103124.GO5565@intel.com \
    --to=ville.syrjala-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
    --cc=bskeggs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org \
    --cc=maarten.lankhorst-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.