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/ufs/chfs

2021-07-16 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jul 16 21:18:41 UTC 2021

Modified Files:
src/sys/ufs/chfs: chfs_gc.c chfs_scan.c

Log Message:
Fix incorrect function name, some grammar and typos in comments. Remove 
trailing tab symbol.
No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/chfs/chfs_gc.c \
src/sys/ufs/chfs/chfs_scan.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/ufs/chfs/chfs_gc.c
diff -u src/sys/ufs/chfs/chfs_gc.c:1.9 src/sys/ufs/chfs/chfs_gc.c:1.10
--- src/sys/ufs/chfs/chfs_gc.c:1.9	Thu Jun  1 02:45:15 2017
+++ src/sys/ufs/chfs/chfs_gc.c	Fri Jul 16 21:18:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: chfs_gc.c,v 1.9 2017/06/01 02:45:15 chs Exp $	*/
+/*	$NetBSD: chfs_gc.c,v 1.10 2021/07/16 21:18:41 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -89,7 +89,7 @@ chfs_gc_thread(void *data)
 	mutex_enter(>chm_lock_mountfields);
 	while (gc->gcth_running) {
 		/* we must call chfs_gc_thread_should_wake with chm_lock_mountfields
-		 * held, which is a bit awkwardly done here, but we cant relly
+		 * held, which is a bit awkwardly done here, but we can't really
 		 * do it otherway with the current design...
 		 */
 		if (chfs_gc_thread_should_wake(chmp)) {
@@ -127,7 +127,7 @@ chfs_gc_thread_start(struct chfs_mount *
 	"chfsgcth");
 }
 
-/* chfs_gc_thread_start - stops GC */
+/* chfs_gc_thread_stop - stops GC */
 void
 chfs_gc_thread_stop(struct chfs_mount *chmp)
 {
@@ -191,7 +191,7 @@ chfs_gc_thread_should_wake(struct chfs_m
 		return 1;
 	}
 
-	/* There is too much very dirty blocks. */
+	/* There are too much very dirty blocks. */
 	TAILQ_FOREACH(cheb, >chm_very_dirty_queue, queue) {
 		nr_very_dirty++;
 		if (nr_very_dirty == chmp->chm_vdirty_blocks_gctrigger) {
@@ -200,7 +200,7 @@ chfs_gc_thread_should_wake(struct chfs_m
 		}
 	}
 
-	/* Everythin OK, GC shouldn't run. */
+	/* Everything is OK, GC shouldn't run. */
 	return 0;
 }
 
Index: src/sys/ufs/chfs/chfs_scan.c
diff -u src/sys/ufs/chfs/chfs_scan.c:1.9 src/sys/ufs/chfs/chfs_scan.c:1.10
--- src/sys/ufs/chfs/chfs_scan.c:1.9	Thu Jul 15 22:39:06 2021
+++ src/sys/ufs/chfs/chfs_scan.c	Fri Jul 16 21:18:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: chfs_scan.c,v 1.9 2021/07/15 22:39:06 andvar Exp $	*/
+/*	$NetBSD: chfs_scan.c,v 1.10 2021/07/16 21:18:41 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -225,7 +225,7 @@ chfs_add_fd_to_list(struct chfs_mount *c
 	new->nsize);
 	cheb = >chm_blocks[new->nref->nref_lnr];
 
-	mutex_enter(>chm_lock_sizes);	
+	mutex_enter(>chm_lock_sizes);
 	TAILQ_FOREACH_SAFE(fd, >scan_dirents, fds, tmpfd) {
 		if (fd->nhash > new->nhash) {
 			/* insert new before fd */



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

2021-07-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 16 19:13:21 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: vm_machdep.c

Log Message:
Instrument success/faulure of phyisically contiguous uarea allocation.


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/alpha/alpha/vm_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/alpha/vm_machdep.c
diff -u src/sys/arch/alpha/alpha/vm_machdep.c:1.120 src/sys/arch/alpha/alpha/vm_machdep.c:1.121
--- src/sys/arch/alpha/alpha/vm_machdep.c:1.120	Tue Jul  6 12:20:52 2021
+++ src/sys/arch/alpha/alpha/vm_machdep.c	Fri Jul 16 19:13:21 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vm_machdep.c,v 1.120 2021/07/06 12:20:52 thorpej Exp $ */
+/* $NetBSD: vm_machdep.c,v 1.121 2021/07/16 19:13:21 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -29,7 +29,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.120 2021/07/06 12:20:52 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.121 2021/07/16 19:13:21 thorpej Exp $");
 
 #include 
 #include 
@@ -248,6 +248,14 @@ vunmapbuf(struct buf *bp, vsize_t len)
 }
 
 #ifdef __HAVE_CPU_UAREA_ROUTINES
+static struct evcnt uarea_direct_success =
+EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "uarea direct", "success");
+static struct evcnt uarea_direct_failure =
+EVCNT_INITIALIZER(EVCNT_TYPE_MISC, NULL, "uarea direct", "failure");
+
+EVCNT_ATTACH_STATIC(uarea_direct_success);
+EVCNT_ATTACH_STATIC(uarea_direct_failure);
+
 void *
 cpu_uarea_alloc(bool system)
 {
@@ -259,8 +267,11 @@ cpu_uarea_alloc(bool system)
 	 * direct-mapped.
 	 */
 	error = uvm_pglistalloc(USPACE, 0, ptoa(physmem), 0, 0, , 1, 1);
-	if (error)
+	if (error) {
+		atomic_inc_ulong(_direct_failure.ev_count);
 		return NULL;
+	}
+	atomic_inc_ulong(_direct_success.ev_count);
 
 	/*
 	 * Get the physical address from the first page.



CVS commit: src/sys/arch/alpha

2021-07-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 16 19:02:22 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: interrupt.c pmap.c
src/sys/arch/alpha/include: intr.h

Log Message:
The Alpha AXP Architecture Reference Manual is explcit that the only
valid bits in the PSL are the IPL and USER bits, the latter of which
will always be clear when in the kernel, and that all other bits MBZ.
So, when reading the PSL to get the current IPL, don't bother masking
with ALPHA_PSL_IPL_MASK.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/alpha/alpha/interrupt.c
cvs rdiff -u -r1.297 -r1.298 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/alpha/include/intr.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/alpha/interrupt.c
diff -u src/sys/arch/alpha/alpha/interrupt.c:1.98 src/sys/arch/alpha/alpha/interrupt.c:1.99
--- src/sys/arch/alpha/alpha/interrupt.c:1.98	Sun Jul  4 22:42:35 2021
+++ src/sys/arch/alpha/alpha/interrupt.c	Fri Jul 16 19:02:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: interrupt.c,v 1.98 2021/07/04 22:42:35 thorpej Exp $ */
+/* $NetBSD: interrupt.c,v 1.99 2021/07/16 19:02:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.98 2021/07/04 22:42:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupt.c,v 1.99 2021/07/16 19:02:22 thorpej Exp $");
 
 #include 
 #include 
@@ -502,7 +502,7 @@ void
 softint_trigger(uintptr_t const machdep)
 {
 	/* No need for an atomic; called at splhigh(). */
-	KASSERT((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) == ALPHA_PSL_IPL_HIGH);
+	KASSERT(alpha_pal_rdps() == ALPHA_PSL_IPL_HIGH);
 	curcpu()->ci_ssir |= machdep;
 }
 
@@ -534,8 +534,7 @@ softint_init_md(lwp_t * const l, u_int c
 		ci->ci_ssir &= ~SOFTINT_##level##_MASK;			\
 		alpha_softint_switchto(l, IPL_SOFT##level,		\
 		ci->ci_silwps[SOFTINT_##level]);			\
-		KASSERT((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) ==	\
-		ALPHA_PSL_IPL_HIGH);\
+		KASSERT(alpha_pal_rdps() == ALPHA_PSL_IPL_HIGH);	\
 		continue;		\
 	}\
 
@@ -553,7 +552,7 @@ alpha_softint_dispatch(int const ipl)
 	unsigned long ssir;
 	const unsigned long eligible = SOFTINTS_ELIGIBLE(ipl);
 
-	KASSERT((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) == ALPHA_PSL_IPL_HIGH);
+	KASSERT(alpha_pal_rdps() == ALPHA_PSL_IPL_HIGH);
 
 	for (;;) {
 		ssir = ci->ci_ssir & eligible;

Index: src/sys/arch/alpha/alpha/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.297 src/sys/arch/alpha/alpha/pmap.c:1.298
--- src/sys/arch/alpha/alpha/pmap.c:1.297	Sat Jul 10 20:22:37 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Fri Jul 16 19:02:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.297 2021/07/10 20:22:37 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.298 2021/07/16 19:02:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.297 2021/07/10 20:22:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.298 2021/07/16 19:02:22 thorpej Exp $");
 
 #include 
 #include 
@@ -1027,7 +1027,7 @@ pmap_tlb_shootnow(const struct pmap_tlb_
 	 * interrupts and disable preemption.  It is critically important
 	 * that IPIs not be blocked in this routine.
 	 */
-	KASSERT((alpha_pal_rdps() & ALPHA_PSL_IPL_MASK) < ALPHA_PSL_IPL_CLOCK);
+	KASSERT(alpha_pal_rdps() < ALPHA_PSL_IPL_CLOCK);
 	mutex_spin_enter(_lock);
 	tlb_evcnt.ev_count++;
 
@@ -1121,7 +1121,7 @@ pmap_tlb_shootnow(const struct pmap_tlb_
 tlb_pending);
 printf("TLB CONTEXT = %p\n", tlb_context);
 printf("TLB LOCAL IPL = %lu\n",
-alpha_pal_rdps() & ALPHA_PSL_IPL_MASK);
+alpha_pal_rdps());
 panic("pmap_tlb_shootnow");
 			}
 		}

Index: src/sys/arch/alpha/include/intr.h
diff -u src/sys/arch/alpha/include/intr.h:1.84 src/sys/arch/alpha/include/intr.h:1.85
--- src/sys/arch/alpha/include/intr.h:1.84	Sun Jul  4 22:36:43 2021
+++ src/sys/arch/alpha/include/intr.h	Fri Jul 16 19:02:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: intr.h,v 1.84 2021/07/04 22:36:43 thorpej Exp $ */
+/* $NetBSD: intr.h,v 1.85 2021/07/16 19:02:22 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -157,7 +157,7 @@ void	spllower(int);
 static __inline int
 _splraise(int s)
 {
-	int cur = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK;
+	int cur = (int)alpha_pal_rdps();
 	return (s > cur ? (int)alpha_pal_swpipl(s) : cur);
 }
 



CVS commit: src/sys/arch/alpha

2021-07-16 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 16 18:50:19 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: dec_alphabook1.c dec_axppci_33.c dec_eb66.c
src/sys/arch/alpha/pci: lca.c lcavar.h

Log Message:
On LCA45 systems, look at the memory controller's Bcache configuration
to initialize uvmexp.ncolors rather than hard-coding a value per model
(some models can have more than one configuration).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/alpha/dec_alphabook1.c
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/alpha/alpha/dec_axppci_33.c
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/alpha/alpha/dec_eb66.c
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/alpha/pci/lca.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/pci/lcavar.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/alpha/dec_alphabook1.c
diff -u src/sys/arch/alpha/alpha/dec_alphabook1.c:1.27 src/sys/arch/alpha/alpha/dec_alphabook1.c:1.28
--- src/sys/arch/alpha/alpha/dec_alphabook1.c:1.27	Sat Oct 13 17:58:54 2012
+++ src/sys/arch/alpha/alpha/dec_alphabook1.c	Fri Jul 16 18:50:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_alphabook1.c,v 1.27 2012/10/13 17:58:54 jdc Exp $ */
+/* $NetBSD: dec_alphabook1.c,v 1.28 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_alphabook1.c,v 1.27 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_alphabook1.c,v 1.28 2021/07/16 18:50:19 thorpej Exp $");
 
 #include 
 #include 
@@ -107,6 +107,8 @@ dec_alphabook1_init(void)
 	platform.iobus = "lca";
 	platform.cons_init = dec_alphabook1_cons_init;
 	platform.device_register = dec_alphabook1_device_register;
+
+	lca_probe_bcache();
 }
 
 static void

Index: src/sys/arch/alpha/alpha/dec_axppci_33.c
diff -u src/sys/arch/alpha/alpha/dec_axppci_33.c:1.67 src/sys/arch/alpha/alpha/dec_axppci_33.c:1.68
--- src/sys/arch/alpha/alpha/dec_axppci_33.c:1.67	Sat Oct 13 17:58:54 2012
+++ src/sys/arch/alpha/alpha/dec_axppci_33.c	Fri Jul 16 18:50:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_axppci_33.c,v 1.67 2012/10/13 17:58:54 jdc Exp $ */
+/* $NetBSD: dec_axppci_33.c,v 1.68 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_axppci_33.c,v 1.67 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_axppci_33.c,v 1.68 2021/07/16 18:50:19 thorpej Exp $");
 
 #include 
 #include 
@@ -43,8 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: dec_axppci_3
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
@@ -156,13 +154,7 @@ dec_axppci_33_init(void)
 
 	/* Leave nsio mapped to catch any accidental port space collisions  */
 
-	/*
-	 * AXPpci33 systems have either 0, 256K, or 1M secondary
-	 * caches.  Default to middle-of-the-road.
-	 *
-	 * XXX Dynamically size it!
-	 */
-	uvmexp.ncolors = atop(256 * 1024);
+	lca_probe_bcache();
 }
 
 static void

Index: src/sys/arch/alpha/alpha/dec_eb66.c
diff -u src/sys/arch/alpha/alpha/dec_eb66.c:1.28 src/sys/arch/alpha/alpha/dec_eb66.c:1.29
--- src/sys/arch/alpha/alpha/dec_eb66.c:1.28	Sat Oct 13 17:58:54 2012
+++ src/sys/arch/alpha/alpha/dec_eb66.c	Fri Jul 16 18:50:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dec_eb66.c,v 1.28 2012/10/13 17:58:54 jdc Exp $ */
+/* $NetBSD: dec_eb66.c,v 1.29 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*
  * Copyright (c) 1995, 1996, 1997 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: dec_eb66.c,v 1.28 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dec_eb66.c,v 1.29 2021/07/16 18:50:19 thorpej Exp $");
 
 #include 
 #include 
@@ -43,8 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: dec_eb66.c,v
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
@@ -110,10 +108,7 @@ dec_eb66_init(void)
 	platform.cons_init = dec_eb66_cons_init;
 	platform.device_register = dec_eb66_device_register;
 
-	/*
-	 * EB66 systems have 1M secondary caches.
-	 */
-	uvmexp.ncolors = atop(1 * 1024 * 1024);
+	lca_probe_bcache();
 }
 
 static void

Index: src/sys/arch/alpha/pci/lca.c
diff -u src/sys/arch/alpha/pci/lca.c:1.55 src/sys/arch/alpha/pci/lca.c:1.56
--- src/sys/arch/alpha/pci/lca.c:1.55	Sun Jul  4 22:42:36 2021
+++ src/sys/arch/alpha/pci/lca.c	Fri Jul 16 18:50:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lca.c,v 1.55 2021/07/04 22:42:36 thorpej Exp $ */
+/* $NetBSD: lca.c,v 1.56 2021/07/16 18:50:19 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -58,13 +58,15 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lca.c,v 1.55 2021/07/04 22:42:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lca.c,v 1.56 

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/lib/libc/stdio

2021-07-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jul 16 12:34:10 UTC 2021

Modified Files:
src/lib/libc/stdio: fvwrite.c

Log Message:
When fflush fails, adjust pointers and the io vectors. From RVP. Fixes
core-dump at cvs(1) exit(3).


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/stdio/fvwrite.c

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

Modified files:

Index: src/lib/libc/stdio/fvwrite.c
diff -u src/lib/libc/stdio/fvwrite.c:1.27 src/lib/libc/stdio/fvwrite.c:1.28
--- src/lib/libc/stdio/fvwrite.c:1.27	Thu Jul  8 05:06:51 2021
+++ src/lib/libc/stdio/fvwrite.c	Fri Jul 16 08:34:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fvwrite.c,v 1.27 2021/07/08 09:06:51 christos Exp $	*/
+/*	$NetBSD: fvwrite.c,v 1.28 2021/07/16 12:34:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fvwrite.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fvwrite.c,v 1.27 2021/07/08 09:06:51 christos Exp $");
+__RCSID("$NetBSD: fvwrite.c,v 1.28 2021/07/16 12:34:10 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -51,6 +51,40 @@ __RCSID("$NetBSD: fvwrite.c,v 1.27 2021/
 #include "local.h"
 #include "fvwrite.h"
 
+static int
+flush_adj(FILE *fp, struct __suio *uio, struct __siov *iov, ssize_t w)
+{
+	int rc;
+
+	_DIAGASSERT(w >= 0);
+	_DIAGASSERT(fp->_w >= 0);
+
+	if ((rc = fflush(fp)) == 0)
+		return 0;
+
+	/*
+	 * If we have to return without writing the whole buffer,
+	 * adjust for how much fflush() has written for us.
+	 * `w' is the amt. of new user data just copied into our
+	 * internal buffer in _this_ fwrite() call.
+ */
+	if (fp->_w < w)	{
+		/* some new data was also written */
+		ssize_t i = w - fp->_w;
+
+		/* adjust amt. written */
+		uio->uio_resid -= i;
+		iov->iov_len -= i;
+	} else {
+		/* only old stuff was written */
+
+		/* adjust _p and _w so user can retry */
+		fp->_p -= w;
+		fp->_w += w;
+	}
+	return rc;
+}
+
 /*
  * Write some memory regions.  Return zero on success, EOF on error.
  *
@@ -102,10 +136,8 @@ __sfvwrite(FILE *fp, struct __suio *uio)
 	if (w <= 0) \
 		goto err
 #define FLUSH(nw) \
-	if (fflush(fp)) { \
-		fp->_p -= nw;	/* rewind unwritten */ \
-		goto err; \
-	}
+	if (flush_adj(fp, uio, iov - 1, nw)) \
+		goto err
 
 	if (fp->_flags & __SNBF) {
 		/*



CVS commit: src/sys/dev/pci

2021-07-16 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jul 16 12:20:01 UTC 2021

Modified Files:
src/sys/dev/pci: xmm7360.c

Log Message:
Add missing RCSID, remove non-breaking space characters in copyright, remove 
vim modeline (from yambo in IRC).
ok riastradh


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/xmm7360.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/dev/pci/xmm7360.c
diff -u src/sys/dev/pci/xmm7360.c:1.7 src/sys/dev/pci/xmm7360.c:1.8
--- src/sys/dev/pci/xmm7360.c:1.7	Sat Apr 24 23:36:57 2021
+++ src/sys/dev/pci/xmm7360.c	Fri Jul 16 12:20:01 2021
@@ -1,4 +1,5 @@
-// vim: noet ts=8 sts=8 sw=8
+/*	$NetBSD: xmm7360.c,v 1.8 2021/07/16 12:20:01 andvar Exp $	*/
+
 /*
  * Device driver for Intel XMM7360 LTE modems, eg. Fibocom L850-GL.
  * Written by James Wah
@@ -6,8 +7,8 @@
  *
  * Development of this driver was supported by genua GmbH
  *
- * Copyright (c) 2020 genua GmbH 
- * Copyright (c) 2020 James Wah 
+ * Copyright (c) 2020 genua GmbH 
+ * Copyright (c) 2020 James Wah 
  *
  * The OpenBSD and NetBSD support was written by Jaromir Dolecek for
  * Moritz Systems Technology Company Sp. z o.o.
@@ -74,7 +75,7 @@ MODULE_DEVICE_TABLE(pci, xmm7360_ids);
 #include "opt_gateway.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.7 2021/04/24 23:36:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xmm7360.c,v 1.8 2021/07/16 12:20:01 andvar Exp $");
 #endif
 
 #include 



CVS commit: src/sbin/mount_chfs

2021-07-16 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jul 16 12:09:36 UTC 2021

Modified Files:
src/sbin/mount_chfs: mount_chfs.c

Log Message:
Remove commented code, including empty if block. Replace tab with whitespace in 
usage declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/mount_chfs/mount_chfs.c

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

Modified files:

Index: src/sbin/mount_chfs/mount_chfs.c
diff -u src/sbin/mount_chfs/mount_chfs.c:1.4 src/sbin/mount_chfs/mount_chfs.c:1.5
--- src/sbin/mount_chfs/mount_chfs.c:1.4	Mon Jun  7 21:44:35 2021
+++ src/sbin/mount_chfs/mount_chfs.c	Fri Jul 16 12:09:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount_chfs.c,v 1.4 2021/06/07 21:44:35 dholland Exp $	*/
+/*	$NetBSD: mount_chfs.c,v 1.5 2021/07/16 12:09:36 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -61,7 +61,7 @@ static const struct mntopt mopts[] = {
 
 /* - */
 
-static void	usage(void) __dead;
+static void usage(void) __dead;
 
 /* - */
 
@@ -98,7 +98,6 @@ mount_chfs_parseargs(int argc, char *arg
 	if (argc != 2)
 		usage();
 
-	//strlcpy(canon_dev, argv[0], MAXPATHLEN);
 	pathadj(argv[0], canon_dev);
 	pathadj(argv[1], canon_dir);
 
@@ -137,11 +136,6 @@ mount_chfs(int argc, char *argv[])
 		err(EXIT_FAILURE, "chfs on %s", fs_name);
 	}
 
-	if (mntflags & MNT_GETARGS) {
-
-		//(void)printf("flash index=%d\n",  args.fl_index);
-	}
-
 	return EXIT_SUCCESS;
 }
 



CVS commit: src/doc

2021-07-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Jul 16 10:02:50 UTC 2021

Modified Files:
src/doc: HACKS

Log Message:
PR port-sh3/56311

Correct misinterpretation for the cause of the problem, and link to
the bug report for upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/doc/HACKS

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

Modified files:

Index: src/doc/HACKS
diff -u src/doc/HACKS:1.223 src/doc/HACKS:1.224
--- src/doc/HACKS:1.223	Thu Jul 15 08:02:47 2021
+++ src/doc/HACKS	Fri Jul 16 10:02:50 2021
@@ -1,4 +1,4 @@
-# $NetBSD: HACKS,v 1.223 2021/07/15 08:02:47 rin Exp $
+# $NetBSD: HACKS,v 1.224 2021/07/16 10:02:50 rin Exp $
 #
 # This file is intended to document workarounds for currently unsolved
 # (mostly) compiler bugs.
@@ -1001,9 +1001,12 @@ kcah
 port	sh3
 hack	compile lint1/initdecl() with -O0 for sh3 (port-sh3/56311)
 cdate	Thu Jul 15 07:58:05 UTC 2021
+mdate	Fri Jul 16 10:00:00 UTC 2021
 who	rin
 file	src/usr.bin/xlint/lint1/decl.c: 1.200
-descr	GCC 9 and 10 miscompile initdecl() due to improper use of scratch
-	register, as described in the PR. Compiling this function with -O0
-	works around the problem.
+descr	GCC 9 and 10 miscompile initdecl() due to mischoice of register,
+	as described in the PR. Compiling this function with -O0 works
+	around the problem.
+	The problem has been reported to upstream as GCC Bug 101469:
+	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101469
 kcah