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@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel