linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Lyude Paul <lyude@redhat.com>,
	nouveau@lists.freedesktop.org, David Airlie <airlied@linux.ie>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Ben Skeggs <bskeggs@redhat.com>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: [Nouveau] [PATCH 1/5] drm/nouveau: Prevent RPM callback recursion in suspend/resume paths
Date: Wed, 18 Jul 2018 10:25:05 +0200	[thread overview]
Message-ID: <20180718082505.GB16072@wunner.de> (raw)
In-Reply-To: <CAJZ5v0g8O8J0U8V-gLMe+NnTd3xgZ5_pjr9p2oci7yAfW54B-A@mail.gmail.com>

On Wed, Jul 18, 2018 at 09:38:41AM +0200, Rafael J. Wysocki wrote:
> On Tue, Jul 17, 2018 at 8:20 PM, Lukas Wunner <lukas@wunner.de> wrote:
> > Okay, the PCI device is suspending and the nvkm_i2c_aux_acquire()
> > wants it in resumed state, so is waiting forever for the device to
> > runtime suspend in order to resume it again immediately afterwards.
> >
> > The deadlock in the stack trace you've posted could be resolved using
> > the technique I used in d61a5c106351 by adding the following to
> > include/linux/pm_runtime.h:
> >
> > static inline bool pm_runtime_status_suspending(struct device *dev)
> > {
> >         return dev->power.runtime_status == RPM_SUSPENDING;
> > }
> >
> > static inline bool is_pm_work(struct device *dev)
> > {
> >         struct work_struct *work = current_work();
> >
> >         return work && work->func == dev->power.work;
> > }
> >
> > Then adding this to nvkm_i2c_aux_acquire():
> >
> >         struct device *dev = pad->i2c->subdev.device->dev;
> >
> >         if (!(is_pm_work(dev) && pm_runtime_status_suspending(dev))) {
> >                 ret = pm_runtime_get_sync(dev);
> >                 if (ret < 0 && ret != -EACCES)
> >                         return ret;
> >         }
[snip]
> 
> For the record, I don't quite like this approach as it seems to be
> working around a broken dependency graph.
> 
> If you need to resume device A from within the runtime resume callback
> of device B, then clearly B depends on A and there should be a link
> between them.
> 
> That said, I do realize that it may be the path of least resistance,
> but then I wonder if we can do better than this.

The GPU contains an i2c subdevice for each connector with DDC lines.
I believe those are modelled as children of the GPU's PCI device as
they're accessed via mmio of the PCI device.

The problem here is that when the GPU's PCI device runtime suspends,
its i2c child device needs to be runtime active to suspend the MST
topology.  Catch-22.

I don't know whether or not it's necessary to suspend the MST topology.
I'm not an expert on DisplayPort MultiStream transport.

BTW Lyude, in patch 4 and 5 of this series, you're runtime resuming
pad->i2c->subdev.device->dev.  Is this the PCI device or is it the i2c
device?  I'm always confused by nouveau's structs.  In nvkm_i2c_bus_ctor()
I can see that the device you're runtime resuming is the parent of the
i2c_adapter:

	struct nvkm_device *device = pad->i2c->subdev.device;
	[...]
	bus->i2c.dev.parent = device->dev;

If the i2c_adapter is a child of the PCI device, it's sufficient
to runtime resume the i2c_adapter, i.e. bus->i2c.dev, and this will
implicitly runtime resume its parent.

Thanks,

Lukas

  reply	other threads:[~2018-07-18  8:25 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 23:59 [PATCH 0/5] drm/nouveau: Fix a lot of nasty RPM bugs and deadlocks Lyude Paul
2018-07-16 23:59 ` [PATCH 1/5] drm/nouveau: Prevent RPM callback recursion in suspend/resume paths Lyude Paul
2018-07-17  7:16   ` [Nouveau] " Lukas Wunner
2018-07-17  7:39     ` Rafael J. Wysocki
2018-07-17 16:53     ` Lyude Paul
2018-07-17 18:20       ` Lukas Wunner
2018-07-17 18:24         ` Lyude Paul
2018-07-17 18:32           ` Lukas Wunner
2018-07-17 18:34             ` Lyude Paul
2018-07-18  7:40               ` Rafael J. Wysocki
2018-07-18  7:47               ` Lukas Wunner
2018-07-18  7:38         ` Rafael J. Wysocki
2018-07-18  8:25           ` Lukas Wunner [this message]
2018-07-18  8:35             ` Rafael J. Wysocki
2018-07-18  8:36             ` Lukas Wunner
2018-07-18 20:11               ` Lyude Paul
2018-07-18 21:49                 ` Rafael J. Wysocki
2018-07-16 23:59 ` [PATCH 2/5] drm/nouveau: Grab RPM ref while probing outputs Lyude Paul
2018-07-17  7:21   ` [Nouveau] " Lukas Wunner
2018-07-17 10:12     ` Karol Herbst
2018-07-16 23:59 ` [PATCH 3/5] drm/nouveau: Add missing RPM get/put() when probing connectors Lyude Paul
2018-07-17 10:11   ` [Nouveau] " Karol Herbst
2018-07-16 23:59 ` [PATCH 4/5] drm/nouveau: Grab RPM ref when i2c bus is in use Lyude Paul
2018-07-17 10:17   ` [Nouveau] " Karol Herbst
2018-07-17 11:54     ` Ben Skeggs
2018-07-17 12:10       ` Karol Herbst
2018-07-16 23:59 ` [PATCH 5/5] drm/nouveau: Grab RPM ref when aux " Lyude Paul

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=20180718082505.GB16072@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 \
    --cc=rafael@kernel.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).