drm: Nix drm_agp_borrow. This horrible kludge dates from before I understood the relation of genfb_pci and pci drm drivers in the old and new worlds of drm. The only user of it, in i915, was changed to use agp_i810_borrow directly in the last drm update, so this hack can die.diff -r1.12 -r1.13 src/sys/external/bsd/drm2/dist/drm/drm_agpsupport.c
(riastradh)
--- src/sys/external/bsd/drm2/dist/drm/drm_agpsupport.c 2021/12/18 23:44:57 1.12
+++ src/sys/external/bsd/drm2/dist/drm/drm_agpsupport.c 2022/07/19 22:24:33 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_agpsupport.c,v 1.12 2021/12/18 23:44:57 riastradh Exp $ */ | 1 | /* $NetBSD: drm_agpsupport.c,v 1.13 2022/07/19 22:24:33 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * \file drm_agpsupport.c | 4 | * \file drm_agpsupport.c | |
5 | * DRM support for AGP/GART backend | 5 | * DRM support for AGP/GART backend | |
6 | * | 6 | * | |
7 | * \author Rickard E. (Rik) Faith <faith@valinux.com> | 7 | * \author Rickard E. (Rik) Faith <faith@valinux.com> | |
8 | * \author Gareth Hughes <gareth@valinux.com> | 8 | * \author Gareth Hughes <gareth@valinux.com> | |
9 | */ | 9 | */ | |
10 | 10 | |||
11 | /* | 11 | /* | |
12 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | 12 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | |
13 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | 13 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | |
14 | * All Rights Reserved. | 14 | * All Rights Reserved. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * paragraph) shall be included in all copies or substantial portions of the | 24 | * paragraph) shall be included in all copies or substantial portions of the | |
25 | * Software. | 25 | * Software. | |
26 | * | 26 | * | |
27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
30 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | 30 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
31 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | 31 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
32 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 32 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
33 | * OTHER DEALINGS IN THE SOFTWARE. | 33 | * OTHER DEALINGS IN THE SOFTWARE. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: drm_agpsupport.c,v 1.12 2021/12/18 23:44:57 riastradh Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: drm_agpsupport.c,v 1.13 2022/07/19 22:24:33 riastradh Exp $"); | |
38 | 38 | |||
39 | #include <linux/module.h> | 39 | #include <linux/module.h> | |
40 | #include <linux/pci.h> | 40 | #include <linux/pci.h> | |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> | |
42 | 42 | |||
43 | #include <asm/agp.h> | 43 | #include <asm/agp.h> | |
44 | 44 | |||
45 | #include <drm/drm_agpsupport.h> | 45 | #include <drm/drm_agpsupport.h> | |
46 | #include <drm/drm_device.h> | 46 | #include <drm/drm_device.h> | |
47 | #include <drm/drm_drv.h> | 47 | #include <drm/drm_drv.h> | |
48 | #include <drm/drm_file.h> | 48 | #include <drm/drm_file.h> | |
49 | #include <drm/drm_print.h> | 49 | #include <drm/drm_print.h> | |
50 | 50 | |||
@@ -517,44 +517,28 @@ static void drm_agp_clear_hook(struct dr | @@ -517,44 +517,28 @@ static void drm_agp_clear_hook(struct dr | |||
517 | drm_unbind_agp(entry->memory); | 517 | drm_unbind_agp(entry->memory); | |
518 | drm_free_agp(entry->memory, entry->pages); | 518 | drm_free_agp(entry->memory, entry->pages); | |
519 | #endif | 519 | #endif | |
520 | kfree(entry); | 520 | kfree(entry); | |
521 | } | 521 | } | |
522 | INIT_LIST_HEAD(&dev->agp->memory); | 522 | INIT_LIST_HEAD(&dev->agp->memory); | |
523 | 523 | |||
524 | if (dev->agp->acquired) | 524 | if (dev->agp->acquired) | |
525 | drm_agp_release(dev); | 525 | drm_agp_release(dev); | |
526 | 526 | |||
527 | dev->agp->acquired = 0; | 527 | dev->agp->acquired = 0; | |
528 | dev->agp->enabled = 0; | 528 | dev->agp->enabled = 0; | |
529 | } | 529 | } | |
530 | #ifdef __NetBSD__ | |||
531 | ||||
532 | static void __pci_iomem * | |||
533 | drm_agp_borrow_hook(struct drm_device *dev, unsigned i, bus_size_t size) | |||
534 | { | |||
535 | struct pci_dev *pdev = dev->pdev; | |||
536 | 530 | |||
537 | if (!agp_i810_borrow(pdev->pd_resources[i].addr, size, | 531 | #ifdef __NetBSD__ | |
538 | &pdev->pd_resources[i].bsh)) | |||
539 | return NULL; | |||
540 | /* XXX Synchronize with pci_iomap in linux_pci.c. */ | |||
541 | pdev->pd_resources[i].bst = pdev->pd_pa.pa_memt; | |||
542 | pdev->pd_resources[i].kva = bus_space_vaddr(pdev->pd_resources[i].bst, | |||
543 | pdev->pd_resources[i].bsh); | |||
544 | pdev->pd_resources[i].mapped = true; | |||
545 | ||||
546 | return pdev->pd_resources[i].kva; | |||
547 | } | |||
548 | 532 | |||
549 | static void | 533 | static void | |
550 | drm_agp_flush_hook(void) | 534 | drm_agp_flush_hook(void) | |
551 | { | 535 | { | |
552 | 536 | |||
553 | agp_flush_cache(); | 537 | agp_flush_cache(); | |
554 | } | 538 | } | |
555 | 539 | |||
556 | static const struct drm_agp_hooks agp_hooks = { | 540 | static const struct drm_agp_hooks agp_hooks = { | |
557 | .agph_info = drm_agp_info_hook, | 541 | .agph_info = drm_agp_info_hook, | |
558 | .agph_info_ioctl = drm_agp_info_ioctl_hook, | 542 | .agph_info_ioctl = drm_agp_info_ioctl_hook, | |
559 | .agph_acquire = drm_agp_acquire_hook, | 543 | .agph_acquire = drm_agp_acquire_hook, | |
560 | .agph_acquire_ioctl = drm_agp_acquire_ioctl_hook, | 544 | .agph_acquire_ioctl = drm_agp_acquire_ioctl_hook, | |
@@ -562,27 +546,26 @@ static const struct drm_agp_hooks agp_ho | @@ -562,27 +546,26 @@ static const struct drm_agp_hooks agp_ho | |||
562 | .agph_release_ioctl = drm_agp_release_ioctl_hook, | 546 | .agph_release_ioctl = drm_agp_release_ioctl_hook, | |
563 | .agph_enable = drm_agp_enable_hook, | 547 | .agph_enable = drm_agp_enable_hook, | |
564 | .agph_enable_ioctl = drm_agp_enable_ioctl_hook, | 548 | .agph_enable_ioctl = drm_agp_enable_ioctl_hook, | |
565 | .agph_alloc = drm_agp_alloc_hook, | 549 | .agph_alloc = drm_agp_alloc_hook, | |
566 | .agph_alloc_ioctl = drm_agp_alloc_ioctl_hook, | 550 | .agph_alloc_ioctl = drm_agp_alloc_ioctl_hook, | |
567 | .agph_unbind = drm_agp_unbind_hook, | 551 | .agph_unbind = drm_agp_unbind_hook, | |
568 | .agph_unbind_ioctl = drm_agp_unbind_ioctl_hook, | 552 | .agph_unbind_ioctl = drm_agp_unbind_ioctl_hook, | |
569 | .agph_bind = drm_agp_bind_hook, | 553 | .agph_bind = drm_agp_bind_hook, | |
570 | .agph_bind_ioctl = drm_agp_bind_ioctl_hook, | 554 | .agph_bind_ioctl = drm_agp_bind_ioctl_hook, | |
571 | .agph_free = drm_agp_free_hook, | 555 | .agph_free = drm_agp_free_hook, | |
572 | .agph_free_ioctl = drm_agp_free_ioctl_hook, | 556 | .agph_free_ioctl = drm_agp_free_ioctl_hook, | |
573 | .agph_init = drm_agp_init_hook, | 557 | .agph_init = drm_agp_init_hook, | |
574 | .agph_clear = drm_agp_clear_hook, | 558 | .agph_clear = drm_agp_clear_hook, | |
575 | .agph_borrow = drm_agp_borrow_hook, | |||
576 | .agph_flush = drm_agp_flush_hook, | 559 | .agph_flush = drm_agp_flush_hook, | |
577 | }; | 560 | }; | |
578 | 561 | |||
579 | #include <sys/module.h> | 562 | #include <sys/module.h> | |
580 | #include <sys/once.h> | 563 | #include <sys/once.h> | |
581 | 564 | |||
582 | MODULE(MODULE_CLASS_MISC, drmkms_agp, "drmkms"); /* XXX agp */ | 565 | MODULE(MODULE_CLASS_MISC, drmkms_agp, "drmkms"); /* XXX agp */ | |
583 | 566 | |||
584 | static int | 567 | static int | |
585 | drmkms_agp_init(void) | 568 | drmkms_agp_init(void) | |
586 | { | 569 | { | |
587 | 570 | |||
588 | return drm_agp_register(&agp_hooks); | 571 | return drm_agp_register(&agp_hooks); | |
@@ -612,24 +595,26 @@ drmkms_agp_modcmd(modcmd_t cmd, void *ar | @@ -612,24 +595,26 @@ drmkms_agp_modcmd(modcmd_t cmd, void *ar | |||
612 | { | 595 | { | |
613 | int error; | 596 | int error; | |
614 | 597 | |||
615 | switch (cmd) { | 598 | switch (cmd) { | |
616 | case MODULE_CMD_INIT: | 599 | case MODULE_CMD_INIT: | |
617 | #ifdef _MODULE | 600 | #ifdef _MODULE | |
618 | error = drmkms_agp_init(); | 601 | error = drmkms_agp_init(); | |
619 | #else | 602 | #else | |
620 | error = drmkms_agp_guarantee_initialized(); | 603 | error = drmkms_agp_guarantee_initialized(); | |
621 | #endif | 604 | #endif | |
622 | if (error) | 605 | if (error) | |
623 | return error; | 606 | return error; | |
624 | return 0; | 607 | return 0; | |
608 | case MODULE_CMD_AUTOUNLOAD: | |||
609 | return EBUSY; | |||
625 | case MODULE_CMD_FINI: | 610 | case MODULE_CMD_FINI: | |
626 | error = drmkms_agp_fini(); | 611 | error = drmkms_agp_fini(); | |
627 | if (error) | 612 | if (error) | |
628 | return error; | 613 | return error; | |
629 | return 0; | 614 | return 0; | |
630 | default: | 615 | default: | |
631 | return ENOTTY; | 616 | return ENOTTY; | |
632 | } | 617 | } | |
633 | } | 618 | } | |
634 | 619 | |||
635 | #endif /* __NetBSD__ */ | 620 | #endif /* __NetBSD__ */ |
--- src/sys/external/bsd/drm2/dist/include/drm/drm_agpsupport.h 2021/12/18 23:45:45 1.9
+++ src/sys/external/bsd/drm2/dist/include/drm/drm_agpsupport.h 2022/07/19 22:24:34 1.10
@@ -1,37 +1,35 @@ | @@ -1,37 +1,35 @@ | |||
1 | /* $NetBSD: drm_agpsupport.h,v 1.9 2021/12/18 23:45:45 riastradh Exp $ */ | 1 | /* $NetBSD: drm_agpsupport.h,v 1.10 2022/07/19 22:24:34 riastradh Exp $ */ | |
2 | 2 | |||
3 | /* SPDX-License-Identifier: GPL-2.0 */ | 3 | /* SPDX-License-Identifier: GPL-2.0 */ | |
4 | #ifndef _DRM_AGPSUPPORT_H_ | 4 | #ifndef _DRM_AGPSUPPORT_H_ | |
5 | #define _DRM_AGPSUPPORT_H_ | 5 | #define _DRM_AGPSUPPORT_H_ | |
6 | 6 | |||
7 | #include <linux/agp_backend.h> | 7 | #include <linux/agp_backend.h> | |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> | |
9 | #include <linux/list.h> | 9 | #include <linux/list.h> | |
10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> | |
11 | #include <linux/mutex.h> | 11 | #include <linux/mutex.h> | |
12 | #include <linux/types.h> | 12 | #include <linux/types.h> | |
13 | #include <uapi/drm/drm.h> | 13 | #include <uapi/drm/drm.h> | |
14 | 14 | |||
15 | #ifdef __NetBSD__ | 15 | #ifdef __NetBSD__ | |
16 | #include <drm/drm_agp_netbsd.h> | 16 | #include <drm/drm_agp_netbsd.h> | |
17 | #endif | 17 | #endif | |
18 | 18 | |||
19 | struct drm_device; | 19 | struct drm_device; | |
20 | struct drm_file; | 20 | struct drm_file; | |
21 | 21 | |||
22 | struct drm_agp_hooks { | 22 | struct drm_agp_hooks { | |
23 | void __pci_iomem * | |||
24 | (*agph_borrow)(struct drm_device *, unsigned, bus_size_t); | |||
25 | void (*agph_flush)(void); | 23 | void (*agph_flush)(void); | |
26 | 24 | |||
27 | struct drm_agp_head * | 25 | struct drm_agp_head * | |
28 | (*agph_init)(struct drm_device *); | 26 | (*agph_init)(struct drm_device *); | |
29 | void (*agph_clear)(struct drm_device *); | 27 | void (*agph_clear)(struct drm_device *); | |
30 | int (*agph_acquire)(struct drm_device *); | 28 | int (*agph_acquire)(struct drm_device *); | |
31 | int (*agph_release)(struct drm_device *); | 29 | int (*agph_release)(struct drm_device *); | |
32 | int (*agph_enable)(struct drm_device *, struct drm_agp_mode); | 30 | int (*agph_enable)(struct drm_device *, struct drm_agp_mode); | |
33 | int (*agph_info)(struct drm_device *, struct drm_agp_info *); | 31 | int (*agph_info)(struct drm_device *, struct drm_agp_info *); | |
34 | int (*agph_alloc)(struct drm_device *, struct drm_agp_buffer *); | 32 | int (*agph_alloc)(struct drm_device *, struct drm_agp_buffer *); | |
35 | int (*agph_free)(struct drm_device *, struct drm_agp_buffer *); | 33 | int (*agph_free)(struct drm_device *, struct drm_agp_buffer *); | |
36 | int (*agph_bind)(struct drm_device *, struct drm_agp_binding *); | 34 | int (*agph_bind)(struct drm_device *, struct drm_agp_binding *); | |
37 | int (*agph_unbind)(struct drm_device *, struct drm_agp_binding *); | 35 | int (*agph_unbind)(struct drm_device *, struct drm_agp_binding *); | |
@@ -98,27 +96,26 @@ int drm_agp_alloc(struct drm_device *dev | @@ -98,27 +96,26 @@ int drm_agp_alloc(struct drm_device *dev | |||
98 | int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, | 96 | int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, | |
99 | struct drm_file *file_priv); | 97 | struct drm_file *file_priv); | |
100 | int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); | 98 | int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); | |
101 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, | 99 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, | |
102 | struct drm_file *file_priv); | 100 | struct drm_file *file_priv); | |
103 | int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); | 101 | int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); | |
104 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, | 102 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, | |
105 | struct drm_file *file_priv); | 103 | struct drm_file *file_priv); | |
106 | int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); | 104 | int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); | |
107 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, | 105 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, | |
108 | struct drm_file *file_priv); | 106 | struct drm_file *file_priv); | |
109 | 107 | |||
110 | #ifdef __NetBSD__ | 108 | #ifdef __NetBSD__ | |
111 | void __pci_iomem *drm_agp_borrow(struct drm_device *, unsigned, bus_size_t); | |||
112 | void drm_agp_flush(void); | 109 | void drm_agp_flush(void); | |
113 | void drm_agp_fini(struct drm_device *); | 110 | void drm_agp_fini(struct drm_device *); | |
114 | int drm_agp_register(const struct drm_agp_hooks *); | 111 | int drm_agp_register(const struct drm_agp_hooks *); | |
115 | int drm_agp_deregister(const struct drm_agp_hooks *); | 112 | int drm_agp_deregister(const struct drm_agp_hooks *); | |
116 | void drm_agp_hooks_init(void); | 113 | void drm_agp_hooks_init(void); | |
117 | void drm_agp_hooks_fini(void); | 114 | void drm_agp_hooks_fini(void); | |
118 | int drmkms_agp_guarantee_initialized(void); | 115 | int drmkms_agp_guarantee_initialized(void); | |
119 | #endif | 116 | #endif | |
120 | 117 | |||
121 | #else /* CONFIG_AGP */ | 118 | #else /* CONFIG_AGP */ | |
122 | 119 | |||
123 | #if !defined(__NetBSD__) | 120 | #if !defined(__NetBSD__) | |
124 | 121 |
--- src/sys/external/bsd/drm2/drm/drm_agp_hook.c 2021/12/19 09:52:00 1.6
+++ src/sys/external/bsd/drm2/drm/drm_agp_hook.c 2022/07/19 22:24:34 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_agp_hook.c,v 1.6 2021/12/19 09:52:00 riastradh Exp $ */ | 1 | /* $NetBSD: drm_agp_hook.c,v 1.7 2022/07/19 22:24:34 riastradh Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2018 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2018 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_agp_hook.c,v 1.6 2021/12/19 09:52:00 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_agp_hook.c,v 1.7 2022/07/19 22:24:34 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/condvar.h> | 36 | #include <sys/condvar.h> | |
37 | #include <sys/errno.h> | 37 | #include <sys/errno.h> | |
38 | #include <sys/mutex.h> | 38 | #include <sys/mutex.h> | |
39 | #include <sys/once.h> | 39 | #include <sys/once.h> | |
40 | 40 | |||
41 | #include <drm/drm_agpsupport.h> | 41 | #include <drm/drm_agpsupport.h> | |
42 | #include <drm/drm_drv.h> | 42 | #include <drm/drm_drv.h> | |
43 | #include "../dist/drm/drm_internal.h" | 43 | #include "../dist/drm/drm_internal.h" | |
44 | 44 | |||
45 | static struct { | 45 | static struct { | |
46 | kmutex_t lock; | 46 | kmutex_t lock; | |
@@ -254,37 +254,23 @@ NAME(struct drm_device *dev, void *data, | @@ -254,37 +254,23 @@ NAME(struct drm_device *dev, void *data, | |||
254 | return -ENODEV; \ | 254 | return -ENODEV; \ | |
255 | return dev->agp->hooks->FIELD(dev, data, file); \ | 255 | return dev->agp->hooks->FIELD(dev, data, file); \ | |
256 | } | 256 | } | |
257 | 257 | |||
258 | DEFINE_AGP_HOOK_IOCTL(drm_agp_acquire_ioctl, agph_acquire_ioctl) | 258 | DEFINE_AGP_HOOK_IOCTL(drm_agp_acquire_ioctl, agph_acquire_ioctl) | |
259 | DEFINE_AGP_HOOK_IOCTL(drm_agp_release_ioctl, agph_release_ioctl) | 259 | DEFINE_AGP_HOOK_IOCTL(drm_agp_release_ioctl, agph_release_ioctl) | |
260 | DEFINE_AGP_HOOK_IOCTL(drm_agp_enable_ioctl, agph_enable_ioctl) | 260 | DEFINE_AGP_HOOK_IOCTL(drm_agp_enable_ioctl, agph_enable_ioctl) | |
261 | DEFINE_AGP_HOOK_IOCTL(drm_agp_info_ioctl, agph_info_ioctl) | 261 | DEFINE_AGP_HOOK_IOCTL(drm_agp_info_ioctl, agph_info_ioctl) | |
262 | DEFINE_AGP_HOOK_IOCTL(drm_agp_alloc_ioctl, agph_alloc_ioctl) | 262 | DEFINE_AGP_HOOK_IOCTL(drm_agp_alloc_ioctl, agph_alloc_ioctl) | |
263 | DEFINE_AGP_HOOK_IOCTL(drm_agp_free_ioctl, agph_free_ioctl) | 263 | DEFINE_AGP_HOOK_IOCTL(drm_agp_free_ioctl, agph_free_ioctl) | |
264 | DEFINE_AGP_HOOK_IOCTL(drm_agp_bind_ioctl, agph_bind_ioctl) | 264 | DEFINE_AGP_HOOK_IOCTL(drm_agp_bind_ioctl, agph_bind_ioctl) | |
265 | DEFINE_AGP_HOOK_IOCTL(drm_agp_unbind_ioctl, agph_unbind_ioctl) | 265 | DEFINE_AGP_HOOK_IOCTL(drm_agp_unbind_ioctl, agph_unbind_ioctl) | |
266 | 266 | |||
267 | void __pci_iomem * | |||
268 | drm_agp_borrow(struct drm_device *dev, unsigned bar, bus_size_t size) | |||
269 | { | |||
270 | const struct drm_agp_hooks *hooks; | |||
271 | void __pci_iomem *iomem; | |||
272 | ||||
273 | if ((hooks = drm_agp_hooks_acquire()) == NULL) | |||
274 | return NULL; | |||
275 | iomem = hooks->agph_borrow(dev, bar, size); | |||
276 | drm_agp_hooks_release(hooks); | |||
277 | ||||
278 | return iomem; | |||
279 | } | |||
280 | ||||
281 | void | 267 | void | |
282 | drm_agp_flush(void) | 268 | drm_agp_flush(void) | |
283 | { | 269 | { | |
284 | const struct drm_agp_hooks *hooks; | 270 | const struct drm_agp_hooks *hooks; | |
285 | 271 | |||
286 | if ((hooks = drm_agp_hooks_acquire()) == NULL) | 272 | if ((hooks = drm_agp_hooks_acquire()) == NULL) | |
287 | return; | 273 | return; | |
288 | hooks->agph_flush(); | 274 | hooks->agph_flush(); | |
289 | drm_agp_hooks_release(hooks); | 275 | drm_agp_hooks_release(hooks); | |
290 | } | 276 | } |
--- src/sys/external/bsd/drm2/linux/linux_pci.c 2022/02/27 14:19:20 1.21
+++ src/sys/external/bsd/drm2/linux/linux_pci.c 2022/07/19 22:24:34 1.22
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: linux_pci.c,v 1.21 2022/02/27 14:19:20 riastradh Exp $ */ | 1 | /* $NetBSD: linux_pci.c,v 1.22 2022/07/19 22:24:34 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. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
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 | #ifdef _KERNEL_OPT | 32 | #ifdef _KERNEL_OPT | |
33 | #include "acpica.h" | 33 | #include "acpica.h" | |
34 | #include "opt_pci.h" | 34 | #include "opt_pci.h" | |
35 | #endif | 35 | #endif | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.21 2022/02/27 14:19:20 riastradh Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.22 2022/07/19 22:24:34 riastradh Exp $"); | |
39 | 39 | |||
40 | #if NACPICA > 0 | 40 | #if NACPICA > 0 | |
41 | #include <dev/acpi/acpivar.h> | 41 | #include <dev/acpi/acpivar.h> | |
42 | #include <dev/acpi/acpi_pci.h> | 42 | #include <dev/acpi/acpi_pci.h> | |
43 | #endif | 43 | #endif | |
44 | 44 | |||
45 | #include <linux/pci.h> | 45 | #include <linux/pci.h> | |
46 | 46 | |||
47 | #include <drm/drm_agp_netbsd.h> | 47 | #include <drm/drm_agp_netbsd.h> | |
48 | 48 | |||
49 | device_t | 49 | device_t | |
50 | pci_dev_dev(struct pci_dev *pdev) | 50 | pci_dev_dev(struct pci_dev *pdev) | |
51 | { | 51 | { | |
@@ -629,27 +629,26 @@ pci_iomap(struct pci_dev *pdev, unsigned | @@ -629,27 +629,26 @@ pci_iomap(struct pci_dev *pdev, unsigned | |||
629 | 629 | |||
630 | KASSERT(i < PCI_NUM_RESOURCES); | 630 | KASSERT(i < PCI_NUM_RESOURCES); | |
631 | KASSERT(pdev->pd_resources[i].kva == NULL); | 631 | KASSERT(pdev->pd_resources[i].kva == NULL); | |
632 | 632 | |||
633 | if (PCI_MAPREG_TYPE(pdev->pd_resources[i].type) != PCI_MAPREG_TYPE_MEM) | 633 | if (PCI_MAPREG_TYPE(pdev->pd_resources[i].type) != PCI_MAPREG_TYPE_MEM) | |
634 | return NULL; | 634 | return NULL; | |
635 | if (pdev->pd_resources[i].size < size) | 635 | if (pdev->pd_resources[i].size < size) | |
636 | return NULL; | 636 | return NULL; | |
637 | error = bus_space_map(pdev->pd_pa.pa_memt, pdev->pd_resources[i].addr, | 637 | error = bus_space_map(pdev->pd_pa.pa_memt, pdev->pd_resources[i].addr, | |
638 | size, BUS_SPACE_MAP_LINEAR | pdev->pd_resources[i].flags, | 638 | size, BUS_SPACE_MAP_LINEAR | pdev->pd_resources[i].flags, | |
639 | &pdev->pd_resources[i].bsh); | 639 | &pdev->pd_resources[i].bsh); | |
640 | if (error) | 640 | if (error) | |
641 | return NULL; | 641 | return NULL; | |
642 | /* XXX Synchronize with drm_agp_borrow_hook in drm_agpsupport.c. */ | |||
643 | pdev->pd_resources[i].bst = pdev->pd_pa.pa_memt; | 642 | pdev->pd_resources[i].bst = pdev->pd_pa.pa_memt; | |
644 | pdev->pd_resources[i].kva = bus_space_vaddr(pdev->pd_resources[i].bst, | 643 | pdev->pd_resources[i].kva = bus_space_vaddr(pdev->pd_resources[i].bst, | |
645 | pdev->pd_resources[i].bsh); | 644 | pdev->pd_resources[i].bsh); | |
646 | pdev->pd_resources[i].mapped = true; | 645 | pdev->pd_resources[i].mapped = true; | |
647 | 646 | |||
648 | return pdev->pd_resources[i].kva; | 647 | return pdev->pd_resources[i].kva; | |
649 | } | 648 | } | |
650 | 649 | |||
651 | void | 650 | void | |
652 | pci_iounmap(struct pci_dev *pdev, void __pci_iomem *kva) | 651 | pci_iounmap(struct pci_dev *pdev, void __pci_iomem *kva) | |
653 | { | 652 | { | |
654 | unsigned i; | 653 | unsigned i; | |
655 | 654 |