Sun Jul 18 05:12:27 2021 UTC ()
Allow for the SGMAP implementation to specify a minimum alignment for
SGMAP DMA segments. If not specified, PAGE_SIZE will be used, as before.
(thorpej)
diff -r1.28 -r1.29 src/sys/arch/alpha/common/sgmap_common.c
diff -r1.42 -r1.43 src/sys/arch/alpha/common/sgmap_typedep.c
diff -r1.5 -r1.6 src/sys/arch/alpha/include/bus_defs.h
diff -r1.14 -r1.15 src/sys/arch/alpha/tc/tc_dma.c
diff -r1.23 -r1.24 src/sys/arch/alpha/tc/tc_dma_3000_500.c
--- 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,4 +1,4 @@
-/* $NetBSD: sgmap_common.c,v 1.28 2021/07/04 22:42:35 thorpej Exp $ */
+/* $NetBSD: sgmap_common.c,v 1.29 2021/07/18 05:12:27 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.28 2021/07/04 22:42:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.29 2021/07/18 05:12:27 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,6 +66,14 @@
if (sgvasize & PGOFSET) {
printf("size botch for sgmap `%s'\n", name);
goto die;
+ }
+
+ /*
+ * If we don't yet have a minimum SGVA alignment, default
+ * to the system page size.
+ */
+ if (t->_sgmap_minalign < PAGE_SIZE) {
+ t->_sgmap_minalign = PAGE_SIZE;
}
sgmap->aps_wbase = wbase;
--- 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,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.42 2021/06/24 16:41:16 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.42 2021/06/24 16:41:16 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $");
#include "opt_ddb.h"
@@ -130,7 +130,8 @@
const vm_flag_t vmflags = VM_INSTANTFIT |
((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
- alignment = PAGE_SIZE;
+ KASSERT(t->_sgmap_minalign != 0);
+ alignment = t->_sgmap_minalign;
sgvalen = (endva - va);
SGMAP_PTE_TYPE spill_pte_v = __C(SGMAP_TYPE,_prefetch_spill_page_pte);
@@ -193,13 +194,16 @@
* ARGH! If the addition of the spill page bumped us
* over our boundary, we have to 2x the boundary limit.
* To compensate (and enforce the original boundary
- * constraint), we force our alignment to be the previous
- * boundary, thus ensuring that the only boundary violation
- * is the pre-fetch that the SGMAP controller performs that
- * necessitates the spill page in the first place.
+ * constraint), we force our alignment to be at least the
+ * previous boundary, thus ensuring that the only boundary
+ * violation is the pre-fetch that the SGMAP controller
+ * performs that necessitates the spill page in the first
+ * place.
*/
if (boundary && boundary < sgvalen) {
- alignment = boundary;
+ if (alignment < boundary) {
+ alignment = boundary;
+ }
do {
boundary <<= 1;
} while (boundary < sgvalen);
--- 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,4 +1,4 @@
-/* $NetBSD: bus_defs.h,v 1.5 2019/09/23 16:17:54 skrll Exp $ */
+/* $NetBSD: bus_defs.h,v 1.6 2021/07/18 05:12:27 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -362,6 +362,12 @@
* windows also get a pointer to their SGMAP state.
*/
struct alpha_sgmap *_sgmap;
+
+ /*
+ * Some chipsets may want to enforce a minimum alignment
+ * constraint for SGMAP DMA addresses.
+ */
+ bus_size_t _sgmap_minalign;
/*
* The SGMAP MMU implements a prefetch FIFO to keep data
--- 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,4 +1,4 @@
-/* $NetBSD: tc_dma.c,v 1.14 2020/10/10 21:59:03 thorpej Exp $ */
+/* $NetBSD: tc_dma.c,v 1.15 2021/07/18 05:12:27 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: tc_dma.c,v 1.14 2020/10/10 21:59:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc_dma.c,v 1.15 2021/07/18 05:12:27 thorpej Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -49,6 +49,7 @@
NULL, /* _next_window */
0, /* _boundary */
NULL, /* _sgmap */
+ 0, /* _sgmap_minalign */
0, /* _pfthresh */
NULL, /* _get_tag */
_bus_dmamap_create,
--- 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,4 +1,4 @@
-/* $NetBSD: tc_dma_3000_500.c,v 1.23 2020/11/18 02:04:30 thorpej Exp $ */
+/* $NetBSD: tc_dma_3000_500.c,v 1.24 2021/07/18 05:12:27 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: tc_dma_3000_500.c,v 1.23 2020/11/18 02:04:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc_dma_3000_500.c,v 1.24 2021/07/18 05:12:27 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,6 +54,7 @@
NULL, /* _next_window */
0, /* _boundary */
NULL, /* _sgmap */
+ PAGE_SIZE, /* _sgmap_minalign */
0, /* _pfthresh */
NULL, /* _get_tag */
tc_bus_dmamap_create_sgmap,