aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2012-04-16 16:26:02 -0400
committerDave Airlie <airlied@redhat.com>2012-04-24 04:50:15 -0400
commit1a39b310e920bb7098067d96411b31e459ae8f32 (patch)
tree90f45eed83bcd5308ac9ad850844d0b57038e5f8
parentf122c6109b1a79153cfb1e188c665ce3f312a886 (diff)
vgaarb: Add support for setting the default video device (v2)
The default VGA device is a somewhat fluid concept on platforms with multiple GPUs. Add support for setting it so switching code can update things appropriately, and make sure that the sysfs code returns the right device if it's changed. v2: Updated to fix builds when __ARCH_HAS_VGA_DEFAULT_DEVICE is false. Signed-off-by: Matthew Garrett <mjg@redhat.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Acked-by: benh@kernel.crashing.org Cc: airlied@redhat.com Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/vga/vgaarb.c7
-rw-r--r--drivers/pci/pci-sysfs.c5
-rw-r--r--include/linux/vgaarb.h2
3 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 111d956d8e7d..e223b96fa6a0 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -136,6 +136,11 @@ struct pci_dev *vga_default_device(void)
136{ 136{
137 return vga_default; 137 return vga_default;
138} 138}
139
140void vga_set_default_device(struct pci_dev *pdev)
141{
142 vga_default = pdev;
143}
139#endif 144#endif
140 145
141static inline void vga_irq_set_state(struct vga_device *vgadev, bool state) 146static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
@@ -605,10 +610,12 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
605 goto bail; 610 goto bail;
606 } 611 }
607 612
613#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
608 if (vga_default == pdev) { 614 if (vga_default == pdev) {
609 pci_dev_put(vga_default); 615 pci_dev_put(vga_default);
610 vga_default = NULL; 616 vga_default = NULL;
611 } 617 }
618#endif
612 619
613 if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM)) 620 if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM))
614 vga_decode_count--; 621 vga_decode_count--;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index a55e248618cd..86c63fe45d11 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -27,6 +27,7 @@
27#include <linux/security.h> 27#include <linux/security.h>
28#include <linux/pci-aspm.h> 28#include <linux/pci-aspm.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/vgaarb.h>
30#include "pci.h" 31#include "pci.h"
31 32
32static int sysfs_initialized; /* = 0 */ 33static int sysfs_initialized; /* = 0 */
@@ -417,6 +418,10 @@ static ssize_t
417boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) 418boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
418{ 419{
419 struct pci_dev *pdev = to_pci_dev(dev); 420 struct pci_dev *pdev = to_pci_dev(dev);
421 struct pci_dev *vga_dev = vga_default_device();
422
423 if (vga_dev)
424 return sprintf(buf, "%u\n", (pdev == vga_dev));
420 425
421 return sprintf(buf, "%u\n", 426 return sprintf(buf, "%u\n",
422 !!(pdev->resource[PCI_ROM_RESOURCE].flags & 427 !!(pdev->resource[PCI_ROM_RESOURCE].flags &
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index 9c3120dca294..759a25ba0539 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -31,6 +31,7 @@
31#ifndef LINUX_VGA_H 31#ifndef LINUX_VGA_H
32#define LINUX_VGA_H 32#define LINUX_VGA_H
33 33
34#include <video/vga.h>
34 35
35/* Legacy VGA regions */ 36/* Legacy VGA regions */
36#define VGA_RSRC_NONE 0x00 37#define VGA_RSRC_NONE 0x00
@@ -181,6 +182,7 @@ extern void vga_put(struct pci_dev *pdev, unsigned int rsrc);
181 182
182#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE 183#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
183extern struct pci_dev *vga_default_device(void); 184extern struct pci_dev *vga_default_device(void);
185extern void vga_set_default_device(struct pci_dev *pdev);
184#endif 186#endif
185 187
186/** 188/**