summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-02-05 10:05:13 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-02-05 10:05:13 +0000
commit047d75521db9f039032f717089325418f775a339 (patch)
tree4511c543073f4b1bcde6d3b3f0b2105d5c98bf91 /sys/dev/pci
parent4b48c89128dcbfd22e8d90c09937f8916d741123 (diff)
Improve Linux PCI compatibility code.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/drm/drmP.h4
-rw-r--r--sys/dev/pci/drm/drm_drv.c14
-rw-r--r--sys/dev/pci/drm/drm_linux.h13
3 files changed, 24 insertions, 7 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 0a2e2f568c2..4cff9515d94 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.200 2015/11/22 15:35:49 kettenis Exp $ */
+/* $OpenBSD: drmP.h,v 1.201 2016/02/05 10:05:12 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -606,7 +606,7 @@ struct drm_device {
struct drm_driver_info *driver;
- struct pci_dev drm_pci;
+ struct pci_dev _pdev;
struct pci_dev *pdev;
u_int16_t pci_device;
u_int16_t pci_vendor;
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index a21db3b229e..c00d1195f1c 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_drv.c,v 1.144 2016/01/09 11:34:57 kettenis Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.145 2016/02/05 10:05:12 kettenis Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
@@ -399,8 +399,9 @@ drm_probe(struct device *parent, void *match, void *aux)
void
drm_attach(struct device *parent, struct device *self, void *aux)
{
- struct drm_device *dev = (struct drm_device *)self;
- struct drm_attach_args *da = aux;
+ struct drm_device *dev = (struct drm_device *)self;
+ struct drm_attach_args *da = aux;
+ int bus, slot, func;
dev->dev_private = parent;
dev->driver = da->driver;
@@ -409,12 +410,17 @@ drm_attach(struct device *parent, struct device *self, void *aux)
dev->bst = da->bst;
dev->unique = da->busid;
dev->unique_len = da->busid_len;
- dev->pdev = &dev->drm_pci;
+ dev->pdev = &dev->_pdev;
dev->pci_vendor = dev->pdev->vendor = da->pci_vendor;
dev->pci_device = dev->pdev->device = da->pci_device;
dev->pdev->subsystem_vendor = da->pci_subvendor;
dev->pdev->subsystem_device = da->pci_subdevice;
+ pci_decompose_tag(da->pc, da->tag, &bus, &slot, &func);
+ dev->pdev->bus = &dev->pdev->_bus;
+ dev->pdev->bus->number = bus;
+ dev->pdev->devfn = PCI_DEVFN(slot, func);
+
dev->pc = da->pc;
dev->pdev->pc = da->pc;
dev->bridgetag = da->bridgetag;
diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h
index 16d4e621df6..63708a7af1a 100644
--- a/sys/dev/pci/drm/drm_linux.h
+++ b/sys/dev/pci/drm/drm_linux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.h,v 1.43 2015/12/31 13:01:00 kettenis Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.44 2016/02/05 10:05:12 kettenis Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
*
@@ -975,11 +975,20 @@ struct resource {
u_long start;
};
+struct pci_bus {
+ unsigned char number;
+};
+
struct pci_dev {
+ struct pci_bus _bus;
+ struct pci_bus *bus;
+
+ unsigned int devfn;
uint16_t vendor;
uint16_t device;
uint16_t subsystem_vendor;
uint16_t subsystem_device;
+
pci_chipset_tag_t pc;
pcitag_t tag;
struct pci_softc *pci;
@@ -998,6 +1007,8 @@ struct pci_dev {
#define PCI_DEVICE_ID_ATI_RADEON_QY PCI_PRODUCT_ATI_RADEON_QY
#define PCI_DEVFN(slot, func) ((slot) << 3 | (func))
+#define PCI_SLOT(devfn) ((devfn) >> 3)
+#define PCI_FUNC(devfn) ((devfn) & 0x7)
static inline void
pci_read_config_dword(struct pci_dev *pdev, int reg, u32 *val)