Kludge up Linux PCI device shims. . New drm_pci_attach/drm_pci_detach simplify initialization of autoconf-derived struct pci_dev. . New linux_pci_dev_init initializes struct pci_dev so that there's one place where all its fields are listed. The kludge parameter is, well, kludgey. Sorry. . Replace pci_kludgey_find_dev by pci_get_bus_and_slot with the same interface as Linux's, but some kasserts requiring it to look for the one bus/device/function tuple that i915drm is interested in. . Add pci_get_class which does similarly, for intel_detect_pch. Later pci_get_bus_and_slot and pci_get_class should be fixed once we can pass a cookie through PCI bus enumeration and pci_find_device.diff -r1.1.1.1.2.48 -r1.1.1.1.2.49 src/sys/external/bsd/drm2/dist/include/drm/drmP.h
(riastradh)
--- src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2013/07/24 03:23:31 1.1.1.1.2.48
+++ src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2013/07/24 03:24:03 1.1.1.1.2.49
@@ -1820,26 +1820,31 @@ extern int drm_sg_alloc(struct drm_devic | @@ -1820,26 +1820,31 @@ extern int drm_sg_alloc(struct drm_devic | |||
1820 | extern int drm_sg_free(struct drm_device *dev, void *data, | 1820 | extern int drm_sg_free(struct drm_device *dev, void *data, | |
1821 | struct drm_file *file_priv); | 1821 | struct drm_file *file_priv); | |
1822 | 1822 | |||
1823 | /* ATI PCIGART support (ati_pcigart.h) */ | 1823 | /* ATI PCIGART support (ati_pcigart.h) */ | |
1824 | extern int drm_ati_pcigart_init(struct drm_device *dev, | 1824 | extern int drm_ati_pcigart_init(struct drm_device *dev, | |
1825 | struct drm_ati_pcigart_info * gart_info); | 1825 | struct drm_ati_pcigart_info * gart_info); | |
1826 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, | 1826 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, | |
1827 | struct drm_ati_pcigart_info * gart_info); | 1827 | struct drm_ati_pcigart_info * gart_info); | |
1828 | 1828 | |||
1829 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, | 1829 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, | |
1830 | size_t align); | 1830 | size_t align); | |
1831 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | 1831 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | |
1832 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | 1832 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | |
1833 | #ifdef __NetBSD__ | |||
1834 | extern void drm_pci_attach(device_t, const struct pci_attach_args *, | |||
1835 | struct pci_dev *, struct drm_device *); | |||
1836 | extern int drm_pci_detach(struct drm_device *, int); | |||
1837 | #endif | |||
1833 | 1838 | |||
1834 | /* sysfs support (drm_sysfs.c) */ | 1839 | /* sysfs support (drm_sysfs.c) */ | |
1835 | struct drm_sysfs_class; | 1840 | struct drm_sysfs_class; | |
1836 | extern struct class *drm_sysfs_create(struct module *owner, char *name); | 1841 | extern struct class *drm_sysfs_create(struct module *owner, char *name); | |
1837 | extern void drm_sysfs_destroy(void); | 1842 | extern void drm_sysfs_destroy(void); | |
1838 | extern int drm_sysfs_device_add(struct drm_minor *minor); | 1843 | extern int drm_sysfs_device_add(struct drm_minor *minor); | |
1839 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | 1844 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | |
1840 | extern void drm_sysfs_device_remove(struct drm_minor *minor); | 1845 | extern void drm_sysfs_device_remove(struct drm_minor *minor); | |
1841 | #ifndef __NetBSD__ | 1846 | #ifndef __NetBSD__ | |
1842 | extern char *drm_get_connector_status_name(enum drm_connector_status status); | 1847 | extern char *drm_get_connector_status_name(enum drm_connector_status status); | |
1843 | #endif | 1848 | #endif | |
1844 | extern int drm_sysfs_connector_add(struct drm_connector *connector); | 1849 | extern int drm_sysfs_connector_add(struct drm_connector *connector); | |
1845 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); | 1850 | extern void drm_sysfs_connector_remove(struct drm_connector *connector); |
--- src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:20:05 1.1.2.12
+++ src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:24:03 1.1.2.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pci.h,v 1.1.2.12 2013/07/24 03:20:05 riastradh Exp $ */ | 1 | /* $NetBSD: pci.h,v 1.1.2.13 2013/07/24 03:24:03 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -49,57 +49,80 @@ struct pci_device_id { | @@ -49,57 +49,80 @@ struct pci_device_id { | |||
49 | uint32_t vendor; | 49 | uint32_t vendor; | |
50 | uint32_t device; | 50 | uint32_t device; | |
51 | uint32_t subvendor; | 51 | uint32_t subvendor; | |
52 | uint32_t subdevice; | 52 | uint32_t subdevice; | |
53 | uint32_t class; | 53 | uint32_t class; | |
54 | uint32_t class_mask; | 54 | uint32_t class_mask; | |
55 | unsigned long driver_data; | 55 | unsigned long driver_data; | |
56 | }; | 56 | }; | |
57 | 57 | |||
58 | #define PCI_ANY_ID ((pcireg_t)-1) | 58 | #define PCI_ANY_ID ((pcireg_t)-1) | |
59 | 59 | |||
60 | #define PCI_BASE_CLASS_DISPLAY PCI_CLASS_DISPLAY | 60 | #define PCI_BASE_CLASS_DISPLAY PCI_CLASS_DISPLAY | |
61 | 61 | |||
62 | #define PCI_CLASS_BRIDGE_ISA PCI_SUBCLASS_BRIDGE_ISA | 62 | #define PCI_CLASS_BRIDGE_ISA \ | |
63 | ((PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_ISA) | |||
64 | CTASSERT(PCI_CLASS_BRIDGE_ISA == 0x0601); | |||
63 | 65 | |||
64 | #define PCI_VENDOR_ID_INTEL PCI_VENDOR_INTEL | 66 | #define PCI_VENDOR_ID_INTEL PCI_VENDOR_INTEL | |
65 | 67 | |||
68 | #define PCI_DEVFN(DEV, FN) \ | |||
69 | (__SHIFTIN((DEV), __BITS(3, 7)) | __SHIFTIN((FN), __BITS(0, 2))) | |||
70 | #define PCI_SLOT(DEVFN) __SHIFTOUT((DEVFN), __BITS(3, 7)) | |||
71 | #define PCI_FUNC(DEVFN) __SHIFTOUT((DEVFN), __BITS(0, 2)) | |||
72 | ||||
73 | #define PCI_CAP_ID_AGP PCI_CAP_AGP | |||
74 | ||||
66 | struct pci_dev { | 75 | struct pci_dev { | |
67 | struct pci_attach_args pd_pa; | 76 | struct pci_attach_args pd_pa; | |
68 | bool pd_kludged; /* XXX pci_kludgey_find_dev */ | 77 | bool pd_kludged; /* XXX pci_kludgey_find_dev */ | |
69 | device_t pd_dev; | 78 | device_t pd_dev; | |
70 | struct pci_bus *bus; | 79 | struct pci_bus *bus; | |
71 | uint32_t devfn; | 80 | uint32_t devfn; | |
72 | uint16_t vendor; | 81 | uint16_t vendor; | |
73 | uint16_t device; | 82 | uint16_t device; | |
74 | uint16_t subsystem_vendor; | 83 | uint16_t subsystem_vendor; | |
75 | uint16_t subsystem_device; | 84 | uint16_t subsystem_device; | |
76 | uint8_t revision; | 85 | uint8_t revision; | |
77 | uint32_t class; | 86 | uint32_t class; | |
78 | bool msi_enabled; | 87 | bool msi_enabled; | |
79 | }; | 88 | }; | |
80 | 89 | |||
81 | static inline device_t | 90 | static inline device_t | |
82 | pci_dev_dev(struct pci_dev *pdev) | 91 | pci_dev_dev(struct pci_dev *pdev) | |
83 | { | 92 | { | |
84 | return pdev->pd_dev; | 93 | return pdev->pd_dev; | |
85 | } | 94 | } | |
86 | 95 | |||
87 | #define PCI_DEVFN(DEV, FN) \ | 96 | static inline void | |
88 | (__SHIFTIN((DEV), __BITS(3, 7)) | __SHIFTIN((FN), __BITS(0, 2))) | 97 | linux_pci_dev_init(struct pci_dev *pdev, device_t dev, | |
89 | #define PCI_SLOT(DEVFN) __SHIFTOUT((DEVFN), __BITS(3, 7)) | 98 | const struct pci_attach_args *pa, bool kludged) | |
90 | #define PCI_FUNC(DEVFN) __SHIFTOUT((DEVFN), __BITS(0, 2)) | 99 | { | |
100 | const uint32_t subsystem_id = pci_conf_read(pa->pa_pc, pa->pa_tag, | |||
101 | PCI_SUBSYS_ID_REG); | |||
91 | 102 | |||
92 | #define PCI_CAP_ID_AGP PCI_CAP_AGP | 103 | pdev->pd_pa = *pa; | |
104 | pdev->pd_kludged = kludged; | |||
105 | pdev->pd_dev = dev; | |||
106 | pdev->bus = NULL; /* XXX struct pci_dev::bus */ | |||
107 | pdev->devfn = PCI_DEVFN(pa->pa_device, pa->pa_function); | |||
108 | pdev->vendor = PCI_VENDOR(pa->pa_id); | |||
109 | pdev->device = PCI_PRODUCT(pa->pa_id); | |||
110 | pdev->subsystem_vendor = PCI_SUBSYS_VENDOR(subsystem_id); | |||
111 | pdev->subsystem_device = PCI_SUBSYS_ID(subsystem_id); | |||
112 | pdev->revision = PCI_REVISION(pa->pa_class); | |||
113 | pdev->class = __SHIFTOUT(pa->pa_class, 0xffffff00UL); /* ? */ | |||
114 | pdev->msi_enabled = false; | |||
115 | } | |||
93 | 116 | |||
94 | static inline int | 117 | static inline int | |
95 | pci_find_capability(struct pci_dev *pdev, int cap) | 118 | pci_find_capability(struct pci_dev *pdev, int cap) | |
96 | { | 119 | { | |
97 | return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap, | 120 | return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap, | |
98 | NULL, NULL); | 121 | NULL, NULL); | |
99 | } | 122 | } | |
100 | 123 | |||
101 | static inline void | 124 | static inline void | |
102 | pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep) | 125 | pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep) | |
103 | { | 126 | { | |
104 | KASSERT(!ISSET(reg, 3)); | 127 | KASSERT(!ISSET(reg, 3)); | |
105 | *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg); | 128 | *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg); | |
@@ -220,53 +243,90 @@ pci_bus_alloc_resource(struct pci_bus *b | @@ -220,53 +243,90 @@ pci_bus_alloc_resource(struct pci_bus *b | |||
220 | } | 243 | } | |
221 | 244 | |||
222 | resource->r_bst = bst; | 245 | resource->r_bst = bst; | |
223 | error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */, | 246 | error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */, | |
224 | size, align, 0, 0, &resource->start, &resource->r_bsh); | 247 | size, align, 0, 0, &resource->start, &resource->r_bsh); | |
225 | if (error) | 248 | if (error) | |
226 | return error; | 249 | return error; | |
227 | 250 | |||
228 | resource->size = size; | 251 | resource->size = size; | |
229 | return 0; | 252 | return 0; | |
230 | } | 253 | } | |
231 | 254 | |||
232 | /* | 255 | /* | |
233 | * XXX Mega-kludgerific! | 256 | * XXX Mega-kludgerific! pci_get_bus_and_slot and pci_get_class are | |
234 | * | 257 | * defined only for their single purposes in i915drm, in | |
235 | * XXX Doesn't check whether any such device actually exists. | 258 | * i915_get_bridge_dev and intel_detect_pch. We can't define them more | |
259 | * generally without adapting pci_find_device (and pci_enumerate_bus | |||
260 | * internally) to pass a cookie through. | |||
236 | */ | 261 | */ | |
237 | 262 | |||
263 | static inline int /* XXX inline? */ | |||
264 | pci_kludgey_match_bus0_dev0_func0(const struct pci_attach_args *pa) | |||
265 | { | |||
266 | ||||
267 | if (pa->pa_bus != 0) | |||
268 | return 0; | |||
269 | if (pa->pa_device != 0) | |||
270 | return 0; | |||
271 | if (pa->pa_function != 0) | |||
272 | return 0; | |||
273 | ||||
274 | return 1; | |||
275 | } | |||
276 | ||||
238 | static inline struct pci_dev * | 277 | static inline struct pci_dev * | |
239 | pci_kludgey_find_dev(struct pci_dev *pdev, int bus, int dev, int func) | 278 | pci_get_bus_and_slot(int bus, int slot) | |
240 | { | 279 | { | |
241 | struct pci_dev *const otherdev = kmem_zalloc(sizeof(*otherdev), | 280 | struct pci_attach_args pa; | |
242 | KM_SLEEP); | |||
243 | 281 | |||
244 | #ifdef DIAGNOSTIC | 282 | KASSERT(bus == 0); | |
245 | { | 283 | KASSERT(slot == PCI_DEVFN(0, 0)); | |
246 | int obus, odev, ofunc; | 284 | ||
247 | 285 | if (!pci_find_device(&pa, &pci_kludgey_match_bus0_dev0_func0)) | ||
248 | pci_decompose_tag(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, &obus, | 286 | return NULL; | |
249 | &odev, &ofunc); | 287 | ||
250 | KASSERT(obus == bus); | 288 | struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP); | |
251 | } | 289 | linux_pci_dev_init(pdev, NULL, &pa, true); | |
252 | #endif | 290 | ||
291 | return pdev; | |||
292 | } | |||
293 | ||||
294 | static inline int /* XXX inline? */ | |||
295 | pci_kludgey_match_isa_bridge(const struct pci_attach_args *pa) | |||
296 | { | |||
297 | ||||
298 | if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE) | |||
299 | return 0; | |||
300 | if (PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA) | |||
301 | return 0; | |||
302 | ||||
303 | return 1; | |||
304 | } | |||
305 | ||||
306 | static inline struct pci_dev * | |||
307 | pci_get_class(uint32_t class_subclass_shifted __unused, | |||
308 | struct pci_dev *from __unused) | |||
309 | { | |||
310 | struct pci_attach_args pa; | |||
311 | ||||
312 | KASSERT(class_subclass_shifted == (PCI_CLASS_BRIDGE_ISA << 8)); | |||
313 | KASSERT(from == NULL); | |||
314 | ||||
315 | if (!pci_find_device(&pa, &pci_kludgey_match_isa_bridge)) | |||
316 | return NULL; | |||
253 | 317 | |||
254 | otherdev->bus = NULL; /* XXX struct pci_dev::bus */ | 318 | struct pci_dev *const pdev = kmem_zalloc(sizeof(*pdev), KM_SLEEP); | |
255 | otherdev->device = dev; | 319 | linux_pci_dev_init(pdev, NULL, &pa, true); | |
256 | otherdev->pd_pa = pdev->pd_pa; | |||
257 | otherdev->pd_pa.pa_tag = pci_make_tag(otherdev->pd_pa.pa_pc, | |||
258 | bus, dev, func); | |||
259 | otherdev->pd_kludged = true; | |||
260 | 320 | |||
261 | return otherdev; | 321 | return pdev; | |
262 | } | 322 | } | |
263 | 323 | |||
264 | static inline void | 324 | static inline void | |
265 | pci_dev_put(struct pci_dev *pdev) | 325 | pci_dev_put(struct pci_dev *pdev) | |
266 | { | 326 | { | |
267 | 327 | |||
268 | KASSERT(pdev->pd_kludged); | 328 | KASSERT(pdev->pd_kludged); | |
269 | kmem_free(pdev, sizeof(*pdev)); | 329 | kmem_free(pdev, sizeof(*pdev)); | |
270 | } | 330 | } | |
271 | 331 | |||
272 | #endif /* _LINUX_PCI_H_ */ | 332 | #endif /* _LINUX_PCI_H_ */ |
--- src/sys/external/bsd/drm2/pci/drm_pci.c 2013/07/24 02:35:07 1.1.2.1
+++ src/sys/external/bsd/drm2/pci/drm_pci.c 2013/07/24 03:24:03 1.1.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_pci.c,v 1.1.2.1 2013/07/24 02:35:07 riastradh Exp $ */ | 1 | /* $NetBSD: drm_pci.c,v 1.1.2.2 2013/07/24 03:24:03 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Taylor R. Campbell. | 8 | * by Taylor R. Campbell. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.1.2.1 2013/07/24 02:35:07 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.1.2.2 2013/07/24 03:24:03 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/errno.h> | 36 | #include <sys/errno.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | 38 | |||
39 | #include <dev/pci/pcivar.h> | 39 | #include <dev/pci/pcivar.h> | |
40 | 40 | |||
41 | #include <drm/drmP.h> | 41 | #include <drm/drmP.h> | |
42 | 42 | |||
43 | static int drm_pci_get_irq(struct drm_device *); | 43 | static int drm_pci_get_irq(struct drm_device *); | |
44 | static int drm_pci_irq_install(struct drm_device *, | 44 | static int drm_pci_irq_install(struct drm_device *, | |
45 | irqreturn_t (*)(void *), int, const char *, void *, | 45 | irqreturn_t (*)(void *), int, const char *, void *, | |
46 | struct drm_bus_irq_cookie **); | 46 | struct drm_bus_irq_cookie **); | |
@@ -63,26 +63,48 @@ const struct drm_bus drm_pci_bus = { | @@ -63,26 +63,48 @@ const struct drm_bus drm_pci_bus = { | |||
63 | .get_name = drm_pci_get_name, | 63 | .get_name = drm_pci_get_name, | |
64 | .set_busid = drm_pci_set_busid, | 64 | .set_busid = drm_pci_set_busid, | |
65 | .set_unique = drm_pci_set_unique, | 65 | .set_unique = drm_pci_set_unique, | |
66 | .irq_by_busid = drm_pci_irq_by_busid, | 66 | .irq_by_busid = drm_pci_irq_by_busid, | |
67 | .agp_init = drm_pci_agp_init, | 67 | .agp_init = drm_pci_agp_init, | |
68 | }; | 68 | }; | |
69 | 69 | |||
70 | static const struct pci_attach_args * | 70 | static const struct pci_attach_args * | |
71 | drm_pci_attach_args(struct drm_device *dev) | 71 | drm_pci_attach_args(struct drm_device *dev) | |
72 | { | 72 | { | |
73 | return &dev->pdev->pd_pa; | 73 | return &dev->pdev->pd_pa; | |
74 | } | 74 | } | |
75 | 75 | |||
76 | void | |||
77 | drm_pci_attach(device_t self, const struct pci_attach_args *pa, | |||
78 | struct pci_dev *pdev, struct drm_device *dev) | |||
79 | { | |||
80 | ||||
81 | linux_pci_dev_init(pdev, self, pa, false); | |||
82 | ||||
83 | dev->pdev = pdev; | |||
84 | dev->pci_vendor = pdev->vendor; | |||
85 | dev->pci_device = pdev->device; | |||
86 | ||||
87 | /* XXX Set the power state to D0? */ | |||
88 | } | |||
89 | ||||
90 | int | |||
91 | drm_pci_detach(struct drm_device *dev __unused, int flags __unused) | |||
92 | { | |||
93 | ||||
94 | /* XXX Disestablish irqs or anything? */ | |||
95 | return 0; | |||
96 | } | |||
97 | ||||
76 | static int | 98 | static int | |
77 | drm_pci_get_irq(struct drm_device *dev) | 99 | drm_pci_get_irq(struct drm_device *dev) | |
78 | { | 100 | { | |
79 | pci_intr_handle_t ih_pih; | 101 | pci_intr_handle_t ih_pih; | |
80 | int ih_int; | 102 | int ih_int; | |
81 | 103 | |||
82 | /* | 104 | /* | |
83 | * This is a compile-time assertion that the types match. If | 105 | * This is a compile-time assertion that the types match. If | |
84 | * this fails, we have to change a bunch of drm code that uses | 106 | * this fails, we have to change a bunch of drm code that uses | |
85 | * int for intr handles. | 107 | * int for intr handles. | |
86 | */ | 108 | */ | |
87 | KASSERT(&ih_pih != &ih_int); | 109 | KASSERT(&ih_pih != &ih_int); | |
88 | 110 |