0xbb / gpu-switch

gpu-switch is an application that allows to switch between the graphic cards of dual-GPU Macbook Pro models
MIT License
537 stars 57 forks source link

MacBookPro11,5 black screen for integrated graphics #27

Open katef opened 8 years ago

katef commented 8 years ago

Hi,

Thanks for doing the reverse engineering work for gpu-switch!

I have a MacbookPro11,5 which is booting to Linux 4.6.0-1amd64 by grubx64.efi I'd like to use the integrated Intel graphics only.

Running gpu-switch -i and rebooting, my system shows grub, and then gives a black screen when starting Linux. The system boots okay - I can ssh to it.

lshw -c video shows:

what# lshw -c video
  *-display UNCLAIMED
       description: VGA compatible controller
       product: Venus XT [Radeon HD 8870M / R9 M270X/M370X]
       vendor: Advanced Micro Devices, Inc. [AMD/ATI]
       physical id: 0
       bus info: pci@0000:01:00.0
       version: 83
       width: 64 bits
       clock: 33MHz
       capabilities: pm pciexpress msi vga_controller bus_master cap_list
       configuration: latency=0
       resources: memory:80000000-8fffffff memory:b0c00000-b0c3ffff ioport:3000(size=256) memory:b0c40000-b0c5ffff

which surprises me, because I thought the ATI GPU would be powered off, and therefore not visible on the PCI bus.

Appologies if this is the wrong place to ask; I've found so much conflicting information for different models, I'm very confused about what's applicable.

What's causing the black screen?

Should I try booting by Debian's EFIStub instead of via grubx64.efi?

Thank you,

katef commented 8 years ago

Ah, I booted rEFInd's USB flash image, which has an option to run apple_set_os and then continue to run grub from my EFI partition. That worked just fine - the integrated graphics works, and now I see it on the PCI bus:

what# lshw -c video
  *-display UNCLAIMED
       description: VGA compatible controller
       product: Venus XT [Radeon HD 8870M / R9 M270X/M370X]
       vendor: Advanced Micro Devices, Inc. [AMD/ATI]
       physical id: 0
       bus info: pci@0000:01:00.0
       version: 83
       width: 64 bits
       clock: 33MHz
       capabilities: pm pciexpress msi vga_controller bus_master cap_list
       configuration: latency=0
       resources: memory:80000000-8fffffff memory:b0c00000-b0c3ffff ioport:3000(size=256) memory:b0c40000-b0c5ffff
  *-display
       description: VGA compatible controller
       product: Crystal Well Integrated Graphics Controller
       vendor: Intel Corporation
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 08
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm vga_controller bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:49 memory:b0000000-b03fffff memory:a0000000-afffffff ioport:4000(size=64) memory:c0000-dffff

I don't want to install rEFInd to my disk's EFI partition, but I think it's using this EFI thing which just sets apple_set_os and then chainloads another EFI bootloader: https://github.com/0xbb/apple_set_os.efi So I'll try that instead of using rEFInd from a USB device.

Meanwhile I have the same question: why is the ATI card visible on my PCI bus? Is it really that both cards are enabled?

Thanks,

0xbb commented 8 years ago

Hi, yes both cars are enabled. Linux may will support dynamically switching between both cards in the future.

Meanwhile you could use cat /sys/kernel/debug/vgaswitcheroo/switch to see which card is active and echo OFF > /sys/kernel/debug/vgaswitcheroo/switch to switch of the unused dedicated card.

katef commented 7 years ago

Hi,

Sorry it's taken me a while to get back to you.

I'm currently trying to figure out why /sys/kernel/debug/vgaswitcheroo doesn't exist.

I'm running a kernel with:

CONFIG_VGA_SWITCHEROO=y

and I have grub booting with /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash i915.modeset=1 radeon.modeset=1"

which indeed I see in dmesg:

[    0.000000] Linux version 4.6.4 (root@what) (gcc version 6.2.0 20160822 (Debian 6.2.0-1) ) #1 SMP Mon Aug 29 00:10:39 BST 2016
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.6.4 root=UUID=c70a8075-c8f3-4047-a33c-bbbdfcfb22a1 ro libata.force=noncq quiet nosplash i915.modeset=1 radeon.modeset=1

yet nothing here:

# ls /sys/kernel/debug/vgaswitcheroo
ls: cannot access '/sys/kernel/debug/vgaswitcheroo': No such file or directory

Any idea what I might be missing? Thank you!

neutral888 commented 7 years ago

Hi all, @0xbb THANKS for putting this together!

I had the same problems as you @katef (MBP 11,5) - also got it working via rEFind and apple_set_os. By 'working' I mean the system can use both graphics cards whilst in debian.

@katef have you been able to use just the intel integrated graphics card only (and disable the dedicated GPU) yet?

Also, are proprietary drivers required to be able to just boot into the os using integrated card or can this be done completely open source? Thanks :-)

katef commented 7 years ago

Hi @neutral888 - No, I'm not able to disable the discrete GPU, because /sys/kernel/debug/vgaswitcheroo does not exist for me. I haven't been able to find why it's not present.

So currently I'm using the Intel GPU, but the dedicated GPU is not disabled.

neutral888 commented 7 years ago

Hi @katef thanks for the reply. Bummer about the dGPU - I haven't been able to get it to shut off either yet. I wonder if using the 4.8.6 kernel will make a difference? Apparently it has more recently added support AMDGPU, Radeon, i915 etc.

neutral888 commented 7 years ago

Hi everyone and @katef I have been able to switch off the dGPU and use only the iGPU using the following commands:

sudo mount -t debugfs debugfs /sys/kernel/debug -> this mounts vgaswitcheroo sudo cat /sys/kernel/debug/vgaswitcheroo/switch -> this shows what is being used echo OFF > /sys/kernel/debug/vgaswitcheroo/switch -> this turns off the GPU that doesn't have the + sign next to it. (must be done in root, not just via sudo).

Only problem now is that this has lead to no longer being able to adjust brigtness settings. Any ideas anyone?

ah- commented 7 years ago

It probably picks the wrong backlight driver, try finding the gmux one in /sys and setting the brightness by writing to the brightness file.

neutral888 commented 7 years ago

Thanks for the reply, @ah- /sys/class/backlight contains gmux-backlight and radeon_bl0 I am able to adjust the brightness with the backlight file in gmux-backlight! How do I link it to my brightness buttons and refer them to changing the setting in this file? ps sorry for my newbie question

ah- commented 7 years ago

Sorry, I don't know. I just remember having the same issue myself a long time ago.

egorenar commented 7 years ago

Hi all,

I also have a MacBook Pro 11,5 and running Void Linux with Linux 4.11.11. I have a blackscreen when I disable DIS and enable IDG. I have macOS 10.12.6 and use apple_set_os.efi. Any idea what could be the problem ?

Thanks in advance Regards

dortamiguel commented 6 years ago

I have a MacBook Pro 11,5 and it runs perfectly

ghost commented 6 years ago

@neutral888 I know this question is ancient at this point, and I hope by now you've figured it out, but I hope it'll help someone else if it doesn't help you. I made the following script after studying all of the comments on these links: https://askubuntu.com/questions/812734/macbook-pro-backlight-control-not-working-on-ubuntu-16-04 https://bugzilla.kernel.org/show_bug.cgi?id=105051

I have to run this every now and then after kernel updates, but it's still working as of this post.

cd ~/
mkdir brightness-fix
cd brightness-fix

# grab copy of source
curl -O https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.8.7.tar.xz
tar xf linux-4.8.7.tar.xz
cd linux-4.8.7/drivers/platform/x86

# patch it
curl -o file.patch https://bugzilla.kernel.org/attachment.cgi?id=218051
patch apple-gmux.c < file.patch

# build it
echo '
obj-m += apple-gmux.o
all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
' > Makefile
make

# install
targetDir="/lib/modules/$(uname -r)/kernel/drivers/platform/x86"
sudo cp ${targetDir}/apple-gmux.ko ${targetDir}/apple-gmux.ko.backup
sudo cp apple-gmux.ko ${targetDir}

cd ~/
rm -r ./brightness-fix

reboot

This worked for me on Ubuntu Gnome 16.04 last year, and has since been working on Linux Mint 18.3