CVS commit: src/sys/arch/alpha/pci

2021-07-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jul 19 01:06:14 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: cia_dma.c ciavar.h tsp_dma.c tsvar.h

Log Message:
For CIA/Pyxis and Tsunami/Typhoon/Titan, save the firmware's idea of
the DMA window configuration, and restore it at shutdown time.  Make
sure that all assumptions we've made on the firmware's configuration
of DMA windows is correct.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/alpha/pci/cia_dma.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/pci/ciavar.h \
src/sys/arch/alpha/pci/tsp_dma.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/tsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/cia_dma.c
diff -u src/sys/arch/alpha/pci/cia_dma.c:1.36 src/sys/arch/alpha/pci/cia_dma.c:1.37
--- src/sys/arch/alpha/pci/cia_dma.c:1.36	Sun Jul 18 05:09:47 2021
+++ src/sys/arch/alpha/pci/cia_dma.c	Mon Jul 19 01:06:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_dma.c,v 1.36 2021/07/18 05:09:47 thorpej Exp $ */
+/* $NetBSD: cia_dma.c,v 1.37 2021/07/19 01:06:14 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.36 2021/07/18 05:09:47 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.37 2021/07/19 01:06:14 thorpej Exp $");
 
 #include 
 #include 
@@ -100,12 +100,49 @@ struct alpha_sgmap cia_pyxis_bug_sgmap;
 #define	CIA_PYXIS_BUG_BASE	(128UL*1024*1024)
 #define	CIA_PYXIS_BUG_SIZE	(2UL*1024*1024)
 
+static void
+cia_dma_shutdown(void *arg)
+{
+	struct cia_config *ccp = arg;
+	int i;
+
+	/*
+	 * Restore the original values, to make the firmware happy.
+	 */
+	for (i = 0; i < 4; i++) {
+		REGVAL(CIA_PCI_W0BASE + (i * 0x100)) =
+		ccp->cc_saved_windows.wbase[i];
+		alpha_mb();
+		REGVAL(CIA_PCI_W0MASK + (i * 0x100)) =
+		ccp->cc_saved_windows.wmask[i];
+		alpha_mb();
+		REGVAL(CIA_PCI_T0BASE + (i * 0x100)) =
+		ccp->cc_saved_windows.tbase[i];
+		alpha_mb();
+	}
+}
+
 void
 cia_dma_init(struct cia_config *ccp)
 {
 	bus_addr_t tbase;
 	bus_dma_tag_t t;
 	bus_dma_tag_t t_sg_hi = NULL;
+	int i;
+
+	/*
+	 * Save our configuration to restore at shutdown, just
+	 * in case the firmware would get cranky with us.
+	 */
+	for (i = 0; i < 4; i++) {
+		ccp->cc_saved_windows.wbase[i] =
+		REGVAL(CIA_PCI_W0BASE + (i * 0x100));
+		ccp->cc_saved_windows.wmask[i] =
+		REGVAL(CIA_PCI_W0MASK + (i * 0x100));
+		ccp->cc_saved_windows.tbase[i] =
+		REGVAL(CIA_PCI_T0BASE + (i * 0x100));
+	}
+	shutdownhook_establish(cia_dma_shutdown, ccp);
 
 	/*
 	 * If we have more than 1GB of RAM, then set up an sgmap-mapped
@@ -195,11 +232,17 @@ cia_dma_init(struct cia_config *ccp)
 	t->_dmamem_mmap = _bus_dmamem_mmap;
 
 	/*
-	 * The firmware has set up window 1 as a 1G direct-mapped DMA
-	 * window beginning at 1G.  We leave it alone.  Leave window
-	 * 0 alone until we reconfigure it for SGMAP-mapped DMA.
-	 * Windows 2 and 3 are already disabled.
+	 * The firmware will have set up window 1 as a 1G dirct-mapped
+	 * DMA window beginning at 1G.  While it's pretty safe to assume
+	 * this is the case, we'll go ahead and program the registers
+	 * as we expect as a belt-and-suspenders measure.
 	 */
+	REGVAL(CIA_PCI_W1BASE) = CIA_DIRECT_MAPPED_BASE | CIA_PCI_WnBASE_W_EN;
+	alpha_mb();
+	REGVAL(CIA_PCI_W1MASK) = CIA_PCI_WnMASK_1G;
+	alpha_mb();
+	REGVAL(CIA_PCI_T1BASE) = 0;
+	alpha_mb();
 
 	/*
 	 * Initialize the SGMAP(s).  Must align page table to at least 32k
@@ -248,6 +291,9 @@ cia_dma_init(struct cia_config *ccp)
 			panic("cia_dma_init: bad page table address");
 		REGVAL(CIA_PCI_T3BASE) = tbase;
 		alpha_mb();
+	} else {
+		REGVAL(CIA_PCI_W3BASE) = 0;
+		alpha_mb();
 	}
 
 	/*
@@ -261,7 +307,6 @@ cia_dma_init(struct cia_config *ccp)
 	 */
 	if ((ccp->cc_flags & CCF_ISPYXIS) != 0 && ccp->cc_rev <= 1) {
 		uint64_t *page_table;
-		int i;
 
 		cia_tlb_invalidate_fn =
 		cia_broken_pyxis_tlb_invalidate;
@@ -296,8 +341,12 @@ cia_dma_init(struct cia_config *ccp)
 			pci_sgmap_pte64_prefetch_spill_page_pte;
 		}
 		alpha_mb();
-	} else
+	} else {
+		REGVAL(CIA_PCI_W2BASE) = 0;
+		alpha_mb();
+
 		cia_tlb_invalidate_fn = cia_tlb_invalidate;
+	}
 
 	CIA_TLB_INVALIDATE();
 }

Index: src/sys/arch/alpha/pci/ciavar.h
diff -u src/sys/arch/alpha/pci/ciavar.h:1.21 src/sys/arch/alpha/pci/ciavar.h:1.22
--- src/sys/arch/alpha/pci/ciavar.h:1.21	Sat Jul 17 00:30:39 2021
+++ src/sys/arch/alpha/pci/ciavar.h	Mon Jul 19 01:06:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ciavar.h,v 1.21 2021/07/17 00:30:39 thorpej Exp $ */
+/* $NetBSD: ciavar.h,v 1.22 2021/07/19 01:06:14 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -65,6 +65,12 @@ struct cia_config {
 
 	struct extent *cc_io_ex, *cc_d_mem_ex, *cc_s_mem_ex;
 	int	cc_mallocsafe;
+
+	struct {
+	

CVS commit: src/sys/arch/alpha/pci

2021-07-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 18 19:58:34 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: tsp_dma.c

Log Message:
According to section 8.1.2.2 of the Tsunami/Typhoon hardware reference
manual (DS-0025A-TE), the SGMAP TLB is arranged as 168 locations of 4
consecutive quadwords.  It seems that on some revisions of the Pchip,
SGMAP translation is not perfectly reliable unless we align the DMA
segments to the TLBs natural boundaries (observed on the API CS20).

N.B. the Titan (as observed on a Compaq DS25) does not seem to have this
problem, but we'll play it safe and run this way on both variants.

PR port-alpha/40604.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/pci/tsp_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsp_dma.c
diff -u src/sys/arch/alpha/pci/tsp_dma.c:1.20 src/sys/arch/alpha/pci/tsp_dma.c:1.21
--- src/sys/arch/alpha/pci/tsp_dma.c:1.20	Sun Jul 18 05:09:47 2021
+++ src/sys/arch/alpha/pci/tsp_dma.c	Sun Jul 18 19:58:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tsp_dma.c,v 1.20 2021/07/18 05:09:47 thorpej Exp $ */
+/* $NetBSD: tsp_dma.c,v 1.21 2021/07/18 19:58:34 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.20 2021/07/18 05:09:47 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.21 2021/07/18 19:58:34 thorpej Exp $");
 
 #include 
 #include 
@@ -187,6 +187,20 @@ tsp_dma_init(struct tsp_config *pcp)
 		t->_next_window = NULL;
 		t->_boundary = 0;
 		t->_sgmap = >pc_sgmap_hi;
+		/*
+		 * According to section 8.1.2.2 of the Tsunami/Typhoon
+		 * hardware reference manual (DS-0025A-TE), the SGMAP
+		 * TLB is arranged as 168 locations of 4 consecutive
+		 * quadwords.  It seems that on some revisions of the
+		 * Pchip, SGMAP translation is not perfectly reliable
+		 * unless we align the DMA segments to the TLBs natural
+		 * boundaries (observed on the API CS20).
+		 *
+		 * N.B. the Titan (as observed on a Compaq DS25) does not
+		 * seem to have this problem, but we'll play it safe and
+		 * run this way on both variants.
+		 */
+		t->_sgmap_minalign = PAGE_SIZE * 4;
 		t->_pfthresh = TSP_SGMAP_PFTHRESH;
 		t->_get_tag = tsp_dma_get_tag;
 		t->_dmamap_create = alpha_sgmap_dmamap_create;
@@ -267,6 +281,11 @@ tsp_dma_init(struct tsp_config *pcp)
 	t->_next_window = NULL;
 	t->_boundary = 0;
 	t->_sgmap = >pc_sgmap_lo;
+	/*
+	 * This appears to be needed to make DMA on the ALI southbridge
+	 * that's present in some systems happy.  ???
+	 */
+	t->_sgmap_minalign = (64UL * 1024);
 	t->_pfthresh = TSP_SGMAP_PFTHRESH;
 	t->_get_tag = tsp_dma_get_tag;
 	t->_dmamap_create = alpha_sgmap_dmamap_create;



CVS commit: src/sys/arch/alpha/pci

2021-07-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 18 05:09:47 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: cia_dma.c tsp_dma.c

Log Message:
Oops, pass the correct bus_dma_tag_t to the "hi" sgmap init function.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/alpha/pci/cia_dma.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/pci/tsp_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/cia_dma.c
diff -u src/sys/arch/alpha/pci/cia_dma.c:1.35 src/sys/arch/alpha/pci/cia_dma.c:1.36
--- src/sys/arch/alpha/pci/cia_dma.c:1.35	Sat Jul 17 00:30:39 2021
+++ src/sys/arch/alpha/pci/cia_dma.c	Sun Jul 18 05:09:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_dma.c,v 1.35 2021/07/17 00:30:39 thorpej Exp $ */
+/* $NetBSD: cia_dma.c,v 1.36 2021/07/18 05:09:47 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.35 2021/07/17 00:30:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.36 2021/07/18 05:09:47 thorpej Exp $");
 
 #include 
 #include 
@@ -202,14 +202,14 @@ cia_dma_init(struct cia_config *ccp)
 	 */
 
 	/*
-	 * Initialize the SGMAP(s).  Must align page table to 32k
+	 * Initialize the SGMAP(s).  Must align page table to at least 32k
 	 * (hardware bug?).
 	 */
 	alpha_sgmap_init(t, >cc_sgmap_lo, "cia_sgmap_lo",
 	CIA_SGMAP_MAPPED_LO_BASE, 0, CIA_SGMAP_MAPPED_LO_SIZE,
 	sizeof(uint64_t), NULL, (32*1024));
 	if (t_sg_hi != NULL) {
-		alpha_sgmap_init(t, >cc_sgmap_hi, "cia_sgmap_hi",
+		alpha_sgmap_init(t_sg_hi, >cc_sgmap_hi, "cia_sgmap_hi",
 		CIA_SGMAP_MAPPED_HI_BASE, 0, CIA_SGMAP_MAPPED_HI_SIZE,
 		sizeof(uint64_t), NULL, (32*1024));
 	}

Index: src/sys/arch/alpha/pci/tsp_dma.c
diff -u src/sys/arch/alpha/pci/tsp_dma.c:1.19 src/sys/arch/alpha/pci/tsp_dma.c:1.20
--- src/sys/arch/alpha/pci/tsp_dma.c:1.19	Sun Jul 18 00:01:20 2021
+++ src/sys/arch/alpha/pci/tsp_dma.c	Sun Jul 18 05:09:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tsp_dma.c,v 1.19 2021/07/18 00:01:20 thorpej Exp $ */
+/* $NetBSD: tsp_dma.c,v 1.20 2021/07/18 05:09:47 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.19 2021/07/18 00:01:20 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.20 2021/07/18 05:09:47 thorpej Exp $");
 
 #include 
 #include 
@@ -292,7 +292,7 @@ tsp_dma_init(struct tsp_config *pcp)
 	TSP_SGMAP_MAPPED_LO_BASE, 0, TSP_SGMAP_MAPPED_LO_SIZE,
 	sizeof(uint64_t), NULL, (32*1024));
 	if (t_sg_hi != NULL) {
-		alpha_sgmap_init(t, >pc_sgmap_hi, "tsp_sgmap_hi",
+		alpha_sgmap_init(t_sg_hi, >pc_sgmap_hi, "tsp_sgmap_hi",
 		TSP_SGMAP_MAPPED_HI_BASE, 0, TSP_SGMAP_MAPPED_HI_SIZE,
 		sizeof(uint64_t), NULL, (32*1024));
 	}



CVS commit: src/sys/arch/alpha/pci

2021-07-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 18 00:01:21 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: tsp_dma.c tsvar.h

Log Message:
- Don't bother issuing a warning if we program the WBASE / WSM register
  to different values than the firmware.
- Reduce the differences in how we initialize the DMA tags vis a vis the
  other Alpha implementations.
- Use Window 2 to provide a 1G @ 3G PCI SGMAP window on systems with more
  than 1G of RAM, rather than falling back on the ISA DMA window which is
  small and could get starved by PCI devices.
- Make sure we set TBASE to 0 for direct-mapped windows.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/pci/tsp_dma.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/alpha/pci/tsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsp_dma.c
diff -u src/sys/arch/alpha/pci/tsp_dma.c:1.18 src/sys/arch/alpha/pci/tsp_dma.c:1.19
--- src/sys/arch/alpha/pci/tsp_dma.c:1.18	Sun Jul  4 22:42:36 2021
+++ src/sys/arch/alpha/pci/tsp_dma.c	Sun Jul 18 00:01:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tsp_dma.c,v 1.18 2021/07/04 22:42:36 thorpej Exp $ */
+/* $NetBSD: tsp_dma.c,v 1.19 2021/07/18 00:01:20 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2021 The NetBSD Foundation, Inc.
@@ -61,13 +61,15 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.18 2021/07/04 22:42:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 1.19 2021/07/18 00:01:20 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
 
+#include 
+
 #include 
 #define _ALPHA_BUS_DMA_PRIVATE
 #include 
@@ -80,8 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: tsp_dma.c,v 
 
 #define tsp_dma() { Generate ctags(1) key. }
 
-#define	EDIFF(a, b) (((a) | WSBA_ENA | WSBA_SG)	!= ((b) | WSBA_ENA | WSBA_SG))
-
 static bus_dma_tag_t tsp_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
 
 static int	tsp_bus_dmamap_load_sgmap(bus_dma_tag_t, bus_dmamap_t, void *,
@@ -126,53 +126,93 @@ static void	tsp_tlb_invalidate(struct ts
  * 64-bit DMA tag.  This leaves us possibly having to fall back on SGMAP
  * DMA on a Titan system (those support up to 64GB of RAM), and we may have
  * to address that with an additional large SGMAP DAC window at another
- * time.
+ * time.  XXX Does the Titan Monster Window support the extra bit?
  */
 #define	TSP_MONSTER_DMA_WINDOW_BASE	0x100##UL
 #define	TSP_MONSTER_DMA_WINDOW_SIZE	0x008##UL
 
+/*
+ * Basic 24-bit ISA DMA window is 8MB @ 8MB.  The firmware will
+ * have set this up in Window 0.
+ */
+#define	TSP_SGMAP_MAPPED_LO_BASE	(8UL * 1024 * 1024)
+#define	TSP_SGMAP_MAPPED_LO_SIZE	(8UL * 1024 * 1024)
+
+/*
+ * Basic 32-bit PCI DMA window is 1GB @ 2GB.  The firmware will
+ * have set this up in Window 1.
+ */
+#define	TSP_DIRECT_MAPPED_BASE		(2UL * 1024 * 1024 * 1024)
+#define	TSP_DIRECT_MAPPED_SIZE		(1UL * 1024 * 1024 * 1024)
+
+/*
+ * For systems that have > 1GB of RAM, but PCI devices that don't
+ * support dual-address cycle, we will also set up an additional
+ * SGMAP DMA window 1GB @ 3GB.  We will use Window 2 for this purpose.
+ */
+#define	TSP_SGMAP_MAPPED_HI_BASE	(3UL * 1024 * 1024 * 1024)
+#define	TSP_SGMAP_MAPPED_HI_SIZE	(1UL * 1024 * 1024 * 1024)
+
+/*
+ * Window 3 is still available for use in the future.  Window 3 supports
+ * dual address cycle.
+ */
+
 void
 tsp_dma_init(struct tsp_config *pcp)
 {
-	int i;
 	bus_dma_tag_t t;
+	bus_dma_tag_t t_sg_hi = NULL;
 	struct ts_pchip *pccsr = pcp->pc_csr;
-	bus_addr_t dwbase, dwlen, sgwbase, sgwlen, tbase;
-	static struct map_expected {
-		uint32_t base, mask, enables;
-	} premap[4] = {
-		{ 0x0080, 0x0070, WSBA_ENA | WSBA_SG },
-		{ 0x8000, 0x3ff0, WSBA_ENA   },
-		{ 0, 0, 0 },
-		{ 0, 0, 0 }
-	};
-
-	alpha_mb();
-	for(i = 0; i < 4; ++i) {
-		if (EDIFF(pccsr->tsp_wsba[i].tsg_r, premap[i].base) ||
-		EDIFF(pccsr->tsp_wsm[i].tsg_r, premap[i].mask))
-			printf("tsp%d: window %d: %lx/base %lx/mask %lx"
-			" reinitialized\n",
-			pcp->pc_pslot, i,
-			pccsr->tsp_wsba[i].tsg_r,
-			pccsr->tsp_wsm[i].tsg_r,
-			pccsr->tsp_tba[i].tsg_r);
-		pccsr->tsp_wsba[i].tsg_r = premap[i].base | premap[i].enables;
-		pccsr->tsp_wsm[i].tsg_r = premap[i].mask;
-	}
+	bus_addr_t tbase;
 
 	/* Ensure the Monster Window is enabled. */
+	alpha_mb();
 	pccsr->tsp_pctl.tsg_r |= PCTL_MWIN;
 	alpha_mb();
 
 	/*
+	 * If we have more than 1GB of RAM, then set up an sgmap-mapped
+	 * DMA window for non-DAC PCI.  This is better than using the ISA
+	 * window, which is pretty small and PCI devices could starve it.
+	 *
+	 * N.B. avail_end is "last-usable PFN + 1".
+	 */
+	if (uvm_physseg_get_avail_end(uvm_physseg_get_last()) >
+	atop(TSP_DIRECT_MAPPED_SIZE)) {
+		t = t_sg_hi = >pc_dmat_sgmap_hi;
+		t->_cookie = pcp;
+		t->_wbase = TSP_SGMAP_MAPPED_HI_BASE;
+		t->_wsize = TSP_SGMAP_MAPPED_HI_SIZE;
+		t->_next_window = NULL;
+		

CVS commit: src/sys/arch/alpha/pci

2021-07-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jul 17 23:53:02 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: tsreg.h

Log Message:
- Define the DAC enable bit that's present in WSBA3.
- Define symbolic constants for the valid WSM values.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/pci/tsreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsreg.h
diff -u src/sys/arch/alpha/pci/tsreg.h:1.9 src/sys/arch/alpha/pci/tsreg.h:1.10
--- src/sys/arch/alpha/pci/tsreg.h:1.9	Thu May 27 22:11:31 2021
+++ src/sys/arch/alpha/pci/tsreg.h	Sat Jul 17 23:53:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tsreg.h,v 1.9 2021/05/27 22:11:31 thorpej Exp $ */
+/* $NetBSD: tsreg.h,v 1.10 2021/07/17 23:53:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -150,14 +150,29 @@
 #define P_WSBA3		0x00c0
 
 #	define	WSBA_ADDR(r) (TSFIELDBB((r), 31, 20) << 20)
-#	define	WSBA_SG	 2
-#	define	WSBA_ENA 1
+#	define	WSBA3_DAC__BIT(39)
+#	define	WSBA_SG	 __BIT(1)
+#	define	WSBA_ENA __BIT(0)
 
 #define P_WSM0		0x0100
 #define P_WSM1		0x0140
 #define P_WSM2		0x0180
 #define P_WSM3		0x01c0
 
+#	define	WSM_1MB  (0x000UL << 20)
+#	define	WSM_2MB  (0x001UL << 20)
+#	define	WSM_4MB  (0x003UL << 20)
+#	define	WSM_8MB  (0x007UL << 20)
+#	define	WSM_16MB (0x00fUL << 20)
+#	define	WSM_32MB (0x01fUL << 20)
+#	define	WSM_64MB (0x03fUL << 20)
+#	define	WSM_128MB(0x07fUL << 20)
+#	define	WSM_256MB(0x0ffUL << 20)
+#	define	WSM_512MB(0x1ffUL << 20)
+#	define	WSM_1GB  (0x3ffUL << 20)
+#	define	WSM_2GB  (0x7ffUL << 20)
+/*#	define	WSM_4GB  N/A		monster window / DAC only */
+
 #	define	WSM_AM(r)TSFIELDBB((r), 31, 20)
 #	define	WSM_LEN(r)   ((WSM_AM(r) + 1) << 20)
 



CVS commit: src/sys/arch/alpha/pci

2021-07-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jul 17 00:30:39 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: cia_dma.c ciavar.h

Log Message:
Back in rev 1.21, mhitch@ fixed an issue with his 1.5GB RAM PWS 500au
by using a fall-back to the ISA DMA window if DMA was out of range for
the 1G @ 1G PCI DMA window.  Alas, the ISA DMA window is pretty small
(8M @ 8M), and it's possible to starve it with PCI devices that might
have, for example, large control data structures there.

So, instead, if the system has more than 1G of RAM, use Window 3
(previously unused) as a SGMAP window 1G @ 3G, and set that as the
fall-back if the direct-mapped window fails.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/alpha/pci/cia_dma.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/pci/ciavar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/cia_dma.c
diff -u src/sys/arch/alpha/pci/cia_dma.c:1.34 src/sys/arch/alpha/pci/cia_dma.c:1.35
--- src/sys/arch/alpha/pci/cia_dma.c:1.34	Sun Jul  4 22:42:36 2021
+++ src/sys/arch/alpha/pci/cia_dma.c	Sat Jul 17 00:30:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_dma.c,v 1.34 2021/07/04 22:42:36 thorpej Exp $ */
+/* $NetBSD: cia_dma.c,v 1.35 2021/07/17 00:30:39 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.34 2021/07/04 22:42:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.35 2021/07/17 00:30:39 thorpej Exp $");
 
 #include 
 #include 
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 
 #define _ALPHA_BUS_DMA_PRIVATE
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -69,14 +71,20 @@ static void	cia_bus_dmamap_unload_sgmap(
 /*
  * Direct-mapped window: 1G at 1G
  */
-#define	CIA_DIRECT_MAPPED_BASE	(1*1024*1024*1024)
-#define	CIA_DIRECT_MAPPED_SIZE	(1*1024*1024*1024)
+#define	CIA_DIRECT_MAPPED_BASE	(1UL*1024*1024*1024)
+#define	CIA_DIRECT_MAPPED_SIZE	(1UL*1024*1024*1024)
+
+/*
+ * SGMAP window for ISA: 8M at 8M
+ */
+#define	CIA_SGMAP_MAPPED_LO_BASE (8UL*1024*1024)
+#define	CIA_SGMAP_MAPPED_LO_SIZE (8UL*1024*1024)
 
 /*
- * SGMAP window: 8M at 8M
+ * SGMAP window for PCI: 1G at 3G
  */
-#define	CIA_SGMAP_MAPPED_BASE	(8*1024*1024)
-#define	CIA_SGMAP_MAPPED_SIZE	(8*1024*1024)
+#define	CIA_SGMAP_MAPPED_HI_BASE (3UL*1024*1024*1024)
+#define	CIA_SGMAP_MAPPED_HI_SIZE (1UL*1024*1024*1024)
 
 /* ALCOR/ALGOR2/PYXIS have a 256-byte out-bound DMA prefetch threshold. */
 #define	CIA_SGMAP_PFTHRESH	256
@@ -89,14 +97,49 @@ static void	(*cia_tlb_invalidate_fn)(voi
 #define	CIA_TLB_INVALIDATE()	(*cia_tlb_invalidate_fn)()
 
 struct alpha_sgmap cia_pyxis_bug_sgmap;
-#define	CIA_PYXIS_BUG_BASE	(128*1024*1024)
-#define	CIA_PYXIS_BUG_SIZE	(2*1024*1024)
+#define	CIA_PYXIS_BUG_BASE	(128UL*1024*1024)
+#define	CIA_PYXIS_BUG_SIZE	(2UL*1024*1024)
 
 void
 cia_dma_init(struct cia_config *ccp)
 {
 	bus_addr_t tbase;
 	bus_dma_tag_t t;
+	bus_dma_tag_t t_sg_hi = NULL;
+
+	/*
+	 * If we have more than 1GB of RAM, then set up an sgmap-mapped
+	 * DMA window for PCI.  This is better than using the ISA window,
+	 * which is pretty small and PCI devices could starve it.
+	 *
+	 * N.B. avail_end is "last-usable PFN + 1".
+	 */
+	if (uvm_physseg_get_avail_end(uvm_physseg_get_last()) >
+	atop(CIA_DIRECT_MAPPED_SIZE)) {
+		t = t_sg_hi = >cc_dmat_sgmap_hi;
+		t->_cookie = ccp;
+		t->_wbase = CIA_SGMAP_MAPPED_HI_BASE;
+		t->_wsize = CIA_SGMAP_MAPPED_HI_SIZE;
+		t->_next_window = NULL;
+		t->_boundary = 0;
+		t->_sgmap = >cc_sgmap_hi;
+		t->_pfthresh = CIA_SGMAP_PFTHRESH;
+		t->_get_tag = cia_dma_get_tag;
+		t->_dmamap_create = alpha_sgmap_dmamap_create;
+		t->_dmamap_destroy = alpha_sgmap_dmamap_destroy;
+		t->_dmamap_load = cia_bus_dmamap_load_sgmap;
+		t->_dmamap_load_mbuf = cia_bus_dmamap_load_mbuf_sgmap;
+		t->_dmamap_load_uio = cia_bus_dmamap_load_uio_sgmap;
+		t->_dmamap_load_raw = cia_bus_dmamap_load_raw_sgmap;
+		t->_dmamap_unload = cia_bus_dmamap_unload_sgmap;
+		t->_dmamap_sync = _bus_dmamap_sync;
+
+		t->_dmamem_alloc = _bus_dmamem_alloc;
+		t->_dmamem_free = _bus_dmamem_free;
+		t->_dmamem_map = _bus_dmamem_map;
+		t->_dmamem_unmap = _bus_dmamem_unmap;
+		t->_dmamem_mmap = _bus_dmamem_mmap;
+	}
 
 	/*
 	 * Initialize the DMA tag used for direct-mapped DMA.
@@ -105,7 +148,7 @@ cia_dma_init(struct cia_config *ccp)
 	t->_cookie = ccp;
 	t->_wbase = CIA_DIRECT_MAPPED_BASE;
 	t->_wsize = CIA_DIRECT_MAPPED_SIZE;
-	t->_next_window = >cc_dmat_sgmap;
+	t->_next_window = t_sg_hi;
 	t->_boundary = 0;
 	t->_sgmap = NULL;
 	t->_get_tag = cia_dma_get_tag;
@@ -125,15 +168,15 @@ cia_dma_init(struct cia_config *ccp)
 	t->_dmamem_mmap = _bus_dmamem_mmap;
 
 	/*
-	 * Initialize the DMA tag used for sgmap-mapped DMA.
+	 * Initialize the DMA tag used for sgmap-mapped ISA DMA.
 	 */
-	t = 

CVS commit: src/sys/arch/alpha/pci

2021-07-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 16 17:09:33 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: lcareg.h

Log Message:
Define the memory controller registers, and contents for the Cache
register.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/pci/lcareg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/lcareg.h
diff -u src/sys/arch/alpha/pci/lcareg.h:1.9 src/sys/arch/alpha/pci/lcareg.h:1.10
--- src/sys/arch/alpha/pci/lcareg.h:1.9	Mon Feb  6 02:14:14 2012
+++ src/sys/arch/alpha/pci/lcareg.h	Fri Jul 16 17:09:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lcareg.h,v 1.9 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: lcareg.h,v 1.10 2021/07/16 17:09:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
@@ -37,12 +37,52 @@
 /*
  * Base addresses
  */
+#define	LCA_MEMC_BASE	0x12000L		/* LCA memory controller regs */
 #define LCA_IOC_BASE	0x18000L		/* LCA IOC Regs */
 #define LCA_PCI_SIO	0x1c000L		/* PCI Sp. I/O Space */
 #define LCA_PCI_CONF	0x1e000L		/* PCI Conf. Space */
 #define LCA_PCI_SPARSE	0x2L		/* PCI Sparse Space */
 #define LCA_PCI_DENSE	0x3L		/* PCI Dense Space */
 
+#define LCA_MEMC_BCR0	(LCA_MEMC_BASE + 0x00)	/* Bank Configuration 0 */
+#define LCA_MEMC_BCR1	(LCA_MEMC_BASE + 0x08)	/* Bank Configuration 1 */
+#define LCA_MEMC_BCR2	(LCA_MEMC_BASE + 0x10)	/* Bank Configuration 2 */
+#define LCA_MEMC_BCR3	(LCA_MEMC_BASE + 0x18)	/* Bank Configuration 3 */
+#define LCA_MEMC_BMR0	(LCA_MEMC_BASE + 0x20)	/* Bank Address Mask 0 */
+#define LCA_MEMC_BMR1	(LCA_MEMC_BASE + 0x28)	/* Bank Address Mask 1 */
+#define LCA_MEMC_BMR2	(LCA_MEMC_BASE + 0x30)	/* Bank Address Mask 2 */
+#define LCA_MEMC_BMR3	(LCA_MEMC_BASE + 0x38)	/* Bank Address Mask 3 */
+#define LCA_MEMC_BTR0	(LCA_MEMC_BASE + 0x40)	/* Bank Timing 0 */
+#define LCA_MEMC_BTR1	(LCA_MEMC_BASE + 0x48)	/* Bank Timing 1 */
+#define LCA_MEMC_BTR2	(LCA_MEMC_BASE + 0x50)	/* Bank Timing 2 */
+#define LCA_MEMC_BTR3	(LCA_MEMC_BASE + 0x58)	/* Bank Timing 3 */
+#define LCA_MEMC_GTR	(LCA_MEMC_BASE + 0x60)	/* Global Timing */
+#define LCA_MEMC_ESR	(LCA_MEMC_BASE + 0x68)	/* Error Status */
+#define LCA_MEMC_EAR	(LCA_MEMC_BASE + 0x70)	/* Error Address */
+#define LCA_MEMC_CAR	(LCA_MEMC_BASE + 0x78)	/* Cache */
+#define LCA_MEMC_VGR	(LCA_MEMC_BASE + 0x80)	/* Video and Graphics Control */
+#define LCA_MEMC_PLM	(LCA_MEMC_BASE + 0x88)	/* Plane mask */
+#define LCA_MEMC_FOR	(LCA_MEMC_BASE + 0x90)	/* Foreground */
+
+#define MEMC_CAR_BCE	__BIT(0)	/* Bcache enable */
+#define MEMC_CAR_ETP	__BIT(2)	/* Enable tag parity check */
+#define MEMC_CAR_WWP	__BIT(3)	/* Write wrong tag parity */
+#define MEMC_CAR_ECE	__BIT(4)	/* Enable Bcache ECC */
+#define MEMC_CAR_BCS	__BITS(5,7)	/* Bcache size */
+#define MEMC_CAR_RCC	__BITS(8,10)	/* Read Cycle Count */
+#define MEMC_CAR_WCC	__BITS(11,13)	/* Write Cycle Count */
+#define MEMC_CAR_WHD	__BIT(14)	/* Write Hold Time */
+#define MEMC_CAR_PWR	__BIT(15)	/* Power Saving */
+#define MEMC_CAR_TAG	__BITS(16,30)	/* latched Bcache tag value */
+#define MEMC_CAR_HIT	__BIT(31)	/* Bcache hit */
+
+#define BCS_64K		0
+#define BCS_128K	1
+#define BCS_256K	2
+#define BCS_512K	3
+#define BCS_1M		4
+#define BCS_2M		5
+
 #define LCA_IOC_HAE	LCA_IOC_BASE		/* Host Address Ext. (64) */
 #define	IOC_HAE_ADDREXT	0xf800UL
 #define	IOC_HAE_RSVSD	0x07ffUL



CVS commit: src/sys/arch/alpha/pci

2021-07-14 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 15 01:29:23 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: sio_pic.c

Log Message:
- Use defined constants for PIC registers, not magic numbers.
- Inline specific_eoi().

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/alpha/pci/sio_pic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/sio_pic.c
diff -u src/sys/arch/alpha/pci/sio_pic.c:1.52 src/sys/arch/alpha/pci/sio_pic.c:1.53
--- src/sys/arch/alpha/pci/sio_pic.c:1.52	Sun Jul  4 22:42:36 2021
+++ src/sys/arch/alpha/pci/sio_pic.c	Thu Jul 15 01:29:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sio_pic.c,v 1.52 2021/07/04 22:42:36 thorpej Exp $ */
+/* $NetBSD: sio_pic.c,v 1.53 2021/07/15 01:29:23 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2020 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.52 2021/07/04 22:42:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.53 2021/07/15 01:29:23 thorpej Exp $");
 
 #include 
 #include 
@@ -78,6 +78,8 @@ __KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 
@@ -150,7 +152,7 @@ i82378_setup_elcr(void)
 	 * fall-back in case nothing else matches.
 	 */
 
-	rv = bus_space_map(sio_iot, 0x4d0, 2, 0, _ioh_elcr);
+	rv = bus_space_map(sio_iot, SIO_REG_ICU1ELC, 2, 0, _ioh_elcr);
 
 	if (rv == 0) {
 		sio_read_elcr = i82378_read_elcr;
@@ -270,6 +272,17 @@ static int (*const sio_elcr_setup_funcs[
 
 / Shared SIO/Cypress functions /
 
+static inline void
+specific_eoi(int irq)
+{
+	if (irq > 7) {
+		bus_space_write_1(sio_iot, sio_ioh_icu2, PIC_OCW2,
+		OCW2_EOI | OCW2_SL | (irq & 0x07));	/* XXX */
+	}
+	bus_space_write_1(sio_iot, sio_ioh_icu1, PIC_OCW2,
+	OCW2_EOI | OCW2_SL | (irq > 7 ? 2 : irq));
+}
+
 static void
 sio_setirqstat(int irq, int enabled, int type)
 {
@@ -284,8 +297,8 @@ sio_setirqstat(int irq, int enabled, int
 	icu = irq / 8;
 	bit = irq % 8;
 
-	ocw1[0] = bus_space_read_1(sio_iot, sio_ioh_icu1, 1);
-	ocw1[1] = bus_space_read_1(sio_iot, sio_ioh_icu2, 1);
+	ocw1[0] = bus_space_read_1(sio_iot, sio_ioh_icu1, PIC_OCW1);
+	ocw1[1] = bus_space_read_1(sio_iot, sio_ioh_icu2, PIC_OCW1);
 	elcr[0] = (*sio_read_elcr)(0);/* XXX */
 	elcr[1] = (*sio_read_elcr)(1);/* XXX */
 
@@ -730,12 +743,3 @@ sio_intr_alloc(void *v, int mask, int ty
 
 	return (0);
 }
-
-static void
-specific_eoi(int irq)
-{
-	if (irq > 7)
-		bus_space_write_1(sio_iot,
-		sio_ioh_icu2, 0, 0x60 | (irq & 0x07));	/* XXX */
-	bus_space_write_1(sio_iot, sio_ioh_icu1, 0, 0x60 | (irq > 7 ? 2 : irq));
-}



CVS commit: src/sys/arch/alpha/pci

2021-06-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 13:41:34 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: pci_2100_a50.c pci_axppci_33.c sio_pic.c
siovar.h

Log Message:
Reduce code duplication among platforms that use the i82378 SIO to
route PCI interrupts to the ISA PIC by refactoring it into a new
sio_pirq_intr_map() function.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/alpha/pci/pci_2100_a50.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/alpha/pci/pci_axppci_33.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/alpha/pci/sio_pic.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/alpha/pci/siovar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_2100_a50.c
diff -u src/sys/arch/alpha/pci/pci_2100_a50.c:1.43 src/sys/arch/alpha/pci/pci_2100_a50.c:1.44
--- src/sys/arch/alpha/pci/pci_2100_a50.c:1.43	Sat Jun 19 16:59:07 2021
+++ src/sys/arch/alpha/pci/pci_2100_a50.c	Fri Jun 25 13:41:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_2100_a50.c,v 1.43 2021/06/19 16:59:07 thorpej Exp $ */
+/* $NetBSD: pci_2100_a50.c,v 1.44 2021/06/25 13:41:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_2100_a50.c,v 1.43 2021/06/19 16:59:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_2100_a50.c,v 1.44 2021/06/25 13:41:33 thorpej Exp $");
 
 #include 
 #include 
@@ -57,21 +57,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_2100_a50
 static int	dec_2100_a50_intr_map(const struct pci_attach_args *,
 		pci_intr_handle_t *);
 
-#define	APECS_SIO_DEVICE	7	/* XXX */
-
 static void
 pci_2100_a50_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt,
 pci_chipset_tag_t pc)
 {
-	pcireg_t sioclass;
-	int sioII;
-
-	/* XXX MAGIC NUMBER */
-	sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, 7, 0), PCI_CLASS_REG);
-	sioII = (sioclass & 0xff) >= 3;
-
-	if (!sioII)
-		printf("WARNING: SIO NOT SIO II... NO BETS...\n");
 
 	pc->pc_intr_v = core;
 	pc->pc_intr_map = dec_2100_a50_intr_map;
@@ -98,8 +87,6 @@ dec_2100_a50_intr_map(const struct pci_a
 	int buspin = pa->pa_intrpin;
 	pci_chipset_tag_t pc = pa->pa_pc;
 	int device, pirq;
-	pcireg_t pirqreg;
-	uint8_t pirqline;
 
 #ifndef DIAGNOSTIC
 	pirq = 0;/* XXX gcc -Wuninitialized */
@@ -189,22 +176,10 @@ dec_2100_a50_intr_map(const struct pci_a
 	return 1;
 	}
 
-	pirqreg = pci_conf_read(pc, pci_make_tag(pc, 0, APECS_SIO_DEVICE, 0),
-	SIO_PCIREG_PIRQ_RTCTRL);
-#if 0
-	printf("pci_2100_a50_intr_map: device %d pin %c: pirq %d, reg = %x\n",
-		device, '@' + buspin, pirq, pirqreg);
-#endif
-	pirqline = (pirqreg >> (pirq * 8)) & 0xff;
-	if ((pirqline & 0x80) != 0)
-		return 1;
-	pirqline &= 0xf;
-
 #if 0
-	printf("pci_2100_a50_intr_map: device %d pin %c: mapped to line %d\n",
-	device, '@' + buspin, pirqline);
+	printf("pci_2100_a50_intr_map: device %d pin %c: pirq %d\n",
+		device, '@' + buspin, pirq);
 #endif
 
-	alpha_pci_intr_handle_init(ihp, pirqline, 0);
-	return (0);
+	return sio_pirq_intr_map(pc, pirq, ihp);
 }

Index: src/sys/arch/alpha/pci/pci_axppci_33.c
diff -u src/sys/arch/alpha/pci/pci_axppci_33.c:1.40 src/sys/arch/alpha/pci/pci_axppci_33.c:1.41
--- src/sys/arch/alpha/pci/pci_axppci_33.c:1.40	Sat Jun 19 16:59:07 2021
+++ src/sys/arch/alpha/pci/pci_axppci_33.c	Fri Jun 25 13:41:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_axppci_33.c,v 1.40 2021/06/19 16:59:07 thorpej Exp $ */
+/* $NetBSD: pci_axppci_33.c,v 1.41 2021/06/25 13:41:33 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_axppci_33.c,v 1.40 2021/06/19 16:59:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_axppci_33.c,v 1.41 2021/06/25 13:41:33 thorpej Exp $");
 
 #include 
 #include 
@@ -57,22 +57,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_axppci_3
 static int	dec_axppci_33_intr_map(const struct pci_attach_args *,
 		pci_intr_handle_t *);
 
-#define	LCA_SIO_DEVICE	7	/* XXX */
-
 static void
 pci_axppci_33_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt,
 pci_chipset_tag_t pc)
 {
-	pcireg_t sioclass;
-	int sioII;
-
-	/* XXX MAGIC NUMBER */
-	sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0),
-	PCI_CLASS_REG);
-	sioII = (sioclass & 0xff) >= 3;
-
-	if (!sioII)
-		printf("WARNING: SIO NOT SIO II... NO BETS...\n");
 
 	pc->pc_intr_v = core;
 	pc->pc_intr_map = dec_axppci_33_intr_map;
@@ -99,8 +87,6 @@ dec_axppci_33_intr_map(const struct pci_
 	int buspin = pa->pa_intrpin;
 	pci_chipset_tag_t pc = pa->pa_pc;
 	int device, pirq;
-	pcireg_t pirqreg;
-	uint8_t pirqline;
 
 #ifndef DIAGNOSTIC
 	pirq = 0;/* XXX gcc -Wuninitialized */
@@ -189,22 +175,10 @@ dec_axppci_33_intr_map(const struct pci_
 	return 1;
 	}
 
-	pirqreg = 

CVS commit: src/sys/arch/alpha/pci

2021-06-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 13:38:21 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: pci_alphabook1.c

Log Message:
Remove pointless warning.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/pci/pci_alphabook1.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_alphabook1.c
diff -u src/sys/arch/alpha/pci/pci_alphabook1.c:1.19 src/sys/arch/alpha/pci/pci_alphabook1.c:1.20
--- src/sys/arch/alpha/pci/pci_alphabook1.c:1.19	Sat Jun 19 16:59:07 2021
+++ src/sys/arch/alpha/pci/pci_alphabook1.c	Fri Jun 25 13:38:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_alphabook1.c,v 1.19 2021/06/19 16:59:07 thorpej Exp $ */
+/* $NetBSD: pci_alphabook1.c,v 1.20 2021/06/25 13:38:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_alphabook1.c,v 1.19 2021/06/19 16:59:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_alphabook1.c,v 1.20 2021/06/25 13:38:21 thorpej Exp $");
 
 #include 
 #include 
@@ -85,22 +85,10 @@ __KERNEL_RCSID(0, "$NetBSD: pci_alphaboo
 static int	dec_alphabook1_intr_map(const struct pci_attach_args *,
 		pci_intr_handle_t *);
 
-#define	LCA_SIO_DEVICE	7	/* XXX */
-
 static void
 pci_alphabook1_pickintr(void *core, bus_space_tag_t iot, bus_space_tag_t memt,
 pci_chipset_tag_t pc)
 {
-	pcireg_t sioclass;
-	int sioII;
-
-	/* XXX MAGIC NUMBER */
-	sioclass = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0),
-	PCI_CLASS_REG);
-	sioII = (sioclass & 0xff) >= 3;
-
-	if (!sioII)
-		printf("WARNING: SIO NOT SIO II... NO BETS...\n");
 
 	pc->pc_intr_v = core;
 	pc->pc_intr_map = dec_alphabook1_intr_map;



CVS commit: src/sys/arch/alpha/pci

2021-06-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 13:32:39 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: sioreg.h

Log Message:
Define macros to desribe the PIRQ_RTCTRL register(s).


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/alpha/pci/sioreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/sioreg.h
diff -u src/sys/arch/alpha/pci/sioreg.h:1.2 src/sys/arch/alpha/pci/sioreg.h:1.3
--- src/sys/arch/alpha/pci/sioreg.h:1.2	Mon Apr  7 02:00:07 1997
+++ src/sys/arch/alpha/pci/sioreg.h	Fri Jun 25 13:32:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sioreg.h,v 1.2 1997/04/07 02:00:07 cgd Exp $ */
+/* $NetBSD: sioreg.h,v 1.3 2021/06/25 13:32:39 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996 BBN Corporation.
@@ -83,6 +83,13 @@
 #define	SIO_PCIREG_PIRQ3	0x63	/* PIRQ3 Route Control */
 #define	SIO_PCIREG_PIRQ_RTCTRL	SIO_PCIREG_PIRQ0
 
+	/* extract the PIRQx field from 32-bit reg */
+#define	PIRQ_RTCTRL_PIRQx(r, p)	(((r) >> ((p) * 8)) & 0xff)
+
+	/* bits within each PIRQx field */
+#define	PIRQ_RTCTRL_NOT_ROUTED	__BIT(7)/* 0 == interrupt routed */
+#define	PIRQ_RTCTRL_IRQ		__BITS(0,3) /* PIRQ routed to this ISA IRQ */
+
 /*
  * System Management Interrupt (SMI)
  */



CVS commit: src/sys/arch/alpha/pci

2021-06-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 03:52:41 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: lca_pci.c

Log Message:
- Use the default implementations of attach_hook(), make_tag(), and
  decompose_tag().
- In lca_bus_maxdevs(), only allow devices 0-15 on bus #0.
- Re-factor some duplicated code into lca_make_type0addr().


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/alpha/pci/lca_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/lca_pci.c
diff -u src/sys/arch/alpha/pci/lca_pci.c:1.23 src/sys/arch/alpha/pci/lca_pci.c:1.24
--- src/sys/arch/alpha/pci/lca_pci.c:1.23	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/lca_pci.c	Fri Jun 25 03:52:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lca_pci.c,v 1.23 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: lca_pci.c,v 1.24 2021/06/25 03:52:41 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lca_pci.c,v 1.23 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lca_pci.c,v 1.24 2021/06/25 03:52:41 thorpej Exp $");
 
 #include 
 #include 
@@ -41,11 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: lca_pci.c,v 
 #include 
 #include 
 
-static void	lca_attach_hook(device_t, device_t,
-		struct pcibus_attach_args *);
 static int	lca_bus_maxdevs(void *, int);
-static pcitag_t	lca_make_tag(void *, int, int, int);
-static void	lca_decompose_tag(void *, pcitag_t, int *, int *, int *);
 static pcireg_t	lca_conf_read(void *, pcitag_t, int);
 static void	lca_conf_write(void *, pcitag_t, int, pcireg_t);
 
@@ -54,46 +50,26 @@ lca_pci_init(pci_chipset_tag_t pc, void 
 {
 
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = lca_attach_hook;
 	pc->pc_bus_maxdevs = lca_bus_maxdevs;
-	pc->pc_make_tag = lca_make_tag;
-	pc->pc_decompose_tag = lca_decompose_tag;
 	pc->pc_conf_read = lca_conf_read;
 	pc->pc_conf_write = lca_conf_write;
 }
 
-static void
-lca_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba)
-{
-}
-
 static int
 lca_bus_maxdevs(void *cpv, int busno)
 {
-
-	if (busno == 0)
-		return 16;
-	else
-		return 32;
+	/*
+	 * We have to drive the IDSEL directly on bus 0, so we are
+	 * limited to 16 devices there.
+	 */
+	return busno == 0 ? 16 : 32;
 }
 
-static pcitag_t
-lca_make_tag(void *cpv, int b, int d, int f)
+static paddr_t
+lca_make_type0addr(int d, int f)
 {
-
-	return (b << 16) | (d << 11) | (f << 8);
-}
-
-static void
-lca_decompose_tag(void *cpv, pcitag_t tag, int *bp, int *dp, int *fp)
-{
-
-	if (bp != NULL)
-		*bp = (tag >> 16) & 0xff;
-	if (dp != NULL)
-		*dp = (tag >> 11) & 0x1f;
-	if (fp != NULL)
-		*fp = (tag >> 8) & 0x7;
+	KASSERT(d < 16);
+	return PCI_CONF_TYPE0_IDSEL(d) | __SHIFTIN(f, PCI_CONF_TYPE0_FUNCTION);
 }
 
 static pcireg_t
@@ -101,7 +77,8 @@ lca_conf_read(void *cpv, pcitag_t tag, i
 {
 	struct lca_config *lcp = cpv;
 	pcireg_t *datap, data;
-	int s, secondary, device, ba;
+	paddr_t confaddr;
+	int s, secondary, d, f, ba;
 
 	if ((unsigned int)offset >= PCI_CONF_SIZE)
 		return (pcireg_t) -1;
@@ -109,24 +86,19 @@ lca_conf_read(void *cpv, pcitag_t tag, i
 	s = 0;	/* XXX gcc -Wuninitialized */
 
 	/* secondary if bus # != 0 */
-	pci_decompose_tag(>lc_pc, tag, , , 0);
+	pci_decompose_tag(>lc_pc, tag, , , );
 	if (secondary) {
 		s = splhigh();
 		alpha_mb();
 		REGVAL(LCA_IOC_CONF) = 0x01;
 		alpha_mb();
+		confaddr = tag;
 	} else {
-		/*
-		 * on the LCA, must frob the tag used for
-		 * devices on the primary bus, in the same ways
-		 * as is used by type 1 configuration cycles
-		 * on PCs.
-		 */
-		tag = (1 << (device + 11)) | (tag & 0x7ff);
+		confaddr = lca_make_type0addr(d, f);
 	}
 
 	datap = (pcireg_t *)ALPHA_PHYS_TO_K0SEG(LCA_PCI_CONF |
-	tag << 5UL |	/* XXX */
+	confaddr << 5UL |	/* XXX */
 	(offset & ~0x03) << 5 |/* XXX */
 	0 << 5 |		/* XXX */
 	0x3 << 3);		/* XXX */
@@ -154,7 +126,8 @@ lca_conf_write(void *cpv, pcitag_t tag, 
 {
 	struct lca_config *lcp = cpv;
 	pcireg_t *datap;
-	int s, secondary, device;
+	paddr_t confaddr;
+	int s, secondary, d, f;
 
 	if ((unsigned int)offset >= PCI_CONF_SIZE)
 		return;
@@ -162,24 +135,19 @@ lca_conf_write(void *cpv, pcitag_t tag, 
 	s = 0;	/* XXX gcc -Wuninitialized */
 
 	/* secondary if bus # != 0 */
-	pci_decompose_tag(>lc_pc, tag, , , 0);
+	pci_decompose_tag(>lc_pc, tag, , , );
 	if (secondary) {
 		s = splhigh();
 		alpha_mb();
 		REGVAL(LCA_IOC_CONF) = 0x01;
 		alpha_mb();
+		confaddr = tag;
 	} else {
-		/*
-		 * on the LCA, must frob the tag used for
-		 * devices on the primary bus, in the same ways
-		 * as is used by type 1 configuration cycles
-		 * on PCs.
-		 */
-		tag = (1 << (device + 11)) | (tag & 0x7ff);
+		confaddr = lca_make_type0addr(d, f);
 	}
 
 	datap = (pcireg_t 

CVS commit: src/sys/arch/alpha/pci

2021-06-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 03:49:47 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: ttwoga_pci.c

Log Message:
- Use the default implementations of attach_hook(), make_tag(), and
  decompose_tag().
- In ttwoga_make_type0addr(), assert that we have an IDSEL in our range,
  and otherwise always succeed.
- In ttwoga_bus_maxdevs(), allow only devices 0-9 on bus #0.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/pci/ttwoga_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/ttwoga_pci.c
diff -u src/sys/arch/alpha/pci/ttwoga_pci.c:1.9 src/sys/arch/alpha/pci/ttwoga_pci.c:1.10
--- src/sys/arch/alpha/pci/ttwoga_pci.c:1.9	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/ttwoga_pci.c	Fri Jun 25 03:49:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ttwoga_pci.c,v 1.9 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: ttwoga_pci.c,v 1.10 2021/06/25 03:49:47 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c,v 1.9 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c,v 1.10 2021/06/25 03:49:47 thorpej Exp $");
 
 #include 
 #include 
@@ -44,12 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: ttwoga_pci.c
 #include 
 #include 
 
-static void	ttwoga_attach_hook(device_t, device_t,
-		struct pcibus_attach_args *);
 static int	ttwoga_bus_maxdevs(void *, int);
-static pcitag_t	ttwoga_make_tag(void *, int, int, int);
-static void	ttwoga_decompose_tag(void *, pcitag_t, int *, int *,
-		int *);
 static pcireg_t	ttwoga_conf_read(void *, pcitag_t, int);
 static void	ttwoga_conf_write(void *, pcitag_t, int, pcireg_t);
 
@@ -87,54 +82,26 @@ ttwoga_pci_init(pci_chipset_tag_t pc, vo
 	mutex_init(_conf_lock, MUTEX_DEFAULT, IPL_HIGH);
 
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = ttwoga_attach_hook;
 	pc->pc_bus_maxdevs = ttwoga_bus_maxdevs;
-	pc->pc_make_tag = ttwoga_make_tag;
-	pc->pc_decompose_tag = ttwoga_decompose_tag;
 	pc->pc_conf_read = ttwoga_conf_read;
 	pc->pc_conf_write = ttwoga_conf_write;
 }
 
-static void
-ttwoga_attach_hook(device_t parent, device_t self,
-struct pcibus_attach_args *pba)
-{
-}
-
 static int
 ttwoga_bus_maxdevs(void *cpv, int busno)
 {
-
-	return 32;
-}
-
-static pcitag_t
-ttwoga_make_tag(void *cpv, int b, int d, int f)
-{
-
-	/* This is the format used for Type 1 configuration cycles. */
-	return (b << 16) | (d << 11) | (f << 8);
-}
-
-static void
-ttwoga_decompose_tag(void *cpv, pcitag_t tag, int *bp, int *dp, int *fp)
-{
-
-	if (bp != NULL)
-		*bp = (tag >> 16) & 0xff;
-	if (dp != NULL)
-		*dp = (tag >> 11) & 0x1f;
-	if (fp != NULL)
-		*fp = (tag >> 8) & 0x7;
+	/*
+	 * We have to drive the IDSEL directly on bus 0, so we are
+	 * limited to 9 devices there.
+	 */
+	return busno == 0 ? 9 : 32;
 }
 
 static paddr_t
 ttwoga_make_type0addr(int d, int f)
 {
-
-	if (d > 8)			/* XXX ??? */
-		return ((paddr_t) -1);
-	return ((0x0800UL << d) | (f << 8));
+	KASSERT(d < 9);
+	return PCI_CONF_TYPE0_IDSEL(d) | __SHIFTIN(f, PCI_CONF_TYPE1_FUNCTION);
 }
 
 static pcireg_t
@@ -152,8 +119,6 @@ ttwoga_conf_read(void *cpv, pcitag_t tag
 	pci_decompose_tag(>tc_pc, tag, , , );
 
 	addr = b ? tag : ttwoga_make_type0addr(d, f);
-	if (addr == (paddr_t)-1)
-		return ((pcireg_t) -1);
 
 	TTWOGA_CONF_LOCK();
 
@@ -207,8 +172,6 @@ ttwoga_conf_write(void *cpv, pcitag_t ta
 	pci_decompose_tag(>tc_pc, tag, , , );
 
 	addr = b ? tag : ttwoga_make_type0addr(d, f);
-	if (addr == (paddr_t)-1)
-		return;
 
 	TTWOGA_CONF_LOCK();
 



CVS commit: src/sys/arch/alpha/pci

2021-06-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 03:46:54 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: mcpcia_pci.c

Log Message:
Use the default implementation of attach_hook().


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/alpha/pci/mcpcia_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/mcpcia_pci.c
diff -u src/sys/arch/alpha/pci/mcpcia_pci.c:1.13 src/sys/arch/alpha/pci/mcpcia_pci.c:1.14
--- src/sys/arch/alpha/pci/mcpcia_pci.c:1.13	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/mcpcia_pci.c	Fri Jun 25 03:46:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mcpcia_pci.c,v 1.13 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: mcpcia_pci.c,v 1.14 2021/06/25 03:46:54 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcpcia_pci.c,v 1.13 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcpcia_pci.c,v 1.14 2021/06/25 03:46:54 thorpej Exp $");
 
 #include 
 #include 
@@ -46,8 +46,6 @@ __KERNEL_RCSID(0, "$NetBSD: mcpcia_pci.c
 
 #define	KV(_addr)	((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
 
-static void	mcpcia_attach_hook(device_t, device_t,
-		struct pcibus_attach_args *);
 static int	mcpcia_bus_maxdevs(void *, int);
 static pcitag_t	mcpcia_make_tag(void *, int, int, int);
 static void	mcpcia_decompose_tag(void *, pcitag_t, int *, int *, int *);
@@ -58,7 +56,6 @@ void
 mcpcia_pci_init(pci_chipset_tag_t pc, void *v)
 {
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = mcpcia_attach_hook;
 	pc->pc_bus_maxdevs = mcpcia_bus_maxdevs;
 	pc->pc_make_tag = mcpcia_make_tag;
 	pc->pc_decompose_tag = mcpcia_decompose_tag;
@@ -66,11 +63,6 @@ mcpcia_pci_init(pci_chipset_tag_t pc, vo
 	pc->pc_conf_write = mcpcia_conf_write;
 }
 
-static void
-mcpcia_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba)
-{
-}
-
 static int
 mcpcia_bus_maxdevs(void *cpv, int busno)
 {



CVS commit: src/sys/arch/alpha/pci

2021-06-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 03:46:30 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: dwlpx_pci.c

Log Message:
Use the default implementation of attach_hook().


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/pci/dwlpx_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/dwlpx_pci.c
diff -u src/sys/arch/alpha/pci/dwlpx_pci.c:1.20 src/sys/arch/alpha/pci/dwlpx_pci.c:1.21
--- src/sys/arch/alpha/pci/dwlpx_pci.c:1.20	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/dwlpx_pci.c	Fri Jun 25 03:46:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwlpx_pci.c,v 1.20 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: dwlpx_pci.c,v 1.21 2021/06/25 03:46:30 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dwlpx_pci.c,v 1.20 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwlpx_pci.c,v 1.21 2021/06/25 03:46:30 thorpej Exp $");
 
 #include 
 #include 
@@ -47,8 +47,6 @@ __KERNEL_RCSID(0, "$NetBSD: dwlpx_pci.c,
 
 #define	KV(_addr)	((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
 
-static void	dwlpx_attach_hook(device_t, device_t,
-		struct pcibus_attach_args *);
 static int	dwlpx_bus_maxdevs(void *, int);
 static pcitag_t	dwlpx_make_tag(void *, int, int, int);
 static void	dwlpx_decompose_tag(void *, pcitag_t, int *, int *,
@@ -60,7 +58,6 @@ void
 dwlpx_pci_init(pci_chipset_tag_t pc, void *v)
 {
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = dwlpx_attach_hook;
 	pc->pc_bus_maxdevs = dwlpx_bus_maxdevs;
 	pc->pc_make_tag = dwlpx_make_tag;
 	pc->pc_decompose_tag = dwlpx_decompose_tag;
@@ -68,11 +65,6 @@ dwlpx_pci_init(pci_chipset_tag_t pc, voi
 	pc->pc_conf_write = dwlpx_conf_write;
 }
 
-static void
-dwlpx_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba)
-{
-}
-
 static int
 dwlpx_bus_maxdevs(void *cpv, int busno)
 {



CVS commit: src/sys/arch/alpha/pci

2021-06-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 03:45:59 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: apecs_pci.c cia_pci.c irongate_pci.c tsp_pci.c

Log Message:
Use the default implementations of attach_hook(), bus_maxdevs(),
make_tag(), and decompose_tag().


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/pci/apecs_pci.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/alpha/pci/cia_pci.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/pci/irongate_pci.c \
src/sys/arch/alpha/pci/tsp_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/apecs_pci.c
diff -u src/sys/arch/alpha/pci/apecs_pci.c:1.27 src/sys/arch/alpha/pci/apecs_pci.c:1.28
--- src/sys/arch/alpha/pci/apecs_pci.c:1.27	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/apecs_pci.c	Fri Jun 25 03:45:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: apecs_pci.c,v 1.27 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: apecs_pci.c,v 1.28 2021/06/25 03:45:59 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: apecs_pci.c,v 1.27 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apecs_pci.c,v 1.28 2021/06/25 03:45:59 thorpej Exp $");
 
 #include 
 #include 
@@ -41,11 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: apecs_pci.c,
 #include 
 #include 
 
-static void	apecs_attach_hook(device_t, device_t,
-		struct pcibus_attach_args *);
-static int	apecs_bus_maxdevs(void *, int);
-static pcitag_t	apecs_make_tag(void *, int, int, int);
-static void	apecs_decompose_tag(void *, pcitag_t, int *, int *, int *);
 static pcireg_t	apecs_conf_read(void *, pcitag_t, int);
 static void	apecs_conf_write(void *, pcitag_t, int, pcireg_t);
 
@@ -54,45 +49,10 @@ apecs_pci_init(pci_chipset_tag_t pc, voi
 {
 
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = apecs_attach_hook;
-	pc->pc_bus_maxdevs = apecs_bus_maxdevs;
-	pc->pc_make_tag = apecs_make_tag;
-	pc->pc_decompose_tag = apecs_decompose_tag;
 	pc->pc_conf_read = apecs_conf_read;
 	pc->pc_conf_write = apecs_conf_write;
 }
 
-static void
-apecs_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba)
-{
-}
-
-static int
-apecs_bus_maxdevs(void *cpv, int busno)
-{
-
-	return 32;
-}
-
-static pcitag_t
-apecs_make_tag(void *cpv, int b, int d, int f)
-{
-
-	return (b << 16) | (d << 11) | (f << 8);
-}
-
-static void
-apecs_decompose_tag(void *cpv, pcitag_t tag, int *bp, int *dp, int *fp)
-{
-
-	if (bp != NULL)
-		*bp = (tag >> 16) & 0xff;
-	if (dp != NULL)
-		*dp = (tag >> 11) & 0x1f;
-	if (fp != NULL)
-		*fp = (tag >> 8) & 0x7;
-}
-
 static pcireg_t
 apecs_conf_read(void *cpv, pcitag_t tag, int offset)
 {

Index: src/sys/arch/alpha/pci/cia_pci.c
diff -u src/sys/arch/alpha/pci/cia_pci.c:1.34 src/sys/arch/alpha/pci/cia_pci.c:1.35
--- src/sys/arch/alpha/pci/cia_pci.c:1.34	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/cia_pci.c	Fri Jun 25 03:45:59 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_pci.c,v 1.34 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: cia_pci.c,v 1.35 2021/06/25 03:45:59 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia_pci.c,v 1.34 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia_pci.c,v 1.35 2021/06/25 03:45:59 thorpej Exp $");
 
 #include 
 #include 
@@ -41,11 +41,6 @@ __KERNEL_RCSID(0, "$NetBSD: cia_pci.c,v 
 #include 
 #include 
 
-static void	cia_attach_hook(device_t, device_t,
-		struct pcibus_attach_args *);
-static int	cia_bus_maxdevs(void *, int);
-static pcitag_t	cia_make_tag(void *, int, int, int);
-static void	cia_decompose_tag(void *, pcitag_t, int *, int *, int *);
 static pcireg_t	cia_conf_read(void *, pcitag_t, int);
 static void	cia_conf_write(void *, pcitag_t, int, pcireg_t);
 
@@ -54,45 +49,10 @@ cia_pci_init(pci_chipset_tag_t pc, void 
 {
 
 	pc->pc_conf_v = v;
-	pc->pc_attach_hook = cia_attach_hook;
-	pc->pc_bus_maxdevs = cia_bus_maxdevs;
-	pc->pc_make_tag = cia_make_tag;
-	pc->pc_decompose_tag = cia_decompose_tag;
 	pc->pc_conf_read = cia_conf_read;
 	pc->pc_conf_write = cia_conf_write;
 }
 
-static void
-cia_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba)
-{
-}
-
-static int
-cia_bus_maxdevs(void *cpv, int busno)
-{
-
-	return 32;
-}
-
-static pcitag_t
-cia_make_tag(void *cpv, int b, int d, int f)
-{
-
-	return (b << 16) | (d << 11) | (f << 8);
-}
-
-static void
-cia_decompose_tag(void *cpv, pcitag_t tag, int *bp, int *dp, int *fp)
-{
-
-	if (bp != NULL)
-		*bp = (tag >> 16) & 0xff;
-	if (dp != NULL)
-		*dp = (tag >> 11) & 0x1f;
-	if (fp != NULL)
-		*fp = (tag >> 8) & 0x7;
-}
-
 static pcireg_t
 cia_conf_read(void *cpv, pcitag_t tag, int offset)
 {

Index: src/sys/arch/alpha/pci/irongate_pci.c

CVS commit: src/sys/arch/alpha/pci

2021-06-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 25 03:44:10 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: pci_machdep.c

Log Message:
Make the following PCI chipset functions optional:
- attach_hook()
- bus_maxdevs()
- make_tag()
- decompose_tag()
...and provide a default implementation for each.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/pci/pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_machdep.c
diff -u src/sys/arch/alpha/pci/pci_machdep.c:1.29 src/sys/arch/alpha/pci/pci_machdep.c:1.30
--- src/sys/arch/alpha/pci/pci_machdep.c:1.29	Sat Jun 19 16:59:07 2021
+++ src/sys/arch/alpha/pci/pci_machdep.c	Fri Jun 25 03:44:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.29 2021/06/19 16:59:07 thorpej Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.30 2021/06/25 03:44:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.29 2021/06/19 16:59:07 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.30 2021/06/25 03:44:10 thorpej Exp $");
 
 #include 
 #include 
@@ -481,14 +481,18 @@ pci_attach_hook(device_t const parent, d
 {
 	pci_chipset_tag_t const pc = pba->pba_pc;
 
-	KASSERT(pc->pc_attach_hook != NULL);
-	pc->pc_attach_hook(parent, self, pba);
+	if (pc->pc_attach_hook != NULL) {
+		pc->pc_attach_hook(parent, self, pba);
+	}
 }
 
 int
 pci_bus_maxdevs(pci_chipset_tag_t const pc, int const busno)
 {
-	KASSERT(pc->pc_bus_maxdevs != NULL);
+	if (pc->pc_bus_maxdevs == NULL) {
+		return 32;
+	}
+
 	return pc->pc_bus_maxdevs(pc->pc_conf_v, busno);
 }
 
@@ -496,7 +500,13 @@ pcitag_t
 pci_make_tag(pci_chipset_tag_t const pc, int const bus, int const dev,
 int const func)
 {
-	KASSERT(pc->pc_make_tag != NULL);
+	if (__predict_true(pc->pc_make_tag == NULL)) {
+		/* Just use the standard Type 1 address format. */
+		return __SHIFTIN(bus, PCI_CONF_TYPE1_BUS) |
+		   __SHIFTIN(dev, PCI_CONF_TYPE1_DEVICE) |
+		   __SHIFTIN(func, PCI_CONF_TYPE1_FUNCTION);
+	}
+
 	return pc->pc_make_tag(pc->pc_conf_v, bus, dev, func);
 }
 
@@ -504,7 +514,16 @@ void
 pci_decompose_tag(pci_chipset_tag_t const pc, pcitag_t const tag,
 int * const busp, int * const devp, int * const funcp)
 {
-	KASSERT(pc->pc_decompose_tag != NULL);
+	if (__predict_true(pc->pc_decompose_tag == NULL)) {
+		if (busp != NULL)
+			*busp = __SHIFTOUT(tag, PCI_CONF_TYPE1_BUS);
+		if (devp != NULL)
+			*devp = __SHIFTOUT(tag, PCI_CONF_TYPE1_DEVICE);
+		if (funcp != NULL)
+			*funcp = __SHIFTOUT(tag, PCI_CONF_TYPE1_FUNCTION);
+		return;
+	}
+
 	pc->pc_decompose_tag(pc->pc_conf_v, tag, busp, devp, funcp);
 }
 



CVS commit: src/sys/arch/alpha/pci

2021-06-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun 19 16:43:11 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: dwlpx_dma.c

Log Message:
No need to include pci_kn8ae.h here.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/pci/dwlpx_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/dwlpx_dma.c
diff -u src/sys/arch/alpha/pci/dwlpx_dma.c:1.29 src/sys/arch/alpha/pci/dwlpx_dma.c:1.30
--- src/sys/arch/alpha/pci/dwlpx_dma.c:1.29	Wed May  5 02:15:18 2021
+++ src/sys/arch/alpha/pci/dwlpx_dma.c	Sat Jun 19 16:43:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwlpx_dma.c,v 1.29 2021/05/05 02:15:18 thorpej Exp $ */
+/* $NetBSD: dwlpx_dma.c,v 1.30 2021/06/19 16:43:11 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dwlpx_dma.c,v 1.29 2021/05/05 02:15:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwlpx_dma.c,v 1.30 2021/06/19 16:43:11 thorpej Exp $");
 
 #include 
 #include 
@@ -50,7 +50,6 @@ __KERNEL_RCSID(0, "$NetBSD: dwlpx_dma.c,
 #include 
 #include 
 #include 
-#include 
 
 static bus_dma_tag_t dwlpx_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
 



CVS commit: src/sys/arch/alpha/pci

2021-06-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun 19 16:29:04 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: dwlpx.c pci_kn8ae.c pci_kn8ae.h

Log Message:
Remove the "first" argument from pci_kn8ae_pickintr(), instead using
a real once control in that function. Removes a needless divergence from
other "pickintr" routines.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/alpha/pci/dwlpx.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/alpha/pci/pci_kn8ae.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/pci/pci_kn8ae.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/dwlpx.c
diff -u src/sys/arch/alpha/pci/dwlpx.c:1.40 src/sys/arch/alpha/pci/dwlpx.c:1.41
--- src/sys/arch/alpha/pci/dwlpx.c:1.40	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/dwlpx.c	Sat Jun 19 16:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dwlpx.c,v 1.40 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: dwlpx.c,v 1.41 2021/06/19 16:29:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dwlpx.c,v 1.40 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwlpx.c,v 1.41 2021/06/19 16:29:03 thorpej Exp $");
 
 #include 
 #include 
@@ -106,7 +106,6 @@ dwlpxmatch(device_t parent, cfdata_t cf,
 static void
 dwlpxattach(device_t parent, device_t self, void *aux)
 {
-	static int once = 0;
 	struct dwlpx_softc *sc = device_private(self);
 	struct dwlpx_config *ccp = >dwlpx_cc;
 	struct kft_dev_attach_args *ka = aux;
@@ -158,15 +157,10 @@ dwlpxattach(device_t parent, device_t se
 	}
 #endif
 
-	if (once == 0) {
-		/*
-		 * Set up interrupts
-		 */
-		pci_kn8ae_pickintr(>dwlpx_cc, 1);
-		once++;
-	} else {
-		pci_kn8ae_pickintr(>dwlpx_cc, 0);
-	}
+	/*
+	 * Set up interrupts
+	 */
+	pci_kn8ae_pickintr(>dwlpx_cc);
 
 	/*
 	 * Attach PCI bus

Index: src/sys/arch/alpha/pci/pci_kn8ae.c
diff -u src/sys/arch/alpha/pci/pci_kn8ae.c:1.31 src/sys/arch/alpha/pci/pci_kn8ae.c:1.32
--- src/sys/arch/alpha/pci/pci_kn8ae.c:1.31	Fri Sep 25 03:40:11 2020
+++ src/sys/arch/alpha/pci/pci_kn8ae.c	Sat Jun 19 16:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn8ae.c,v 1.31 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: pci_kn8ae.c,v 1.32 2021/06/19 16:29:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_kn8ae.c,v 1.31 2020/09/25 03:40:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_kn8ae.c,v 1.32 2021/06/19 16:29:03 thorpej Exp $");
 
 #include 
 #include 
@@ -43,6 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_kn8ae.c,
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -87,10 +88,27 @@ kn8ae_intr_wrapper(void *arg, u_long vec
 	KERNEL_UNLOCK_ONE(NULL);
 }
 
-void
-pci_kn8ae_pickintr(struct dwlpx_config *ccp, int first)
+static ONCE_DECL(pci_kn8ae_once);
+
+static int
+pci_kn8ae_init_imaskcache(void)
 {
 	int io, hose, dev;
+
+	for (io = 0; io < DWLPX_NIONODE; io++) {
+		for (hose = 0; hose < DWLPX_NHOSE; hose++) {
+			for (dev = 0; dev < NHPC; dev++) {
+imaskcache[io][hose][dev] = DWLPX_IMASK_DFLT;
+			}
+		}
+	}
+
+	return 0;
+}
+
+void
+pci_kn8ae_pickintr(struct dwlpx_config *ccp)
+{
 	pci_chipset_tag_t pc = >cc_pc;
 
 	pc->pc_intr_v = ccp;
@@ -103,17 +121,7 @@ pci_kn8ae_pickintr(struct dwlpx_config *
 	/* Not supported on KN8AE. */
 	pc->pc_pciide_compat_intr_establish = NULL;
 
-	if (!first) {
-		return;
-	}
-
-	for (io = 0; io < DWLPX_NIONODE; io++) {
-		for (hose = 0; hose < DWLPX_NHOSE; hose++) {
-			for (dev = 0; dev < NHPC; dev++) {
-imaskcache[io][hose][dev] = DWLPX_IMASK_DFLT;
-			}
-		}
-	}
+	RUN_ONCE(_kn8ae_once, pci_kn8ae_init_imaskcache);
 }
 
 #define	IH_MAKE(vec, dev, pin)		\

Index: src/sys/arch/alpha/pci/pci_kn8ae.h
diff -u src/sys/arch/alpha/pci/pci_kn8ae.h:1.5 src/sys/arch/alpha/pci/pci_kn8ae.h:1.6
--- src/sys/arch/alpha/pci/pci_kn8ae.h:1.5	Sat Mar 14 14:45:53 2009
+++ src/sys/arch/alpha/pci/pci_kn8ae.h	Sat Jun 19 16:29:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn8ae.h,v 1.5 2009/03/14 14:45:53 dsl Exp $ */
+/* $NetBSD: pci_kn8ae.h,v 1.6 2021/06/19 16:29:03 thorpej Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -30,4 +30,4 @@
  * SUCH DAMAGE.
  */
 
-void	pci_kn8ae_pickintr(struct dwlpx_config *, int);
+void	pci_kn8ae_pickintr(struct dwlpx_config *);



CVS commit: src/sys/arch/alpha/pci

2021-06-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun 19 16:13:40 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: mcpcia.c pci_kn300.c pci_kn300.h

Log Message:
Remove the "first" argument from pci_kn300_pickintr().  It's redundant with
information we already have, and is a needless divergence from other
"pickintr" routines.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/alpha/pci/mcpcia.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/alpha/pci/pci_kn300.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/pci/pci_kn300.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/mcpcia.c
diff -u src/sys/arch/alpha/pci/mcpcia.c:1.32 src/sys/arch/alpha/pci/mcpcia.c:1.33
--- src/sys/arch/alpha/pci/mcpcia.c:1.32	Fri Jun 18 22:17:53 2021
+++ src/sys/arch/alpha/pci/mcpcia.c	Sat Jun 19 16:13:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: mcpcia.c,v 1.32 2021/06/18 22:17:53 thorpej Exp $ */
+/* $NetBSD: mcpcia.c,v 1.33 2021/06/19 16:13:40 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: mcpcia.c,v 1.32 2021/06/18 22:17:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcpcia.c,v 1.33 2021/06/19 16:13:40 thorpej Exp $");
 
 #include 
 #include 
@@ -126,7 +126,6 @@ mcpciamatch(device_t parent, cfdata_t cf
 static void
 mcpciaattach(device_t parent, device_t self, void *aux)
 {
-	static int first = 1;
 	struct mcbus_dev_attach_args *ma = aux;
 	struct mcpcia_softc *mcp = device_private(self);
 	struct mcpcia_config *ccp;
@@ -174,8 +173,7 @@ mcpciaattach(device_t parent, device_t s
 	/*
 	 * Set up interrupts
 	 */
-	pci_kn300_pickintr(ccp, first);
-	first = 0;
+	pci_kn300_pickintr(ccp);
 
 	/*
 	 * Attach PCI bus

Index: src/sys/arch/alpha/pci/pci_kn300.c
diff -u src/sys/arch/alpha/pci/pci_kn300.c:1.38 src/sys/arch/alpha/pci/pci_kn300.c:1.39
--- src/sys/arch/alpha/pci/pci_kn300.c:1.38	Fri Sep 25 03:40:11 2020
+++ src/sys/arch/alpha/pci/pci_kn300.c	Sat Jun 19 16:13:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn300.c,v 1.38 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: pci_kn300.c,v 1.39 2021/06/19 16:13:40 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pci_kn300.c,v 1.38 2020/09/25 03:40:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_kn300.c,v 1.39 2021/06/19 16:13:40 thorpej Exp $");
 
 #include 
 #include 
@@ -85,12 +85,12 @@ static void	kn300_enable_intr(struct mcp
 static void	kn300_disable_intr(struct mcpcia_config *, int);
 
 void
-pci_kn300_pickintr(struct mcpcia_config *ccp, int first)
+pci_kn300_pickintr(struct mcpcia_config *ccp)
 {
 	char *cp;
 	pci_chipset_tag_t pc = >cc_pc;
 
-	if (first) {
+	if (kn300_pci_intr == NULL) {
 		int g;
 
 #define PCI_KN300_IRQ_STR	16

Index: src/sys/arch/alpha/pci/pci_kn300.h
diff -u src/sys/arch/alpha/pci/pci_kn300.h:1.3 src/sys/arch/alpha/pci/pci_kn300.h:1.4
--- src/sys/arch/alpha/pci/pci_kn300.h:1.3	Sat Mar 14 14:45:53 2009
+++ src/sys/arch/alpha/pci/pci_kn300.h	Sat Jun 19 16:13:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn300.h,v 1.3 2009/03/14 14:45:53 dsl Exp $ */
+/* $NetBSD: pci_kn300.h,v 1.4 2021/06/19 16:13:40 thorpej Exp $ */
 
 /*
  * Copyright (c) 1998 by Matthew Jacob
@@ -30,4 +30,4 @@
  * SUCH DAMAGE.
  */
 
-void	pci_kn300_pickintr(struct mcpcia_config *, int);
+void	pci_kn300_pickintr(struct mcpcia_config *);



CVS commit: src/sys/arch/alpha/pci

2021-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 18 22:18:10 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: cia_dma.c

Log Message:
Wrap a couple of long lines.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/alpha/pci/cia_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/cia_dma.c
diff -u src/sys/arch/alpha/pci/cia_dma.c:1.32 src/sys/arch/alpha/pci/cia_dma.c:1.33
--- src/sys/arch/alpha/pci/cia_dma.c:1.32	Wed May  5 02:15:18 2021
+++ src/sys/arch/alpha/pci/cia_dma.c	Fri Jun 18 22:18:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_dma.c,v 1.32 2021/05/05 02:15:18 thorpej Exp $ */
+/* $NetBSD: cia_dma.c,v 1.33 2021/06/18 22:18:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.32 2021/05/05 02:15:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia_dma.c,v 1.33 2021/06/18 22:18:10 thorpej Exp $");
 
 #include 
 #include 
@@ -321,7 +321,8 @@ cia_bus_dmamap_create_direct(
  * Load a CIA SGMAP-mapped DMA map with a linear buffer.
  */
 static int
-cia_bus_dmamap_load_sgmap(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen, struct proc *p, int flags)
+cia_bus_dmamap_load_sgmap(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
+bus_size_t buflen, struct proc *p, int flags)
 {
 	int error;
 
@@ -337,7 +338,8 @@ cia_bus_dmamap_load_sgmap(bus_dma_tag_t 
  * Load a CIA SGMAP-mapped DMA map with an mbuf chain.
  */
 static int
-cia_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m, int flags)
+cia_bus_dmamap_load_mbuf_sgmap(bus_dma_tag_t t, bus_dmamap_t map,
+struct mbuf *m, int flags)
 {
 	int error;
 
@@ -352,7 +354,8 @@ cia_bus_dmamap_load_mbuf_sgmap(bus_dma_t
  * Load a CIA SGMAP-mapped DMA map with a uio.
  */
 static int
-cia_bus_dmamap_load_uio_sgmap(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio, int flags)
+cia_bus_dmamap_load_uio_sgmap(bus_dma_tag_t t, bus_dmamap_t map,
+struct uio *uio, int flags)
 {
 	int error;
 
@@ -367,7 +370,8 @@ cia_bus_dmamap_load_uio_sgmap(bus_dma_ta
  * Load a CIA SGMAP-mapped DMA map with raw memory.
  */
 static int
-cia_bus_dmamap_load_raw_sgmap(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
+cia_bus_dmamap_load_raw_sgmap(bus_dma_tag_t t, bus_dmamap_t map,
+bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags)
 {
 	int error;
 



CVS commit: src/sys/arch/alpha/pci

2021-06-18 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 18 22:17:53 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: apecs.c cia.c irongate.c lca.c mcpcia.c

Log Message:
Sprinkle some static.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/pci/apecs.c
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/alpha/pci/cia.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/pci/irongate.c
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/alpha/pci/lca.c
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/alpha/pci/mcpcia.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/apecs.c
diff -u src/sys/arch/alpha/pci/apecs.c:1.55 src/sys/arch/alpha/pci/apecs.c:1.56
--- src/sys/arch/alpha/pci/apecs.c:1.55	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/apecs.c	Fri Jun 18 22:17:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: apecs.c,v 1.55 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: apecs.c,v 1.56 2021/06/18 22:17:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.55 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apecs.c,v 1.56 2021/06/18 22:17:53 thorpej Exp $");
 
 #include 
 #include 
@@ -106,7 +106,7 @@ static int apecs_bus_get_window(int, int
 struct alpha_bus_space_translation *);
 
 /* There can be only one. */
-int apecsfound;
+static int apecsfound;
 struct apecs_config apecs_configuration;
 
 static int
@@ -234,7 +234,8 @@ apecsattach(device_t parent, device_t se
 }
 
 static int
-apecs_bus_get_window(int type, int window, struct alpha_bus_space_translation *abst)
+apecs_bus_get_window(int type, int window,
+struct alpha_bus_space_translation *abst)
 {
 	struct apecs_config *acp = _configuration;
 	bus_space_tag_t st;

Index: src/sys/arch/alpha/pci/cia.c
diff -u src/sys/arch/alpha/pci/cia.c:1.75 src/sys/arch/alpha/pci/cia.c:1.76
--- src/sys/arch/alpha/pci/cia.c:1.75	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/cia.c	Fri Jun 18 22:17:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cia.c,v 1.75 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: cia.c,v 1.76 2021/06/18 22:17:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.75 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.76 2021/06/18 22:17:53 thorpej Exp $");
 
 #include 
 #include 
@@ -102,18 +102,19 @@ __KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.75
 #include 
 #endif
 
-int	ciamatch(device_t, cfdata_t, void *);
-void	ciaattach(device_t, device_t, void *);
+static int	ciamatch(device_t, cfdata_t, void *);
+static void	ciaattach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(cia, sizeof(struct cia_softc),
 ciamatch, ciaattach, NULL, NULL);
 
 extern struct cfdriver cia_cd;
 
-int	cia_bus_get_window(int, int, struct alpha_bus_space_translation *);
+static int	cia_bus_get_window(int, int,
+		struct alpha_bus_space_translation *);
 
 /* There can be only one. */
-int ciafound;
+static int ciafound;
 struct cia_config cia_configuration;
 
 /*
@@ -147,7 +148,7 @@ int	cia_pci_use_bwx = CIA_PCI_USE_BWX;
 int	cia_bus_use_bwx = CIA_BUS_USE_BWX;
 int	cia_pyxis_force_bwx = CIA_PYXIS_FORCE_BWX;
 
-int
+static int
 ciamatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
@@ -260,7 +261,7 @@ cia_init(struct cia_config *ccp, int mal
 	ccp->cc_initted = 1;
 }
 
-void
+static void
 ciaattach(device_t parent, device_t self, void *aux)
 {
 	struct cia_softc *sc = device_private(self);
@@ -404,8 +405,9 @@ ciaattach(device_t parent, device_t self
 	config_found(self, , pcibusprint, CFARG_EOL);
 }
 
-int
-cia_bus_get_window(int type, int window, struct alpha_bus_space_translation *abst)
+static int
+cia_bus_get_window(int type, int window,
+struct alpha_bus_space_translation *abst)
 {
 	struct cia_config *ccp = _configuration;
 	bus_space_tag_t st;

Index: src/sys/arch/alpha/pci/irongate.c
diff -u src/sys/arch/alpha/pci/irongate.c:1.17 src/sys/arch/alpha/pci/irongate.c:1.18
--- src/sys/arch/alpha/pci/irongate.c:1.17	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/irongate.c	Fri Jun 18 22:17:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: irongate.c,v 1.17 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: irongate.c,v 1.18 2021/06/18 22:17:53 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: irongate.c,v 1.17 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irongate.c,v 1.18 2021/06/18 22:17:53 thorpej Exp $");
 
 #include 
 #include 
@@ -57,8 +57,8 @@ __KERNEL_RCSID(0, "$NetBSD: irongate.c,v
 #include 
 #endif
 
-int	irongate_match(device_t, cfdata_t, void *);
-void	

CVS commit: src/sys/arch/alpha/pci

2021-05-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat May  8 00:08:43 UTC 2021

Modified Files:
src/sys/arch/alpha/pci: sio_pic.c ttwoga.c ttwoga_dma.c ttwogavar.h

Log Message:
More symbol sanitizing.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/alpha/pci/sio_pic.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/ttwoga.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/pci/ttwoga_dma.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/pci/ttwogavar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/sio_pic.c
diff -u src/sys/arch/alpha/pci/sio_pic.c:1.47 src/sys/arch/alpha/pci/sio_pic.c:1.48
--- src/sys/arch/alpha/pci/sio_pic.c:1.47	Fri May  7 16:58:34 2021
+++ src/sys/arch/alpha/pci/sio_pic.c	Sat May  8 00:08:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sio_pic.c,v 1.47 2021/05/07 16:58:34 thorpej Exp $ */
+/* $NetBSD: sio_pic.c,v 1.48 2021/05/08 00:08:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2020 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.47 2021/05/07 16:58:34 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.48 2021/05/08 00:08:43 thorpej Exp $");
 
 #include 
 #include 
@@ -102,9 +102,9 @@ __KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 
  * Private functions and variables.
  */
 
-bus_space_tag_t sio_iot;
-pci_chipset_tag_t sio_pc;
-bus_space_handle_t sio_ioh_icu1, sio_ioh_icu2;
+static bus_space_tag_t sio_iot;
+static pci_chipset_tag_t sio_pc;
+static bus_space_handle_t sio_ioh_icu1, sio_ioh_icu2;
 
 #define	ICU_LEN		16		/* number of ISA IRQs */
 
@@ -262,7 +262,7 @@ cy82c693_write_elcr(int elcr, uint8_t va
  * they should panic.
  */
 
-int (*const sio_elcr_setup_funcs[])(void) = {
+static int (*const sio_elcr_setup_funcs[])(void) = {
 	cy82c693_setup_elcr,
 	i82378_setup_elcr,
 	NULL,

Index: src/sys/arch/alpha/pci/ttwoga.c
diff -u src/sys/arch/alpha/pci/ttwoga.c:1.16 src/sys/arch/alpha/pci/ttwoga.c:1.17
--- src/sys/arch/alpha/pci/ttwoga.c:1.16	Sat Apr 24 23:36:23 2021
+++ src/sys/arch/alpha/pci/ttwoga.c	Sat May  8 00:08:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ttwoga.c,v 1.16 2021/04/24 23:36:23 thorpej Exp $ */
+/* $NetBSD: ttwoga.c,v 1.17 2021/05/08 00:08:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1.16 2021/04/24 23:36:23 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1.17 2021/05/08 00:08:43 thorpej Exp $");
 
 #include 
 #include 
@@ -62,27 +62,27 @@ __KERNEL_RCSID(0, "$NetBSD: ttwoga.c,v 1
 
 #include "locators.h"
 
-int	ttwogamatch(device_t, cfdata_t, void *);
-void	ttwogaattach(device_t, device_t, void *);
+static int	ttwogamatch(device_t, cfdata_t, void *);
+static void	ttwogaattach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(ttwoga, 0,
 ttwogamatch, ttwogaattach, NULL, NULL);
 
-int	ttwogaprint(void *, const char *);
+static int	ttwogaprint(void *, const char *);
 
-int	ttwopcimatch(device_t, cfdata_t, void *);
-void	ttwopciattach(device_t, device_t, void *);
+static int	ttwopcimatch(device_t, cfdata_t, void *);
+static void	ttwopciattach(device_t, device_t, void *);
 
 CFATTACH_DECL_NEW(ttwopci, 0,
 ttwopcimatch, ttwopciattach, NULL, NULL);
 
-int	ttwosableioprint(void *, const char *);
+static int	ttwosableioprint(void *, const char *);
 
 /*
  * There can be only one, but it might have 2 primary PCI busses.
  */
-int ttwogafound;
-struct ttwoga_config ttwoga_configuration[2];
+static int ttwogafound;
+static struct ttwoga_config ttwoga_configuration[2];
 
 /* CBUS address bias for Gamma systems. */
 bus_addr_t ttwoga_gamma_cbus_bias;
@@ -90,7 +90,7 @@ bus_addr_t ttwoga_gamma_cbus_bias;
 #define	GIGABYTE	(1024UL * 1024UL * 1024UL)
 #define	MEGABYTE	(1024UL * 1024UL)
 
-const struct ttwoga_sysmap ttwoga_sysmap[2] = {
+static const struct ttwoga_sysmap ttwoga_sysmap[2] = {
 /*	  Base			System size	Bus size	*/
 	{ T2_PCI0_SIO_BASE,	256UL * MEGABYTE, 8UL * MEGABYTE,
 	  T2_PCI0_SMEM_BASE,	4UL * GIGABYTE,	128UL * MEGABYTE,
@@ -107,7 +107,7 @@ const struct ttwoga_sysmap ttwoga_sysmap
 #undef GIGABYTE
 #undef MEGABYTE
 
-int
+static int
 ttwogamatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
@@ -122,7 +122,7 @@ ttwogamatch(device_t parent, cfdata_t ma
 	return (1);
 }
 
-void
+static void
 ttwogaattach(device_t parent, device_t self, void *aux)
 {
 	struct pcibus_attach_args pba;
@@ -149,7 +149,7 @@ ttwogaattach(device_t parent, device_t s
 	}
 }
 
-int
+static int
 ttwogaprint(void *aux, const char *pnp)
 {
 	struct pcibus_attach_args *pba = aux;
@@ -204,7 +204,7 @@ ttwoga_init(int hose, int mallocsafe)
 	return (tcp);
 }
 
-int
+static int
 ttwopcimatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct 

CVS commit: src/sys/arch/alpha/pci

2020-09-28 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Sep 29 01:19:52 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: sio_pic.c

Log Message:
If running in Qemu, don't report stray edge-triggered ISA interrupts.
Works around an issue I obvserved with serial console in Qemu.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/alpha/pci/sio_pic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/sio_pic.c
diff -u src/sys/arch/alpha/pci/sio_pic.c:1.45 src/sys/arch/alpha/pci/sio_pic.c:1.46
--- src/sys/arch/alpha/pci/sio_pic.c:1.45	Fri Sep 25 03:40:11 2020
+++ src/sys/arch/alpha/pci/sio_pic.c	Tue Sep 29 01:19:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sio_pic.c,v 1.45 2020/09/25 03:40:11 thorpej Exp $ */
+/* $NetBSD: sio_pic.c,v 1.46 2020/09/29 01:19:52 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2020 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.45 2020/09/25 03:40:11 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 1.46 2020/09/29 01:19:52 thorpej Exp $");
 
 #include 
 #include 
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: sio_pic.c,v 
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -463,6 +464,16 @@ sio_intr_establish(void *v, int irq, int
 		scb_set(0x800 + SCB_IDXTOVEC(irq), sio_iointr, NULL);
 		sio_setirqstat(irq, 1,
 		alpha_shared_intr_get_sharetype(sio_intr, irq));
+
+		/*
+		 * I've obsesrved stray ISA interrupts when interacting
+		 * with the serial console under Qemu.  Work around that
+		 * for now by suppressing stray interrupt reporting for
+		 * edge-triggered interrupts.
+		 */
+		if (alpha_is_qemu && type == IST_EDGE) {
+			alpha_shared_intr_set_maxstrays(sio_intr, irq, 0);
+		}
 	}
 
 	mutex_exit(_lock);
@@ -508,6 +519,7 @@ sio_intr_disestablish(void *v, void *coo
 		}
 		sio_setirqstat(irq, 0, ist);
 		alpha_shared_intr_set_dfltsharetype(sio_intr, irq, ist);
+		alpha_shared_intr_set_maxstrays(sio_intr, irq, STRAY_MAX);
 
 		/* Release our SCB vector. */
 		scb_free(0x800 + SCB_IDXTOVEC(irq));



CVS commit: src/sys/arch/alpha/pci

2020-09-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Sep 26 02:50:42 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: pci_6600.c

Log Message:
Support CPU interrupt affinity on Tsunami systems.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/pci/pci_6600.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_6600.c
diff -u src/sys/arch/alpha/pci/pci_6600.c:1.27 src/sys/arch/alpha/pci/pci_6600.c:1.28
--- src/sys/arch/alpha/pci/pci_6600.c:1.27	Wed Sep 23 18:48:50 2020
+++ src/sys/arch/alpha/pci/pci_6600.c	Sat Sep 26 02:50:41 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_6600.c,v 1.27 2020/09/23 18:48:50 thorpej Exp $ */
+/* $NetBSD: pci_6600.c,v 1.28 2020/09/26 02:50:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -33,13 +33,14 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.27 2020/09/23 18:48:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.28 2020/09/26 02:50:41 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #define _ALPHA_BUS_DMA_PRIVATE
@@ -94,9 +95,15 @@ static void	 *dec_6600_pciide_compat_int
 
 static void	dec_6600_intr_enable(pci_chipset_tag_t, int irq);
 static void	dec_6600_intr_disable(pci_chipset_tag_t, int irq);
+static void	dec_6600_intr_set_affinity(pci_chipset_tag_t, int,
+		struct cpu_info *);
 
-/* Software copy of enabled interrupt bits. */
+/*
+ * We keep 2 software copies of the interrupt enables: one global one,
+ * and one per-CPU for setting the interrupt affinity.
+ */
 static uint64_t	dec_6600_intr_enables __read_mostly;
+static uint64_t dec_6600_cpu_intr_enables[4] __read_mostly;
 
 void
 pci_6600_pickintr(struct tsp_config *pcp)
@@ -105,6 +112,8 @@ pci_6600_pickintr(struct tsp_config *pcp
 	pci_chipset_tag_t pc = >pc_pc;
 	char *cp;
 	int i;
+	struct cpu_info *ci;
+	CPU_INFO_ITERATOR cii;
 
 	pc->pc_intr_v = pcp;
 	pc->pc_intr_map = dec_6600_intr_map;
@@ -121,12 +130,25 @@ pci_6600_pickintr(struct tsp_config *pcp
 
 	pc->pc_intr_enable = dec_6600_intr_enable;
 	pc->pc_intr_disable = dec_6600_intr_disable;
+	pc->pc_intr_set_affinity = dec_6600_intr_set_affinity;
+
+	/* Note eligible CPUs for interrupt routing purposes. */
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		KASSERT(ci->ci_cpuid < 4);
+		pc->pc_eligible_cpus |= __BIT(ci->ci_cpuid);
+	}
 
 	/*
 	 * System-wide and Pchip-0-only logic...
 	 */
 	if (sioprimary == NULL) {
 		sioprimary = pcp;
+		/*
+		 * Unless explicitly routed, all interrupts go to the
+		 * primary CPU.
+		 */
+		dec_6600_cpu_intr_enables[cpu_info_primary.ci_cpuid] =
+		__BITS(0,63);
 		pc->pc_pciide_compat_intr_establish =
 		dec_6600_pciide_compat_intr_establish;
 #define PCI_6600_IRQ_STR	8
@@ -146,7 +168,10 @@ pci_6600_pickintr(struct tsp_config *pcp
 		}
 #if NSIO
 		sio_intr_setup(pc, iot);
-		dec_6600_intr_enable(pc, PCI_SIO_IRQ);	/* irq line for sio */
+
+		mutex_enter(_lock);
+		dec_6600_intr_enable(pc, PCI_SIO_IRQ);
+		mutex_exit(_lock);
 #endif
 	} else {
 		pc->pc_shared_intrs = sioprimary->pc_pc.pc_shared_intrs;
@@ -266,21 +291,109 @@ dec_6600_intr_disestablish(pci_chipset_t
 }
 
 static void
-dec_6600_intr_enable(pci_chipset_tag_t const pc __unused, int const irq)
+dec_6600_intr_program(pci_chipset_tag_t const pc)
 {
-	dec_6600_intr_enables |= 1UL << irq;
+	unsigned int irq, cpuno, cnt;
+
+	/*
+	 * Validate the configuration before we program it: each enabled
+	 * IRQ must be routed to exactly one CPU.
+	 */
+	for (irq = 0; irq < PCI_NIRQ; irq++) {
+		if ((dec_6600_intr_enables & __BIT(irq)) == 0)
+			continue;
+		for (cpuno = 0, cnt = 0; cpuno < 4; cpuno++) {
+			if (dec_6600_cpu_intr_enables[cpuno] != 0 &&
+			(pc->pc_eligible_cpus & __BIT(cpuno)) == 0)
+panic("%s: interrupts enabled on non-existent CPU %u",
+__func__, cpuno);
+			if (dec_6600_cpu_intr_enables[cpuno] & __BIT(irq))
+cnt++;
+		}
+		if (cnt != 1) {
+			panic("%s: irq %u enabled on %u CPUs", __func__,
+			irq, cnt);
+		}
+	}
+
+	const uint64_t enab0 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[0];
+	const uint64_t enab1 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[1];
+	const uint64_t enab2 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[2];
+	const uint64_t enab3 =
+	dec_6600_intr_enables & dec_6600_cpu_intr_enables[3];
+
+	/* Don't touch DIMx registers for non-existent CPUs. */
+	uint64_t black_hole;
+	volatile uint64_t * const dim0 = (pc->pc_eligible_cpus & __BIT(0)) ?
+	(void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM0) : _hole;
+	volatile uint64_t * const dim1 = (pc->pc_eligible_cpus & __BIT(1)) ?
+	(void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM1) : _hole;
+	volatile uint64_t * const dim2 = (pc->pc_eligible_cpus & __BIT(2)) ?
+	(void *)ALPHA_PHYS_TO_K0SEG(TS_C_DIM2) : _hole;
+	volatile uint64_t * const dim3 = (pc->pc_eligible_cpus & 

CVS commit: src/sys/arch/alpha/pci

2020-09-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Sep 23 18:48:51 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: pci_6600.c

Log Message:
Define a constant for the SIO IRQ line, and keep a shadow copy of
the interrupt enables.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/pci/pci_6600.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_6600.c
diff -u src/sys/arch/alpha/pci/pci_6600.c:1.26 src/sys/arch/alpha/pci/pci_6600.c:1.27
--- src/sys/arch/alpha/pci/pci_6600.c:1.26	Tue Sep 22 15:24:02 2020
+++ src/sys/arch/alpha/pci/pci_6600.c	Wed Sep 23 18:48:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_6600.c,v 1.26 2020/09/22 15:24:02 thorpej Exp $ */
+/* $NetBSD: pci_6600.c,v 1.27 2020/09/23 18:48:50 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -33,7 +33,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.26 2020/09/22 15:24:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v 1.27 2020/09/23 18:48:50 thorpej Exp $");
 
 #include 
 #include 
@@ -64,6 +64,7 @@ __KERNEL_RCSID(0, "$NetBSD: pci_6600.c,v
 #endif
 
 #define	PCI_NIRQ		64
+#define	PCI_SIO_IRQ		55
 #define	PCI_STRAY_MAX		5
 
 /*
@@ -94,6 +95,9 @@ static void	 *dec_6600_pciide_compat_int
 static void	dec_6600_intr_enable(pci_chipset_tag_t, int irq);
 static void	dec_6600_intr_disable(pci_chipset_tag_t, int irq);
 
+/* Software copy of enabled interrupt bits. */
+static uint64_t	dec_6600_intr_enables __read_mostly;
+
 void
 pci_6600_pickintr(struct tsp_config *pcp)
 {
@@ -142,7 +146,7 @@ pci_6600_pickintr(struct tsp_config *pcp
 		}
 #if NSIO
 		sio_intr_setup(pc, iot);
-		dec_6600_intr_enable(pc, 55);	/* irq line for sio */
+		dec_6600_intr_enable(pc, PCI_SIO_IRQ);	/* irq line for sio */
 #endif
 	} else {
 		pc->pc_shared_intrs = sioprimary->pc_pc.pc_shared_intrs;
@@ -264,16 +268,18 @@ dec_6600_intr_disestablish(pci_chipset_t
 static void
 dec_6600_intr_enable(pci_chipset_tag_t const pc __unused, int const irq)
 {
+	dec_6600_intr_enables |= 1UL << irq;
 	alpha_mb();
-	STQP(TS_C_DIM0) |= 1UL << irq;
+	STQP(TS_C_DIM0) = dec_6600_intr_enables;
 	alpha_mb();
 }
 
 static void
 dec_6600_intr_disable(pci_chipset_tag_t const pc __unused, int const irq)
 {
+	dec_6600_intr_enables &= ~(1UL << irq);
 	alpha_mb();
-	STQP(TS_C_DIM0) &= ~(1UL << irq);
+	STQP(TS_C_DIM0) = dec_6600_intr_enables;
 	alpha_mb();
 }
 



CVS commit: src/sys/arch/alpha/pci

2020-09-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Sep 23 00:46:17 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: tsreg.h

Log Message:
Define some additional Cchip registers.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/pci/tsreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsreg.h
diff -u src/sys/arch/alpha/pci/tsreg.h:1.7 src/sys/arch/alpha/pci/tsreg.h:1.8
--- src/sys/arch/alpha/pci/tsreg.h:1.7	Fri Feb 21 12:23:30 2014
+++ src/sys/arch/alpha/pci/tsreg.h	Wed Sep 23 00:46:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tsreg.h,v 1.7 2014/02/21 12:23:30 jdc Exp $ */
+/* $NetBSD: tsreg.h,v 1.8 2020/09/23 00:46:17 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -124,6 +124,12 @@
 
 #define TS_C_TTR	0x101##a000##0580UL
 #define TS_C_TDR	0x101##a000##05c0UL
+#define TS_C_DIM2	0x101##a000##0600UL
+#define TS_C_DIM3	0x101##a000##0640UL
+#define TS_C_DIR2	0x101##a000##0680UL
+#define TS_C_DIR3	0x101##a000##06c0UL
+#define TS_C_IIC2	0x101##a000##0700UL
+#define TS_C_IIC3	0x101##a000##0740UL
 
 /*
  * Dchip CSR Map



CVS commit: src/sys/arch/alpha/pci

2020-06-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jun 17 03:50:05 UTC 2020

Modified Files:
src/sys/arch/alpha/pci: tsvar.h ttwogavar.h

Log Message:
#include  explicitly.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/alpha/pci/tsvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/pci/ttwogavar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsvar.h
diff -u src/sys/arch/alpha/pci/tsvar.h:1.13 src/sys/arch/alpha/pci/tsvar.h:1.14
--- src/sys/arch/alpha/pci/tsvar.h:1.13	Sun Dec 22 23:23:29 2019
+++ src/sys/arch/alpha/pci/tsvar.h	Wed Jun 17 03:50:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: tsvar.h,v 1.13 2019/12/22 23:23:29 thorpej Exp $ */
+/* $NetBSD: tsvar.h,v 1.14 2020/06/17 03:50:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -31,6 +31,7 @@
  *
  */
 
+#include 
 #include 
 #include 
 #include 

Index: src/sys/arch/alpha/pci/ttwogavar.h
diff -u src/sys/arch/alpha/pci/ttwogavar.h:1.4 src/sys/arch/alpha/pci/ttwogavar.h:1.5
--- src/sys/arch/alpha/pci/ttwogavar.h:1.4	Mon Feb  6 02:14:15 2012
+++ src/sys/arch/alpha/pci/ttwogavar.h	Wed Jun 17 03:50:04 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ttwogavar.h,v 1.4 2012/02/06 02:14:15 matt Exp $ */
+/* $NetBSD: ttwogavar.h,v 1.5 2020/06/17 03:50:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -29,6 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/alpha/pci

2015-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 11 08:46:43 UTC 2015

Modified Files:
src/sys/arch/alpha/pci: cia.c

Log Message:
Felix Deichmann in PR port-alpha/50326: cosmetic patch for Pyxis attach
message.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/alpha/pci/cia.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/cia.c
diff -u src/sys/arch/alpha/pci/cia.c:1.73 src/sys/arch/alpha/pci/cia.c:1.74
--- src/sys/arch/alpha/pci/cia.c:1.73	Mon Feb  6 02:14:14 2012
+++ src/sys/arch/alpha/pci/cia.c	Sun Oct 11 08:46:43 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cia.c,v 1.73 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: cia.c,v 1.74 2015/10/11 08:46:43 martin Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.73 2012/02/06 02:14:14 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cia.c,v 1.74 2015/10/11 08:46:43 martin Exp $");
 
 #include 
 #include 
@@ -268,7 +268,6 @@ ciaattach(device_t parent, device_t self
 	struct pcibus_attach_args pba;
 	char bits[64];
 	const char *name;
-	int pass;
 
 	/* note that we've attached the chipset; can't have 2 CIAs. */
 	ciafound = 1;
@@ -284,14 +283,12 @@ ciaattach(device_t parent, device_t self
 
 	if (ccp->cc_flags & CCF_ISPYXIS) {
 		name = "Pyxis";
-		pass = ccp->cc_rev;
 	} else {
 		name = "ALCOR/ALCOR2";
-		pass = ccp->cc_rev + 1;
 	}
 
 	aprint_normal(": DECchip 2117x Core Logic Chipset (%s), pass %d\n",
-	name, pass);
+	name, ccp->cc_rev + 1);
 	if (ccp->cc_cnfg) {
 		snprintb(bits, sizeof(bits), CIA_CSR_CNFG_BITS, ccp->cc_cnfg);
 		aprint_normal_dev(self, "extended capabilities: %s\n", bits);



CVS commit: src/sys/arch/alpha/pci

2014-01-18 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jan 19 03:44:13 UTC 2014

Modified Files:
src/sys/arch/alpha/pci: tsp_bus_mem.c

Log Message:
Set a proper address for PCI memspace to make bus_space_mmap(9) work correctly.

Reported and confirmed with radeonfb(4) by Naruaki Etomi in PR port-48431.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/pci/tsp_bus_mem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsp_bus_mem.c
diff -u src/sys/arch/alpha/pci/tsp_bus_mem.c:1.12 src/sys/arch/alpha/pci/tsp_bus_mem.c:1.13
--- src/sys/arch/alpha/pci/tsp_bus_mem.c:1.12	Mon Feb  6 02:14:15 2012
+++ src/sys/arch/alpha/pci/tsp_bus_mem.c	Sun Jan 19 03:44:13 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tsp_bus_mem.c,v 1.12 2012/02/06 02:14:15 matt Exp $ */
+/* $NetBSD: tsp_bus_mem.c,v 1.13 2014/01/19 03:44:13 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tsp_bus_mem.c,v 1.12 2012/02/06 02:14:15 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: tsp_bus_mem.c,v 1.13 2014/01/19 03:44:13 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -57,7 +57,8 @@ __KERNEL_RCSID(0, $NetBSD: tsp_bus_mem.
 #define	CHIP_MEM_EX_STORE_SIZE(v)	\
 	(sizeof (((struct tsp_config *)(v))-pc_mem_exstorage))
 
-#define CHIP_MEM_SYS_START(v)(((struct tsp_config *)(v))-pc_iobase)
+#define CHIP_MEM_SYS_START(v)		\
+	(((struct tsp_config *)(v))-pc_iobase | P_PCI_MEM)
 
 /*
  * Tsunami core logic appears on EV6.  We require at least EV56



CVS commit: src/sys/arch/alpha/pci

2014-01-15 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Wed Jan 15 14:27:49 UTC 2014

Modified Files:
src/sys/arch/alpha/pci: pci_bwx_bus_mem_chipdep.c

Log Message:
Revert previous.  PR/48431 claims ALPHA_PHYS_TO_K0SEG() is necessary.

Actually CHIP_MEM_SYS_START(v) seems a physical address per *_mem_map()
function, but I don't think mmap() function should return K0SEG address
(it should return PA cookie IIUC) so I guess there is something wrong
in Titan's bus space functions.  I'll investigate them later.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c
diff -u src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c:1.26 src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c:1.27
--- src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c:1.26	Mon Jan 13 15:48:09 2014
+++ src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c	Wed Jan 15 14:27:49 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.26 2014/01/13 15:48:09 tsutsui Exp $ */
+/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.27 2014/01/15 14:27:49 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.26 2014/01/13 15:48:09 tsutsui Exp $);
+__KERNEL_RCSID(1, $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.27 2014/01/15 14:27:49 tsutsui Exp $);
 
 #include sys/extent.h
 
@@ -499,10 +499,8 @@ __C(CHIP,_mem_mmap)(
 	int prot,
 	int flags)
 {
-	bus_addr_t memaddr;
 
-	memaddr = CHIP_MEM_SYS_START(v) + addr + off;
-	return (alpha_btop(ALPHA_K0SEG_TO_PHYS(memaddr)));
+	return (alpha_btop(CHIP_MEM_SYS_START(v) + addr + off));
 }
 
 static inline void



CVS commit: src/sys/arch/alpha/pci

2014-01-13 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Jan 13 15:48:09 UTC 2014

Modified Files:
src/sys/arch/alpha/pci: pci_bwx_bus_mem_chipdep.c

Log Message:
bus_space_mmap(9) function should return alpha_btop(PA), not alpha_btop(VA).

Pointed out in PR port-alpha/48431 from nullnilaki.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c
diff -u src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c:1.25 src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c:1.26
--- src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c:1.25	Mon Feb  6 02:14:15 2012
+++ src/sys/arch/alpha/pci/pci_bwx_bus_mem_chipdep.c	Mon Jan 13 15:48:09 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.25 2012/02/06 02:14:15 matt Exp $ */
+/* $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.26 2014/01/13 15:48:09 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.25 2012/02/06 02:14:15 matt Exp $);
+__KERNEL_RCSID(1, $NetBSD: pci_bwx_bus_mem_chipdep.c,v 1.26 2014/01/13 15:48:09 tsutsui Exp $);
 
 #include sys/extent.h
 
@@ -499,8 +499,10 @@ __C(CHIP,_mem_mmap)(
 	int prot,
 	int flags)
 {
+	bus_addr_t memaddr;
 
-	return (alpha_btop(CHIP_MEM_SYS_START(v) + addr + off));
+	memaddr = CHIP_MEM_SYS_START(v) + addr + off;
+	return (alpha_btop(ALPHA_K0SEG_TO_PHYS(memaddr)));
 }
 
 static inline void



CVS commit: src/sys/arch/alpha/pci

2013-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  4 16:58:14 UTC 2013

Modified Files:
src/sys/arch/alpha/pci: cia_dma.c pci_kn8ae.c

Log Message:
mark variables used


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/alpha/pci/cia_dma.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/pci/pci_kn8ae.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/cia_dma.c
diff -u src/sys/arch/alpha/pci/cia_dma.c:1.28 src/sys/arch/alpha/pci/cia_dma.c:1.29
--- src/sys/arch/alpha/pci/cia_dma.c:1.28	Sun Feb  5 21:14:14 2012
+++ src/sys/arch/alpha/pci/cia_dma.c	Mon Nov  4 11:58:14 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cia_dma.c,v 1.28 2012/02/06 02:14:14 matt Exp $ */
+/* $NetBSD: cia_dma.c,v 1.29 2013/11/04 16:58:14 christos 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: cia_dma.c,v 1.28 2012/02/06 02:14:14 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: cia_dma.c,v 1.29 2013/11/04 16:58:14 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -424,7 +424,6 @@ cia_tlb_invalidate(void)
 void
 cia_broken_pyxis_tlb_invalidate(void)
 {
-	volatile uint64_t dummy;
 	uint32_t ctrl;
 	int i, s;
 
@@ -447,9 +446,11 @@ cia_broken_pyxis_tlb_invalidate(void)
 	 * XXX to read more times than there are actual tags!
 	 */
 	for (i = 0; i  CIA_TLB_NTAGS + 4; i++) {
+		volatile uint64_t dummy;
 		dummy = *((volatile uint64_t *)
 		ALPHA_PHYS_TO_K0SEG(CIA_PCI_DENSE + CIA_PYXIS_BUG_BASE +
 		(i * 65536)));
+		__USE(dummy);
 	}
 
 	/*

Index: src/sys/arch/alpha/pci/pci_kn8ae.c
diff -u src/sys/arch/alpha/pci/pci_kn8ae.c:1.27 src/sys/arch/alpha/pci/pci_kn8ae.c:1.28
--- src/sys/arch/alpha/pci/pci_kn8ae.c:1.27	Sun Feb  5 21:14:15 2012
+++ src/sys/arch/alpha/pci/pci_kn8ae.c	Mon Nov  4 11:58:14 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_kn8ae.c,v 1.27 2012/02/06 02:14:15 matt Exp $ */
+/* $NetBSD: pci_kn8ae.c,v 1.28 2013/11/04 16:58:14 christos Exp $ */
 
 /*
  * Copyright (c) 1997 by Matthew Jacob
@@ -32,7 +32,7 @@
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: pci_kn8ae.c,v 1.27 2012/02/06 02:14:15 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: pci_kn8ae.c,v 1.28 2013/11/04 16:58:14 christos Exp $);
 
 #include sys/types.h
 #include sys/param.h
@@ -215,6 +215,7 @@ dec_kn8ae_intr_disestablish(void *ccv, v
 	vec = IH_VEC(ih);
 
 	scb = scb_iovectab[SCB_VECTOIDX(vec - SCB_IOVECBASE)];
+	__USE(scb);
 
 	kn8ae_enadis_intr(ccp, ih, 0);
 



CVS commit: src/sys/arch/alpha/pci

2013-11-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov  4 16:58:33 UTC 2013

Modified Files:
src/sys/arch/alpha/pci: pci_swiz_bus_io_chipdep.c
pci_swiz_bus_mem_chipdep.c

Log Message:
move ifdef'ed out code inside if 0


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/alpha/pci/pci_swiz_bus_io_chipdep.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/alpha/pci/pci_swiz_bus_mem_chipdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/pci_swiz_bus_io_chipdep.c
diff -u src/sys/arch/alpha/pci/pci_swiz_bus_io_chipdep.c:1.41 src/sys/arch/alpha/pci/pci_swiz_bus_io_chipdep.c:1.42
--- src/sys/arch/alpha/pci/pci_swiz_bus_io_chipdep.c:1.41	Sun Feb  5 21:14:15 2012
+++ src/sys/arch/alpha/pci/pci_swiz_bus_io_chipdep.c	Mon Nov  4 11:58:33 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.41 2012/02/06 02:14:15 matt Exp $ */
+/* $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.42 2013/11/04 16:58:33 christos Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.41 2012/02/06 02:14:15 matt Exp $);
+__KERNEL_RCSID(1, $NetBSD: pci_swiz_bus_io_chipdep.c,v 1.42 2013/11/04 16:58:33 christos Exp $);
 
 #include sys/extent.h
 
@@ -656,16 +656,15 @@ __C(CHIP,_io_read_4)(void *v, bus_space_
 	register bus_space_handle_t tmpioh;
 	register uint32_t *port, val;
 	register uint32_t rval;
-	register int offset;
 
 	alpha_mb();
 
 	tmpioh = ioh + off;
-	offset = tmpioh  3;
 	port = (uint32_t *)((tmpioh  CHIP_ADDR_SHIFT) |
 	(3  CHIP_SIZE_SHIFT));
 	val = *port;
 #if 0
+	int offset = tmpioh  3;
 	rval = ((val)  (8 * offset))  0x;
 #else
 	rval = val;
@@ -753,10 +752,12 @@ __C(CHIP,_io_write_4)(void *v, bus_space
 {
 	register bus_space_handle_t tmpioh;
 	register uint32_t *port, nval;
-	register int offset;
 
 	tmpioh = ioh + off;
+#if 0
+	register int offset;
 	offset = tmpioh  3;
+#endif
 	nval = val /* (8 * offset)*/;
 	port = (uint32_t *)((tmpioh  CHIP_ADDR_SHIFT) |
 	(3  CHIP_SIZE_SHIFT));

Index: src/sys/arch/alpha/pci/pci_swiz_bus_mem_chipdep.c
diff -u src/sys/arch/alpha/pci/pci_swiz_bus_mem_chipdep.c:1.46 src/sys/arch/alpha/pci/pci_swiz_bus_mem_chipdep.c:1.47
--- src/sys/arch/alpha/pci/pci_swiz_bus_mem_chipdep.c:1.46	Sun Feb  5 21:14:15 2012
+++ src/sys/arch/alpha/pci/pci_swiz_bus_mem_chipdep.c	Mon Nov  4 11:58:33 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.46 2012/02/06 02:14:15 matt Exp $ */
+/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.47 2013/11/04 16:58:33 christos Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -85,7 +85,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(1, $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.46 2012/02/06 02:14:15 matt Exp $);
+__KERNEL_RCSID(1, $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.47 2013/11/04 16:58:33 christos Exp $);
 
 #include sys/extent.h
 
@@ -982,7 +982,6 @@ __C(CHIP,_mem_read_4)(void *v, bus_space
 	register bus_space_handle_t tmpmemh;
 	register uint32_t *port, val;
 	register uint32_t rval;
-	register int offset;
 
 	alpha_mb();
 
@@ -992,11 +991,12 @@ __C(CHIP,_mem_read_4)(void *v, bus_space
 #endif
 
 	tmpmemh = memh + off;
-	offset = tmpmemh  3;
 	port = (uint32_t *)((tmpmemh  CHIP_ADDR_SHIFT) |
 	(3  CHIP_SIZE_SHIFT));
 	val = *port;
 #if 0
+	int offset;
+	offset = tmpmemh  3;
 	rval = ((val)  (8 * offset))  0x;
 #else
 	rval = val;
@@ -1102,7 +1102,6 @@ __C(CHIP,_mem_write_4)(void *v, bus_spac
 {
 	register bus_space_handle_t tmpmemh;
 	register uint32_t *port, nval;
-	register int offset;
 
 #ifdef CHIP_D_MEM_W1_SYS_START
 	if ((memh  63) != 0)
@@ -,7 +1110,10 @@ __C(CHIP,_mem_write_4)(void *v, bus_spac
 #endif
 	{
 		tmpmemh = memh + off;
+#if 0
+		int offset;
 		offset = tmpmemh  3;
+#endif
 	nval = val /* (8 * offset)*/;
 	port = (uint32_t *)((tmpmemh  CHIP_ADDR_SHIFT) |
 	(3  CHIP_SIZE_SHIFT));



CVS commit: src/sys/arch/alpha/pci

2013-09-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Sep 23 16:44:30 UTC 2013

Modified Files:
src/sys/arch/alpha/pci: tsc.c

Log Message:
Remove a 'register' declaration. Noted in PR port-alpha/48148.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/pci/tsc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsc.c
diff -u src/sys/arch/alpha/pci/tsc.c:1.20 src/sys/arch/alpha/pci/tsc.c:1.21
--- src/sys/arch/alpha/pci/tsc.c:1.20	Mon Sep 23 16:41:57 2013
+++ src/sys/arch/alpha/pci/tsc.c	Mon Sep 23 16:44:30 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: tsc.c,v 1.20 2013/09/23 16:41:57 tsutsui Exp $ */
+/* $NetBSD: tsc.c,v 1.21 2013/09/23 16:44:30 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: tsc.c,v 1.20 2013/09/23 16:41:57 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: tsc.c,v 1.21 2013/09/23 16:44:30 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -151,7 +151,7 @@ tscattach(device_t parent, device_t self
 static int
 tscprint(void *aux, const char *p)
 {
-	register struct tsp_attach_args *tsp = aux;
+	struct tsp_attach_args *tsp = aux;
 
 	if(p)
 		aprint_normal(%s%d at %s, tsp-tsp_name, tsp-tsp_slot, p);



CVS commit: src/sys/arch/alpha/pci

2013-09-23 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Sep 23 16:50:12 UTC 2013

Modified Files:
src/sys/arch/alpha/pci: tsc.c

Log Message:
KNF and TAB/space cleanup.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/pci/tsc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsc.c
diff -u src/sys/arch/alpha/pci/tsc.c:1.21 src/sys/arch/alpha/pci/tsc.c:1.22
--- src/sys/arch/alpha/pci/tsc.c:1.21	Mon Sep 23 16:44:30 2013
+++ src/sys/arch/alpha/pci/tsc.c	Mon Sep 23 16:50:12 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: tsc.c,v 1.21 2013/09/23 16:44:30 tsutsui Exp $ */
+/* $NetBSD: tsc.c,v 1.22 2013/09/23 16:50:12 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: tsc.c,v 1.21 2013/09/23 16:44:30 tsutsui Exp $);
+__KERNEL_RCSID(0, $NetBSD: tsc.c,v 1.22 2013/09/23 16:50:12 tsutsui Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -121,7 +121,7 @@ tscattach(device_t parent, device_t self
 		ma-ma_name, ma-ma_slot, 2448[CSC_BC(csc)],
 		nbus, nbus  1 ? es : , 16 + 16 * ((csc  CSC_AW) != 0));
 	printf(%s%d: arrays present: , ma-ma_name, ma-ma_slot);
-	for(i = 0; i  4; ++i) {
+	for (i = 0; i  4; ++i) {
 		aar = LDQP(TS_C_AAR0 + i * TS_STEP);
 		printf(%s%dMB%s, i ? ,  : , (8  AAR_ASIZ(aar))  ~0xf,
 		aar  AAR_SPLIT ?  (split) : );
@@ -130,8 +130,8 @@ tscattach(device_t parent, device_t self
 
 	memset(tsp, 0, sizeof tsp);
 	tsp.tsp_name = tsp;
-	tsp.tsp_slot = 0; 
-	
+	tsp.tsp_slot = 0;
+
 	config_found(self, tsp, tscprint);
 	if (titan) {
 		tsp.tsp_slot += 2;
@@ -153,7 +153,7 @@ tscprint(void *aux, const char *p)
 {
 	struct tsp_attach_args *tsp = aux;
 
-	if(p)
+	if (p)
 		aprint_normal(%s%d at %s, tsp-tsp_name, tsp-tsp_slot, p);
 	return UNCONF;
 }
@@ -185,7 +185,7 @@ tspattach(device_t parent, device_t self
 	pcp = tsp_init(1, t-tsp_slot);
 
 	tsp_dma_init(pcp);
-	
+
 	/*
 	 * Do PCI memory initialization that needs to be deferred until
 	 * malloc is safe.  On the Tsunami, we need to do this after
@@ -269,12 +269,12 @@ tsp_bus_get_window(int type, int window,
 
 	error = alpha_bus_space_get_window(st, window, abst);
 	if (error)
-		return (error);
+		return error;
 
 	abst-abst_sys_start = TS_PHYSADDR(abst-abst_sys_start);
 	abst-abst_sys_end = TS_PHYSADDR(abst-abst_sys_end);
 
-	return (0);
+	return 0;
 }
 
 void



CVS commit: src/sys/arch/alpha/pci

2010-12-14 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Dec 15 01:27:19 UTC 2010

Modified Files:
src/sys/arch/alpha/pci: a12c.c a12c_dma.c a12c_pci.c apecs.c
apecs_bus_io.c apecs_bus_mem.c apecs_dma.c apecs_pci.c cia.c
cia_bwx_bus_io.c cia_bwx_bus_mem.c cia_dma.c cia_pci.c
cia_swiz_bus_io.c cia_swiz_bus_mem.c dwlpx.c dwlpx_bus_io.c
dwlpx_bus_mem.c dwlpx_dma.c dwlpx_pci.c irongate_bus_io.c
irongate_bus_mem.c irongate_dma.c irongate_pci.c lca.c lca_bus_io.c
lca_bus_mem.c lca_dma.c lca_pci.c mcpcia_bus_io.c mcpcia_bus_mem.c
mcpcia_dma.c mcpcia_pci.c pci_1000.c pci_1000a.c pci_2100_a50.c
pci_550.c pci_6600.c pci_a12.c pci_alphabook1.c pci_axppci_33.c
pci_eb164.c pci_eb64plus.c pci_eb66.c pci_kn20aa.c pci_kn300.c
pci_kn8ae.c pci_machdep.c pci_sgmap_pte32.c pci_sgmap_pte64.c
pci_up1000.c tsp_bus_io.c tsp_bus_mem.c tsp_dma.c tsp_pci.c
ttwoga_dma.c

Log Message:
Remove unneeded includes of uvm/uvm_extern.h


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/alpha/pci/a12c.c \
src/sys/arch/alpha/pci/pci_1000.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/pci/a12c_dma.c \
src/sys/arch/alpha/pci/a12c_pci.c src/sys/arch/alpha/pci/irongate_pci.c \
src/sys/arch/alpha/pci/pci_sgmap_pte32.c \
src/sys/arch/alpha/pci/pci_sgmap_pte64.c \
src/sys/arch/alpha/pci/tsp_bus_io.c
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/alpha/pci/apecs.c \
src/sys/arch/alpha/pci/pci_kn20aa.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/pci/apecs_bus_io.c \
src/sys/arch/alpha/pci/apecs_bus_mem.c \
src/sys/arch/alpha/pci/lca_bus_io.c src/sys/arch/alpha/pci/lca_bus_mem.c \
src/sys/arch/alpha/pci/tsp_bus_mem.c src/sys/arch/alpha/pci/tsp_dma.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/alpha/pci/apecs_dma.c \
src/sys/arch/alpha/pci/lca_pci.c src/sys/arch/alpha/pci/mcpcia_dma.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/pci/apecs_pci.c
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/alpha/pci/cia.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/alpha/pci/cia_bwx_bus_io.c \
src/sys/arch/alpha/pci/cia_bwx_bus_mem.c \
src/sys/arch/alpha/pci/mcpcia_bus_io.c \
src/sys/arch/alpha/pci/mcpcia_bus_mem.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/pci/cia_dma.c
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/pci/cia_pci.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/alpha/pci/cia_swiz_bus_io.c \
src/sys/arch/alpha/pci/dwlpx_pci.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/cia_swiz_bus_mem.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/alpha/pci/dwlpx.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/pci/dwlpx_bus_io.c \
src/sys/arch/alpha/pci/dwlpx_bus_mem.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/alpha/pci/dwlpx_dma.c \
src/sys/arch/alpha/pci/pci_6600.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/pci/irongate_bus_io.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/pci/irongate_bus_mem.c \
src/sys/arch/alpha/pci/mcpcia_pci.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/pci/irongate_dma.c \
src/sys/arch/alpha/pci/ttwoga_dma.c
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/alpha/pci/lca.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/alpha/pci/lca_dma.c \
src/sys/arch/alpha/pci/pci_eb64plus.c src/sys/arch/alpha/pci/pci_eb66.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/alpha/pci/pci_1000a.c
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/alpha/pci/pci_2100_a50.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/alpha/pci/pci_550.c \
src/sys/arch/alpha/pci/pci_kn300.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/pci/pci_a12.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/alpha/pci/pci_alphabook1.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/alpha/pci/pci_axppci_33.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/alpha/pci/pci_eb164.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/alpha/pci/pci_kn8ae.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/pci/pci_machdep.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/alpha/pci/pci_up1000.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/pci/tsp_pci.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/a12c.c
diff -u src/sys/arch/alpha/pci/a12c.c:1.21 src/sys/arch/alpha/pci/a12c.c:1.22
--- src/sys/arch/alpha/pci/a12c.c:1.21	Sat Mar 14 21:04:02 2009
+++ src/sys/arch/alpha/pci/a12c.c	Wed Dec 15 01:27:18 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: a12c.c,v 1.21 2009/03/14 21:04:02 dsl Exp $ */
+/* $NetBSD: a12c.c,v 1.22 2010/12/15 01:27:18 matt Exp $ */
 
 /* [Notice revision 2.2]
  * Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
@@ -38,7 +38,7 @@
 #include opt_avalon_a12.h		/* Config options headers */
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: a12c.c,v 1.21 2009/03/14 21:04:02 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: a12c.c,v 1.22 2010/12/15 01:27:18 matt Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ 

CVS commit: src/sys/arch/alpha/pci

2010-04-15 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Apr 15 13:02:13 UTC 2010

Modified Files:
src/sys/arch/alpha/pci: apecs.c apecsvar.h

Log Message:
Share some attention with apecs(4).
 - Convert to CFATTACH_DECL_NEW().
 - Sprinkle static on functions.
 - Recycle now-empty-and/or-unused softc structures.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/alpha/pci/apecs.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/pci/apecsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/apecs.c
diff -u src/sys/arch/alpha/pci/apecs.c:1.49 src/sys/arch/alpha/pci/apecs.c:1.50
--- src/sys/arch/alpha/pci/apecs.c:1.49	Sat Mar 14 21:04:02 2009
+++ src/sys/arch/alpha/pci/apecs.c	Thu Apr 15 13:02:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: apecs.c,v 1.49 2009/03/14 21:04:02 dsl Exp $ */
+/* $NetBSD: apecs.c,v 1.50 2010/04/15 13:02:13 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 
 #include sys/cdefs.h			/* RCS ID  Copyright macro defns */
 
-__KERNEL_RCSID(0, $NetBSD: apecs.c,v 1.49 2009/03/14 21:04:02 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: apecs.c,v 1.50 2010/04/15 13:02:13 jakllsch Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -97,23 +97,22 @@
 #include alpha/pci/pci_1000.h
 #endif
 
-int	apecsmatch(struct device *, struct cfdata *, void *);
-void	apecsattach(struct device *, struct device *, void *);
+static int apecsmatch(device_t, cfdata_t, void *);
+static void apecsattach(device_t, device_t, void *);
 
-CFATTACH_DECL(apecs, sizeof(struct apecs_softc),
-apecsmatch, apecsattach, NULL, NULL);
+CFATTACH_DECL_NEW(apecs, 0, apecsmatch, apecsattach, NULL, NULL);
 
 extern struct cfdriver apecs_cd;
 
-int	apecs_bus_get_window(int, int,
-	struct alpha_bus_space_translation *);
+static int apecs_bus_get_window(int, int,
+struct alpha_bus_space_translation *);
 
 /* There can be only one. */
 int apecsfound;
 struct apecs_config apecs_configuration;
 
-int
-apecsmatch(struct device *parent, struct cfdata *match, void *aux)
+static int
+apecsmatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
 
@@ -163,10 +162,9 @@
 	acp-ac_initted = 1;
 }
 
-void
-apecsattach(struct device *parent, struct device *self, void *aux)
+static void
+apecsattach(device_t parent, device_t self, void *aux)
 {
-	struct apecs_softc *sc = (struct apecs_softc *)self;
 	struct apecs_config *acp;
 	struct pcibus_attach_args pba;
 
@@ -177,7 +175,7 @@
 	 * set up the chipset's info; done once at console init time
 	 * (maybe), but doesn't hurt to do twice.
 	 */
-	acp = sc-sc_acp = apecs_configuration;
+	acp = apecs_configuration;
 	apecs_init(acp, 1);
 
 	apecs_dma_init(acp);
@@ -237,7 +235,7 @@
 	config_found_ia(self, pcibus, pba, pcibusprint);
 }
 
-int
+static int
 apecs_bus_get_window(int type, int window, struct alpha_bus_space_translation *abst)
 {
 	struct apecs_config *acp = apecs_configuration;

Index: src/sys/arch/alpha/pci/apecsvar.h
diff -u src/sys/arch/alpha/pci/apecsvar.h:1.9 src/sys/arch/alpha/pci/apecsvar.h:1.10
--- src/sys/arch/alpha/pci/apecsvar.h:1.9	Sat Mar 14 14:45:53 2009
+++ src/sys/arch/alpha/pci/apecsvar.h	Thu Apr 15 13:02:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: apecsvar.h,v 1.9 2009/03/14 14:45:53 dsl Exp $ */
+/* $NetBSD: apecsvar.h,v 1.10 2010/04/15 13:02:13 jakllsch Exp $ */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -58,12 +58,6 @@
 	int	ac_mallocsafe;
 };
 
-struct apecs_softc {
-	struct	device sc_dev;
-
-	struct	apecs_config *sc_acp;
-};
-
 void	apecs_init(struct apecs_config *, int);
 void	apecs_pci_init(pci_chipset_tag_t, void *);
 void	apecs_dma_init(struct apecs_config *);



CVS commit: src/sys/arch/alpha/pci

2010-04-14 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Apr 15 03:09:12 UTC 2010

Modified Files:
src/sys/arch/alpha/pci: tsc.c tsvar.h

Log Message:
Give tsc(4)/tsp(4) some attention.
 - Convert to CFATTACH_DECL_NEW().
 - Sprinkle static on functions.
 - Improve KNF conformance.
 - Use C99 integer types.
 - Recycle now-empty-and/or-unused softc structures.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/pci/tsc.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/pci/tsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsc.c
diff -u src/sys/arch/alpha/pci/tsc.c:1.16 src/sys/arch/alpha/pci/tsc.c:1.17
--- src/sys/arch/alpha/pci/tsc.c:1.16	Sat Mar 14 21:04:02 2009
+++ src/sys/arch/alpha/pci/tsc.c	Thu Apr 15 03:09:12 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tsc.c,v 1.16 2009/03/14 21:04:02 dsl Exp $ */
+/* $NetBSD: tsc.c,v 1.17 2010/04/15 03:09:12 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -35,7 +35,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(0, $NetBSD: tsc.c,v 1.16 2009/03/14 21:04:02 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: tsc.c,v 1.17 2010/04/15 03:09:12 jakllsch Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -59,11 +59,10 @@
 
 #define tsc() { Generate ctags(1) key. }
 
-int	tscmatch(struct device *, struct cfdata *, void *);
-void	tscattach(struct device *, struct device *, void *);
+static int tscmatch(device_t, cfdata_t, void *);
+static void tscattach(device_t, device_t, void *);
 
-CFATTACH_DECL(tsc, sizeof(struct tsc_softc),
-tscmatch, tscattach, NULL, NULL);
+CFATTACH_DECL_NEW(tsc, 0, tscmatch, tscattach, NULL, NULL);
 
 extern struct cfdriver tsc_cd;
 
@@ -71,11 +70,10 @@
 
 static int tscprint(void *, const char *pnp);
 
-int	tspmatch(struct device *, struct cfdata *, void *);
-void	tspattach(struct device *, struct device *, void *);
+static int tspmatch(device_t, cfdata_t, void *);
+static void tspattach(device_t, device_t, void *);
 
-CFATTACH_DECL(tsp, sizeof(struct tsp_softc),
-tspmatch, tspattach, NULL, NULL);
+CFATTACH_DECL_NEW(tsp, 0, tspmatch, tspattach, NULL, NULL);
 
 extern struct cfdriver tsp_cd;
 
@@ -88,8 +86,8 @@
 /* Which hose is the display console connected to? */
 int tsp_console_hose;
 
-int
-tscmatch(struct device *parent, struct cfdata *match, void *aux)
+static int
+tscmatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct mainbus_attach_args *ma = aux;
 
@@ -98,13 +96,12 @@
 	 !tscfound;
 }
 
-void tscattach(parent, self, aux)
-	struct device *parent, *self;
-	void *aux;
+static void
+tscattach(device_t parent, device_t self, void * aux)
 {
 	int i;
 	int nbus;
-	u_int64_t csc, aar;
+	uint64_t csc, aar;
 	struct tsp_attach_args tsp;
 	struct mainbus_attach_args *ma = aux;
 
@@ -148,8 +145,8 @@
 
 #define tsp() { Generate ctags(1) key. }
 
-int
-tspmatch(struct device *parent, struct cfdata *match, void *aux)
+static int
+tspmatch(device_t parent, cfdata_t match, void *aux)
 {
 	struct tsp_attach_args *t = aux;
 
@@ -157,8 +154,8 @@
 	 strcmp(t-tsp_name, tsp_cd.cd_name) == 0;
 }
 
-void
-tspattach(struct device *parent, struct device *self, void *aux)
+static void
+tspattach(device_t parent, device_t self, void *aux)
 {
 	struct pcibus_attach_args pba;
 	struct tsp_attach_args *t = aux;
@@ -218,7 +215,8 @@
 }
 
 static int
-tsp_bus_get_window(int type, int window, struct alpha_bus_space_translation *abst)
+tsp_bus_get_window(int type, int window,
+struct alpha_bus_space_translation *abst)
 {
 	struct tsp_config *tsp = tsp_configuration[tsp_console_hose];
 	bus_space_tag_t st;

Index: src/sys/arch/alpha/pci/tsvar.h
diff -u src/sys/arch/alpha/pci/tsvar.h:1.7 src/sys/arch/alpha/pci/tsvar.h:1.8
--- src/sys/arch/alpha/pci/tsvar.h:1.7	Fri Oct 30 18:55:45 2009
+++ src/sys/arch/alpha/pci/tsvar.h	Thu Apr 15 03:09:12 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: tsvar.h,v 1.7 2009/10/30 18:55:45 mhitch Exp $ */
+/* $NetBSD: tsvar.h,v 1.8 2010/04/15 03:09:12 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -39,10 +39,6 @@
 
 #define	tsvar() { Generate ctags(1) key. }
 
-struct tsc_softc {
-	struct	device tsc_dev;
-};
-
 struct tsp_config {
 	int	pc_pslot;		/* Pchip 0 or 1 */
 	int	pc_initted;		/* Initialized */
@@ -66,11 +62,6 @@
 	int	pc_mallocsafe;
 };
 
-struct tsp_softc {
-	struct	device sc_dev;
-	struct	tsp_config *sc_ccp;
-};
-
 struct tsp_attach_args {
 	const char *tsp_name;
 	int	tsp_slot;



CVS commit: src/sys/arch/alpha/pci

2009-10-30 Thread Michael L. Hitch
Module Name:src
Committed By:   mhitch
Date:   Fri Oct 30 18:55:45 UTC 2009

Modified Files:
src/sys/arch/alpha/pci: tsp_bus_io.c tsp_bus_mem.c tsvar.h

Log Message:
The tsc(4) bus initialization was using a single statically allocated
extent storage for each tsp(4), which caused a LOCKDEBUG kernel to fail
because the extent storage contained a mutex which panics when the second
mutex_init() is attempted.  Put the extent storage into the tsp_config
structure so each tsp(4) gets it own.  Fixes PR port-alpha/38358.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/pci/tsp_bus_io.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/pci/tsp_bus_mem.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/pci/tsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/pci/tsp_bus_io.c
diff -u src/sys/arch/alpha/pci/tsp_bus_io.c:1.5 src/sys/arch/alpha/pci/tsp_bus_io.c:1.6
--- src/sys/arch/alpha/pci/tsp_bus_io.c:1.5	Thu Jun 29 08:58:50 2000
+++ src/sys/arch/alpha/pci/tsp_bus_io.c	Fri Oct 30 18:55:45 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tsp_bus_io.c,v 1.5 2000/06/29 08:58:50 mrg Exp $ */
+/* $NetBSD: tsp_bus_io.c,v 1.6 2009/10/30 18:55:45 mhitch Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -33,7 +33,7 @@
 
 #include sys/cdefs.h
 
-__KERNEL_RCSID(1, $NetBSD: tsp_bus_io.c,v 1.5 2000/06/29 08:58:50 mrg Exp $);
+__KERNEL_RCSID(1, $NetBSD: tsp_bus_io.c,v 1.6 2009/10/30 18:55:45 mhitch Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -58,6 +58,8 @@
 
 #define	CHIP_EX_MALLOC_SAFE(v)  (((TSPCON)(v))-pc_mallocsafe)
 #define CHIP_IO_EXTENT(v)   (((TSPCON)(v))-pc_io_ex)
+#define	CHIP_IO_EX_STORE(v)	(((TSPCON)(v))-pc_io_exstorage)
+#define	CHIP_IO_EX_STORE_SIZE(v) (sizeof (((TSPCON)(v))-pc_io_exstorage))
 
 #define CHIP_IO_SYS_START(v)(((TSPCON)(v))-pc_iobase | P_PCI_IO)
 

Index: src/sys/arch/alpha/pci/tsp_bus_mem.c
diff -u src/sys/arch/alpha/pci/tsp_bus_mem.c:1.8 src/sys/arch/alpha/pci/tsp_bus_mem.c:1.9
--- src/sys/arch/alpha/pci/tsp_bus_mem.c:1.8	Sun Dec 11 12:16:17 2005
+++ src/sys/arch/alpha/pci/tsp_bus_mem.c	Fri Oct 30 18:55:45 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tsp_bus_mem.c,v 1.8 2005/12/11 12:16:17 christos Exp $ */
+/* $NetBSD: tsp_bus_mem.c,v 1.9 2009/10/30 18:55:45 mhitch Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tsp_bus_mem.c,v 1.8 2005/12/11 12:16:17 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: tsp_bus_mem.c,v 1.9 2009/10/30 18:55:45 mhitch Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -55,6 +55,9 @@
 
 #define	CHIP_EX_MALLOC_SAFE(v)  (((struct tsp_config *)(v))-pc_mallocsafe)
 #define CHIP_MEM_EXTENT(v)   (((struct tsp_config *)(v))-pc_mem_ex)
+#define	CHIP_MEM_EX_STORE(v)	(((struct tsp_config *)(v))-pc_mem_exstorage)
+#define	CHIP_MEM_EX_STORE_SIZE(v)	\
+	(sizeof (((struct tsp_config *)(v))-pc_mem_exstorage))
 
 #define CHIP_MEM_SYS_START(v)(((struct tsp_config *)(v))-pc_iobase)
 

Index: src/sys/arch/alpha/pci/tsvar.h
diff -u src/sys/arch/alpha/pci/tsvar.h:1.6 src/sys/arch/alpha/pci/tsvar.h:1.7
--- src/sys/arch/alpha/pci/tsvar.h:1.6	Sat Mar 14 14:45:53 2009
+++ src/sys/arch/alpha/pci/tsvar.h	Fri Oct 30 18:55:45 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tsvar.h,v 1.6 2009/03/14 14:45:53 dsl Exp $ */
+/* $NetBSD: tsvar.h,v 1.7 2009/10/30 18:55:45 mhitch Exp $ */
 
 /*-
  * Copyright (c) 1999 by Ross Harvey.  All rights reserved.
@@ -35,6 +35,8 @@
 #include dev/pci/pcivar.h
 #include alpha/pci/pci_sgmap_pte64.h
 
+#define	_FSTORE	(EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long))
+
 #define	tsvar() { Generate ctags(1) key. }
 
 struct tsc_softc {
@@ -58,6 +60,8 @@
 	u_int32_t pc_hae_mem;
 	u_int32_t pc_hae_io;
 
+	long	pc_io_exstorage[_FSTORE];
+	long	pc_mem_exstorage[_FSTORE];
 	struct	extent *pc_io_ex, *pc_mem_ex;
 	int	pc_mallocsafe;
 };