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 <[email protected]>
Acked-by: H. Peter Anvin <[email protected]>
Acked-by: [email protected]
Cc: [email protected]
Signed-off-by: Dave Airlie <[email protected]>
This commit is contained in:
Matthew Garrett 2012-04-16 16:26:02 -04:00 • committed by Dave Airlie
commit 1a39b310e9
3 changed files with 14 additions and 0 deletions

View file

@ -27,6 +27,7 @@
#include <linux/security.h>
#include <linux/pci-aspm.h>
#include <linux/slab.h>
#include <linux/vgaarb.h>
#include "pci.h"
static int sysfs_initialized; /* = 0 */
@ -417,6 +418,10 @@ static ssize_t
boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_dev *vga_dev = vga_default_device();
if (vga_dev)
return sprintf(buf, "%u\n", (pdev == vga_dev));
return sprintf(buf, "%u\n",
!!(pdev->resource[PCI_ROM_RESOURCE].flags &