Skip to content

Commit 20cde69

Browse files
Bruno Prémontbjorn-helgaas
authored andcommitted
x86, ia64: Move EFI_FB vga_default_device() initialization to pci_vga_fixup()
Commit b4aa016 ("efifb: Implement vga_default_device() (v2)") added efifb vga_default_device() so EFI systems that do not load shadow VBIOS or setup VGA get proper value for boot_vga PCI sysfs attribute on the corresponding PCI device. Xorg doesn't detect devices when boot_vga=0, e.g., on some EFI systems such as MacBookAir2,1. Xorg detects the GPU and finds the DRI device but then bails out with "no devices detected". 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. With introduction of sysfb/simplefb/simpledrm efifb is getting obsolete while having native drivers for the GPU also makes selecting sysfb/efifb optional. Remove the efifb implementation of vga_default_device() and initialize vgaarb's vga_default_device() with the PCI GPU that matches boot screen_info in pci_fixup_video(). [bhelgaas: remove unused "dev" in efifb_setup()] Fixes: b4aa016 ("efifb: Implement vga_default_device() (v2)") Tested-by: Anibal Francisco Martinez Cortina <linuxkid.zeuz@gmail.com> Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Matthew Garrett <matthew.garrett@nebula.com> CC: stable@vger.kernel.org # v3.5+
1 parent dcfa9be commit 20cde69

4 files changed

Lines changed: 43 additions & 45 deletions

File tree

‎arch/ia64/pci/fixup.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/pci.h>
77
#include <linux/init.h>
88
#include <linux/vgaarb.h>
9+
#include <linux/screen_info.h>
910

1011
#include <asm/machvec.h>
1112

@@ -37,6 +38,27 @@ static void pci_fixup_video(struct pci_dev *pdev)
3738
return;
3839
/* Maybe, this machine supports legacy memory map. */
3940

41+
if (!vga_default_device()) {
42+
resource_size_t start, end;
43+
int i;
44+
45+
/* Does firmware framebuffer belong to us? */
46+
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
47+
if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
48+
continue;
49+
50+
start = pci_resource_start(pdev, i);
51+
end = pci_resource_end(pdev, i);
52+
53+
if (!start || !end)
54+
continue;
55+
56+
if (screen_info.lfb_base >= start &&
57+
(screen_info.lfb_base + screen_info.lfb_size) < end)
58+
vga_set_default_device(pdev);
59+
}
60+
}
61+
4062
/* Is VGA routed to us? */
4163
bus = pdev->bus;
4264
while (bus) {

‎arch/x86/include/asm/vga.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,4 @@
1717
#define vga_readb(x) (*(x))
1818
#define vga_writeb(x, y) (*(y) = (x))
1919

20-
#ifdef CONFIG_FB_EFI
21-
#define __ARCH_HAS_VGA_DEFAULT_DEVICE
22-
extern struct pci_dev *vga_default_device(void);
23-
extern void vga_set_default_device(struct pci_dev *pdev);
24-
#endif
25-
2620
#endif /* _ASM_X86_VGA_H */

‎arch/x86/pci/fixup.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,27 @@ static void pci_fixup_video(struct pci_dev *pdev)
326326
struct pci_bus *bus;
327327
u16 config;
328328

329+
if (!vga_default_device()) {
330+
resource_size_t start, end;
331+
int i;
332+
333+
/* Does firmware framebuffer belong to us? */
334+
for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
335+
if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
336+
continue;
337+
338+
start = pci_resource_start(pdev, i);
339+
end = pci_resource_end(pdev, i);
340+
341+
if (!start || !end)
342+
continue;
343+
344+
if (screen_info.lfb_base >= start &&
345+
(screen_info.lfb_base + screen_info.lfb_size) < end)
346+
vga_set_default_device(pdev);
347+
}
348+
}
349+
329350
/* Is VGA routed to us? */
330351
bus = pdev->bus;
331352
while (bus) {

‎drivers/video/fbdev/efifb.c‎

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
static bool request_mem_succeeded = false;
2121

22-
static struct pci_dev *default_vga;
23-
2422
static struct fb_var_screeninfo efifb_defined = {
2523
.activate = FB_ACTIVATE_NOW,
2624
.height = -1,
@@ -84,23 +82,10 @@ static struct fb_ops efifb_ops = {
8482
.fb_imageblit = cfb_imageblit,
8583
};
8684

87-
struct pci_dev *vga_default_device(void)
88-
{
89-
return default_vga;
90-
}
91-
92-
EXPORT_SYMBOL_GPL(vga_default_device);
93-
94-
void vga_set_default_device(struct pci_dev *pdev)
95-
{
96-
default_vga = pdev;
97-
}
98-
9985
static int efifb_setup(char *options)
10086
{
10187
char *this_opt;
10288
int i;
103-
struct pci_dev *dev = NULL;
10489

10590
if (options && *options) {
10691
while ((this_opt = strsep(&options, ",")) != NULL) {
@@ -126,30 +111,6 @@ static int efifb_setup(char *options)
126111
}
127112
}
128113

129-
for_each_pci_dev(dev) {
130-
int i;
131-
132-
if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
133-
continue;
134-
135-
for (i=0; i < DEVICE_COUNT_RESOURCE; i++) {
136-
resource_size_t start, end;
137-
138-
if (!(pci_resource_flags(dev, i) & IORESOURCE_MEM))
139-
continue;
140-
141-
start = pci_resource_start(dev, i);
142-
end = pci_resource_end(dev, i);
143-
144-
if (!start || !end)
145-
continue;
146-
147-
if (screen_info.lfb_base >= start &&
148-
(screen_info.lfb_base + screen_info.lfb_size) < end)
149-
default_vga = dev;
150-
}
151-
}
152-
153114
return 0;
154115
}
155116

0 commit comments

Comments
 (0)