From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Michael Jamet <michael.jamet@intel.com>,
"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
DRI mailing list <dri-devel@lists.freedesktop.org>,
"Levy, Amir (Jer)" <amir.jer.levy@intel.com>,
Ben Skeggs <bskeggs@redhat.com>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Peter Wu <peter@lekensteyn.nl>
Subject: Re: [PATCH 3/5] drm/nouveau: Don't register Thunderbolt eGPU with vga_switcheroo
Date: Sat, 4 Mar 2017 11:16:36 +0100 [thread overview]
Message-ID: <20170304101636.GA3143@wunner.de> (raw)
In-Reply-To: <CAErSpo5Vvk8F=nVgsvTBze+P-=v2rwk1waUMaGVXj2BDKdsiEg@mail.gmail.com>
On Fri, Feb 24, 2017 at 02:59:44PM -0600, Bjorn Helgaas wrote:
> On Fri, Feb 24, 2017 at 1:19 PM, Lukas Wunner <lukas@wunner.de> wrote:
> > An external Thunderbolt GPU can neither drive the laptop's panel nor be
> > powered off by the platform, so there's no point in registering it with
> > vga_switcheroo.
>
> > In fact, when the external GPU is runtime suspended,
> > vga_switcheroo will cut power to the internal discrete GPU, resulting in
> > a lockup.
>
> Why does suspending the external GPU cause vga_switcheroo to cut power
> to the internal GPU? No doubt this would be obvious to a GPU person,
> which I definitely am not.
vga_switcheroo_init_domain_pm_ops() is currently called both for an
internal discrete GPU as well as an external one attached with Thunderbolt.
That function overrides the ->runtime_suspend hook to cut power to the
internal discrete GPU after runtime suspending whichever GPU the
->runtime_suspend hook was called for. So the external GPU runtime
suspends, the hook cuts power to the internal GPU, boom.
The function should only be called for the internal GPU, which is the
objective of this patch.
> > --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
> > +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
> > @@ -95,6 +95,10 @@ nouveau_vga_init(struct nouveau_drm *drm)
> >
> > vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
> >
> > + /* don't register Thunderbolt eGPU with vga_switcheroo */
> > + if (pci_is_thunderbolt_attached(dev->pdev))
> > + return;
>
> I guess there's no way to move this inside
> vga_switcheroo_register_client() instead of putting the test in all
> the drivers?
It's only needed for a subset of the drivers, in particular not for i915.
The preferred approach in the kernel seems to be to avoid midlayers which
bundle stuff that is not applicable to every driver interfacing with it,
and instead put the functionality in library functions which drivers can
opt in to if necessary. In this case that library function would be
pci_is_thunderbolt_attached().
A link list on midlayers vs. libraries is here:
http://blog.ffwll.ch/2016/12/midlayers-once-more-with-feeling.html
> > @@ -111,6 +115,11 @@ nouveau_vga_fini(struct nouveau_drm *drm)
> > struct drm_device *dev = drm->dev;
> > bool runtime = false;
> >
> > + vga_client_register(dev->pdev, NULL, NULL, NULL);
> > +
> > + if (pci_is_thunderbolt_attached(dev->pdev))
> > + return;
> > +
> > if (nouveau_runtime_pm == 1)
> > runtime = true;
> > if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_is_v1_dsm()))
> > @@ -119,7 +128,6 @@ nouveau_vga_fini(struct nouveau_drm *drm)
> > vga_switcheroo_unregister_client(dev->pdev);
> > if (runtime && nouveau_is_v1_dsm() && !nouveau_is_optimus())
> > vga_switcheroo_fini_domain_pm_ops(drm->dev->dev);
> > - vga_client_register(dev->pdev, NULL, NULL, NULL);
>
> The amd & radeon patches look like this:
>
> - vga_switcheroo_unregister_client(rdev->pdev);
> + if (!pci_is_thunderbolt_attached(adev->pdev))
> + vga_switcheroo_unregister_client(adev->pdev);
>
> This nouveau patch looks suspiciously different. But again, I'm not a
> GPU guy so all I can really say is "hmm, I wonder why it's different?"
Functionally it's the same, it only looks differently because the
DRM drivers aren't structured identically. In particular, radeon
and amdgpu call vga_switcheroo_init_domain_pm_ops() only if the flag
RADEON_IS_PX / AMD_IS_PX (is PowerXpress) has been set, so a call
to pci_is_thunderbolt_attached() is added when setting that flag,
whereas nouveau doesn't have that indirection.
Thanks,
Lukas
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-03-04 10:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 19:19 [PATCH 0/5] Thunderbolt GPU fixes Lukas Wunner
2017-02-24 19:19 ` [PATCH 3/5] drm/nouveau: Don't register Thunderbolt eGPU with vga_switcheroo Lukas Wunner
2017-02-24 20:59 ` Bjorn Helgaas
2017-03-04 10:16 ` Lukas Wunner [this message]
2017-02-24 19:19 ` [PATCH 4/5] drm/radeon: " Lukas Wunner
[not found] ` <d466d25ba40b5289f2cafa881b990bf687b29abd.1487938189.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2017-03-07 20:30 ` Alex Deucher
2017-03-08 5:01 ` Lukas Wunner
2017-03-08 10:46 ` Peter Wu
2017-03-08 12:22 ` Lukas Wunner
[not found] ` <20170308050154.GA4250-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2017-03-08 20:34 ` Alex Deucher
2017-03-09 10:55 ` Lukas Wunner
2017-03-09 13:57 ` Alex Deucher
[not found] ` <cover.1487938188.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2017-02-24 19:19 ` [PATCH 5/5] drm/amdgpu: " Lukas Wunner
2017-02-24 19:19 ` [PATCH 1/5] PCI: Recognize Thunderbolt devices Lukas Wunner
2017-02-24 22:17 ` Bjorn Helgaas
2017-02-25 7:40 ` Lukas Wunner
2017-02-25 14:44 ` Bjorn Helgaas
[not found] ` <20170224221724.GA26430-1RhO1Y9PlrlHTL0Zs8A6p5iNqAH0jzoTYJqu5kTmcBRl57MIdRCFDg@public.gmane.org>
2017-03-04 11:14 ` Lukas Wunner
2017-02-24 19:19 ` [PATCH 2/5] apple-gmux: Don't switch external DP port on 2011+ MacBook Pros Lukas Wunner
2017-03-09 15:03 ` [PATCH 0/5] Thunderbolt GPU fixes Daniel Vetter
[not found] ` <20170309150347.a4k4w2sclox2365t-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2017-03-10 12:07 ` Lukas Wunner
2017-03-10 12:15 ` Andy Shevchenko
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=20170304101636.GA3143@wunner.de \
--to=lukas@wunner.de \
--cc=amir.jer.levy@intel.com \
--cc=bhelgaas@google.com \
--cc=bskeggs@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=michael.jamet@intel.com \
--cc=mika.westerberg@linux.intel.com \
--cc=nouveau@lists.freedesktop.org \
--cc=peter@lekensteyn.nl \
/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).