linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Lyude Paul <lyude@redhat.com>
Cc: nouveau@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Ben Skeggs <bskeggs@redhat.com>,
	linux-pm@vger.kernel.org
Subject: Re: [Nouveau] [PATCH 1/5] drm/nouveau: Prevent RPM callback recursion in suspend/resume paths
Date: Tue, 17 Jul 2018 09:16:41 +0200	[thread overview]
Message-ID: <20180717071641.GA5411@wunner.de> (raw)
In-Reply-To: <20180716235936.11268-2-lyude@redhat.com>

[cc += linux-pm]

Hi Lyude,

First of all, thanks a lot for looking into this. 

On Mon, Jul 16, 2018 at 07:59:25PM -0400, Lyude Paul wrote:
> In order to fix all of the spots that need to have runtime PM get/puts()
> added, we need to ensure that it's possible for us to call
> pm_runtime_get/put() in any context, regardless of how deep, since
> almost all of the spots that are currently missing refs can potentially
> get called in the runtime suspend/resume path. Otherwise, we'll try to
> resume the GPU as we're trying to resume the GPU (and vice-versa) and
> cause the kernel to deadlock.
> 
> With this, it should be safe to call the pm runtime functions in any
> context in nouveau with one condition: any point in the driver that
> calls pm_runtime_get*() cannot hold any locks owned by nouveau that
> would be acquired anywhere inside nouveau_pmops_runtime_resume().
> This includes modesetting locks, i2c bus locks, etc.
[snip]
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -835,6 +835,8 @@ nouveau_pmops_runtime_suspend(struct device *dev)
>  		return -EBUSY;
>  	}
>  
> +	dev->power.disable_depth++;
> +

I'm not sure if that variable is actually private to the PM core.
Grepping through the tree I only find a single occurrence where it's
accessed outside the PM core and that's in amdgpu.  So this looks
a little fishy TBH.  It may make sense to cc such patches to linux-pm
to get Rafael & other folks involved with the PM core to comment.

Also, the disable_depth variable only exists if the kernel was
compiled with CONFIG_PM enabled, but I can't find a "depends on PM"
or something like that in nouveau's Kconfig.  Actually, if PM is
not selected, all the nouveau_pmops_*() functions should be #ifdef'ed
away, but oddly there's no #ifdef CONFIG_PM anywhere in nouveau_drm.c.

Anywayn, if I understand the commit message correctly, you're hitting a
pm_runtime_get_sync() in a code path that itself is called during a
pm_runtime_get_sync().  Could you include stack traces in the commit
message?  My gut feeling is that this patch masks a deeper issue,
e.g. if the runtime_resume code path does in fact directly poll outputs,
that would seem wrong.  Runtime resume should merely make the card
accessible, i.e. reinstate power if necessary, put into PCI_D0,
restore registers, etc.  Output polling should be scheduled
asynchronously.

Thanks,

Lukas

       reply	other threads:[~2018-07-17  7:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180716235936.11268-1-lyude@redhat.com>
     [not found] ` <20180716235936.11268-2-lyude@redhat.com>
2018-07-17  7:16   ` Lukas Wunner [this message]
     [not found]     ` <20180717071641.GA5411-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2018-07-17  7:39       ` [PATCH 1/5] drm/nouveau: Prevent RPM callback recursion in suspend/resume paths Rafael J. Wysocki
2018-07-17 16:53     ` [Nouveau] " Lyude Paul
     [not found]       ` <d7c25a7f41df70685c0c4726315592d1d9b561ff.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-07-17 18:20         ` Lukas Wunner
     [not found]           ` <20180717182041.GA18363-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2018-07-17 18:24             ` Lyude Paul
2018-07-17 18:32               ` [Nouveau] " Lukas Wunner
2018-07-17 18:34                 ` Lyude Paul
     [not found]                   ` <2dbe75b1a83c025b9cddc229dbca9af6fb30111e.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-07-18  7:40                     ` Rafael J. Wysocki
2018-07-18  7:47                     ` Lukas Wunner
2018-07-18  7:38             ` Rafael J. Wysocki
     [not found]               ` <CAJZ5v0g8O8J0U8V-gLMe+NnTd3xgZ5_pjr9p2oci7yAfW54B-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-07-18  8:25                 ` Lukas Wunner
     [not found]                   ` <20180718082505.GB16072-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2018-07-18  8:35                     ` Rafael J. Wysocki
2018-07-18  8:36                   ` [Nouveau] " Lukas Wunner
2018-07-18 20:11                     ` Lyude Paul
     [not found]                       ` <2724dd5eee8a1e4e523e43915fa184ad5afe1c59.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-07-18 21:49                         ` Rafael J. Wysocki

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=20180717071641.GA5411@wunner.de \
    --to=lukas@wunner.de \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lyude@redhat.com \
    --cc=nouveau@lists.freedesktop.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).