dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Bastien Nocera <hadess@hadess.net>
To: Lukas Wunner <lukas@wunner.de>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v5 00/12] Enable GPU switching on pre-retina?MacBook Pro
Date: Sat, 05 Mar 2016 17:31:55 +0100	[thread overview]
Message-ID: <1457195515.2648.41.camel@hadess.net> (raw)
In-Reply-To: <20160305141627.GA25017@wunner.de>

On Sat, 2016-03-05 at 15:16 +0100, Lukas Wunner wrote:
> Hi Bastien,
> 
> On Fri, Mar 04, 2016 at 04:12:27PM +0000, Bastien Nocera wrote:
> > 
> > Lukas Wunner <lukas <at> wunner.de> writes:
> > > 
> > > Enable GPU switching on the pre-retina MacBook Pro (2008 - 2013),
> > > v5.
> > I've tested your patchset on a MacBookPro8,1, with an integrated
> > Intel and
> > discrete AMD/ATI GPUs.
> Hm, it must be either an 8,2 or 8,3. The 8,1 was a 13" machine and
> only
> had an integrated GPU.

Sorry, it's an "8,2". That's what I get for having not having my mail
on that machine.

> > 
> > I've used the COPR repository here to cut down on my compilation
> > time:
> > https://copr.fedorainfracloud.org/coprs/firstyear/kernel-mbp/
> > 
> > I'm not certain how to test out your changes, or what the
> > consequences should
> > be on a stock Fedora 23/GNOME 3.18 installation. After booting
> > (note that I
> > did not change any command-line options in grub), a gnome-shell/gdm 
> > X11
> > session comes up (I disabled Wayland, to rule out behavioural
> > changes), I'd
> > log in to GNOME and gnome-shell (which starts another X11 session
> > on
> > another VT).
> Switching and power control currently requires manual intervention
> by echoing commands to /sys/kernel/debug/vgaswitcheroo/switch
> as documented here:
> https://01.org/linuxgraphics/gfx-docs/drm/modes_of_use.html

Right, though I would intend on automating this.

> As you've correctly observed, the machine is initially switched to
> the discrete GPU and both GPUs are turned on. By echoing "IGD" to
> the sysfs file, you'll switch to the integrated GPU and turn off
> the discrete GPU.
> 
> It's possible to let the EFI firmware switch to the integrated GPU
> on boot by using this tool: https://github.com/0xbb/gpu-switch
> However still both GPUs will be powered up, so you have to issue
> the "OFF" command to sysfs to power the discrete GPU down. Also,
> once you boot into OS X, the setting made by the gpu-switch tool
> will be overwritten and the machine will be switched to the discrete
> GPU again the next time you boot Linux.

We could, on boot, force using the integrated GPU, turning off the
discrete GPU that we're not interested in.
So I'd push DIGD to the switch sysfs entry on boot. But I'm guessing
that won't turn off the other output we're not interested in.

> Note that switching is only possible from the text console, with
> X11/Wayland shut down. Obviously this is not great in terms of UX.
> A few years ago there was a GSoC proposal to get hot GPU switching
> to work on Linux (akin to what OS X does) but nothing ever came of
> it:
> http://www.phoronix.com/scan.php?page=news_item&px=OTIyMQ
> https://lists.x.org/archives/xorg/2011-March/052522.html
> 
> Unfortunately this seems to be a low priority item for kernel
> graphics
> developers since nowadays most dual GPU notebooks no longer have a
> mux
> and cannot switch. The MacBook Pro seems to be the last one
> supporting
> this but I've witnessed a bit of an anti-Apple sentiment among kernel
> graphics developers since everything is non-standard there. Which is
> unfortunate because these machines have a large market share and
> Apple
> software quality is deteriorating rapidly so a lot of Mac users are
> ripe for converting to Linux.

DIGD and DDIS should help (you need to log out/log in again), and if
the current GPU is the integrated one, you could force running, say, a
game on the discrete GPU using DRI_PRIME=1, correct?

FWIW, using OFF at runtime made my machine hang, and without any ways
for me to get debug output.

> Anyway, one short-term improvement will be to add runtime pm support
> (called "Driver power control" in the vga_switcheroo documentation
> linked above). That way it'll no longer be necessary to power the
> discrete GPU up and down manually, this will happen automatically
> as needed (when switching or using render offloading with DRI PRIME).

Ok, so using GIGD or DDIS would just switch the output, but not turn
off the unused GPU without runtime PM management.

> I have patches to enable this for radeon but they're completely
> untested:
> 
> http://wunner.de/mbp_switcheroo_v5-4.5.tar.gz       => gpu switching
> for 4.5

That's the same patch that's already applied to the kernel above (the
ones from this patchset thread), right?

> http://wunner.de/mbp_switcheroo_v5-4.5-runpm.tar.gz => runtime pm for
> radeon

OK, will test those out.

> I have an Nvidia based machine and runtime pm doesn't work there yet
> because of bugs in nouveau that I haven't had the time to look into.
> 
> 
> > 
> > I did not use any external screens to test this.
> Since your machine has Thunderbolt, the external port is no longer
> switchable between GPUs, it can only be driven by the discrete GPU.
> So you need to power it up manually for this to work. You don't need
> to switch to it, but it's probably recommendable to save energy.
> (Otherwise both GPUs are on with the integrated GPU driving the panel
> and the discrete GPU driving the DP port.)
> 
> The runpm tarball linked above contains a patch to automatically
> wake the discrete GPU on hotplug.
> 
> I've heard that the AMD GPU is picky about external monitors and
> doesn't recognize them unless they're plugged in at exactly the
> right moment, so you may need to retry a couple of times until it
> works.

To sum up, and if we take the above patches into consideration:
- on boot, one or more GPUs are powered on, an init script would queue
a GPU switch to the integrated one. The other GPU would be switched off
(automatically?)
- when X/wayland is running, queue the requests using DIGD or DDIS. If
the integrated GPU is used, allow offloading to the discrete GPU with
DRI_PRIME (which will again power up automatically thanks to the
runtime PM patches above).

My concerns here would be:
- Do we know how to turn off the integrated GPU automatically, if the
user only used the internal screen and wanted to use the discrete GPU?
- If only the discrete GPU is powered on, do we know how to power on
the integrated GPU so it can drive the external screen when plugged in?
- While plymouth is short-lived at boot, Wayland and X11 GNOME sessions
use the GPU. The first user session will run on a VT that's separate
from the greeter to implement fast-user switching. So, if we wanted to
force using the other GPU for future sessions, we'd need to tell gdm to
kill its graphical session and to respawn it so it doesn't hog the GPU
and avoid the switch happening. Correct?

FWIW, this is what I had written down a couple of months ago, about
supporting dual-GPU computers with GNOME:
https://wiki.gnome.org/Design/OS/DualGPU

Those use-cases are a lot simpler than what could be achieved with the
vga_switcheroo sub-system, but they probably cover the "90%" use cases
we're interested in.

Once I've managed to get the MacBook Pro into a good state, I also have
a Lenovo machine around with dual GPU, though I couldn't tell you what
the discrete one is.

Cheers
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2016-03-05 16:31 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11 19:09 [PATCH v5 00/12] Enable GPU switching on pre-retina MacBook Pro Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 04/12] apple-gmux: Add switch_ddc support Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 02/12] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 03/12] apple-gmux: Track switch state Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 12/12] drm/radeon: Defer probe if gmux is present but its driver isn't Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 07/12] drm/nouveau: Switch DDC when reading the EDID Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 09/12] apple-gmux: Add helper for presence detect Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 01/12] vga_switcheroo: Add handler flags infrastructure Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 05/12] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 11/12] drm/nouveau: Defer probe if gmux is present but its driver isn't Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 08/12] drm/radeon: Switch DDC when reading the EDID Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 06/12] drm/i915: " Lukas Wunner
2016-01-11 19:09 ` [PATCH v5 10/12] drm/i915: Defer probe if gmux is present but its driver isn't Lukas Wunner
2016-02-09  9:04   ` Daniel Vetter
2016-02-14 12:10     ` Lukas Wunner
2016-02-14 12:46       ` Daniel Vetter
2016-02-16 15:58         ` Lukas Wunner
2016-02-16 16:08           ` Daniel Vetter
2016-02-18 20:34             ` Lukas Wunner
2016-02-18 21:39               ` Daniel Vetter
2016-02-18 22:20                 ` Lukas Wunner
2016-02-18 23:11                   ` Daniel Vetter
2016-02-18 23:53                     ` Deucher, Alexander
     [not found] ` <cover.1452525860.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-02-01 22:49   ` [PATCH v5 00/12] Enable GPU switching on pre-retina MacBook Pro Lukas Wunner
2016-02-02  1:10     ` Dave Airlie
2016-02-02  1:19       ` Dave Airlie
2016-02-02 15:03       ` Lukas Wunner
     [not found]     ` <20160201224944.GA12944-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-02-02  6:33       ` Pierre Moreau
2016-02-08 18:10 ` Darren Hart
     [not found]   ` <20160208181000.GL1779-Z5kFBHtJu+EzCVHREhWfF0EOCMrvLtNR@public.gmane.org>
2016-02-09  9:01     ` Daniel Vetter
     [not found] ` <loom.20160304T170007-454@post.gmane.org>
2016-03-05 14:16   ` [Intel-gfx] [PATCH v5 00/12] Enable GPU switching on pre-retina?MacBook Pro Lukas Wunner
2016-03-05 16:31     ` Bastien Nocera [this message]
2016-03-09 23:30       ` Dave Airlie
2016-03-10 15:29         ` Bastien Nocera
2016-03-10 15:33           ` Bastien Nocera
2016-03-14 12:41       ` [Intel-gfx] " Lukas Wunner
2016-03-14 13:37         ` Bastien Nocera
2016-03-15  7:51           ` Daniel Vetter
2016-03-15 11:10           ` [Intel-gfx] " Dave Airlie
2016-03-15 11:55             ` Bastien Nocera
2016-04-05 16:59         ` Bastien Nocera
2016-04-05 17:43           ` Lukas Wunner
2016-03-05 17:28     ` [Intel-gfx] " Bastien Nocera
2016-03-05 18:10     ` Alex Deucher
2016-03-15 17:54       ` Lukas Wunner
2016-03-15 18:33         ` Alex Deucher
2016-03-15 20:41           ` Lukas Wunner

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=1457195515.2648.41.camel@hadess.net \
    --to=hadess@hadess.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lukas@wunner.de \
    /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).