Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha Allow for the SGMAP implementation to specify...



details:   https://anonhg.NetBSD.org/src/rev/696ab5b86cfc
branches:  trunk
changeset: 984702:696ab5b86cfc
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jul 18 05:12:27 2021 +0000

description:
Allow for the SGMAP implementation to specify a minimum alignment for
SGMAP DMA segments.  If not specified, PAGE_SIZE will be used, as before.

diffstat:

 sys/arch/alpha/common/sgmap_common.c  |  12 ++++++++++--
 sys/arch/alpha/common/sgmap_typedep.c |  20 ++++++++++++--------
 sys/arch/alpha/include/bus_defs.h     |   8 +++++++-
 sys/arch/alpha/tc/tc_dma.c            |   5 +++--
 sys/arch/alpha/tc/tc_dma_3000_500.c   |   5 +++--
 5 files changed, 35 insertions(+), 15 deletions(-)

diffs (157 lines):

diff -r 911dc588d8c3 -r 696ab5b86cfc sys/arch/alpha/common/sgmap_common.c
--- a/sys/arch/alpha/common/sgmap_common.c      Sun Jul 18 05:09:47 2021 +0000
+++ b/sys/arch/alpha/common/sgmap_common.c      Sun Jul 18 05:12:27 2021 +0000
@@ -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>
@@ -68,6 +68,14 @@
                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;
        sgmap->aps_sgvabase = sgvabase;
        sgmap->aps_sgvasize = sgvasize;
diff -r 911dc588d8c3 -r 696ab5b86cfc sys/arch/alpha/common/sgmap_typedep.c
--- a/sys/arch/alpha/common/sgmap_typedep.c     Sun Jul 18 05:09:47 2021 +0000
+++ b/sys/arch/alpha/common/sgmap_typedep.c     Sun Jul 18 05:12:27 2021 +0000
@@ -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);
diff -r 911dc588d8c3 -r 696ab5b86cfc sys/arch/alpha/include/bus_defs.h
--- a/sys/arch/alpha/include/bus_defs.h Sun Jul 18 05:09:47 2021 +0000
+++ b/sys/arch/alpha/include/bus_defs.h Sun Jul 18 05:12:27 2021 +0000
@@ -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.
@@ -364,6 +364,12 @@
        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
         * moving down the pipe, when doing host->bus DMA writes.
         * The threshold (distance until the next page) used to
diff -r 911dc588d8c3 -r 696ab5b86cfc sys/arch/alpha/tc/tc_dma.c
--- a/sys/arch/alpha/tc/tc_dma.c        Sun Jul 18 05:09:47 2021 +0000
+++ b/sys/arch/alpha/tc/tc_dma.c        Sun Jul 18 05:12:27 2021 +0000
@@ -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,
diff -r 911dc588d8c3 -r 696ab5b86cfc sys/arch/alpha/tc/tc_dma_3000_500.c
--- a/sys/arch/alpha/tc/tc_dma_3000_500.c       Sun Jul 18 05:09:47 2021 +0000
+++ b/sys/arch/alpha/tc/tc_dma_3000_500.c       Sun Jul 18 05:12:27 2021 +0000
@@ -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,



Home | Main Index | Thread Index | Old Index