Adapt drmkms_pci module initialization to work as builtin, for agp.diff -r1.9 -r1.10 src/sys/external/bsd/drm2/dist/include/drm/drmP.h
(riastradh)
--- src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2014/12/02 21:49:36 1.9
+++ src/sys/external/bsd/drm2/dist/include/drm/Attic/drmP.h 2015/03/06 01:24:24 1.10
@@ -1741,26 +1741,27 @@ extern int drm_sg_free(struct drm_device | @@ -1741,26 +1741,27 @@ extern int drm_sg_free(struct drm_device | |||
1741 | struct drm_file *file_priv); | 1741 | struct drm_file *file_priv); | |
1742 | 1742 | |||
1743 | /* ATI PCIGART support (ati_pcigart.h) */ | 1743 | /* ATI PCIGART support (ati_pcigart.h) */ | |
1744 | extern int drm_ati_pcigart_init(struct drm_device *dev, | 1744 | extern int drm_ati_pcigart_init(struct drm_device *dev, | |
1745 | struct drm_ati_pcigart_info * gart_info); | 1745 | struct drm_ati_pcigart_info * gart_info); | |
1746 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, | 1746 | extern int drm_ati_pcigart_cleanup(struct drm_device *dev, | |
1747 | struct drm_ati_pcigart_info * gart_info); | 1747 | struct drm_ati_pcigart_info * gart_info); | |
1748 | 1748 | |||
1749 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, | 1749 | extern drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, | |
1750 | size_t align); | 1750 | size_t align); | |
1751 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | 1751 | extern void __drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | |
1752 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | 1752 | extern void drm_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah); | |
1753 | #ifdef __NetBSD__ | 1753 | #ifdef __NetBSD__ | |
1754 | extern int drmkms_pci_agp_guarantee_initialized(void); | |||
1754 | extern int drm_pci_attach(device_t, const struct pci_attach_args *, | 1755 | extern int drm_pci_attach(device_t, const struct pci_attach_args *, | |
1755 | struct pci_dev *, struct drm_driver *, unsigned long, | 1756 | struct pci_dev *, struct drm_driver *, unsigned long, | |
1756 | struct drm_device **); | 1757 | struct drm_device **); | |
1757 | extern int drm_pci_detach(struct drm_device *, int); | 1758 | extern int drm_pci_detach(struct drm_device *, int); | |
1758 | #endif | 1759 | #endif | |
1759 | 1760 | |||
1760 | /* sysfs support (drm_sysfs.c) */ | 1761 | /* sysfs support (drm_sysfs.c) */ | |
1761 | struct drm_sysfs_class; | 1762 | struct drm_sysfs_class; | |
1762 | extern struct class *drm_sysfs_create(struct module *owner, char *name); | 1763 | extern struct class *drm_sysfs_create(struct module *owner, char *name); | |
1763 | extern void drm_sysfs_destroy(void); | 1764 | extern void drm_sysfs_destroy(void); | |
1764 | extern int drm_sysfs_device_add(struct drm_minor *minor); | 1765 | extern int drm_sysfs_device_add(struct drm_minor *minor); | |
1765 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | 1766 | extern void drm_sysfs_hotplug_event(struct drm_device *dev); | |
1766 | extern void drm_sysfs_device_remove(struct drm_minor *minor); | 1767 | extern void drm_sysfs_device_remove(struct drm_minor *minor); |
--- src/sys/external/bsd/drm2/pci/drm_pci.c 2015/01/01 01:15:43 1.9
+++ src/sys/external/bsd/drm2/pci/drm_pci.c 2015/03/06 01:24:24 1.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_pci.c,v 1.9 2015/01/01 01:15:43 mrg Exp $ */ | 1 | /* $NetBSD: drm_pci.c,v 1.10 2015/03/06 01:24:24 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.9 2015/01/01 01:15:43 mrg Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_pci.c,v 1.10 2015/03/06 01:24:24 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 **); | |
@@ -84,26 +84,32 @@ drm_pci_exit(struct drm_driver *driver _ | @@ -84,26 +84,32 @@ drm_pci_exit(struct drm_driver *driver _ | |||
84 | struct pci_driver *pdriver __unused) | 84 | struct pci_driver *pdriver __unused) | |
85 | { | 85 | { | |
86 | } | 86 | } | |
87 | 87 | |||
88 | int | 88 | int | |
89 | drm_pci_attach(device_t self, const struct pci_attach_args *pa, | 89 | drm_pci_attach(device_t self, const struct pci_attach_args *pa, | |
90 | struct pci_dev *pdev, struct drm_driver *driver, unsigned long cookie, | 90 | struct pci_dev *pdev, struct drm_driver *driver, unsigned long cookie, | |
91 | struct drm_device **devp) | 91 | struct drm_device **devp) | |
92 | { | 92 | { | |
93 | struct drm_device *dev; | 93 | struct drm_device *dev; | |
94 | unsigned int unit; | 94 | unsigned int unit; | |
95 | int ret; | 95 | int ret; | |
96 | 96 | |||
97 | /* Ensure the drm agp hooks are installed. */ | |||
98 | /* XXX errno NetBSD->Linux */ | |||
99 | ret = -drmkms_pci_agp_guarantee_initialized(); | |||
100 | if (ret) | |||
101 | goto fail0; | |||
102 | ||||
97 | /* Initialize the Linux PCI device descriptor. */ | 103 | /* Initialize the Linux PCI device descriptor. */ | |
98 | linux_pci_dev_init(pdev, self, pa, 0); | 104 | linux_pci_dev_init(pdev, self, pa, 0); | |
99 | 105 | |||
100 | /* Create a DRM device. */ | 106 | /* Create a DRM device. */ | |
101 | dev = drm_dev_alloc(driver, self); | 107 | dev = drm_dev_alloc(driver, self); | |
102 | if (dev == NULL) { | 108 | if (dev == NULL) { | |
103 | ret = -ENOMEM; | 109 | ret = -ENOMEM; | |
104 | goto fail0; | 110 | goto fail0; | |
105 | } | 111 | } | |
106 | 112 | |||
107 | dev->pdev = pdev; | 113 | dev->pdev = pdev; | |
108 | 114 | |||
109 | /* XXX Set the power state to D0? */ | 115 | /* XXX Set the power state to D0? */ |
--- src/sys/external/bsd/drm2/pci/drm_pci_module.c 2014/11/22 19:18:07 1.3
+++ src/sys/external/bsd/drm2/pci/drm_pci_module.c 2015/03/06 01:24:24 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_pci_module.c,v 1.3 2014/11/22 19:18:07 riastradh Exp $ */ | 1 | /* $NetBSD: drm_pci_module.c,v 1.4 2015/03/06 01:24:24 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,54 +20,90 @@ | @@ -20,54 +20,90 @@ | |||
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_module.c,v 1.3 2014/11/22 19:18:07 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_pci_module.c,v 1.4 2015/03/06 01:24:24 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/module.h> | 35 | #include <sys/module.h> | |
36 | #include <sys/once.h> | |||
36 | 37 | |||
37 | #include <drm/drmP.h> | 38 | #include <drm/drmP.h> | |
38 | 39 | |||
39 | MODULE(MODULE_CLASS_MISC, drmkms_pci, "drmkms,pci"); | 40 | MODULE(MODULE_CLASS_MISC, drmkms_pci, "drmkms,pci"); | |
40 | 41 | |||
41 | const struct drm_agp_hooks drmkms_pci_agp_hooks = { | 42 | const struct drm_agp_hooks drmkms_pci_agp_hooks = { | |
42 | .agph_acquire_ioctl = &drm_agp_acquire_ioctl, | 43 | .agph_acquire_ioctl = &drm_agp_acquire_ioctl, | |
43 | .agph_release_ioctl = &drm_agp_release_ioctl, | 44 | .agph_release_ioctl = &drm_agp_release_ioctl, | |
44 | .agph_enable_ioctl = &drm_agp_enable_ioctl, | 45 | .agph_enable_ioctl = &drm_agp_enable_ioctl, | |
45 | .agph_info_ioctl = &drm_agp_info_ioctl, | 46 | .agph_info_ioctl = &drm_agp_info_ioctl, | |
46 | .agph_alloc_ioctl = &drm_agp_alloc_ioctl, | 47 | .agph_alloc_ioctl = &drm_agp_alloc_ioctl, | |
47 | .agph_free_ioctl = &drm_agp_free_ioctl, | 48 | .agph_free_ioctl = &drm_agp_free_ioctl, | |
48 | .agph_bind_ioctl = &drm_agp_bind_ioctl, | 49 | .agph_bind_ioctl = &drm_agp_bind_ioctl, | |
49 | .agph_unbind_ioctl = &drm_agp_unbind_ioctl, | 50 | .agph_unbind_ioctl = &drm_agp_unbind_ioctl, | |
50 | .agph_release = &drm_agp_release, | 51 | .agph_release = &drm_agp_release, | |
51 | .agph_clear = &drm_agp_clear, | 52 | .agph_clear = &drm_agp_clear, | |
52 | }; | 53 | }; | |
53 | 54 | |||
54 | static int | 55 | static int | |
56 | drmkms_pci_agp_init(void) | |||
57 | { | |||
58 | int error; | |||
59 | ||||
60 | error = drm_agp_register(&drmkms_pci_agp_hooks); | |||
61 | if (error) | |||
62 | return error; | |||
63 | ||||
64 | return 0; | |||
65 | } | |||
66 | ||||
67 | int | |||
68 | drmkms_pci_agp_guarantee_initialized(void) | |||
69 | { | |||
70 | #ifdef _MODULE | |||
71 | return 0; | |||
72 | #else | |||
73 | static ONCE_DECL(drmkms_pci_agp_init_once); | |||
74 | ||||
75 | return RUN_ONCE(&drmkms_pci_agp_init_once, &drmkms_pci_agp_init); | |||
76 | #endif | |||
77 | } | |||
78 | ||||
79 | static void | |||
80 | drmkms_pci_agp_fini(void) | |||
81 | { | |||
82 | ||||
83 | drm_agp_deregister(&drmkms_pci_agp_hooks); | |||
84 | } | |||
85 | ||||
86 | static int | |||
55 | drmkms_pci_modcmd(modcmd_t cmd, void *arg __unused) | 87 | drmkms_pci_modcmd(modcmd_t cmd, void *arg __unused) | |
56 | { | 88 | { | |
57 | int error; | 89 | int error; | |
58 | 90 | |||
59 | switch (cmd) { | 91 | switch (cmd) { | |
60 | case MODULE_CMD_INIT: | 92 | case MODULE_CMD_INIT: | |
61 | error = drm_agp_register(&drmkms_pci_agp_hooks); | 93 | #ifdef _MODULE | |
94 | error = drmkms_pci_agp_init(); | |||
95 | #else | |||
96 | error = drmkms_pci_agp_guarantee_initialized(); | |||
97 | #endif | |||
62 | if (error) | 98 | if (error) | |
63 | return error; | 99 | return error; | |
64 | return 0; | 100 | return 0; | |
65 | 101 | |||
66 | case MODULE_CMD_FINI: | 102 | case MODULE_CMD_FINI: | |
67 | drm_agp_deregister(&drmkms_pci_agp_hooks); | 103 | drmkms_pci_agp_fini(); | |
68 | return 0; | 104 | return 0; | |
69 | 105 | |||
70 | default: | 106 | default: | |
71 | return ENOTTY; | 107 | return ENOTTY; | |
72 | } | 108 | } | |
73 | } | 109 | } |