aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/vga/vgaarb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/vga/vgaarb.c')
-rw-r--r--drivers/gpu/vga/vgaarb.c46
1 files changed, 37 insertions, 9 deletions
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index d2077f040f3e..77711623b973 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -41,6 +41,7 @@
41#include <linux/poll.h> 41#include <linux/poll.h>
42#include <linux/miscdevice.h> 42#include <linux/miscdevice.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/screen_info.h>
44 45
45#include <linux/uaccess.h> 46#include <linux/uaccess.h>
46 47
@@ -112,10 +113,8 @@ both:
112 return 1; 113 return 1;
113} 114}
114 115
115#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
116/* this is only used a cookie - it should not be dereferenced */ 116/* this is only used a cookie - it should not be dereferenced */
117static struct pci_dev *vga_default; 117static struct pci_dev *vga_default;
118#endif
119 118
120static void vga_arb_device_card_gone(struct pci_dev *pdev); 119static void vga_arb_device_card_gone(struct pci_dev *pdev);
121 120
@@ -131,7 +130,6 @@ static struct vga_device *vgadev_find(struct pci_dev *pdev)
131} 130}
132 131
133/* Returns the default VGA device (vgacon's babe) */ 132/* Returns the default VGA device (vgacon's babe) */
134#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
135struct pci_dev *vga_default_device(void) 133struct pci_dev *vga_default_device(void)
136{ 134{
137 return vga_default; 135 return vga_default;
@@ -147,7 +145,6 @@ void vga_set_default_device(struct pci_dev *pdev)
147 pci_dev_put(vga_default); 145 pci_dev_put(vga_default);
148 vga_default = pci_dev_get(pdev); 146 vga_default = pci_dev_get(pdev);
149} 147}
150#endif
151 148
152static inline void vga_irq_set_state(struct vga_device *vgadev, bool state) 149static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
153{ 150{
@@ -583,11 +580,12 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
583 /* Deal with VGA default device. Use first enabled one 580 /* Deal with VGA default device. Use first enabled one
584 * by default if arch doesn't have it's own hook 581 * by default if arch doesn't have it's own hook
585 */ 582 */
586#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
587 if (vga_default == NULL && 583 if (vga_default == NULL &&
588 ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) 584 ((vgadev->owns & VGA_RSRC_LEGACY_MASK) == VGA_RSRC_LEGACY_MASK)) {
585 pr_info("vgaarb: setting as boot device: PCI:%s\n",
586 pci_name(pdev));
589 vga_set_default_device(pdev); 587 vga_set_default_device(pdev);
590#endif 588 }
591 589
592 vga_arbiter_check_bridge_sharing(vgadev); 590 vga_arbiter_check_bridge_sharing(vgadev);
593 591
@@ -621,10 +619,8 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
621 goto bail; 619 goto bail;
622 } 620 }
623 621
624#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
625 if (vga_default == pdev) 622 if (vga_default == pdev)
626 vga_set_default_device(NULL); 623 vga_set_default_device(NULL);
627#endif
628 624
629 if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)) 625 if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM))
630 vga_decode_count--; 626 vga_decode_count--;
@@ -1320,6 +1316,38 @@ static int __init vga_arb_device_init(void)
1320 pr_info("vgaarb: loaded\n"); 1316 pr_info("vgaarb: loaded\n");
1321 1317
1322 list_for_each_entry(vgadev, &vga_list, list) { 1318 list_for_each_entry(vgadev, &vga_list, list) {
1319#if defined(CONFIG_X86) || defined(CONFIG_IA64)
1320 /* Override I/O based detection done by vga_arbiter_add_pci_device()
1321 * as it may take the wrong device (e.g. on Apple system under EFI).
1322 *
1323 * Select the device owning the boot framebuffer if there is one.
1324 */
1325 resource_size_t start, end;
1326 int i;
1327
1328 /* Does firmware framebuffer belong to us? */
1329 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
1330 if (!(pci_resource_flags(vgadev->pdev, i) & IORESOURCE_MEM))
1331 continue;
1332
1333 start = pci_resource_start(vgadev->pdev, i);
1334 end = pci_resource_end(vgadev->pdev, i);
1335
1336 if (!start || !end)
1337 continue;
1338
1339 if (screen_info.lfb_base < start ||
1340 (screen_info.lfb_base + screen_info.lfb_size) >= end)
1341 continue;
1342 if (!vga_default_device())
1343 pr_info("vgaarb: setting as boot device: PCI:%s\n",
1344 pci_name(vgadev->pdev));
1345 else if (vgadev->pdev != vga_default_device())
1346 pr_info("vgaarb: overriding boot device: PCI:%s\n",
1347 pci_name(vgadev->pdev));
1348 vga_set_default_device(vgadev->pdev);
1349 }
1350#endif
1323 if (vgadev->bridge_has_one_vga) 1351 if (vgadev->bridge_has_one_vga)
1324 pr_info("vgaarb: bridge control possible %s\n", pci_name(vgadev->pdev)); 1352 pr_info("vgaarb: bridge control possible %s\n", pci_name(vgadev->pdev));
1325 else 1353 else