summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-08-13 17:24:04 +0200
committerMatthieu Herrb <matthieu@herrb.eu>2018-11-25 19:19:55 +0100
commitae4ca86c99698dc85d95ce2adc0e7a912bfd3482 (patch)
treeda5057da23a9f521730d4eaaf8e10e7257c5e82f /src
parentef1451e24900d1afb88efbf028914b658d4333f8 (diff)
Improve VGA arbiter support now that the kernel gives us information about
the resources required by a particular device. ok matthieu@, jsg@
Diffstat (limited to 'src')
-rw-r--r--src/openbsd_pci.c52
1 files changed, 36 insertions, 16 deletions
diff --git a/src/openbsd_pci.c b/src/openbsd_pci.c
index 60bc659..fa58d7a 100644
--- a/src/openbsd_pci.c
+++ b/src/openbsd_pci.c
@@ -423,6 +423,30 @@ pci_device_openbsd_probe(struct pci_device *device)
return 0;
}
+static int
+pci_device_openbsd_boot_vga(struct pci_device *dev)
+{
+ struct pci_vga pv;
+ int err;
+
+ if (dev->domain != 0)
+ return 0;
+
+ pv.pv_sel.pc_bus = 0;
+ pv.pv_sel.pc_dev = 0;
+ pv.pv_sel.pc_func = 0;
+ err = ioctl(pcifd[0], PCIOCGETVGA, &pv);
+ if (err)
+ return 0;
+
+ if (dev->bus == pv.pv_sel.pc_bus &&
+ dev->dev == pv.pv_sel.pc_dev &&
+ dev->func == pv.pv_sel.pc_func)
+ return 1;
+
+ return 0;
+}
+
#if defined(__i386__) || defined(__amd64__)
#include <machine/sysarch.h>
#include <machine/pio.h>
@@ -575,7 +599,7 @@ static const struct pci_system_methods openbsd_pci_methods = {
pci_device_openbsd_write,
pci_fill_capabilities_generic,
NULL,
- NULL,
+ pci_device_openbsd_boot_vga,
NULL,
NULL,
pci_device_openbsd_open_legacy_io,
@@ -693,10 +717,6 @@ pci_system_openbsd_create(void)
device->base.subvendor_id = PCI_VENDOR(reg);
device->base.subdevice_id = PCI_PRODUCT(reg);
- device->base.vgaarb_rsrc =
- VGA_ARB_RSRC_LEGACY_IO |
- VGA_ARB_RSRC_LEGACY_MEM;
-
device++;
}
}
@@ -741,8 +761,18 @@ pci_device_vgaarb_init(void)
return -1;
pci_sys->vga_count = 0;
while ((dev = pci_device_next(iter)) != NULL) {
- if (dev->domain == 0)
+ if (dev->domain == 0) {
pci_sys->vga_count++;
+ pv.pv_sel.pc_bus = dev->bus;
+ pv.pv_sel.pc_dev = dev->dev;
+ pv.pv_sel.pc_func = dev->func;
+ if (ioctl(pcifd[0], PCIOCGETVGA, &pv))
+ continue;
+ if (pv.pv_decode)
+ dev->vgaarb_rsrc =
+ VGA_ARB_RSRC_LEGACY_IO |
+ VGA_ARB_RSRC_LEGACY_MEM;
+ }
}
pci_iterator_destroy(iter);
@@ -784,13 +814,8 @@ pci_device_vgaarb_lock(void)
if (dev == NULL)
return -1;
-#if 0
if (dev->vgaarb_rsrc == 0 || pci_sys->vga_count == 1)
return 0;
-#else
- if (pci_sys->vga_count == 1)
- return 0;
-#endif
pv.pv_sel.pc_bus = dev->bus;
pv.pv_sel.pc_dev = dev->dev;
@@ -808,13 +833,8 @@ pci_device_vgaarb_unlock(void)
if (dev == NULL)
return -1;
-#if 0
if (dev->vgaarb_rsrc == 0 || pci_sys->vga_count == 1)
return 0;
-#else
- if (pci_sys->vga_count == 1)
- return 0;
-#endif
pv.pv_sel.pc_bus = dev->bus;
pv.pv_sel.pc_dev = dev->dev;