From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjorn Helgaas Subject: Re: [PATCH 1/2 v2] x86, ia64: Move EFI_FB vga_default_device() initialization to pci_vga_fixup() Date: Sat, 5 Jul 2014 11:15:03 -0600 Message-ID: <20140705171503.GC6247@google.com> References: <20140514224339.7f8be3a9@neptune.home> <20140527234255.GJ11907@google.com> <20140602201650.35f0e936@neptune.home> <20140602201926.4d476818@neptune.home> <20140625005501.7ff7e982@neptune.home> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <20140625005501.7ff7e982@neptune.home> Sender: linux-pci-owner@vger.kernel.org To: Bruno =?iso-8859-1?Q?Pr=E9mont?= Cc: DRI mailing list , Linux PCI , Dave Airlie , Matthew Garrett List-Id: dri-devel@lists.freedesktop.org On Wed, Jun 25, 2014 at 12:55:01AM +0200, Bruno Pr=E9mont wrote: > With commit b4aa0163056b ("efifb: Implement vga_default_device() (v2)= ") > Matthew Garrett introduced a efifb vga_default_device() so that EFI > systems that do not load shadow VBIOS or setup VGA get proper value f= or > boot_vga PCI sysfs attribute on the corresponding PCI device. >=20 > Xorg is refusing to detect devices when boot_vga=3D0 which is the cas= e on > some EFI system (e.g. MacBookAir2,1). Xorg detects the GPU and finds > the dri device but then bails out with "no devices detected". >=20 > Note: When vga_default_device() is set boot_vga PCI sysfs attribute > reflects its state. When unset this attribute is 1 whenever > IORESOURCE_ROM_SHADOW flag is set. >=20 > With introduction of sysfb/simplefb/simpledrm efifb is getting obsole= te > while having native drivers for the GPU also makes selecting > sysfb/efifb optional. >=20 > Remove the efifb implementation of vga_default_device() and initializ= e > vgaarb's vga_default_device() with the PCI GPU that matches boot > screen_info in pci_fixup_video(). >=20 > Tested-by: Anibal Francisco Martinez Cortina > Cc: Matthew Garrett > Cc: stable@vger.kernel.org > Signed-off-by: Bruno Pr=E9mont I applied both with Matthew's ack to pci/misc for v3.17, thanks! > --- >=20 > Changes since v1: > Added Tested-by, Cc >=20 > arch/ia64/pci/fixup.c | 21 +++++++++++++++++++++ > arch/x86/include/asm/vga.h | 6 ------ > arch/x86/pci/fixup.c | 21 +++++++++++++++++++++ > drivers/video/fbdev/efifb.c | 38 -----------------------------------= --- > 4 files changed, 42 insertions(+), 44 deletions(-) >=20 > diff --git a/arch/ia64/pci/fixup.c b/arch/ia64/pci/fixup.c > index eee069a..9ed5bef 100644 > --- a/arch/ia64/pci/fixup.c > +++ b/arch/ia64/pci/fixup.c > @@ -37,6 +37,27 @@ static void pci_fixup_video(struct pci_dev *pdev) > return; > /* Maybe, this machine supports legacy memory map. */ > =20 > + if (!vga_default_device()) { > + resource_size_t start, end; > + int i; > + > + /* Does firmware framebuffer belong to us? */ > + for (i=3D0; i < DEVICE_COUNT_RESOURCE; i++) { > + if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM)) > + continue; > + > + start =3D pci_resource_start(pdev, i); > + end =3D pci_resource_end(pdev, i); > + > + if (!start || !end) > + continue; > + > + if (screen_info.lfb_base >=3D start && > + (screen_info.lfb_base + screen_info.lfb_size) < end) > + vga_set_default_device(pdev); > + } > + } > + > /* Is VGA routed to us? */ > bus =3D pdev->bus; > while (bus) { > diff --git a/arch/x86/include/asm/vga.h b/arch/x86/include/asm/vga.h > index 44282fb..c4b9dc2 100644 > --- a/arch/x86/include/asm/vga.h > +++ b/arch/x86/include/asm/vga.h > @@ -17,10 +17,4 @@ > #define vga_readb(x) (*(x)) > #define vga_writeb(x, y) (*(y) =3D (x)) > =20 > -#ifdef CONFIG_FB_EFI > -#define __ARCH_HAS_VGA_DEFAULT_DEVICE > -extern struct pci_dev *vga_default_device(void); > -extern void vga_set_default_device(struct pci_dev *pdev); > -#endif > - > #endif /* _ASM_X86_VGA_H */ > diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c > index 94ae9ae..7246cf2 100644 > --- a/arch/x86/pci/fixup.c > +++ b/arch/x86/pci/fixup.c > @@ -325,6 +325,27 @@ static void pci_fixup_video(struct pci_dev *pdev= ) > struct pci_bus *bus; > u16 config; > =20 > + if (!vga_default_device()) { > + resource_size_t start, end; > + int i; > + > + /* Does firmware framebuffer belong to us? */ > + for (i=3D0; i < DEVICE_COUNT_RESOURCE; i++) { > + if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM)) > + continue; > + > + start =3D pci_resource_start(pdev, i); > + end =3D pci_resource_end(pdev, i); > + > + if (!start || !end) > + continue; > + > + if (screen_info.lfb_base >=3D start && > + (screen_info.lfb_base + screen_info.lfb_size) < end) > + vga_set_default_device(pdev); > + } > + } > + > /* Is VGA routed to us? */ > bus =3D pdev->bus; > while (bus) { > diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.= c > index ae9618f..a033180 100644 > --- a/drivers/video/fbdev/efifb.c > +++ b/drivers/video/fbdev/efifb.c > @@ -19,8 +19,6 @@ > =20 > static bool request_mem_succeeded =3D false; > =20 > -static struct pci_dev *default_vga; > - > static struct fb_var_screeninfo efifb_defined =3D { > .activate =3D FB_ACTIVATE_NOW, > .height =3D -1, > @@ -84,18 +82,6 @@ static struct fb_ops efifb_ops =3D { > .fb_imageblit =3D cfb_imageblit, > }; > =20 > -struct pci_dev *vga_default_device(void) > -{ > - return default_vga; > -} > - > -EXPORT_SYMBOL_GPL(vga_default_device); > - > -void vga_set_default_device(struct pci_dev *pdev) > -{ > - default_vga =3D pdev; > -} > - > static int efifb_setup(char *options) > { > char *this_opt; > @@ -126,30 +112,6 @@ static int efifb_setup(char *options) > } > } > =20 > - for_each_pci_dev(dev) { > - int i; > - > - if ((dev->class >> 8) !=3D PCI_CLASS_DISPLAY_VGA) > - continue; > - > - for (i=3D0; i < DEVICE_COUNT_RESOURCE; i++) { > - resource_size_t start, end; > - > - if (!(pci_resource_flags(dev, i) & IORESOURCE_MEM)) > - continue; > - > - start =3D pci_resource_start(dev, i); > - end =3D pci_resource_end(dev, i); > - > - if (!start || !end) > - continue; > - > - if (screen_info.lfb_base >=3D start && > - (screen_info.lfb_base + screen_info.lfb_size) < end) > - default_vga =3D dev; > - } > - } > - > return 0; > } > =20 > --=20 > 1.8.5.5 >=20