Description of problem: later versions of MacbookPro come with switchable graphics. Since vgaswitcheroo is built into the kernel since 2.6.X, i expected to be able to test the switchable graphics for this laptop. lspci shows both graphics cards enabled and debugfs is mounted, however there is no directory /sys/kernel/debug/vgaswitcheroo. Version-Release number of selected component (if applicable): Tested in 3.4.4 and rawhide 3.5.0-0.git0-2 How reproducible: Always Steps to Reproduce: 1.Boot Fedora 17 EFI 2.ls /sys/kernel/debug/vgaswitcheroo 3. Actual results: ls: cannot access /sys/kernel/debug/vgaswitcheroo: No such file or directory Expected results: Additional info:
Forgot to mention this is x86_64 kernel.
This is also affecting me on a Macbook Pro 6,1. I installed Fedora 17 and vgaswitcheroo is missing.
I'll also add: I've looked all over and cannot find any other method for switching video cards (from integrated to discrete).
From what I have read, there may need to be a patch to apple_gmux to make this work.
Not being able to switch to the integrated graphics card is horrendous for battery life.
With the patches at http://git.infradead.org/users/dwmw2/mbp.git on top of the Fedora 17 3.5.0-2 kernel, booting it from grub1-efi with 'chainloader' and without a ramdisk (a built-in command line with root=/dev/sda7 works here), I have this working on my MacbookPro8.3 You have to switch the mux over first: cd /sys/kernel/debug/vga_switcheroo echo MIGD > switch echo IGD > switch The Intel graphics device only works the *second* time you switch to it; you have to switch back (echo DIS > switch) and then to it again (MIGD, IGD). So there's still work to be done, but it is basically working.
Created attachment 601855 [details] dmesg from macbookpro 8,2 with patches applied. Tried using these patches, but the radeon card still doesn't want to play on my MBP8,2. Find the attached dmesg. This also doesn't work with loadbios in grub2.
For the record, here is the grub2 entry I used - Note the removal of the outb commands to switch of the ati display etc.: menuentry 'Fedora (3.5.0-1.mbp.fc17.x86_64)' { set root='(hd2,gpt4)' set gfxpayload=keep loadbios /vbios.bin /int10.bin echo 'Loading Fedora (3.5.0-1.mbp.fc17.x86_64)' linux /vmlinuz-3.5.0-1.mbp.fc17.x86_64 KEYTABLE=dvorak rd.md=0 rd.dm=0 rd.lvm.lv=vg/lv_swap SYSFONT=True rd.lvm.lv=vg/lv_root rd.luks=0 ro root=/dev/mapper/vg-lv_root LANG=en_US.UTF-8 i915.lvds_channel_mode=2 i915.lvds_use_ssc=0 i5s_enable_igd=1 i5s_3400s_force_ahci=1 echo 'Loading initial ramdisk' initrd /initramfs-3.5.0-1.mbp.fc17.x86_64.img }
The linux command doesn't use the EFI handover protocol and so will skip all the code that makes this work.
So I should try this with grub1-efi instead?
I'm using grub1-efi and loading it with: title Fedora (3.5.0+) root (hd0,4) chainloader /vmlinuz-3.5.0+ Note that you can't load an initrd this way, so you have to build a command line in with CONFIG_CMDLINE, with an appropriate 'root=' argument. Or if you used LVM, you'll probably need to install it and build an initrd the normal way, then rebuild the kernel image with the appropriate initrd built in. With grub2-efi you should apparently be able to do things more normally, but grub2-efi doesn't seem to work on my MBP8,3 — although tab-completion works and it can definitely read the /boot/efi file system, every file it tries to *load* it complains of 'truncated file'
Don't worry, I solved the initramfs issues. I now have the initramfs built in, and vga_switcheroo working correctly. It even works between suspend and resume, which is excellent. Thank you very much.
Do you get sound working at all when switched to IGD? I seem to only get silence... but that's fairly normal since pulseaudio anyway so perhaps it's unrelated?
Can someone post a brief to show how to apply these patches and fix the initramfs issue? Or better yet, an RPM with the patches in place. Thanks,
David : I am on the IGD, after swapping from the DIS and appear to have working audio. Ben : I will write up some instructions as to what I did and post them later.
William, If you can tell me what specific commits you downloaded from the dwmw2/mbp git link you posted and how you applied the patches, I can try and apply and get something together. Thanks, Ben Pierce
Sorry ben - I had some hard drive troubles the past few days. yumdownloader --source kernel rpm -ivh kernel-3.5.0-2.fc17.src.rpm Add our vga_switcheroo.patch to SOURCES In our spec file, on line 26, edit the buildid (I made it .mbp) On line 770 add Patch30000: vga_switcheroo.patch On line 1477 add ApplyPatch: vga_switcheroo.patch Now, we need to edit our kernel config. For x86_64 this is SOURCES/config-x86_64-generic On line 120, add CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE="KEYTABLE=dvorak rd.md=0 rd.dm=0 rd.lvm.lv=vg/lv_swap SYSFONT=True rd.lvm.lv=vg/lv_root rd.luks=0 ro root=/dev/mapper/vg-lv_root LANG=en_US.UTF-8 i915.lvds_downclock=1 i915.i915_enable_rc6=3 i915.i915_enable_fbc=1" CONFIG_CMDLINE_OVERRIDE=y CONFIG_INITRAMFS_SOURCE="" # CONFIG_INITRAMFS_ROOT_UID=0 # CONFIG_INITRAMFS_ROOT_GID=0 # CONFIG_INITRAMFS_COMPRESSION_NONE=y These i915 options are for powersaving, and are not mandatory for this to work. Leave the other INITRAMFS options commented out at this stage. Now, run rpmbulid -bb --target=x86_64 rpmbuild/SPECS/kernel.spec Then run yum localinstall RPMS/x86_64/*.rpm Now, you should have your initramfs in /boot/initramfs-3.5.0-1.mbp.fc17.img . Running 'file' on this reveals that it is a gzip, so we can copy this to /tmp/initramfs and extract it. Now extract the cpio archive also. If you look in /tmp/initramfs/usr/bin, you will notice that mount and umount aren't there. Looking at the system mount with ldd, and checking the libraries are there, it is safe to copy /usr/bit/[u]mount to the initramfs location. Now you can in config-x86_64-generic, uncomment the INITRAMFS options, and add /tmp/initramfs as the initramfs source. Now run rpmbuild -bb again. Finally, install the new RPMs. In grub, you want to replace the linux and initramfs lines with chainload /vmlinuz
Created attachment 603359 [details] vga_switcheroo.patch
This works really well for switching to the intel card, but I am unable to switch back to the radeon card. Is switching back to radeon working for anyone? If so, can you post the switcheroo commands? Thanks
I can switch back and forth with the following. switch-intel systemctl stop display-manager.service cd /sys/kernel/debug/vgaswitcheroo echo OFF > switch echo MIGD > switch echo IGD > switch echo OFF > switch systemctl start display-manager.service switch-ati systemctl stop display-manager.service cd /sys/kernel/debug/vgaswitcheroo echo OFF > switch echo MDIS > switch echo DIS > switch echo OFF > switch systemctl start display-manager.service The final "OFF" isn't "needed" in these, but there is a really subtle issue where if you put the card into on (Such as on resume from suspend) it can blank the display and you can't get your display back. This is just my paranoia to avoid this state.
I followed the instructions in #17 on MacBookPro6,1 and I can get vgaswitcheroo enabled, the kernel sees both cards and i can switch off i915 but switch or a delayed switch to i915 just results in a blank screen. Nouveau works fine btw. Am I missing something or is my 2010 MBP model the culprit? I do see i915 invalid ROM contents message but other than that dmesg seems normal.
Created attachment 627318 [details] Rejects from the patch This patch now no longer applies on kernel 3.6. Some of these components seem to have been made mainline in kernel 3.6. 7 out of 14 hunks FAILED -- saving rejects to file arch/x86/boot/compressed/eboot.c.rej Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] 1 out of 1 hunk ignored -- saving rejects to file arch/x86/boot/compressed/head_32.S.rej Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] 1 out of 1 hunk ignored -- saving rejects to file arch/x86/boot/compressed/head_64.S.rej Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] 2 out of 2 hunks ignored -- saving rejects to file arch/x86/boot/header.S.rej 1 out of 2 hunks FAILED -- saving rejects to file arch/x86/include/asm/bootparam.h.rej Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] 4 out of 4 hunks ignored -- saving rejects to file Documentation/x86/boot.txt.rej 1 out of 1 hunk FAILED -- saving rejects to file drivers/pci/bus.c.rej Reversed (or previously applied) patch detected! Assume -R? [n] Apply anyway? [n] 8 out of 8 hunks ignored -- saving rejects to file drivers/platform/x86/apple-gmux.c.rej error: Bad exit status from /var/tmp/rpm-tmp.03gfzB (%prep)
The patches are present in the F18 kernel except for one patch from mjg59 that I have lying around entitled 'intel-reprobe-lvds.patch'. But it still doesn't work. I just get a screen that 'fades to white' when I attempt to switch, or switch back. I haven't had this working since 3.5.0 with the patches I had at the time. Applying the same patches to 3.5.3 and 3.6.0 has failed variously.
My issue appeared to be regarding the change from the efifb driver to radeon, so I think that the "fix" for vbios loading may also still be omitted.
The patches for vbios loading were present in the F18 kernel for a while, but broken. I fixed them in about 3.6.0-6.fc18 I think.
[ 0.000000] Linux version 3.6.1-1.local.fc17.x86_64 (william.id.au) (gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC) ) #1 SMP Mon Oct 15 20:26:26 CST 2012 [ 3.418109] [drm] radeon defaulting to kernel modesetting. [ 3.419213] [drm] radeon kernel modesetting enabled. [ 3.419247] fb: conflicting fb hw usage radeondrmfb vs EFI VGA - removing generic driver [ 3.422913] radeon 0000:01:00.0: Invalid ROM contents [ 3.422922] radeon 0000:01:00.0: Invalid ROM contents [ 3.422924] [drm:radeon_get_bios] *ERROR* Unable to locate a BIOS ROM [ 3.422926] radeon 0000:01:00.0: Fatal error during GPU init [ 3.422928] [drm] radeon: finishing device. [ 3.424134] radeon: probe of 0000:01:00.0 failed with error -22 Is the dmesg from my Macbookpro 8,2 with kernel 3.6, built with the initramfs built in. (No patches applied) This likely affects F18 also ....
Odd, I don't get this fatal error with 3.6.1-1 on F18 beta TC6. But I do get a black display during startup, and I don't get it back. Bug 765954.
Created attachment 679517 [details] Dmesg from attempt to boot and vgaswitch to i915 This dmesg output is from when I attempt to run: systemctl stop display-manager.service cd /sys/kernel/debug/vgaswitcheroo echo OFF > switch echo MIGD > switch echo IGD > switch echo OFF > switch systemctl start display-manager.service On kernel 3.7.2-201.fc18.x86_64
Created attachment 692139 [details] Dmesg from attempt to switch to i915 on kernel 3.8.0-0-rc6 This is still an issue on kernel 3.8.0-0-rc6. From a first glance many of these issues are because the "pipe" is still on, when it should be off? This makes me think that the issue of the i915 AND radeon both being in the powered on state at boot is far more critical, and the crux of this issue.
It's the firmware's responsibility to negotiate this early on, and seems like Apple manages this within xnu. So the equivalent would be to manage this in the (linux) kernel as well. Currently I'm getting successful boots with mbp 8,2 and 3.6.10 that comes with F18, as well as current 3.7.4-204. EFI booting using GRUB2-EFI, of course. I haven't tried any 3.8 kernels.
3.8 appears to be working now. Technically, VGASWITCHEROO is now working and available to these laptops. The remaining issue with this technically, is now not the lack of mechanism to do the switch, but deficiencies in the i915 driver to reprobe the LVDS display during the switching process. Thus I think this issue should be closed, and the issues with the i915 should be examined more closely.