Thu May 27 22:11:31 2021 UTC ()
The Tsunami / Typhoon chipsets have a static "monster window" for DMA
that allows for up to 32GB of RAM to be direct-mapped if the PCI device
can issue a 64-bit address (the monster window lives at 0x10000000000).
Enable this window and provide this to the PCI bus as a "dmat64".


(thorpej)
diff -r1.21 -r1.22 src/sys/arch/alpha/include/pci_machdep.h
diff -r1.25 -r1.26 src/sys/arch/alpha/pci/tsc.c
diff -r1.16 -r1.17 src/sys/arch/alpha/pci/tsp_dma.c
diff -r1.8 -r1.9 src/sys/arch/alpha/pci/tsreg.h
diff -r1.14 -r1.15 src/sys/arch/alpha/pci/tsvar.h

cvs diff -r1.21 -r1.22 src/sys/arch/alpha/include/pci_machdep.h (expand / switch to unified diff)

--- src/sys/arch/alpha/include/pci_machdep.h 2020/09/26 21:07:48 1.21
+++ src/sys/arch/alpha/include/pci_machdep.h 2021/05/27 22:11:31 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pci_machdep.h,v 1.21 2020/09/26 21:07:48 thorpej Exp $ */ 1/* $NetBSD: pci_machdep.h,v 1.22 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Carnegie-Mellon University. 4 * Copyright (c) 1996 Carnegie-Mellon University.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Author: Chris G. Demetriou 7 * Author: Chris G. Demetriou
8 * 8 *
9 * Permission to use, copy, modify and distribute this software and 9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright 10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the 11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions 12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation. 13 * thereof, and that both notices appear in supporting documentation.
14 * 14 *
@@ -26,26 +26,27 @@ @@ -26,26 +26,27 @@
26 * any improvements or extensions that they make and grant Carnegie the 26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes. 27 * rights to redistribute these changes.
28 */ 28 */
29 29
30#ifndef _ALPHA_PCI_MACHDEP_H_ 30#ifndef _ALPHA_PCI_MACHDEP_H_
31#define _ALPHA_PCI_MACHDEP_H_ 31#define _ALPHA_PCI_MACHDEP_H_
32 32
33#include <sys/errno.h> 33#include <sys/errno.h>
34 34
35/* 35/*
36 * Machine-specific definitions for PCI autoconfiguration. 36 * Machine-specific definitions for PCI autoconfiguration.
37 */ 37 */
38#define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH 38#define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
 39#define _PCI_HAVE_DMA64
39 40
40/* 41/*
41 * Types provided to machine-independent PCI code 42 * Types provided to machine-independent PCI code
42 */ 43 */
43typedef struct alpha_pci_chipset *pci_chipset_tag_t; 44typedef struct alpha_pci_chipset *pci_chipset_tag_t;
44typedef u_long pcitag_t; 45typedef u_long pcitag_t;
45typedef struct { 46typedef struct {
46 u_long value; 47 u_long value;
47} pci_intr_handle_t; 48} pci_intr_handle_t;
48 49
49/* 50/*
50 * Forward declarations. 51 * Forward declarations.
51 */ 52 */

cvs diff -r1.25 -r1.26 src/sys/arch/alpha/pci/tsc.c (expand / switch to unified diff)

--- src/sys/arch/alpha/pci/tsc.c 2021/04/24 23:36:23 1.25
+++ src/sys/arch/alpha/pci/tsc.c 2021/05/27 22:11:31 1.26
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tsc.c,v 1.25 2021/04/24 23:36:23 thorpej Exp $ */ 1/* $NetBSD: tsc.c,v 1.26 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 4 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 30 * SUCH DAMAGE.
31 * 31 *
32 */ 32 */
33 33
34#include "opt_dec_6600.h" 34#include "opt_dec_6600.h"
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37 37
38__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.25 2021/04/24 23:36:23 thorpej Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: tsc.c,v 1.26 2021/05/27 22:11:31 thorpej Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/device.h> 42#include <sys/device.h>
43#include <sys/malloc.h> 43#include <sys/malloc.h>
44 44
45#include <machine/autoconf.h> 45#include <machine/autoconf.h>
46#include <machine/rpb.h> 46#include <machine/rpb.h>
47#include <machine/sysarch.h> 47#include <machine/sysarch.h>
48 48
49#include <dev/isa/isareg.h> 49#include <dev/isa/isareg.h>
50#include <dev/isa/isavar.h> 50#include <dev/isa/isavar.h>
51#include <dev/pci/pcireg.h> 51#include <dev/pci/pcireg.h>
@@ -221,27 +221,27 @@ tspattach(device_t parent, device_t self @@ -221,27 +221,27 @@ tspattach(device_t parent, device_t self
221 /* 221 /*
222 * Do PCI memory initialization that needs to be deferred until 222 * Do PCI memory initialization that needs to be deferred until
223 * malloc is safe. On the Tsunami, we need to do this after 223 * malloc is safe. On the Tsunami, we need to do this after
224 * DMA is initialized, as well. 224 * DMA is initialized, as well.
225 */ 225 */
226 tsp_bus_mem_init2(&pcp->pc_memt, pcp); 226 tsp_bus_mem_init2(&pcp->pc_memt, pcp);
227 227
228 pci_6600_pickintr(pcp); 228 pci_6600_pickintr(pcp);
229 229
230 pba.pba_iot = &pcp->pc_iot; 230 pba.pba_iot = &pcp->pc_iot;
231 pba.pba_memt = &pcp->pc_memt; 231 pba.pba_memt = &pcp->pc_memt;
232 pba.pba_dmat = 232 pba.pba_dmat =
233 alphabus_dma_get_tag(&pcp->pc_dmat_direct, ALPHA_BUS_PCI); 233 alphabus_dma_get_tag(&pcp->pc_dmat_direct, ALPHA_BUS_PCI);
234 pba.pba_dmat64 = NULL; 234 pba.pba_dmat64 = &pcp->pc_dmat64_direct;
235 pba.pba_pc = &pcp->pc_pc; 235 pba.pba_pc = &pcp->pc_pc;
236 pba.pba_bus = 0; 236 pba.pba_bus = 0;
237 pba.pba_bridgetag = NULL; 237 pba.pba_bridgetag = NULL;
238 pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY | 238 pba.pba_flags = PCI_FLAGS_IO_OKAY | PCI_FLAGS_MEM_OKAY |
239 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY; 239 PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
240 config_found(self, &pba, pcibusprint, CFARG_EOL); 240 config_found(self, &pba, pcibusprint, CFARG_EOL);
241} 241}
242 242
243struct tsp_config * 243struct tsp_config *
244tsp_init(int mallocsafe, int n) 244tsp_init(int mallocsafe, int n)
245 /* n: Pchip number */ 245 /* n: Pchip number */
246{ 246{
247 struct tsp_config *pcp; 247 struct tsp_config *pcp;

cvs diff -r1.16 -r1.17 src/sys/arch/alpha/pci/tsp_dma.c (expand / switch to unified diff)

--- src/sys/arch/alpha/pci/tsp_dma.c 2021/05/05 02:15:18 1.16
+++ src/sys/arch/alpha/pci/tsp_dma.c 2021/05/27 22:11:31 1.17
@@ -1,14 +1,44 @@ @@ -1,14 +1,44 @@
1/* $NetBSD: tsp_dma.c,v 1.16 2021/05/05 02:15:18 thorpej Exp $ */ 1/* $NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $ */
 2
 3/*-
 4 * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
 5 * All rights reserved.
 6 *
 7 * This code is derived from software contributed to The NetBSD Foundation
 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
 9 * NASA Ames Research Center.
 10 *
 11 * Redistribution and use in source and binary forms, with or without
 12 * modification, are permitted provided that the following conditions
 13 * are met:
 14 * 1. Redistributions of source code must retain the above copyright
 15 * notice, this list of conditions and the following disclaimer.
 16 * 2. Redistributions in binary form must reproduce the above copyright
 17 * notice, this list of conditions and the following disclaimer in the
 18 * documentation and/or other materials provided with the distribution.
 19 *
 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 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
 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 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
 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
 30 * POSSIBILITY OF SUCH DAMAGE.
 31 */
2 32
3/*- 33/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 34 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 35 *
6 * Redistribution and use in source and binary forms, with or without 36 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 37 * modification, are permitted provided that the following conditions
8 * are met: 38 * are met:
9 * 1. Redistributions of source code must retain the above copyright 39 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 40 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 41 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 42 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 43 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 44 * 3. All advertising materials mentioning features or use of this software
@@ -18,61 +48,30 @@ @@ -18,61 +48,30 @@
18 * derived from this software without specific prior written permission. 48 * derived from this software without specific prior written permission.
19 * 49 *
20 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS 50 * THIS SOFTWARE IS PROVIDED BY ROSS HARVEY ``AS IS'' AND ANY EXPRESS
21 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 51 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE 52 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP0SE
23 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY 53 * ARE DISCLAIMED. IN NO EVENT SHALL ROSS HARVEY BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE. 60 * SUCH DAMAGE.
31 * 
32 */ 
33 
34/*- 
35 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 
36 * All rights reserved. 
37 * 
38 * This code is derived from software contributed to The NetBSD Foundation 
39 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 
40 * NASA Ames Research Center. 
41 * 
42 * Redistribution and use in source and binary forms, with or without 
43 * modification, are permitted provided that the following conditions 
44 * are met: 
45 * 1. Redistributions of source code must retain the above copyright 
46 * notice, this list of conditions and the following disclaimer. 
47 * 2. Redistributions in binary form must reproduce the above copyright 
48 * notice, this list of conditions and the following disclaimer in the 
49 * documentation and/or other materials provided with the distribution. 
50 * 
51 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 
52 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 
53 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
54 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 
55 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
56 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
57 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
58 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
59 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
60 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
61 * POSSIBILITY OF SUCH DAMAGE. 
62 */ 61 */
63 62
64#include <sys/cdefs.h> 63#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.16 2021/05/05 02:15:18 thorpej Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.17 2021/05/27 22:11:31 thorpej Exp $");
66 65
67#include <sys/param.h> 66#include <sys/param.h>
68#include <sys/systm.h> 67#include <sys/systm.h>
69#include <sys/kernel.h> 68#include <sys/kernel.h>
70#include <sys/device.h> 69#include <sys/device.h>
71#include <sys/malloc.h> 70#include <sys/malloc.h>
72 71
73#include <machine/autoconf.h> 72#include <machine/autoconf.h>
74#define _ALPHA_BUS_DMA_PRIVATE 73#define _ALPHA_BUS_DMA_PRIVATE
75#include <sys/bus.h> 74#include <sys/bus.h>
76#include <machine/rpb.h> 75#include <machine/rpb.h>
77 76
78#include <dev/pci/pcireg.h> 77#include <dev/pci/pcireg.h>
@@ -98,26 +97,51 @@ static int tsp_bus_dmamap_load_uio_sgmap @@ -98,26 +97,51 @@ static int tsp_bus_dmamap_load_uio_sgmap
98static int tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t, bus_dmamap_t, 97static int tsp_bus_dmamap_load_raw_sgmap(bus_dma_tag_t, bus_dmamap_t,
99 bus_dma_segment_t *, int, bus_size_t, int); 98 bus_dma_segment_t *, int, bus_size_t, int);
100 99
101static void tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t, bus_dmamap_t); 100static void tsp_bus_dmamap_unload_sgmap(bus_dma_tag_t, bus_dmamap_t);
102 101
103static void tsp_tlb_invalidate(struct tsp_config *); 102static void tsp_tlb_invalidate(struct tsp_config *);
104 103
105/* 104/*
106 * XXX Need to figure out what this is, if any. Initialize it to 105 * XXX Need to figure out what this is, if any. Initialize it to
107 * XXX something that should be safe. 106 * XXX something that should be safe.
108 */ 107 */
109#define TSP_SGMAP_PFTHRESH 256 108#define TSP_SGMAP_PFTHRESH 256
110 109
 110/*
 111 * Quoting the 21272 programmer's reference manual:
 112 *
 113 * <quote>
 114 * 10.1.4.4 Monster Window DMA Address Translation
 115 *
 116 * In case of a PCI dual-address cycle command, the high-order PCI address
 117 * bits <63:40> are compared to the constant value 0x0000_01 (that is, bit
 118 * <40> = 1; all other bits = 0). If these bits match, a monster window hit
 119 * has occurred and the low-order PCI address bits <34:0> are used unchanged
 120 * as the system address bits <34:0>. PCI address bits <39:35> are ignored.
 121 * The high-order 32 PCI address bits are available on b_ad<31:0> in the
 122 * second cycle of a DAC, and also on b_ad<63:32> in the first cycle of a
 123 * DAC if b_req64_l is asserted.
 124 * </quote>
 125 *
 126 * This means that we can address up to 32GB of RAM using a direct-mapped
 127 * 64-bit DMA tag. This leaves us possibly having to fall back on SGMAP
 128 * DMA on a Titan system (those support up to 64GB of RAM), and we may have
 129 * to address that with an additional large SGMAP DAC window at another
 130 * time.
 131 */
 132#define TSP_MONSTER_DMA_WINDOW_BASE 0x100##00000000UL
 133#define TSP_MONSTER_DMA_WINDOW_SIZE 0x008##00000000UL
 134
111void 135void
112tsp_dma_init(struct tsp_config *pcp) 136tsp_dma_init(struct tsp_config *pcp)
113{ 137{
114 int i; 138 int i;
115 bus_dma_tag_t t; 139 bus_dma_tag_t t;
116 struct ts_pchip *pccsr = pcp->pc_csr; 140 struct ts_pchip *pccsr = pcp->pc_csr;
117 bus_addr_t dwbase, dwlen, sgwbase, sgwlen, tbase; 141 bus_addr_t dwbase, dwlen, sgwbase, sgwlen, tbase;
118 static struct map_expected { 142 static struct map_expected {
119 uint32_t base, mask, enables; 143 uint32_t base, mask, enables;
120 } premap[4] = { 144 } premap[4] = {
121 { 0x00800000, 0x00700000, WSBA_ENA | WSBA_SG }, 145 { 0x00800000, 0x00700000, WSBA_ENA | WSBA_SG },
122 { 0x80000000, 0x3ff00000, WSBA_ENA }, 146 { 0x80000000, 0x3ff00000, WSBA_ENA },
123 { 0, 0, 0 }, 147 { 0, 0, 0 },
@@ -127,29 +151,58 @@ tsp_dma_init(struct tsp_config *pcp) @@ -127,29 +151,58 @@ tsp_dma_init(struct tsp_config *pcp)
127 alpha_mb(); 151 alpha_mb();
128 for(i = 0; i < 4; ++i) { 152 for(i = 0; i < 4; ++i) {
129 if (EDIFF(pccsr->tsp_wsba[i].tsg_r, premap[i].base) || 153 if (EDIFF(pccsr->tsp_wsba[i].tsg_r, premap[i].base) ||
130 EDIFF(pccsr->tsp_wsm[i].tsg_r, premap[i].mask)) 154 EDIFF(pccsr->tsp_wsm[i].tsg_r, premap[i].mask))
131 printf("tsp%d: window %d: %lx/base %lx/mask %lx" 155 printf("tsp%d: window %d: %lx/base %lx/mask %lx"
132 " reinitialized\n", 156 " reinitialized\n",
133 pcp->pc_pslot, i, 157 pcp->pc_pslot, i,
134 pccsr->tsp_wsba[i].tsg_r, 158 pccsr->tsp_wsba[i].tsg_r,
135 pccsr->tsp_wsm[i].tsg_r, 159 pccsr->tsp_wsm[i].tsg_r,
136 pccsr->tsp_tba[i].tsg_r); 160 pccsr->tsp_tba[i].tsg_r);
137 pccsr->tsp_wsba[i].tsg_r = premap[i].base | premap[i].enables; 161 pccsr->tsp_wsba[i].tsg_r = premap[i].base | premap[i].enables;
138 pccsr->tsp_wsm[i].tsg_r = premap[i].mask; 162 pccsr->tsp_wsm[i].tsg_r = premap[i].mask;
139 } 163 }
 164
 165 /* Ensure the Monster Window is enabled. */
 166 pccsr->tsp_pctl.tsg_r |= PCTL_MWIN;
140 alpha_mb(); 167 alpha_mb();
141 168
142 /* 169 /*
 170 * Initialize the DMA tag used for direct-mapped 64-bit DMA.
 171 */
 172 t = &pcp->pc_dmat64_direct;
 173 t->_cookie = pcp;
 174 t->_wbase = TSP_MONSTER_DMA_WINDOW_BASE;
 175 t->_wsize = TSP_MONSTER_DMA_WINDOW_SIZE;
 176 t->_next_window = &pcp->pc_dmat_sgmap;
 177 t->_boundary = 0;
 178 t->_sgmap = NULL;
 179 t->_get_tag = tsp_dma_get_tag;
 180 t->_dmamap_create = _bus_dmamap_create;
 181 t->_dmamap_destroy = _bus_dmamap_destroy;
 182 t->_dmamap_load = _bus_dmamap_load_direct;
 183 t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
 184 t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
 185 t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
 186 t->_dmamap_unload = _bus_dmamap_unload;
 187 t->_dmamap_sync = _bus_dmamap_sync;
 188
 189 t->_dmamem_alloc = _bus_dmamem_alloc;
 190 t->_dmamem_free = _bus_dmamem_free;
 191 t->_dmamem_map = _bus_dmamem_map;
 192 t->_dmamem_unmap = _bus_dmamem_unmap;
 193 t->_dmamem_mmap = _bus_dmamem_mmap;
 194
 195 /*
143 * Initialize the DMA tag used for direct-mapped DMA. 196 * Initialize the DMA tag used for direct-mapped DMA.
144 */ 197 */
145 t = &pcp->pc_dmat_direct; 198 t = &pcp->pc_dmat_direct;
146 t->_cookie = pcp; 199 t->_cookie = pcp;
147 t->_wbase = dwbase = WSBA_ADDR(pccsr->tsp_wsba[1].tsg_r); 200 t->_wbase = dwbase = WSBA_ADDR(pccsr->tsp_wsba[1].tsg_r);
148 t->_wsize = dwlen = WSM_LEN(pccsr->tsp_wsm[1].tsg_r); 201 t->_wsize = dwlen = WSM_LEN(pccsr->tsp_wsm[1].tsg_r);
149 t->_next_window = &pcp->pc_dmat_sgmap; 202 t->_next_window = &pcp->pc_dmat_sgmap;
150 t->_boundary = 0; 203 t->_boundary = 0;
151 t->_sgmap = NULL; 204 t->_sgmap = NULL;
152 t->_get_tag = tsp_dma_get_tag; 205 t->_get_tag = tsp_dma_get_tag;
153 t->_dmamap_create = _bus_dmamap_create; 206 t->_dmamap_create = _bus_dmamap_create;
154 t->_dmamap_destroy = _bus_dmamap_destroy; 207 t->_dmamap_destroy = _bus_dmamap_destroy;
155 t->_dmamap_load = _bus_dmamap_load_direct; 208 t->_dmamap_load = _bus_dmamap_load_direct;

cvs diff -r1.8 -r1.9 src/sys/arch/alpha/pci/tsreg.h (expand / switch to unified diff)

--- src/sys/arch/alpha/pci/tsreg.h 2020/09/23 00:46:17 1.8
+++ src/sys/arch/alpha/pci/tsreg.h 2021/05/27 22:11:31 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tsreg.h,v 1.8 2020/09/23 00:46:17 thorpej Exp $ */ 1/* $NetBSD: tsreg.h,v 1.9 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 4 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -157,26 +157,49 @@ @@ -157,26 +157,49 @@
157#define P_WSM1 0x0140 157#define P_WSM1 0x0140
158#define P_WSM2 0x0180 158#define P_WSM2 0x0180
159#define P_WSM3 0x01c0 159#define P_WSM3 0x01c0
160 160
161# define WSM_AM(r) TSFIELDBB((r), 31, 20) 161# define WSM_AM(r) TSFIELDBB((r), 31, 20)
162# define WSM_LEN(r) ((WSM_AM(r) + 1) << 20) 162# define WSM_LEN(r) ((WSM_AM(r) + 1) << 20)
163 163
164#define P_TBA0 0x0200 164#define P_TBA0 0x0200
165#define P_TBA1 0x0240 165#define P_TBA1 0x0240
166#define P_TBA2 0x0280 166#define P_TBA2 0x0280
167#define P_TBA3 0x02c0 167#define P_TBA3 0x02c0
168 168
169#define P_PCTL 0x0300 169#define P_PCTL 0x0300
 170
 171#define PCTL_FDSC __BIT(0) /* fast discard enable */
 172#define PCTL_FBTB __BIT(1) /* fast back-to-back enable */
 173#define PCTL_THDIS __BIT(2) /* disable TLB anti-thrash (debug) */
 174#define PCTL_CHAINDIS __BIT(3) /* disable chaining */
 175#define PCTL_TGTLAT __BIT(4) /* target latency timers enable */
 176#define PCTL_HOLE __BIT(5) /* 512KB->1M hole enable */
 177#define PCTL_MWIN __BIT(6) /* monster window enable */
 178#define PCTL_PRIGRP __BITS(8,14) /* arbiter priority group */
 179#define PCTL_PPRI __BIT(15) /* arbiter priority group for Pchip */
 180#define PCTL_ECCEN __BIT(18) /* ECC enable for DMA and SGTE */
 181#define PCTL_PADM __BIT(19) /* PADbus mode */
 182#define PCTL_CDQMAX __BITS(20,23) /* see manual */
 183#define PCTL_REV __BITS(24,31) /* Pchip revision */
 184#define PCTL_CRQMAX __BITS(32,35) /* see manual */
 185#define PCTL_PTPMAX __BITS(36,39) /* see manual */
 186#define PCTL_PCLKX __BITS(40,41) /* PCI clock freq multipler */
 187#define PCTL_FDSDIS __BIT(42) /* fast DMA start and SGTE disable */
 188#define PCTL_FDWDIS __BIT(43) /* fast DMA read cache block disable */
 189#define PCTL_PTEVRFY __BIT(44) /* PTE verify for DMA read */
 190#define PCTL_RPP __BIT(45) /* remote Pchip present */
 191#define PCTL_PID __BITS(46,47) /* Pchip ID */
 192
170#define P_PLAT 0x0340 193#define P_PLAT 0x0340
171 /* reserved 0x0380 */ 194 /* reserved 0x0380 */
172#define P_PERROR 0x03c0 195#define P_PERROR 0x03c0
173 196
174# define PER_ERR(r) TSFIELD((r), 0, 12) 197# define PER_ERR(r) TSFIELD((r), 0, 12)
175# define PER_ECC(r) TSFIELD((r), 10, 2) 198# define PER_ECC(r) TSFIELD((r), 10, 2)
176# define PER_SADR(r) TSFIELD((r), 16, 34) 199# define PER_SADR(r) TSFIELD((r), 16, 34)
177# define PER_PADR(r) (TSFIELD((r), 18, 32) << 2) 200# define PER_PADR(r) (TSFIELD((r), 18, 32) << 2)
178# define PER_TRNS(r) TSFIELD((r), 16, 2) 201# define PER_TRNS(r) TSFIELD((r), 16, 2)
179# define PER_INV(r) TSFIELD((r), 51, 1) 202# define PER_INV(r) TSFIELD((r), 51, 1)
180# define PER_CMD(r) TSFIELD((r), 52, 4) 203# define PER_CMD(r) TSFIELD((r), 52, 4)
181# define PER_SYN(r) TSFIELD((r), 56, 8) 204# define PER_SYN(r) TSFIELD((r), 56, 8)
182 205

cvs diff -r1.14 -r1.15 src/sys/arch/alpha/pci/tsvar.h (expand / switch to unified diff)

--- src/sys/arch/alpha/pci/tsvar.h 2020/06/17 03:50:04 1.14
+++ src/sys/arch/alpha/pci/tsvar.h 2021/05/27 22:11:31 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tsvar.h,v 1.14 2020/06/17 03:50:04 thorpej Exp $ */ 1/* $NetBSD: tsvar.h,v 1.15 2021/05/27 22:11:31 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 by Ross Harvey. All rights reserved. 4 * Copyright (c) 1999 by Ross Harvey. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software 14 * 3. All advertising materials mentioning features or use of this software
@@ -41,26 +41,27 @@ @@ -41,26 +41,27 @@
41 41
42#define tsvar() { Generate ctags(1) key. } 42#define tsvar() { Generate ctags(1) key. }
43 43
44struct tsp_config { 44struct tsp_config {
45 int pc_pslot; /* Pchip 0 or 1 */ 45 int pc_pslot; /* Pchip 0 or 1 */
46 int pc_initted; /* Initialized */ 46 int pc_initted; /* Initialized */
47 uint64_t pc_iobase; /* All Pchip space starts here */ 47 uint64_t pc_iobase; /* All Pchip space starts here */
48 struct ts_pchip *pc_csr; /* Pchip CSR space starts here */ 48 struct ts_pchip *pc_csr; /* Pchip CSR space starts here */
49 volatile uint64_t *pc_tlbia; /* Pchip TLBIA register address */  49 volatile uint64_t *pc_tlbia; /* Pchip TLBIA register address */
50 50
51 struct alpha_bus_space pc_iot, pc_memt; 51 struct alpha_bus_space pc_iot, pc_memt;
52 struct alpha_pci_chipset pc_pc; 52 struct alpha_pci_chipset pc_pc;
53 53
 54 struct alpha_bus_dma_tag pc_dmat64_direct;
54 struct alpha_bus_dma_tag pc_dmat_direct; 55 struct alpha_bus_dma_tag pc_dmat_direct;
55 struct alpha_bus_dma_tag pc_dmat_sgmap; 56 struct alpha_bus_dma_tag pc_dmat_sgmap;
56 57
57 struct alpha_sgmap pc_sgmap; 58 struct alpha_sgmap pc_sgmap;
58 59
59 uint32_t pc_hae_mem; 60 uint32_t pc_hae_mem;
60 uint32_t pc_hae_io; 61 uint32_t pc_hae_io;
61 62
62 long pc_io_exstorage[_FSTORE]; 63 long pc_io_exstorage[_FSTORE];
63 long pc_mem_exstorage[_FSTORE]; 64 long pc_mem_exstorage[_FSTORE];
64 struct extent *pc_io_ex, *pc_mem_ex; 65 struct extent *pc_io_ex, *pc_mem_ex;
65 int pc_mallocsafe; 66 int pc_mallocsafe;
66}; 67};