Implement Linux alloc_page/__free_page and kmap_atomic/kunmap_atomic.diff -r1.1.2.3 -r1.1.2.4 src/sys/external/bsd/drm2/drm/drm_module.c
(riastradh)
--- src/sys/external/bsd/drm2/drm/drm_module.c 2013/07/24 03:14:31 1.1.2.3
+++ src/sys/external/bsd/drm2/drm/drm_module.c 2013/07/24 03:31:12 1.1.2.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: drm_module.c,v 1.1.2.3 2013/07/24 03:14:31 riastradh Exp $ */ | 1 | /* $NetBSD: drm_module.c,v 1.1.2.4 2013/07/24 03:31:12 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,83 +20,94 @@ | @@ -20,83 +20,94 @@ | |||
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_module.c,v 1.1.2.3 2013/07/24 03:14:31 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.1.2.4 2013/07/24 03:31:12 riastradh Exp $"); | |
34 | 34 | |||
35 | #include <sys/types.h> | 35 | #include <sys/types.h> | |
36 | #include <sys/device.h> | 36 | #include <sys/device.h> | |
37 | #include <sys/module.h> | 37 | #include <sys/module.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | 39 | |||
40 | #include <linux/highmem.h> | |||
41 | ||||
40 | /* | 42 | /* | |
41 | * XXX I2C stuff should be moved to a separate drm2edid module. | 43 | * XXX I2C stuff should be moved to a separate drm2edid module. | |
42 | * | 44 | * | |
43 | * XXX PCI stuff should be moved to a separate drm2pci module. | 45 | * XXX PCI stuff should be moved to a separate drm2pci module. | |
44 | * | 46 | * | |
45 | * XXX Other Linux stuff should be moved to a linux compatibility | 47 | * XXX Other Linux stuff should be moved to a linux compatibility | |
46 | * module on which this one depends. | 48 | * module on which this one depends. | |
47 | */ | 49 | */ | |
48 | MODULE(MODULE_CLASS_MISC, drm, "iic,pci"); | 50 | MODULE(MODULE_CLASS_MISC, drm, "iic,pci"); | |
49 | 51 | |||
50 | #ifdef _MODULE | 52 | #ifdef _MODULE | |
51 | #include "ioconf.c" | 53 | #include "ioconf.c" | |
52 | #endif | 54 | #endif | |
53 | 55 | |||
54 | extern const struct cdevsw drm_cdevsw; /* XXX Put this in a header file? */ | 56 | extern const struct cdevsw drm_cdevsw; /* XXX Put this in a header file? */ | |
55 | 57 | |||
56 | static int | 58 | static int | |
57 | drm_modcmd(modcmd_t cmd, void *arg __unused) | 59 | drm_modcmd(modcmd_t cmd, void *arg __unused) | |
58 | { | 60 | { | |
59 | #ifdef _MODULE | 61 | #ifdef _MODULE | |
60 | devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR; | 62 | devmajor_t bmajor = NODEVMAJOR, cmajor = NODEVMAJOR; | |
61 | int error; | 63 | int error; | |
62 | #endif | 64 | #endif | |
63 | 65 | |||
64 | switch (cmd) { | 66 | switch (cmd) { | |
65 | case MODULE_CMD_INIT: | 67 | case MODULE_CMD_INIT: | |
68 | error = linux_kmap_init(); | |||
69 | if (error) { | |||
70 | aprint_error("drm: unable to initialize linux kmap:" | |||
71 | " %d", error); | |||
72 | return error; | |||
73 | } | |||
66 | #ifdef _MODULE | 74 | #ifdef _MODULE | |
67 | error = config_init_component(cfdriver_ioconf_drm, | 75 | error = config_init_component(cfdriver_ioconf_drm, | |
68 | cfattach_ioconf_drm, cfdata_ioconf_drm); | 76 | cfattach_ioconf_drm, cfdata_ioconf_drm); | |
69 | if (error) { | 77 | if (error) { | |
70 | aprint_error("drm: unable to init component: %d\n", | 78 | aprint_error("drm: unable to init component: %d\n", | |
71 | error); | 79 | error); | |
80 | linux_kmap_fini(); | |||
72 | return error; | 81 | return error; | |
73 | } | 82 | } | |
74 | error = devsw_attach("drm", NULL, &bmajor, | 83 | error = devsw_attach("drm", NULL, &bmajor, | |
75 | &drm_cdevsw, &cmajor); | 84 | &drm_cdevsw, &cmajor); | |
76 | if (error) { | 85 | if (error) { | |
77 | aprint_error("drm: unable to attach devsw: %d\n", | 86 | aprint_error("drm: unable to attach devsw: %d\n", | |
78 | error); | 87 | error); | |
79 | (void)config_fini_component(cfdriver_ioconf_drm, | 88 | (void)config_fini_component(cfdriver_ioconf_drm, | |
80 | cfattach_ioconf_drm, cfdata_ioconf_drm); | 89 | cfattach_ioconf_drm, cfdata_ioconf_drm); | |
90 | linux_kmap_fini(); | |||
81 | return error; | 91 | return error; | |
82 | } | 92 | } | |
83 | #endif | 93 | #endif | |
84 | return 0; | 94 | return 0; | |
85 | 95 | |||
86 | case MODULE_CMD_FINI: | 96 | case MODULE_CMD_FINI: | |
87 | #ifdef _MODULE | 97 | #ifdef _MODULE | |
88 | error = devsw_detach(NULL, &drm_cdevsw); | 98 | error = devsw_detach(NULL, &drm_cdevsw); | |
89 | if (error) | 99 | if (error) | |
90 | return error; | 100 | return error; | |
91 | error = config_fini_component(cfdriver_ioconf_drm, | 101 | error = config_fini_component(cfdriver_ioconf_drm, | |
92 | cfattach_ioconf_drm, cfdata_ioconf_drm); | 102 | cfattach_ioconf_drm, cfdata_ioconf_drm); | |
93 | if (error) | 103 | if (error) | |
94 | /* XXX Now what? Reattach the devsw? */ | 104 | /* XXX Now what? Reattach the devsw? */ | |
95 | return error; | 105 | return error; | |
96 | #endif | 106 | #endif | |
107 | linux_kmap_fini(); | |||
97 | return 0; | 108 | return 0; | |
98 | 109 | |||
99 | default: | 110 | default: | |
100 | return ENOTTY; | 111 | return ENOTTY; | |
101 | } | 112 | } | |
102 | } | 113 | } |
--- src/sys/external/bsd/drm2/include/linux/Attic/gfp.h 2013/07/24 03:30:42 1.1.2.1
+++ src/sys/external/bsd/drm2/include/linux/Attic/gfp.h 2013/07/24 03:31:12 1.1.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gfp.h,v 1.1.2.1 2013/07/24 03:30:42 riastradh Exp $ */ | 1 | /* $NetBSD: gfp.h,v 1.1.2.2 2013/07/24 03:31:12 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. | |
@@ -51,21 +51,21 @@ typedef int gfp_t; | @@ -51,21 +51,21 @@ typedef int gfp_t; | |||
51 | #define __GFP_FS __BIT(2) | 51 | #define __GFP_FS __BIT(2) | |
52 | #define __GFP_HARDWALL __BIT(3) | 52 | #define __GFP_HARDWALL __BIT(3) | |
53 | #define __GFP_HIGH __BIT(4) | 53 | #define __GFP_HIGH __BIT(4) | |
54 | #define __GFP_HIGHMEM __BIT(5) | 54 | #define __GFP_HIGHMEM __BIT(5) | |
55 | #define __GFP_IO __BIT(6) | 55 | #define __GFP_IO __BIT(6) | |
56 | #define __GFP_NORETRY __BIT(7) | 56 | #define __GFP_NORETRY __BIT(7) | |
57 | #define __GFP_NOWARN __BIT(8) | 57 | #define __GFP_NOWARN __BIT(8) | |
58 | #define __GFP_NO_KSWAPD __BIT(9) | 58 | #define __GFP_NO_KSWAPD __BIT(9) | |
59 | #define __GFP_RECLAIMABLE __BIT(10) | 59 | #define __GFP_RECLAIMABLE __BIT(10) | |
60 | #define __GFP_WAIT __BIT(11) | 60 | #define __GFP_WAIT __BIT(11) | |
61 | #define __GFP_ZERO __BIT(12) | 61 | #define __GFP_ZERO __BIT(12) | |
62 | 62 | |||
63 | /* XXX Make the nm output a little more greppable... */ | 63 | /* XXX Make the nm output a little more greppable... */ | |
64 | #define alloc_page linux_gfp_alloc_page | 64 | #define alloc_page linux_alloc_page | |
65 | #define __free_page linux_gfp___free_page | 65 | #define __free_page linux___free_page | |
66 | 66 | |||
67 | struct page; | 67 | struct page; | |
68 | struct page * alloc_page(gfp_t); | 68 | struct page * alloc_page(gfp_t); | |
69 | void __free_page(struct page *); | 69 | void __free_page(struct page *); | |
70 | 70 | |||
71 | #endif /* _LINUX_GFP_H_ */ | 71 | #endif /* _LINUX_GFP_H_ */ |
--- src/sys/external/bsd/drm2/include/linux/highmem.h 2013/07/24 00:33:12 1.1.2.1
+++ src/sys/external/bsd/drm2/include/linux/highmem.h 2013/07/24 03:31:12 1.1.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: highmem.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $ */ | 1 | /* $NetBSD: highmem.h,v 1.1.2.2 2013/07/24 03:31:12 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. | |
@@ -22,14 +22,32 @@ | @@ -22,14 +22,32 @@ | |||
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 | #ifndef _LINUX_HIGHMEM_H_ | 32 | #ifndef _LINUX_HIGHMEM_H_ | |
33 | #define _LINUX_HIGHMEM_H_ | 33 | #define _LINUX_HIGHMEM_H_ | |
34 | 34 | |||
35 | #include <sys/types.h> | |||
36 | #include <sys/queue.h> | |||
37 | ||||
38 | #include <uvm/uvm_extern.h> | |||
39 | ||||
40 | #include <linux/kernel.h> | |||
41 | #include <linux/mm_types.h> | |||
42 | ||||
43 | /* XXX Make the nm output a little more greppable... */ | |||
44 | #define kmap_atomic linux_kmap_atomic | |||
45 | #define kunmap_atomic linux_kunmap_atomic | |||
46 | ||||
47 | int linux_kmap_init(void); | |||
48 | void linux_kmap_fini(void); | |||
49 | ||||
50 | void * kmap_atomic(struct page *); | |||
51 | void kunmap_atomic(void *); | |||
52 | ||||
35 | #endif /* _LINUX_HIGHMEM_H_ */ | 53 | #endif /* _LINUX_HIGHMEM_H_ */ |
/* $NetBSD: linux_gfp.c,v 1.1.2.1 2013/07/24 03:31:12 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Taylor R. Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_gfp.c,v 1.1.2.1 2013/07/24 03:31:12 riastradh Exp $");
#include <sys/types.h>
#include <sys/queue.h>
#include <uvm/uvm_extern.h>
#include <linux/gfp.h>
#include <linux/kernel.h>
#include <linux/mm_types.h>
struct page *
alloc_page(gfp_t gfp)
{
paddr_t low = 0;
paddr_t high = ~(paddr_t)0;
struct pglist pglist;
struct vm_page *vm_page;
int error;
if (ISSET(gfp, __GFP_DMA32))
high = 0xffffffff;
error = uvm_pglistalloc(PAGE_SIZE, low, high, PAGE_SIZE, PAGE_SIZE,
&pglist, 1, ISSET(gfp, __GFP_WAIT));
if (error)
return NULL;
vm_page = TAILQ_FIRST(&pglist);
TAILQ_REMOVE(&pglist, vm_page, pageq.queue); /* paranoia */
KASSERT(TAILQ_EMPTY(&pglist));
return container_of(vm_page, struct page, p_vmp);
}
void
__free_page(struct page *page)
{
struct pglist pglist = TAILQ_HEAD_INITIALIZER(pglist);
TAILQ_INSERT_TAIL(&pglist, &page->p_vmp, pageq.queue);
uvm_pglistfree(&pglist);
}
/* $NetBSD: linux_kmap.c,v 1.1.2.1 2013/07/24 03:31:12 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Taylor R. Campbell.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: linux_kmap.c,v 1.1.2.1 2013/07/24 03:31:12 riastradh Exp $");
#include <sys/types.h>
#include <sys/mutex.h>
#include <uvm/uvm_extern.h>
#include <linux/highmem.h>
/*
* XXX Kludgerific implementation of Linux kmap_atomic, which is
* required not to fail. To accomodate this, we reserve one page of
* kva at boot (or load) and limit the system to at most kmap_atomic in
* use at a time.
*/
static kmutex_t linux_kmap_atomic_lock;
static vaddr_t linux_kmap_atomic_vaddr;
int
linux_kmap_init(void)
{
/* IPL_VM is needed to block pmap_kenter_pa. */
mutex_init(&linux_kmap_atomic_lock, MUTEX_DEFAULT, IPL_VM);
linux_kmap_atomic_vaddr = uvm_km_alloc(kernel_map, PAGE_SIZE, 0,
(UVM_KMF_VAONLY | UVM_KMF_WAITVA));
KASSERT(linux_kmap_atomic_vaddr != 0);
KASSERT(!pmap_extract(pmap_kernel(), linux_kmap_atomic_vaddr, NULL));
return 0;
}
void
linux_kmap_fini(void)
{
KASSERT(linux_kmap_atomic_vaddr != 0);
KASSERT(!pmap_extract(pmap_kernel(), linux_kmap_atomic_vaddr, NULL));
uvm_km_free(kernel_map, linux_kmap_atomic_vaddr, PAGE_SIZE,
(UVM_KMF_VAONLY | UVM_KMF_WAITVA));
mutex_destroy(&linux_kmap_atomic_lock);
}
void *
kmap_atomic(struct page *page)
{
mutex_spin_enter(&linux_kmap_atomic_lock);
KASSERT(linux_kmap_atomic_vaddr != 0);
KASSERT(!pmap_extract(pmap_kernel(), linux_kmap_atomic_vaddr, NULL));
const vaddr_t vaddr = linux_kmap_atomic_vaddr;
const paddr_t paddr = uvm_vm_page_to_phys(&page->p_vmp);
const int prot = (VM_PROT_READ | VM_PROT_WRITE);
const int flags = 0;
pmap_kenter_pa(vaddr, paddr, prot, flags);
pmap_update(pmap_kernel());
return (void *)vaddr;
}
void
kunmap_atomic(void *addr)
{
const vaddr_t vaddr = (vaddr_t)addr;
KASSERT(linux_kmap_atomic_vaddr == vaddr);
KASSERT(pmap_extract(pmap_kernel(), vaddr, NULL));
pmap_kremove(vaddr, PAGE_SIZE);
pmap_update(pmap_kernel());
mutex_spin_exit(&linux_kmap_atomic_lock);
}
--- src/sys/modules/drm2/Attic/Makefile 2013/07/24 03:11:44 1.1.2.35
+++ src/sys/modules/drm2/Attic/Makefile 2013/07/24 03:31:12 1.1.2.36
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: Makefile,v 1.1.2.35 2013/07/24 03:11:44 riastradh Exp $ | 1 | # $NetBSD: Makefile,v 1.1.2.36 2013/07/24 03:31:12 riastradh Exp $ | |
2 | 2 | |||
3 | .include "../Makefile.inc" | 3 | .include "../Makefile.inc" | |
4 | .include "Makefile.inc" | 4 | .include "Makefile.inc" | |
5 | 5 | |||
6 | .PATH: ${S}/external/bsd/drm2/drm | 6 | .PATH: ${S}/external/bsd/drm2/drm | |
7 | .PATH: ${S}/external/bsd/drm2/pci | 7 | .PATH: ${S}/external/bsd/drm2/pci | |
8 | .PATH: ${S}/external/bsd/drm2/linux | 8 | .PATH: ${S}/external/bsd/drm2/linux | |
9 | .PATH: ${S}/external/bsd/drm2/dist/drm | 9 | .PATH: ${S}/external/bsd/drm2/dist/drm | |
10 | 10 | |||
11 | KMOD= drm2 | 11 | KMOD= drm2 | |
12 | IOCONF= drm.ioconf | 12 | IOCONF= drm.ioconf | |
13 | 13 | |||
14 | #SRCS+= ati_pcigart.c # XXX Restore for ATI support. | 14 | #SRCS+= ati_pcigart.c # XXX Restore for ATI support. | |
@@ -41,18 +41,20 @@ SRCS+= drm_modes.c | @@ -41,18 +41,20 @@ SRCS+= drm_modes.c | |||
41 | SRCS+= drm_pci.c # XXX Move to drm2pci module later. | 41 | SRCS+= drm_pci.c # XXX Move to drm2pci module later. | |
42 | #SRCS+= drm_platform.c # XXX Rewrite per platform. | 42 | #SRCS+= drm_platform.c # XXX Rewrite per platform. | |
43 | #SRCS+= drm_prime.c # XXX Revisit later. | 43 | #SRCS+= drm_prime.c # XXX Revisit later. | |
44 | #SRCS+= drm_proc.c # XXX Rewrite for sysctl. | 44 | #SRCS+= drm_proc.c # XXX Rewrite for sysctl. | |
45 | SRCS+= drm_scatter.c | 45 | SRCS+= drm_scatter.c | |
46 | SRCS+= drm_stub.c | 46 | SRCS+= drm_stub.c | |
47 | SRCS+= drm_vm.c | 47 | SRCS+= drm_vm.c | |
48 | 48 | |||
49 | SRCS+= drm_gem_vm.c | 49 | SRCS+= drm_gem_vm.c | |
50 | SRCS+= drm_module.c | 50 | SRCS+= drm_module.c | |
51 | 51 | |||
52 | # XXX The following should be in a separate Linux compatibility module, | 52 | # XXX The following should be in a separate Linux compatibility module, | |
53 | # or modules. | 53 | # or modules. | |
54 | SRCS+= linux_gfp.c | |||
55 | SRCS+= linux_kmap.c | |||
54 | SRCS+= linux_i2c.c | 56 | SRCS+= linux_i2c.c | |
55 | SRCS+= linux_idr.c | 57 | SRCS+= linux_idr.c | |
56 | SRCS+= linux_list_sort.c | 58 | SRCS+= linux_list_sort.c | |
57 | 59 | |||
58 | .include <bsd.kmodule.mk> | 60 | .include <bsd.kmodule.mk> |