• Lukas Wunner's avatar
    Revert "apple-gmux: lock iGP IO to protect from vgaarb changes" · d6fa7588
    Lukas Wunner authored
    Commit 4eebd5a4 ("apple-gmux: lock iGP IO to protect from vgaarb
    changes") amended this driver's ->probe hook to lock decoding of normal
    (non-legacy) I/O space accesses to the integrated GPU on dual-GPU
    MacBook Pros.  The lock stays in place until the driver is unbound.
    
    The change was made to work around an issue with the out-of-tree nvidia
    graphics driver (available at http://www.nvidia.com/object/unix.html).
    It contains the following sequence in nvidia/nv.c:
    
    	#if defined(CONFIG_VGA_ARB) && !defined(NVCPU_PPC64LE)
    	#if defined(VGA_DEFAULT_DEVICE)
    	    vga_tryget(VGA_DEFAULT_DEVICE, VGA_RSRC_LEGACY_MASK);
    	#endif
    	    vga_set_legacy_decoding(dev, VGA_RSRC_NONE);
    	#endif
    
    This code was reported to cause deadlocks with VFIO already in 2013:
    https://devtalk.nvidia.com/default/topic/545560
    
    I've reported the issue to Nvidia developers once more in 2017:
    https://www.spinics.net/lists/dri-devel/msg138754.html
    
    On the MacBookPro10,1, this code apparently breaks backlight control
    (which is handled by apple-gmux via an I/O region starting at 0x700),
    as reported by Petri Hodju:
    https://bugzilla.kernel.org/show_bug.cgi?id=86121
    
    I tried to replicate Petri's observations on my MacBook9,1, which uses
    the same Intel Ivy Bridge + Nvidia GeForce GT 650M architecture, to no
    avail.  On my machine apple-gmux' I/O region remains accessible even
    with the nvidia driver loaded and commit 4eebd5a4 reverted.
    Petri reported that apple-gmux becomes accessible again after a
    suspend/resume cycle because the BIOS changed the VGA routing on the
    root port to the Nvidia GPU.  Perhaps this is a BIOS issue after all
    that can be fixed with an update?
    
    In any case, the change made by commit 4eebd5a4 has turned out to
    cause two new issues:
    
    * Wilfried Klaebe reports a deadlock when launching Xorg because it
      opens /dev/vga_arbiter and calls vga_get(), but apple-gmux is holding
      a lock on I/O space indefinitely.  It looks like apple-gmux' current
      behavior is an abuse of the vgaarb API as locks are not meant to be
      held for longer periods:
      https://bugzilla.kernel.org/show_bug.cgi?id=88861#c11
      https://bugzilla.kernel.org/attachment.cgi?id=217541
    
    * On dual GPU MacBook Pros introduced since 2013, the integrated GPU is
      powergated on boot und thus becomes invisible to Linux unless a custom
      EFI protocol is used to leave it powered on.  (A patch exists but is
      not in mainline yet due to several negative side effects.)  On these
      machines, locking I/O to the integrated GPU (as done by 4eebd5a4)
      fails and backlight control is therefore broken:
      https://bugzilla.kernel.org/show_bug.cgi?id=105051
    
    So let's revert commit 4eebd5a4 please.  Users experiencing the
    issue with the proprietary nvidia driver can comment out the above-
    quoted problematic code as a workaround (or try updating the BIOS).
    
    Cc: Petri Hodju <petrihodju@yahoo.com>
    Cc: Bjorn Helgaas <bhelgaas@google.com>
    Cc: Bruno Prémont <bonbons@linux-vserver.org>
    Cc: Andy Ritger <aritger@nvidia.com>
    Cc: Ronald Tschalär <ronald@innovation.ch>
    Tested-by: default avatarWilfried Klaebe <linux-kernel@lebenslange-mailadresse.de>
    Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
    d6fa7588
apple-gmux.c 25.1 KB