Allow for the SGMAP implementation to specify a minimum alignment for SGMAP DMA segments. If not specified, PAGE_SIZE will be used, as before.diff -r1.28 -r1.29 src/sys/arch/alpha/common/sgmap_common.c
(thorpej)
--- src/sys/arch/alpha/common/sgmap_common.c 2021/07/04 22:42:35 1.28
+++ src/sys/arch/alpha/common/sgmap_common.c 2021/07/18 05:12:27 1.29
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sgmap_common.c,v 1.28 2021/07/04 22:42:35 thorpej Exp $ */ | 1 | /* $NetBSD: sgmap_common.c,v 1.29 2021/07/18 05:12:27 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998, 2001 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | 33 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | |
34 | 34 | |||
35 | __KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.28 2021/07/04 22:42:35 thorpej Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.29 2021/07/18 05:12:27 thorpej Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/kernel.h> | 39 | #include <sys/kernel.h> | |
40 | #include <sys/proc.h> | 40 | #include <sys/proc.h> | |
41 | 41 | |||
42 | #include <uvm/uvm_extern.h> | 42 | #include <uvm/uvm_extern.h> | |
43 | 43 | |||
44 | #define _ALPHA_BUS_DMA_PRIVATE | 44 | #define _ALPHA_BUS_DMA_PRIVATE | |
45 | #include <sys/bus.h> | 45 | #include <sys/bus.h> | |
46 | 46 | |||
47 | #include <alpha/common/sgmapvar.h> | 47 | #include <alpha/common/sgmapvar.h> | |
48 | 48 | |||
@@ -58,26 +58,34 @@ void | @@ -58,26 +58,34 @@ void | |||
58 | alpha_sgmap_init(bus_dma_tag_t t, struct alpha_sgmap *sgmap, const char *name, | 58 | alpha_sgmap_init(bus_dma_tag_t t, struct alpha_sgmap *sgmap, const char *name, | |
59 | bus_addr_t wbase, bus_addr_t sgvabase, bus_size_t sgvasize, size_t ptesize, | 59 | bus_addr_t wbase, bus_addr_t sgvabase, bus_size_t sgvasize, size_t ptesize, | |
60 | void *ptva, bus_size_t minptalign) | 60 | void *ptva, bus_size_t minptalign) | |
61 | { | 61 | { | |
62 | bus_dma_segment_t seg; | 62 | bus_dma_segment_t seg; | |
63 | size_t ptsize; | 63 | size_t ptsize; | |
64 | int rseg; | 64 | int rseg; | |
65 | 65 | |||
66 | if (sgvasize & PGOFSET) { | 66 | if (sgvasize & PGOFSET) { | |
67 | printf("size botch for sgmap `%s'\n", name); | 67 | printf("size botch for sgmap `%s'\n", name); | |
68 | goto die; | 68 | goto die; | |
69 | } | 69 | } | |
70 | 70 | |||
71 | /* | |||
72 | * If we don't yet have a minimum SGVA alignment, default | |||
73 | * to the system page size. | |||
74 | */ | |||
75 | if (t->_sgmap_minalign < PAGE_SIZE) { | |||
76 | t->_sgmap_minalign = PAGE_SIZE; | |||
77 | } | |||
78 | ||||
71 | sgmap->aps_wbase = wbase; | 79 | sgmap->aps_wbase = wbase; | |
72 | sgmap->aps_sgvabase = sgvabase; | 80 | sgmap->aps_sgvabase = sgvabase; | |
73 | sgmap->aps_sgvasize = sgvasize; | 81 | sgmap->aps_sgvasize = sgvasize; | |
74 | 82 | |||
75 | if (ptva != NULL) { | 83 | if (ptva != NULL) { | |
76 | /* | 84 | /* | |
77 | * We already have a page table; this may be a system | 85 | * We already have a page table; this may be a system | |
78 | * where the page table resides in bridge-resident SRAM. | 86 | * where the page table resides in bridge-resident SRAM. | |
79 | */ | 87 | */ | |
80 | sgmap->aps_pt = ptva; | 88 | sgmap->aps_pt = ptva; | |
81 | sgmap->aps_ptpa = 0; | 89 | sgmap->aps_ptpa = 0; | |
82 | } else { | 90 | } else { | |
83 | /* | 91 | /* |
--- src/sys/arch/alpha/common/sgmap_typedep.c 2021/06/24 16:41:16 1.42
+++ src/sys/arch/alpha/common/sgmap_typedep.c 2021/07/18 05:12:27 1.43
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sgmap_typedep.c,v 1.42 2021/06/24 16:41:16 thorpej Exp $ */ | 1 | /* $NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998, 2001 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.42 2021/06/24 16:41:16 thorpej Exp $"); | 34 | __KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $"); | |
35 | 35 | |||
36 | #include "opt_ddb.h" | 36 | #include "opt_ddb.h" | |
37 | 37 | |||
38 | #include <sys/evcnt.h> | 38 | #include <sys/evcnt.h> | |
39 | #include <uvm/uvm_extern.h> | 39 | #include <uvm/uvm_extern.h> | |
40 | 40 | |||
41 | #define DMA_COUNT_DECL(cnt) _DMA_COUNT_DECL(dma_sgmap, cnt) | 41 | #define DMA_COUNT_DECL(cnt) _DMA_COUNT_DECL(dma_sgmap, cnt) | |
42 | #define DMA_COUNT(cnt) _DMA_COUNT(dma_sgmap, cnt) | 42 | #define DMA_COUNT(cnt) _DMA_COUNT(dma_sgmap, cnt) | |
43 | 43 | |||
44 | #ifdef SGMAP_DEBUG | 44 | #ifdef SGMAP_DEBUG | |
45 | int __C(SGMAP_TYPE,_debug) = 0; | 45 | int __C(SGMAP_TYPE,_debug) = 0; | |
46 | #endif | 46 | #endif | |
47 | 47 | |||
@@ -120,27 +120,28 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag | @@ -120,27 +120,28 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag | |||
120 | * Caller's mistake if the requested length is larger than | 120 | * Caller's mistake if the requested length is larger than | |
121 | * their own boundary constraint. | 121 | * their own boundary constraint. | |
122 | */ | 122 | */ | |
123 | if (__predict_false(boundary != 0 && buflen > boundary)) { | 123 | if (__predict_false(boundary != 0 && buflen > boundary)) { | |
124 | return EINVAL; | 124 | return EINVAL; | |
125 | } | 125 | } | |
126 | 126 | |||
127 | endva = round_page(va + buflen); | 127 | endva = round_page(va + buflen); | |
128 | va = trunc_page(va); | 128 | va = trunc_page(va); | |
129 | 129 | |||
130 | const vm_flag_t vmflags = VM_INSTANTFIT | | 130 | const vm_flag_t vmflags = VM_INSTANTFIT | | |
131 | ((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP); | 131 | ((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP); | |
132 | 132 | |||
133 | alignment = PAGE_SIZE; | 133 | KASSERT(t->_sgmap_minalign != 0); | |
134 | alignment = t->_sgmap_minalign; | |||
134 | sgvalen = (endva - va); | 135 | sgvalen = (endva - va); | |
135 | 136 | |||
136 | SGMAP_PTE_TYPE spill_pte_v = __C(SGMAP_TYPE,_prefetch_spill_page_pte); | 137 | SGMAP_PTE_TYPE spill_pte_v = __C(SGMAP_TYPE,_prefetch_spill_page_pte); | |
137 | 138 | |||
138 | /* | 139 | /* | |
139 | * If we have a boundary constraint, it's possible to end up in | 140 | * If we have a boundary constraint, it's possible to end up in | |
140 | * a situation where sgvalen > boundary if the caller's buffer | 141 | * a situation where sgvalen > boundary if the caller's buffer | |
141 | * is not page aligned. In this case, we will have to allocate | 142 | * is not page aligned. In this case, we will have to allocate | |
142 | * an extra SG segment and split the buffer. | 143 | * an extra SG segment and split the buffer. | |
143 | */ | 144 | */ | |
144 | if (__predict_false(boundary != 0 && boundary < sgvalen)) { | 145 | if (__predict_false(boundary != 0 && boundary < sgvalen)) { | |
145 | #ifdef SGMAP_DEBUG | 146 | #ifdef SGMAP_DEBUG | |
146 | if (__C(SGMAP_TYPE,_debug)) { | 147 | if (__C(SGMAP_TYPE,_debug)) { | |
@@ -183,33 +184,36 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag | @@ -183,33 +184,36 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag | |||
183 | extra_sgvalen = 0; | 184 | extra_sgvalen = 0; | |
184 | extra_sgva = 0; | 185 | extra_sgva = 0; | |
185 | } | 186 | } | |
186 | 187 | |||
187 | 188 | |||
188 | if (spill) { | 189 | if (spill) { | |
189 | DMA_COUNT(spill_page); | 190 | DMA_COUNT(spill_page); | |
190 | sgvalen += PAGE_SIZE; | 191 | sgvalen += PAGE_SIZE; | |
191 | 192 | |||
192 | /* | 193 | /* | |
193 | * ARGH! If the addition of the spill page bumped us | 194 | * ARGH! If the addition of the spill page bumped us | |
194 | * over our boundary, we have to 2x the boundary limit. | 195 | * over our boundary, we have to 2x the boundary limit. | |
195 | * To compensate (and enforce the original boundary | 196 | * To compensate (and enforce the original boundary | |
196 | * constraint), we force our alignment to be the previous | 197 | * constraint), we force our alignment to be at least the | |
197 | * boundary, thus ensuring that the only boundary violation | 198 | * previous boundary, thus ensuring that the only boundary | |
198 | * is the pre-fetch that the SGMAP controller performs that | 199 | * violation is the pre-fetch that the SGMAP controller | |
199 | * necessitates the spill page in the first place. | 200 | * performs that necessitates the spill page in the first | |
201 | * place. | |||
200 | */ | 202 | */ | |
201 | if (boundary && boundary < sgvalen) { | 203 | if (boundary && boundary < sgvalen) { | |
202 | alignment = boundary; | 204 | if (alignment < boundary) { | |
205 | alignment = boundary; | |||
206 | } | |||
203 | do { | 207 | do { | |
204 | boundary <<= 1; | 208 | boundary <<= 1; | |
205 | } while (boundary < sgvalen); | 209 | } while (boundary < sgvalen); | |
206 | } | 210 | } | |
207 | } | 211 | } | |
208 | 212 | |||
209 | #ifdef SGMAP_DEBUG | 213 | #ifdef SGMAP_DEBUG | |
210 | if (__C(SGMAP_TYPE,_debug)) { | 214 | if (__C(SGMAP_TYPE,_debug)) { | |
211 | printf("sgmap_load: va:endva = 0x%lx:0x%lx\n", va, endva); | 215 | printf("sgmap_load: va:endva = 0x%lx:0x%lx\n", va, endva); | |
212 | printf("sgmap_load: sgvalen = 0x%lx, boundary = 0x%lx\n", | 216 | printf("sgmap_load: sgvalen = 0x%lx, boundary = 0x%lx\n", | |
213 | sgvalen, boundary); | 217 | sgvalen, boundary); | |
214 | } | 218 | } | |
215 | #endif | 219 | #endif |
--- src/sys/arch/alpha/include/bus_defs.h 2019/09/23 16:17:54 1.5
+++ src/sys/arch/alpha/include/bus_defs.h 2021/07/18 05:12:27 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bus_defs.h,v 1.5 2019/09/23 16:17:54 skrll Exp $ */ | 1 | /* $NetBSD: bus_defs.h,v 1.6 2021/07/18 05:12:27 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998, 2000, 2001 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -354,26 +354,32 @@ struct alpha_bus_dma_tag { | @@ -354,26 +354,32 @@ struct alpha_bus_dma_tag { | |||
354 | * be specified. If the device has a more restrictive constraint, | 354 | * be specified. If the device has a more restrictive constraint, | |
355 | * the map will use that, otherwise this boundary will be used. | 355 | * the map will use that, otherwise this boundary will be used. | |
356 | * This value is ignored if 0. | 356 | * This value is ignored if 0. | |
357 | */ | 357 | */ | |
358 | bus_size_t _boundary; | 358 | bus_size_t _boundary; | |
359 | 359 | |||
360 | /* | 360 | /* | |
361 | * A chipset may have more than one SGMAP window, so SGMAP | 361 | * A chipset may have more than one SGMAP window, so SGMAP | |
362 | * windows also get a pointer to their SGMAP state. | 362 | * windows also get a pointer to their SGMAP state. | |
363 | */ | 363 | */ | |
364 | struct alpha_sgmap *_sgmap; | 364 | struct alpha_sgmap *_sgmap; | |
365 | 365 | |||
366 | /* | 366 | /* | |
367 | * Some chipsets may want to enforce a minimum alignment | |||
368 | * constraint for SGMAP DMA addresses. | |||
369 | */ | |||
370 | bus_size_t _sgmap_minalign; | |||
371 | ||||
372 | /* | |||
367 | * The SGMAP MMU implements a prefetch FIFO to keep data | 373 | * The SGMAP MMU implements a prefetch FIFO to keep data | |
368 | * moving down the pipe, when doing host->bus DMA writes. | 374 | * moving down the pipe, when doing host->bus DMA writes. | |
369 | * The threshold (distance until the next page) used to | 375 | * The threshold (distance until the next page) used to | |
370 | * trigger the prefetch is differnet on different chipsets, | 376 | * trigger the prefetch is differnet on different chipsets, | |
371 | * and we need to know what it is in order to know whether | 377 | * and we need to know what it is in order to know whether | |
372 | * or not to allocate a spill page. | 378 | * or not to allocate a spill page. | |
373 | */ | 379 | */ | |
374 | bus_size_t _pfthresh; | 380 | bus_size_t _pfthresh; | |
375 | 381 | |||
376 | /* | 382 | /* | |
377 | * Internal-use only utility methods. NOT TO BE USED BY | 383 | * Internal-use only utility methods. NOT TO BE USED BY | |
378 | * MACHINE-INDEPENDENT CODE! | 384 | * MACHINE-INDEPENDENT CODE! | |
379 | */ | 385 | */ |
--- src/sys/arch/alpha/tc/tc_dma.c 2020/10/10 21:59:03 1.14
+++ src/sys/arch/alpha/tc/tc_dma.c 2021/07/18 05:12:27 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tc_dma.c,v 1.14 2020/10/10 21:59:03 thorpej Exp $ */ | 1 | /* $NetBSD: tc_dma.c,v 1.15 2021/07/18 05:12:27 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -22,43 +22,44 @@ | @@ -22,43 +22,44 @@ | |||
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | 33 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | |
34 | 34 | |||
35 | __KERNEL_RCSID(0, "$NetBSD: tc_dma.c,v 1.14 2020/10/10 21:59:03 thorpej Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: tc_dma.c,v 1.15 2021/07/18 05:12:27 thorpej Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | 39 | |||
40 | #define _ALPHA_BUS_DMA_PRIVATE | 40 | #define _ALPHA_BUS_DMA_PRIVATE | |
41 | #include <sys/bus.h> | 41 | #include <sys/bus.h> | |
42 | 42 | |||
43 | #include <dev/tc/tcvar.h> | 43 | #include <dev/tc/tcvar.h> | |
44 | 44 | |||
45 | struct alpha_bus_dma_tag tc_dmat_direct = { | 45 | struct alpha_bus_dma_tag tc_dmat_direct = { | |
46 | NULL, /* _cookie */ | 46 | NULL, /* _cookie */ | |
47 | 0, /* _wbase */ | 47 | 0, /* _wbase */ | |
48 | 0, /* _wsize */ | 48 | 0, /* _wsize */ | |
49 | NULL, /* _next_window */ | 49 | NULL, /* _next_window */ | |
50 | 0, /* _boundary */ | 50 | 0, /* _boundary */ | |
51 | NULL, /* _sgmap */ | 51 | NULL, /* _sgmap */ | |
52 | 0, /* _sgmap_minalign */ | |||
52 | 0, /* _pfthresh */ | 53 | 0, /* _pfthresh */ | |
53 | NULL, /* _get_tag */ | 54 | NULL, /* _get_tag */ | |
54 | _bus_dmamap_create, | 55 | _bus_dmamap_create, | |
55 | _bus_dmamap_destroy, | 56 | _bus_dmamap_destroy, | |
56 | _bus_dmamap_load_direct, | 57 | _bus_dmamap_load_direct, | |
57 | _bus_dmamap_load_mbuf_direct, | 58 | _bus_dmamap_load_mbuf_direct, | |
58 | _bus_dmamap_load_uio_direct, | 59 | _bus_dmamap_load_uio_direct, | |
59 | _bus_dmamap_load_raw_direct, | 60 | _bus_dmamap_load_raw_direct, | |
60 | _bus_dmamap_unload, | 61 | _bus_dmamap_unload, | |
61 | _bus_dmamap_sync, | 62 | _bus_dmamap_sync, | |
62 | _bus_dmamem_alloc, | 63 | _bus_dmamem_alloc, | |
63 | _bus_dmamem_free, | 64 | _bus_dmamem_free, | |
64 | _bus_dmamem_map, | 65 | _bus_dmamem_map, |
--- src/sys/arch/alpha/tc/tc_dma_3000_500.c 2020/11/18 02:04:30 1.23
+++ src/sys/arch/alpha/tc/tc_dma_3000_500.c 2021/07/18 05:12:27 1.24
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tc_dma_3000_500.c,v 1.23 2020/11/18 02:04:30 thorpej Exp $ */ | 1 | /* $NetBSD: tc_dma_3000_500.c,v 1.24 2021/07/18 05:12:27 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998 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 Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | |
9 | * NASA Ames Research Center. | 9 | * NASA Ames Research Center. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -22,48 +22,49 @@ | @@ -22,48 +22,49 @@ | |||
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | 30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | 33 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | |
34 | 34 | |||
35 | __KERNEL_RCSID(0, "$NetBSD: tc_dma_3000_500.c,v 1.23 2020/11/18 02:04:30 thorpej Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: tc_dma_3000_500.c,v 1.24 2021/07/18 05:12:27 thorpej Exp $"); | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | #include <sys/kernel.h> | 40 | #include <sys/kernel.h> | |
41 | #include <sys/kmem.h> | 41 | #include <sys/kmem.h> | |
42 | 42 | |||
43 | #define _ALPHA_BUS_DMA_PRIVATE | 43 | #define _ALPHA_BUS_DMA_PRIVATE | |
44 | #include <sys/bus.h> | 44 | #include <sys/bus.h> | |
45 | 45 | |||
46 | #include <dev/tc/tcvar.h> | 46 | #include <dev/tc/tcvar.h> | |
47 | #include <alpha/tc/tc_sgmap.h> | 47 | #include <alpha/tc/tc_sgmap.h> | |
48 | #include <alpha/tc/tc_dma_3000_500.h> | 48 | #include <alpha/tc/tc_dma_3000_500.h> | |
49 | 49 | |||
50 | struct alpha_bus_dma_tag tc_dmat_sgmap = { | 50 | struct alpha_bus_dma_tag tc_dmat_sgmap = { | |
51 | NULL, /* _cookie */ | 51 | NULL, /* _cookie */ | |
52 | 0, /* _wbase */ | 52 | 0, /* _wbase */ | |
53 | 0, /* _wsize */ | 53 | 0, /* _wsize */ | |
54 | NULL, /* _next_window */ | 54 | NULL, /* _next_window */ | |
55 | 0, /* _boundary */ | 55 | 0, /* _boundary */ | |
56 | NULL, /* _sgmap */ | 56 | NULL, /* _sgmap */ | |
57 | PAGE_SIZE, /* _sgmap_minalign */ | |||
57 | 0, /* _pfthresh */ | 58 | 0, /* _pfthresh */ | |
58 | NULL, /* _get_tag */ | 59 | NULL, /* _get_tag */ | |
59 | tc_bus_dmamap_create_sgmap, | 60 | tc_bus_dmamap_create_sgmap, | |
60 | tc_bus_dmamap_destroy_sgmap, | 61 | tc_bus_dmamap_destroy_sgmap, | |
61 | tc_bus_dmamap_load_sgmap, | 62 | tc_bus_dmamap_load_sgmap, | |
62 | tc_bus_dmamap_load_mbuf_sgmap, | 63 | tc_bus_dmamap_load_mbuf_sgmap, | |
63 | tc_bus_dmamap_load_uio_sgmap, | 64 | tc_bus_dmamap_load_uio_sgmap, | |
64 | tc_bus_dmamap_load_raw_sgmap, | 65 | tc_bus_dmamap_load_raw_sgmap, | |
65 | tc_bus_dmamap_unload_sgmap, | 66 | tc_bus_dmamap_unload_sgmap, | |
66 | _bus_dmamap_sync, | 67 | _bus_dmamap_sync, | |
67 | _bus_dmamem_alloc, | 68 | _bus_dmamem_alloc, | |
68 | _bus_dmamem_free, | 69 | _bus_dmamem_free, | |
69 | _bus_dmamem_map, | 70 | _bus_dmamem_map, |