Thunderbolt and other Macbook hardware issues with Linux

Having semi-recently switched to a Macbook Pro Retina 15″ at work, I decided to give MacOS a go. It’s been interesting, it’s not too bad an operating system and whilst it is something I could use on an ongoing basis, I quickly longed for the happy embrace of GNU/Linux where I have a bit more power and control over the system.

Generally the Linux kernel supports most of the Macbook hardware out-of-the-box (As of 3.15 anyway), but with a couple exceptions:

  • I believe support for the dual GPU mode switching is now fixed, however the model I’m using now is Intel only, so I can’t test this unfortunately.
  • The Apple Webcam does not yet have a driver. The older iSight driver doesn’t work, since the new gen of hardware is a PCIe connected device, not USB.
  • The WiFi requires a third party driver to be built for your kernel. You’ll want the latest Broadcom 802.11 STA driver in order for it to built with new kernel versions. Ubuntu users, get this version, or more recent.
  • If you’re having weird hangs where the Macbook just halts frequently waiting on on I/O, add “libata.force=noncq” kernel parameter. It seems that there is some bug with this SSD and some kernel versions that leads to weird I/O halts, which is fixed by this option.
  • Thunderbolt support is limited to only working on devices connected at boot up, no hotplug. Additionally, when using Thunderbolt, Suspend/Resume is disabled (although it works otherwise if there’s no Thunderbolt involved).

Of all these issues, the lack of Thunderbolt support was the one that was really frustrating me, since I need to use a Thunderbolt based Ethernet adaptor currently on a daily basis and I always rely on Suspend and Resume heavily.

Thankfully two kernel developers, Andreas Noever and Matthew J Garrett have been working on a series of kernel patches that introduce support for Thunderbolt hotplug and thus allow it to work on suspend and resume.

Sadly whilst this patch is awesome, it doesn't yet do wireless Thunderbolt for when the ethernet cable you want is too bloody short.

You too can now enjoy the shackles of a wired LAN connection like it’s 1990 all over again!

It doesn’t sound like it has been easy based on the posts on MJG’s blog which are well worth a read – essentially the Apple firmware does weird things with the Thunderbolt hardware when the OS doesn’t identify itself as Darwin (MacOS’s kernel) and likes to power stuff down after suspend/resume, so it’s taken some effort to debug and put in hardware-specific workarounds.
It will surely only be a matter of time before these awesome patches are merged, but if you need them right now and are happy to run rather beta kernel patches (who isn’t??) then the easiest way is to checkout their Git repo of 3.15 with all the patches applied. This repository should build cleanly via the usual means, and provide you with a new kernel module called “thunderbolt”.I’ve been testing it for a few days and it looks really good. I’ve had no kernel panics, freezes, devices failing to work or any issues with suspend/resume with these patches – the features that they claim to work, just work.  The only catches are:

  • If you boot the Macbook with the Thunderbolt device attached, it will be treated like a PCIe hotplug device… except that when you remove it, that Thunderbolt port won’t work again until the next restart. I recommend booting the Macbook with no devices attached, then hotplug once started to avoid this issue. I always remove before suspend and re-connect after resume as well (mostly because it’s a laptop and it’s easy to do so and avoid any issues).
  • The developers advise that Thunderbolt Displays don’t work at this time (however Mini DisplayPort connected screens work fine, even though they share the same socket).
  • The developers advise that chaining Thunderbolt devices is not yet supported. So stick to one device per port for now.

If you’re using Linux on a Macbook, I recommend grabbing the patched source and doing a build. Hopefully all these patches make their way into 3.16 or 3.17 and make this post irrelevant soon.

If you’re extra lazy and trust a random blogger’s binary packages, I’ve built deb packages for Ubuntu 13.10 (and should work just fine on 14.04 as well) for both the Thunderbolt enabled kernel as well as the Broadcom WiFi. You can download these packages here.

7 thoughts on “Thunderbolt and other Macbook hardware issues with Linux

  1. Jacob Hohisel

    Not sure how much of this applies to the 2013 and 2014 models since I’ve only tested with my 2012 Retina MBP:

    – I have dual graphics (HD4000 / GT650M), graphics switching works with this guide:
    https://github.com/ah-/gmux-scripts/issues/1

    – It appears that cold plugging thunderbolt is finally here in 3.18! Only thunderbolt device I have to test with is the ethernet adapter, but after compiling kernel 3.18, it appears to no longer require being plugged in at boot (haven’t tried suspend/resume yet).

    – If you install kernel 3.18, the only working patch for broadcom-sta driver that I could find is supplied by Ubuntu, if you’re using a Debian-based distro you can install this:
    http://security.ubuntu.com/ubuntu/pool/restricted/b/bcmwl/bcmwl-kernel-source_6.30.223.248+bdcom-0ubuntu0.0.1_amd64.deb

    Reply
  2. Magnus

    Hi

    Hotplugging the screen now seems to work, but suspend/resume doesn’t. Did you manage to get this working?

    /Magnus

    Reply
  3. devsk

    Always boot without anything attached.
    Put these in pm-utils hooks in /etc/pm/sleep.d

    upon suspend:
    modprobe -r thunderbolt
    modprobe -r tg3
    echo disabled > “/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0D:00/power/wakeup”

    upon resume:
    modprobe thunderbolt

    With these in place, you can use the wired ethernet and suspend/resume.

    Tested with 4.0.2

    Reply
  4. Alex

    Hi thanks for sharing! Can I use your packages with ubuntu 16 Xenial? Or maybe you have updated packages? I have a macbook air 7 (early 2015) and plugging the Thunderbolt monitor doesn’t work, unless rebooting in Ubuntu from mac without unplugging the Thunderbolt cable.

    Reply
    1. Jethro Carr Post author

      These packages won’t work on Xenial, they’re too old sorry :-( Is this the Apple Thunderbird Cinema display?

      Reply

Leave a Reply