CVS commit: src/sys/arch/evbarm/conf

2021-08-18 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Aug 18 09:18:09 UTC 2021

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
 It's time to add ixg(4) and ixv(4).


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/arch/evbarm/conf/GENERIC64

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/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.179 src/sys/arch/evbarm/conf/GENERIC64:1.180
--- src/sys/arch/evbarm/conf/GENERIC64:1.179	Sat Jun 26 09:29:14 2021
+++ src/sys/arch/evbarm/conf/GENERIC64	Wed Aug 18 09:18:09 2021
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.179 2021/06/26 09:29:14 nia Exp $
+#	$NetBSD: GENERIC64,v 1.180 2021/08/18 09:18:09 msaitoh Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -252,6 +252,8 @@ genet*		at fdt?
 #scx*		at fdt?
 aq*		at pci? dev ? function ?	# Aquantia AQC 10 gigabit
 ena*		at pci? dev ? function ?	# Amazon.com Elastic Network Adapter
+ixg*	at pci? dev ? function ?	# Intel 8259x 10 gigabit
+ixv*	at pci? dev ? function ?	# Intel 8259x 10G virtual function
 mcx*		at pci? dev ? function ?	# Mellanox 5th generation Ethernet
 mskc*		at pci? dev ? function ?	# Marvell Yukon 2 Gigabit Ethernet
 msk*		at mskc?



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

2021-08-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Aug 13 20:19:45 UTC 2021

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

Log Message:
fix multiple typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/sys/arch/alpha/alpha/pmap.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/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.300 src/sys/arch/alpha/alpha/pmap.c:1.301
--- src/sys/arch/alpha/alpha/pmap.c:1.300	Sat Jul 31 14:51:25 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Fri Aug 13 20:19:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.300 2021/07/31 14:51:25 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.301 2021/08/13 20:19:45 andvar Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2007, 2008, 2020
@@ -106,8 +106,8 @@
  *
  *	All user page table access is done via K0SEG.  Kernel
  *	page table access is done via the recursive Virtual Page
- *	Table becase kernel PT pages are pre-allocated and never
- *	freed, so no VPT fault handling is requiried.
+ *	Table because kernel PT pages are pre-allocated and never
+ *	freed, so no VPT fault handling is required.
  */
 
 /*
@@ -135,7 +135,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.300 2021/07/31 14:51:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.301 2021/08/13 20:19:45 andvar Exp $");
 
 #include 
 #include 
@@ -578,9 +578,9 @@ pmap_pvlist_free(struct pmap_pvlist * co
  * that includes room for 8 VAs, the pmap the VAs belong to, a bitmap of
  * CPUs to be notified, and a list for PT pages that are freed during
  * removal off mappings.  The number of valid addresses in the list as
- * well as flags are sqeezed into the lower bits of the first two VAs.
+ * well as flags are squeezed into the lower bits of the first two VAs.
  * Storage for this structure is allocated on the stack.  We need to be
- * careful to keep the size of this struture under control.
+ * careful to keep the size of this structure under control.
  *
  * When notifying remote CPUs, we acquire the tlb_lock (which also
  * blocks IPIs), record the pointer to our context structure, set a
@@ -589,9 +589,9 @@ pmap_pvlist_free(struct pmap_pvlist * co
  * any invalidations necessary on the local CPU.  Once that is done,
  * we then wait the the global context pointer to be cleared, which
  * will be done by the final remote CPU to complete their work. This
- * method reduces cache line contention during pocessing.
+ * method reduces cache line contention during processing.
  *
- * When removing mappings in user pmaps, this implemention frees page
+ * When removing mappings in user pmaps, this implementation frees page
  * table pages back to the VM system once they contain no valid mappings.
  * As we do this, we must ensure to invalidate TLB entries that the
  * CPU might hold for the respective recursive VPT mappings.  This must
@@ -1038,7 +1038,7 @@ pmap_tlb_shootnow(const struct pmap_tlb_
 
 	/*
 	 * Figure out who to notify.  If it's for the kernel or
-	 * multiple aaddress spaces, we notify everybody.  If
+	 * multiple address spaces, we notify everybody.  If
 	 * it's a single user pmap, then we try to acquire the
 	 * activation lock so we can get an accurate accounting
 	 * of who needs to be notified.  If we can't acquire
@@ -2094,7 +2094,7 @@ pmap_enter_tlb_shootdown(pmap_t const pm
  * pmap_enter_l2pt_delref:
  *
  *	Release a reference on an L2 PT page for pmap_enter().
- *	This is factored out separately becacause we expect it
+ *	This is factored out separately because we expect it
  *	to be a rare case.
  */
 static void __noinline
@@ -2105,7 +2105,7 @@ pmap_enter_l2pt_delref(pmap_t const pmap
 
 	/*
 	 * PALcode may have tried to service a TLB miss with
-	 * this L2 PTE, so we need to make sure we don't actully
+	 * this L2 PTE, so we need to make sure we don't actually
 	 * free the PT page untl we've shot down any TLB entries
 	 * for this VPT index.
 	 */
@@ -2122,7 +2122,7 @@ pmap_enter_l2pt_delref(pmap_t const pmap
  * pmap_enter_l3pt_delref:
  *
  *	Release a reference on an L3 PT page for pmap_enter().
- *	This is factored out separately becacause we expect it
+ *	This is factored out separately because we expect it
  *	to be a rare case.
  */
 static void __noinline
@@ -2133,8 +2133,8 @@ pmap_enter_l3pt_delref(pmap_t const pmap
 
 	/*
 	 * PALcode may have tried to service a TLB miss with
-	 * this PTE, so we need to make sure we don't actully
-	 * free the PT page untl we've shot down any TLB entries
+	 * this PTE, so we need to make sure we don't actually
+	 * free the PT page until we've shot down any TLB entries
 	 * for this VPT index.
 	 */
 
@@ -2256,7 +2256,7 @@ pmap_enter(pmap_t pmap, vaddr_t va, padd
 	 * new one immediately.
 	 */
 	if ((opte & PG_V) == 0) {
-		/* No TLB invalidatons needed for new mappings. */
+		/* No TLB 

CVS commit: src/sys/arch/arm/footbridge

2021-08-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug 13 11:40:43 UTC 2021

Modified Files:
src/sys/arch/arm/footbridge: footbridge.c footbridge_clock.c
footbridge_com.c footbridge_com_io.c footbridge_intr.h
footbridge_io.c footbridge_irqhandler.c footbridge_pci.c
src/sys/arch/arm/footbridge/isa: dsrtc.c isa_io.c isa_io_asm.S
isa_machdep.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/footbridge/footbridge.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/footbridge/footbridge_clock.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/arm/footbridge/footbridge_com.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/footbridge/footbridge_com_io.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/footbridge/footbridge_intr.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/footbridge/footbridge_io.c
cvs rdiff -u -r1.27 -r1.28 \
src/sys/arch/arm/footbridge/footbridge_irqhandler.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/footbridge/footbridge_pci.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/footbridge/isa/dsrtc.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/footbridge/isa/isa_io.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/footbridge/isa/isa_io_asm.S
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/footbridge/isa/isa_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/arm/footbridge/footbridge.c
diff -u src/sys/arch/arm/footbridge/footbridge.c:1.28 src/sys/arch/arm/footbridge/footbridge.c:1.29
--- src/sys/arch/arm/footbridge/footbridge.c:1.28	Sat Aug  7 16:18:43 2021
+++ src/sys/arch/arm/footbridge/footbridge.c	Fri Aug 13 11:40:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: footbridge.c,v 1.28 2021/08/07 16:18:43 thorpej Exp $	*/
+/*	$NetBSD: footbridge.c,v 1.29 2021/08/13 11:40:43 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997,1998 Mark Brinicombe.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: footbridge.c,v 1.28 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: footbridge.c,v 1.29 2021/08/13 11:40:43 skrll Exp $");
 
 #include 
 #include 
@@ -58,7 +58,7 @@ __KERNEL_RCSID(0, "$NetBSD: footbridge.c
 #include 
 #include 
 #include 
- 
+
 /*
  * DC21285 'Footbridge' device
  *
@@ -126,8 +126,8 @@ footbridge_print(void *aux, const char *
  * int footbridge_match(device_t parent, cfdata_t cf, void *aux)
  *
  * Just return ok for this if it is device 0
- */ 
- 
+ */
+
 static int
 footbridge_match(device_t parent, cfdata_t cf, void *aux)
 {
@@ -141,7 +141,7 @@ footbridge_match(device_t parent, cfdata
  * void footbridge_attach(device_t parent, device_t dev, void *aux)
  *
  */
-  
+
 static void
 footbridge_attach(device_t parent, device_t self, void *aux)
 {
@@ -188,7 +188,7 @@ footbridge_attach(device_t parent, devic
 	"targ abt", footbridge_intr, sc);
 	sc->sc_parity_ih = footbridge_intr_claim(IRQ_PARITY, IPL_HIGH,
 	"parity", footbridge_intr, sc);
-	
+
 	/* Set up the PCI bus tags */
 	footbridge_create_io_bs_tag(_pci_io_bs_tag,
 	(void *)DC21285_PCI_IO_VBASE);
@@ -220,7 +220,7 @@ footbridge_attach(device_t parent, devic
 break;
 		mask--;
 		mask &= SDRAM_MASK_256MB;
-		
+
 		/*
 		 * configure the mask, the offset into SDRAM and the address
 		 * SDRAM is exposed on the PCI bus.
@@ -255,7 +255,7 @@ footbridge_attach(device_t parent, devic
 	fba.fba_fca.fca_tx_irq = IRQ_SERIAL_TX;
 	config_found(self, _fca, footbridge_print,
 	CFARGS(.iattr = "footbridge"));
-	
+
 	/* Setup fast SA110 cache clean area */
 #ifdef CPU_SA110
 	if (cputype == CPU_ID_SA110)

Index: src/sys/arch/arm/footbridge/footbridge_clock.c
diff -u src/sys/arch/arm/footbridge/footbridge_clock.c:1.26 src/sys/arch/arm/footbridge/footbridge_clock.c:1.27
--- src/sys/arch/arm/footbridge/footbridge_clock.c:1.26	Tue Jul 21 07:35:55 2009
+++ src/sys/arch/arm/footbridge/footbridge_clock.c	Fri Aug 13 11:40:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: footbridge_clock.c,v 1.26 2009/07/21 07:35:55 skrll Exp $	*/
+/*	$NetBSD: footbridge_clock.c,v 1.27 2021/08/13 11:40:43 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997 Mark Brinicombe.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: footbridge_clock.c,v 1.26 2009/07/21 07:35:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: footbridge_clock.c,v 1.27 2021/08/13 11:40:43 skrll Exp $");
 
 /* Include header files */
 
@@ -88,8 +88,8 @@ CFATTACH_DECL_NEW(footbridge_clock, size
  * int clockmatch(device_t parent, cfdata_t cf, void *aux);
  *
  * Just return ok for this if it is device 0
- */ 
- 
+ */
+
 static int
 clockmatch(device_t parent, cfdata_t cf, void *aux)
 {
@@ -105,7 +105,7 @@ clockmatch(device_t parent, cfdata_t cf,
  * void clockattach(device_t parent, device_t self, void *aux)
  *
  */
-  
+
 static void
 clockattach(device_t parent, device_t self, void *aux)
 {
@@ -119,7 +119,7 @@ clockattach(device_t parent, device_t se
 	clock_sc = sc;
 
 	/* 

CVS commit: src/sys/arch/amiga/amiga

2021-08-12 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Aug 12 20:13:54 UTC 2021

Modified Files:
src/sys/arch/amiga/amiga: cc.c cc.h

Log Message:
s/iterrupt sever/interrupt server/


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amiga/amiga/cc.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/amiga/amiga/cc.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/amiga/amiga/cc.c
diff -u src/sys/arch/amiga/amiga/cc.c:1.27 src/sys/arch/amiga/amiga/cc.c:1.28
--- src/sys/arch/amiga/amiga/cc.c:1.27	Sun Aug 20 11:03:04 2017
+++ src/sys/arch/amiga/amiga/cc.c	Thu Aug 12 20:13:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cc.c,v 1.27 2017/08/20 11:03:04 maxv Exp $	*/
+/*	$NetBSD: cc.c,v 1.28 2021/08/12 20:13:54 andvar Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cc.c,v 1.27 2017/08/20 11:03:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cc.c,v 1.28 2021/08/12 20:13:54 andvar Exp $");
 
 #include 
 #include 
@@ -61,7 +61,7 @@ custom_chips_init(void)
 }
 
 /*
- * Vertical blank iterrupt sever chains.
+ * Vertical blank interrupt server chains.
  */
 LIST_HEAD(vbllist, vbl_node) vbl_list;
 

Index: src/sys/arch/amiga/amiga/cc.h
diff -u src/sys/arch/amiga/amiga/cc.h:1.18 src/sys/arch/amiga/amiga/cc.h:1.19
--- src/sys/arch/amiga/amiga/cc.h:1.18	Fri Jan  3 07:14:20 2014
+++ src/sys/arch/amiga/amiga/cc.h	Thu Aug 12 20:13:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cc.h,v 1.18 2014/01/03 07:14:20 mlelstv Exp $	*/
+/*	$NetBSD: cc.h,v 1.19 2021/08/12 20:13:54 andvar Exp $	*/
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -71,7 +71,7 @@ struct audio_channel {
 #define AUCC_ALLDMAF (DMAF_AUD0|DMAF_AUD1|DMAF_AUD2|DMAF_AUD3)
 
 /*
- * Vertical blank iterrupt sever chains.
+ * Vertical blank interrupt server chains.
  */
 
 struct vbl_node {



CVS commit: src/sys/arch/arm/cortex

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 17:12:31 UTC 2021

Modified Files:
src/sys/arch/arm/cortex: files.cortex gic.c gicv3.c

Log Message:
Make gic_splfuncs optional and disable it by default until it has had
more testing.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/cortex/files.cortex
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/arm/cortex/gic.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/arm/cortex/gicv3.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/arm/cortex/files.cortex
diff -u src/sys/arch/arm/cortex/files.cortex:1.15 src/sys/arch/arm/cortex/files.cortex:1.16
--- src/sys/arch/arm/cortex/files.cortex:1.15	Tue Aug 10 15:33:09 2021
+++ src/sys/arch/arm/cortex/files.cortex	Tue Aug 10 17:12:31 2021
@@ -1,4 +1,4 @@
-# $NetBSD: files.cortex,v 1.15 2021/08/10 15:33:09 jmcneill Exp $
+# $NetBSD: files.cortex,v 1.16 2021/08/10 17:12:31 jmcneill Exp $
 
 defflag opt_cpu_in_cksum.h			NEON_IN_CKSUM
 
@@ -11,16 +11,16 @@ device	armperiph: mpcorebus
 attach	armperiph at mainbus
 file	arch/arm/cortex/armperiph.c		armperiph
 
-define	gic_splfuncs
+defflag	opt_gic.hGIC_SPLFUNCS
 file	arch/arm/cortex/gic_splfuncs.c		gic_splfuncs
 
 # ARM Generic Interrupt Controller (initially on Cortex-A9)
-device	armgic: pic, pic_splfuncs, gic_splfuncs
+device	armgic: pic, pic_splfuncs
 attach	armgic at mpcorebus
 file	arch/arm/cortex/gic.c			armgic
 
 # ARM Generic Interrupt Controller v3+
-device	gicvthree: pic, pic_splfuncs, gic_splfuncs
+device	gicvthree: pic, pic_splfuncs
 file	arch/arm/cortex/gicv3.c			gicvthree
 file	arch/arm/cortex/gicv3_its.c		gicvthree & pci & __have_pci_msi_msix
 

Index: src/sys/arch/arm/cortex/gic.c
diff -u src/sys/arch/arm/cortex/gic.c:1.48 src/sys/arch/arm/cortex/gic.c:1.49
--- src/sys/arch/arm/cortex/gic.c:1.48	Tue Aug 10 15:33:09 2021
+++ src/sys/arch/arm/cortex/gic.c	Tue Aug 10 17:12:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic.c,v 1.48 2021/08/10 15:33:09 jmcneill Exp $	*/
+/*	$NetBSD: gic.c,v 1.49 2021/08/10 17:12:31 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,11 +30,12 @@
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
+#include "opt_gic.h"
 
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.48 2021/08/10 15:33:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.49 2021/08/10 17:12:31 jmcneill Exp $");
 
 #include 
 #include 
@@ -50,9 +51,12 @@ __KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.48
 #include 
 
 #include 
-#include 
 #include 
 
+#ifdef GIC_SPLFUNCS
+#include 
+#endif
+
 void armgic_irq_handler(void *);
 
 #define	ARMGIC_SGI_IPIBASE	0
@@ -730,7 +734,9 @@ armgic_attach(device_t parent, device_t 
 	"%u SGIs\n",  priorities, sc->sc_gic_lines - ppis - sgis, ppis,
 	sgis);
 
+#ifdef GIC_SPLFUNCS
 	gic_spl_init();
+#endif
 }
 
 CFATTACH_DECL_NEW(armgic, 0,

Index: src/sys/arch/arm/cortex/gicv3.c
diff -u src/sys/arch/arm/cortex/gicv3.c:1.45 src/sys/arch/arm/cortex/gicv3.c:1.46
--- src/sys/arch/arm/cortex/gicv3.c:1.45	Tue Aug 10 15:33:09 2021
+++ src/sys/arch/arm/cortex/gicv3.c	Tue Aug 10 17:12:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.c,v 1.45 2021/08/10 15:33:09 jmcneill Exp $ */
+/* $NetBSD: gicv3.c,v 1.46 2021/08/10 17:12:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -27,11 +27,12 @@
  */
 
 #include "opt_multiprocessor.h"
+#include "opt_gic.h"
 
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.45 2021/08/10 15:33:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.46 2021/08/10 17:12:31 jmcneill Exp $");
 
 #include 
 #include 
@@ -51,7 +52,10 @@ __KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.
 
 #include 
 #include 
+
+#ifdef GIC_SPLFUNCS
 #include 
+#endif
 
 #define	PICTOSOFTC(pic)	\
 	((void *)((uintptr_t)(pic) - offsetof(struct gicv3_softc, sc_pic)))
@@ -952,7 +956,9 @@ gicv3_init(struct gicv3_softc *sc)
 #endif
 #endif
 
+#ifdef GIC_SPLFUNCS
 	gic_spl_init();
+#endif
 
 	return 0;
 }



CVS commit: src/sys/arch/arm/dts

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 16:52:43 UTC 2021

Modified Files:
src/sys/arch/arm/dts: sun50i-a64-sopine-baseboard.dts

Log Message:
Enable DVFS


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts

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/arm/dts/sun50i-a64-sopine-baseboard.dts
diff -u src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts:1.4 src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts:1.5
--- src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts:1.4	Wed Jun 30 06:24:02 2021
+++ src/sys/arch/arm/dts/sun50i-a64-sopine-baseboard.dts	Tue Aug 10 16:52:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sun50i-a64-sopine-baseboard.dts,v 1.4 2021/06/30 06:24:02 skrll Exp $ */
+/* $NetBSD: sun50i-a64-sopine-baseboard.dts,v 1.5 2021/08/10 16:52:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -37,3 +37,15 @@
 	status = "okay";
 };
 
+ {
+cpu-supply = <_dcdc2>;
+operating-points = <
+/* kHzuV */
+1152000 130
+1104000 126
+1008000 120
+816000  108
+648000  104
+408000  100
+>;
+};



CVS commit: src/sys/arch/arm/cortex

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:33:09 UTC 2021

Modified Files:
src/sys/arch/arm/cortex: files.cortex gic.c gicv3.c
Added Files:
src/sys/arch/arm/cortex: gic_splfuncs.c gic_splfuncs.h

Log Message:
Use custom spl funcs for GIC and avoid unnecessary pmr register accesses
in splx.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/cortex/files.cortex
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/arm/cortex/gic.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/cortex/gic_splfuncs.c \
src/sys/arch/arm/cortex/gic_splfuncs.h
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/cortex/gicv3.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/arm/cortex/files.cortex
diff -u src/sys/arch/arm/cortex/files.cortex:1.14 src/sys/arch/arm/cortex/files.cortex:1.15
--- src/sys/arch/arm/cortex/files.cortex:1.14	Tue Sep 29 19:58:50 2020
+++ src/sys/arch/arm/cortex/files.cortex	Tue Aug 10 15:33:09 2021
@@ -1,4 +1,4 @@
-# $NetBSD: files.cortex,v 1.14 2020/09/29 19:58:50 jmcneill Exp $
+# $NetBSD: files.cortex,v 1.15 2021/08/10 15:33:09 jmcneill Exp $
 
 defflag opt_cpu_in_cksum.h			NEON_IN_CKSUM
 
@@ -11,13 +11,16 @@ device	armperiph: mpcorebus
 attach	armperiph at mainbus
 file	arch/arm/cortex/armperiph.c		armperiph
 
+define	gic_splfuncs
+file	arch/arm/cortex/gic_splfuncs.c		gic_splfuncs
+
 # ARM Generic Interrupt Controller (initially on Cortex-A9)
-device	armgic: pic, pic_splfuncs
+device	armgic: pic, pic_splfuncs, gic_splfuncs
 attach	armgic at mpcorebus
 file	arch/arm/cortex/gic.c			armgic
 
 # ARM Generic Interrupt Controller v3+
-device	gicvthree: pic, pic_splfuncs
+device	gicvthree: pic, pic_splfuncs, gic_splfuncs
 file	arch/arm/cortex/gicv3.c			gicvthree
 file	arch/arm/cortex/gicv3_its.c		gicvthree & pci & __have_pci_msi_msix
 

Index: src/sys/arch/arm/cortex/gic.c
diff -u src/sys/arch/arm/cortex/gic.c:1.47 src/sys/arch/arm/cortex/gic.c:1.48
--- src/sys/arch/arm/cortex/gic.c:1.47	Sun Mar 28 09:11:38 2021
+++ src/sys/arch/arm/cortex/gic.c	Tue Aug 10 15:33:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic.c,v 1.47 2021/03/28 09:11:38 skrll Exp $	*/
+/*	$NetBSD: gic.c,v 1.48 2021/08/10 15:33:09 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -34,7 +34,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.47 2021/03/28 09:11:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.48 2021/08/10 15:33:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -50,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.47
 #include 
 
 #include 
+#include 
 #include 
 
 void armgic_irq_handler(void *);
@@ -224,11 +225,10 @@ armgic_set_priority(struct pic_softc *pi
 	struct armgic_softc * const sc = PICTOSOFTC(pic);
 	struct cpu_info * const ci = curcpu();
 
-	const uint32_t priority = armgic_ipl_to_priority(ipl);
-	if (priority > ci->ci_hwpl) {
+	if (ipl < ci->ci_hwpl) {
 		/* Lowering priority mask */
-		ci->ci_hwpl = priority;
-		gicc_write(sc, GICC_PMR, priority);
+		ci->ci_hwpl = ipl;
+		gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(ipl));
 	}
 }
 
@@ -327,10 +327,9 @@ armgic_irq_handler(void *tf)
 
 	ci->ci_data.cpu_nintr++;
 
-	const uint32_t priority = armgic_ipl_to_priority(old_ipl);
-	if (ci->ci_hwpl != priority) {
-		ci->ci_hwpl = priority;
-		gicc_write(sc, GICC_PMR, priority);
+	if (ci->ci_hwpl != old_ipl) {
+		ci->ci_hwpl = old_ipl;
+		gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(old_ipl));
 		if (old_ipl == IPL_HIGH) {
 			return;
 		}
@@ -545,7 +544,7 @@ armgic_cpu_init(struct pic_softc *pic, s
 			sc->sc_enabled_local);
 		}
 	}
-	ci->ci_hwpl = armgic_ipl_to_priority(ci->ci_cpl);
+	ci->ci_hwpl = ci->ci_cpl;
 	gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(ci->ci_cpl));	// set PMR
 	gicc_write(sc, GICC_CTRL, GICC_CTRL_V1_Enable);	// enable interrupt
 	ENABLE_INTERRUPT();// allow IRQ exceptions
@@ -730,6 +729,8 @@ armgic_attach(device_t parent, device_t 
 	aprint_normal_dev(sc->sc_dev, "%u Priorities, %zu SPIs, %u PPIs, "
 	"%u SGIs\n",  priorities, sc->sc_gic_lines - ppis - sgis, ppis,
 	sgis);
+
+	gic_spl_init();
 }
 
 CFATTACH_DECL_NEW(armgic, 0,

Index: src/sys/arch/arm/cortex/gicv3.c
diff -u src/sys/arch/arm/cortex/gicv3.c:1.44 src/sys/arch/arm/cortex/gicv3.c:1.45
--- src/sys/arch/arm/cortex/gicv3.c:1.44	Sun Mar 28 11:13:24 2021
+++ src/sys/arch/arm/cortex/gicv3.c	Tue Aug 10 15:33:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3.c,v 1.44 2021/03/28 11:13:24 jmcneill Exp $ */
+/* $NetBSD: gicv3.c,v 1.45 2021/08/10 15:33:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -31,7 +31,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.44 2021/03/28 11:13:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3.c,v 1.45 2021/08/10 15:33:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: 

CVS commit: src/sys/arch/arm/pic

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:31:55 UTC 2021

Modified Files:
src/sys/arch/arm/pic: pic_splfuncs.c picvar.h

Log Message:
arm: pic: allow overriding _splraise/_spllower/splx


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/pic/pic_splfuncs.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/arm/pic/picvar.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/arm/pic/pic_splfuncs.c
diff -u src/sys/arch/arm/pic/pic_splfuncs.c:1.20 src/sys/arch/arm/pic/pic_splfuncs.c:1.21
--- src/sys/arch/arm/pic/pic_splfuncs.c:1.20	Sat Mar 27 12:15:09 2021
+++ src/sys/arch/arm/pic/pic_splfuncs.c	Tue Aug 10 15:31:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic_splfuncs.c,v 1.20 2021/03/27 12:15:09 jmcneill Exp $	*/
+/*	$NetBSD: pic_splfuncs.c,v 1.21 2021/08/10 15:31:55 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.20 2021/03/27 12:15:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_splfuncs.c,v 1.21 2021/08/10 15:31:55 jmcneill Exp $");
 
 #define _INTR_PRIVATE
 #include 
@@ -46,9 +46,16 @@ __KERNEL_RCSID(0, "$NetBSD: pic_splfuncs
 
 #include 
 
+static int	pic_default_splraise(int);
+static int	pic_default_spllower(int);
+static void	pic_default_splx(int);
+
+int (*_splraise)(int) = pic_default_splraise;
+int (*_spllower)(int) = pic_default_spllower;
+void (*splx)(int) = pic_default_splx;
 
-int
-_splraise(int newipl)
+static int
+pic_default_splraise(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
@@ -58,8 +65,9 @@ _splraise(int newipl)
 	}
 	return oldipl;
 }
-int
-_spllower(int newipl)
+
+static int
+pic_default_spllower(int newipl)
 {
 	struct cpu_info * const ci = curcpu();
 	const int oldipl = ci->ci_cpl;
@@ -76,8 +84,8 @@ _spllower(int newipl)
 	return oldipl;
 }
 
-void
-splx(int savedipl)
+static void
+pic_default_splx(int savedipl)
 {
 	struct cpu_info * const ci = curcpu();
 	KASSERT(savedipl < NIPL);

Index: src/sys/arch/arm/pic/picvar.h
diff -u src/sys/arch/arm/pic/picvar.h:1.34 src/sys/arch/arm/pic/picvar.h:1.35
--- src/sys/arch/arm/pic/picvar.h:1.34	Sat Mar 27 12:15:09 2021
+++ src/sys/arch/arm/pic/picvar.h	Tue Aug 10 15:31:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: picvar.h,v 1.34 2021/03/27 12:15:09 jmcneill Exp $	*/
+/*	$NetBSD: picvar.h,v 1.35 2021/08/10 15:31:55 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -40,9 +40,10 @@
 
 typedef uint32_t	intr_handle_t;		/* for ACPI */
 
-int	_splraise(int);
-int	_spllower(int);
-void	splx(int);
+extern int	(*_splraise)(int);
+extern int	(*_spllower)(int);
+extern void	(*splx)(int);
+
 const char *
 	intr_typename(int);
 



CVS commit: src/sys/arch/arm/acpi

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:31:38 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Disable MSI if the linux,pcie-nomsi flag is present


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/acpi/acpipchb.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/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.27 src/sys/arch/arm/acpi/acpipchb.c:1.28
--- src/sys/arch/arm/acpi/acpipchb.c:1.27	Sat Aug  7 21:27:53 2021
+++ src/sys/arch/arm/acpi/acpipchb.c	Tue Aug 10 15:31:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.27 2021/08/07 21:27:53 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.28 2021/08/10 15:31:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.27 2021/08/07 21:27:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.28 2021/08/10 15:31:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ acpipchb_attach(device_t parent, device_
 	struct acpipchb_softc * const sc = device_private(self);
 	struct acpi_attach_args *aa = aux;
 	struct pcibus_attach_args pba;
-	ACPI_INTEGER seg;
+	ACPI_INTEGER seg, nomsi;
 	ACPI_STATUS rv;
 	uint16_t bus_start;
 
@@ -148,6 +148,11 @@ acpipchb_attach(device_t parent, device_
 		seg = 0;
 	}
 
+	if (ACPI_FAILURE(acpi_dsd_integer(sc->sc_handle, "linux,pcie-nomsi",
+	))) {
+		nomsi = 0;
+	}
+
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");
 
@@ -156,6 +161,9 @@ acpipchb_attach(device_t parent, device_
 	memset(, 0, sizeof(pba));
 	pba.pba_flags = aa->aa_pciflags &
 			~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
+	if (nomsi) {
+		pba.pba_flags &= ~(PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY);
+	}
 	pba.pba_memt = 0;
 	pba.pba_iot = 0;
 	pba.pba_dmat = aa->aa_dmat;



CVS commit: src/sys/arch/evbarm

2021-08-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Aug 10 06:47:49 UTC 2021

Modified Files:
src/sys/arch/evbarm/imx23_olinuxino: imx23_olinuxino_machdep.c
src/sys/arch/evbarm/include: bootconfig.h
src/sys/arch/evbarm/integrator: integrator_machdep.c

Log Message:
G/C unused flag


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 \
src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/include/bootconfig.h
cvs rdiff -u -r1.79 -r1.80 \
src/sys/arch/evbarm/integrator/integrator_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/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c
diff -u src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c:1.11 src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c:1.12
--- src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c:1.11	Sat Nov 28 14:02:30 2020
+++ src/sys/arch/evbarm/imx23_olinuxino/imx23_olinuxino_machdep.c	Tue Aug 10 06:47:48 2021
@@ -1,4 +1,4 @@
-/* $Id: imx23_olinuxino_machdep.c,v 1.11 2020/11/28 14:02:30 skrll Exp $ */
+/* $Id: imx23_olinuxino_machdep.c,v 1.12 2021/08/10 06:47:48 skrll Exp $ */
 
 /*
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -178,7 +178,7 @@ initarm(void *arg)
 	bootconfig.dramblocks = 1;
 	bootconfig.dram[0].address = DRAM_BASE;
 	bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
-	bootconfig.dram[0].flags = BOOT_DRAM_CAN_DMA | BOOT_DRAM_PREFER;
+	bootconfig.dram[0].flags = BOOT_DRAM_CAN_DMA;
 
 arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
 ((vsize_t)_BASE_phys));

Index: src/sys/arch/evbarm/include/bootconfig.h
diff -u src/sys/arch/evbarm/include/bootconfig.h:1.10 src/sys/arch/evbarm/include/bootconfig.h:1.11
--- src/sys/arch/evbarm/include/bootconfig.h:1.10	Mon Jun 18 13:05:20 2018
+++ src/sys/arch/evbarm/include/bootconfig.h	Tue Aug 10 06:47:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootconfig.h,v 1.10 2018/06/18 13:05:20 jmcneill Exp $	*/
+/*	$NetBSD: bootconfig.h,v 1.11 2021/08/10 06:47:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 1994 Mark Brinicombe.
@@ -51,7 +51,6 @@ typedef struct _PhysMem {
 	u_int pages;
 	u_int flags;
 #define BOOT_DRAM_CAN_DMA 1	/* Can DMA direct to this memory.  */
-#define BOOT_DRAM_PREFER  2	/* UVM should prefer this memory.  */
 } PhysMem;
 
 #ifndef	DRAM_BLOCKS

Index: src/sys/arch/evbarm/integrator/integrator_machdep.c
diff -u src/sys/arch/evbarm/integrator/integrator_machdep.c:1.79 src/sys/arch/evbarm/integrator/integrator_machdep.c:1.80
--- src/sys/arch/evbarm/integrator/integrator_machdep.c:1.79	Sat Apr 18 11:00:39 2020
+++ src/sys/arch/evbarm/integrator/integrator_machdep.c	Tue Aug 10 06:47:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: integrator_machdep.c,v 1.79 2020/04/18 11:00:39 skrll Exp $	*/
+/*	$NetBSD: integrator_machdep.c,v 1.80 2021/08/10 06:47:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001,2002 ARM Ltd
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: integrator_machdep.c,v 1.79 2020/04/18 11:00:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: integrator_machdep.c,v 1.80 2021/08/10 06:47:49 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_console.h"
@@ -371,7 +371,7 @@ initarm(void *arg)
 	bootconfig.dramblocks = 1;
 	bootconfig.dram[0].address = memstart;
 	bootconfig.dram[0].pages = memsize / PAGE_SIZE;
-	bootconfig.dram[0].flags = BOOT_DRAM_CAN_DMA | BOOT_DRAM_PREFER;
+	bootconfig.dram[0].flags = BOOT_DRAM_CAN_DMA;
 
 	arm32_bootmem_init(bootconfig.dram[0].address,
 		bootconfig.dram[0].pages * PAGE_SIZE, (unsigned int) KERNEL_BASE_phys);



CVS commit: src/sys/arch

2021-08-09 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Aug  9 21:13:06 UTC 2021

Modified Files:
src/sys/arch/amiga/dev: grf_rh.c
src/sys/arch/mips/include: cpuregs.h
src/sys/arch/mvme68k/dev: zsvar.h

Log Message:
s/definitons/definitions/


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/amiga/dev/grf_rh.c
cvs rdiff -u -r1.111 -r1.112 src/sys/arch/mips/include/cpuregs.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mvme68k/dev/zsvar.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/amiga/dev/grf_rh.c
diff -u src/sys/arch/amiga/dev/grf_rh.c:1.59 src/sys/arch/amiga/dev/grf_rh.c:1.60
--- src/sys/arch/amiga/dev/grf_rh.c:1.59	Sat Aug  7 16:18:41 2021
+++ src/sys/arch/amiga/dev/grf_rh.c	Mon Aug  9 21:13:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_rh.c,v 1.59 2021/08/07 16:18:41 thorpej Exp $ */
+/*	$NetBSD: grf_rh.c,v 1.60 2021/08/09 21:13:05 andvar Exp $ */
 
 /*
  * Copyright (c) 1994 Markus Wild
@@ -34,7 +34,7 @@
 #include "opt_retina.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: grf_rh.c,v 1.59 2021/08/07 16:18:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_rh.c,v 1.60 2021/08/09 21:13:05 andvar Exp $");
 
 #include "grfrh.h"
 #include "ite.h"
@@ -1221,7 +1221,7 @@ unsigned char RZ3StdPalette[16*3] = {
  * Make sure your maximum width (MW) and height (MH) are even multiples of
  * the fonts' width and height.
  *
- * You may use definitons created by the old DefineMonitor, but you'll get
+ * You may use definitions created by the old DefineMonitor, but you'll get
  * better results with the new DefineMonitor supplied along with the Retin Z3.
 */
 

Index: src/sys/arch/mips/include/cpuregs.h
diff -u src/sys/arch/mips/include/cpuregs.h:1.111 src/sys/arch/mips/include/cpuregs.h:1.112
--- src/sys/arch/mips/include/cpuregs.h:1.111	Sat May 29 12:35:27 2021
+++ src/sys/arch/mips/include/cpuregs.h	Mon Aug  9 21:13:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuregs.h,v 1.111 2021/05/29 12:35:27 simonb Exp $	*/
+/*	$NetBSD: cpuregs.h,v 1.112 2021/08/09 21:13:05 andvar Exp $	*/
 
 /*
  * Copyright (c) 2009 Miodrag Vallat.
@@ -273,7 +273,7 @@
 #define	MIPS_SR_INT_ENA_PREV	MIPS1_SR_INT_ENA_PREV
 
 /*
- * R4000 status register bit definitons,
+ * R4000 status register bit definitions,
  * where different from r2000/r3000.
  */
 #define	MIPS3_SR_XX		0x8000

Index: src/sys/arch/mvme68k/dev/zsvar.h
diff -u src/sys/arch/mvme68k/dev/zsvar.h:1.12 src/sys/arch/mvme68k/dev/zsvar.h:1.13
--- src/sys/arch/mvme68k/dev/zsvar.h:1.12	Mon Apr 28 20:23:29 2008
+++ src/sys/arch/mvme68k/dev/zsvar.h	Mon Aug  9 21:13:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: zsvar.h,v 1.12 2008/04/28 20:23:29 martin Exp $	*/
+/*	$NetBSD: zsvar.h,v 1.13 2021/08/09 21:13:06 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 /*
- * Non-exported definitons common to the different attachment
+ * Non-exported definitions common to the different attachment
  * types for the SCC on the Motorola MVME series of computers.
  */
 



CVS commit: src/sys/arch/macppc/dev

2021-08-08 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Aug  9 04:07:29 UTC 2021

Added Files:
src/sys/arch/macppc/dev: smuiic.c smuiicvar.h

Log Message:
Fix CVS eff-up.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.10 src/sys/arch/macppc/dev/smuiic.c
cvs rdiff -u -r0 -r1.3 src/sys/arch/macppc/dev/smuiicvar.h

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

Added files:

Index: src/sys/arch/macppc/dev/smuiic.c
diff -u /dev/null src/sys/arch/macppc/dev/smuiic.c:1.10
--- /dev/null	Mon Aug  9 04:07:29 2021
+++ src/sys/arch/macppc/dev/smuiic.c	Mon Aug  9 04:07:29 2021
@@ -0,0 +1,135 @@
+/*	$NetBSD: smuiic.c,v 1.10 2021/08/09 04:07:29 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2013 Phileas Fogg
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+struct smuiic_softc {
+	device_t sc_dev;
+	int sc_node;
+	struct i2c_controller *sc_i2c;
+};
+
+static int smuiic_match(device_t, struct cfdata *, void *);
+static void smuiic_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(smuiic, sizeof(struct smuiic_softc),
+smuiic_match, smuiic_attach, NULL, NULL);
+
+static int
+smuiic_match(device_t parent, struct cfdata *cf, void *aux)
+{
+	struct smu_iicbus_confargs *ca = aux;
+
+	if (strcmp(ca->ca_name, "i2c-bus") == 0)
+		return 5;
+	if (strcmp(ca->ca_name, "i2c") == 0)
+		return 5;
+	
+	return 0;
+}
+
+static void
+smuiic_attach(device_t parent, device_t self, void *aux)
+{
+	struct smu_iicbus_confargs *ca = aux;
+	struct smuiic_softc *sc = device_private(self);
+	struct i2cbus_attach_args iba;
+	prop_dictionary_t dict = device_properties(self);
+	int devs, devc;
+	uint32_t addr;
+	char compat[256];
+	prop_array_t cfg;
+	prop_dictionary_t dev;
+	prop_data_t data;
+	char name[32], descr[32], num[8];
+
+	sc->sc_dev = self;
+	sc->sc_node = ca->ca_node;
+	sc->sc_i2c = ca->ca_tag;
+	printf("\n");
+
+	cfg = prop_array_create();
+	prop_dictionary_set(dict, "i2c-child-devices", cfg);
+	prop_object_release(cfg);
+
+	/* look for i2c devices */
+	devs = OF_child(sc->sc_node);
+	while (devs != 0) {
+		if (OF_getprop(devs, "name", name, 256) <= 0)
+			goto skip;
+		if (OF_getprop(devs, "compatible",
+		compat, 256) <= 0)
+			goto skip;
+		if (OF_getprop(devs, "reg", , 4) <= 0)
+			goto skip;
+		addr = (addr & 0xff) >> 1;
+		dev = prop_dictionary_create();
+		prop_dictionary_set_string(dev, "name", name);
+		data = prop_data_create_copy(compat, strlen(compat)+1);
+		prop_dictionary_set(dev, "compatible", data);
+		prop_object_release(data);
+		prop_dictionary_set_uint32(dev, "addr", addr);
+		prop_dictionary_set_uint64(dev, "cookie", devs);
+		devc = OF_child(devs);
+		while (devc != 0) {
+			int reg;
+			if (OF_getprop(devc, "reg", , 4) < 4) goto nope;
+			if (OF_getprop(devc, "location", descr, 32) <= 0)
+goto nope;
+			printf("found '%s' at %02x\n", descr, reg);
+			snprintf(num, 7, "s%02x", reg);
+			prop_dictionary_set_string(dev, num, descr);
+		nope:
+			devc = OF_peer(devc);
+		}
+		prop_array_add(cfg, dev);
+		prop_object_release(dev);
+	skip:
+		devs = OF_peer(devs);
+	}
+
+	memset(, 0, sizeof(iba));
+	iba.iba_tag = sc->sc_i2c;
+
+	config_found(sc->sc_dev, , iicbus_print, CFARGS_NONE);
+}

Index: src/sys/arch/macppc/dev/smuiicvar.h
diff -u /dev/null src/sys/arch/macppc/dev/smuiicvar.h:1.3
--- /dev/null	Mon Aug  9 04:07:29 2021
+++ src/sys/arch/macppc/dev/smuiicvar.h	Mon Aug  9 04:07:29 2021
@@ -0,0 +1,38 @@
+/*-
+ * Copyright (c) 2013 Phileas Fogg
+ * All rights reserved.
+ *
+ * 

CVS commit: src/sys/arch

2021-08-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  8 19:28:09 UTC 2021

Modified Files:
src/sys/arch/aarch64/include: cpu.h
src/sys/arch/arm/include: cpu.h
src/sys/arch/arm/pic: pic.c

Log Message:
Re-apply

Move 'struct pic_pending' from percpu to struct cpu_info. Saves a few
instructions in splx.

There is(/was) no need to use atomic operations on the percpu / cpu_info
members, so don't.

Finally removng the use of percpu should help avoid problems with "late"
attaching cpus.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/aarch64/include/cpu.h
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/arm/include/cpu.h
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/arm/pic/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/aarch64/include/cpu.h
diff -u src/sys/arch/aarch64/include/cpu.h:1.36 src/sys/arch/aarch64/include/cpu.h:1.37
--- src/sys/arch/aarch64/include/cpu.h:1.36	Sat May 29 06:54:20 2021
+++ src/sys/arch/aarch64/include/cpu.h	Sun Aug  8 19:28:08 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.36 2021/05/29 06:54:20 skrll Exp $ */
+/* $NetBSD: cpu.h,v 1.37 2021/08/08 19:28:08 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -104,6 +104,9 @@ struct cpu_info {
 	int ci_hwpl;		/* current hardware priority */
 	volatile u_int ci_softints;
 	volatile u_int ci_intr_depth;
+	volatile uint32_t ci_blocked_pics;
+	volatile uint32_t ci_pending_pics;
+	volatile uint32_t ci_pending_ipls;
 
 	int ci_kfpu_spl;
 

Index: src/sys/arch/arm/include/cpu.h
diff -u src/sys/arch/arm/include/cpu.h:1.117 src/sys/arch/arm/include/cpu.h:1.118
--- src/sys/arch/arm/include/cpu.h:1.117	Sat Mar 27 12:15:08 2021
+++ src/sys/arch/arm/include/cpu.h	Sun Aug  8 19:28:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.117 2021/03/27 12:15:08 jmcneill Exp $	*/
+/*	$NetBSD: cpu.h,v 1.118 2021/08/08 19:28:08 skrll Exp $	*/
 
 /*
  * Copyright (c) 1994-1996 Mark Brinicombe.
@@ -190,6 +190,9 @@ struct cpu_info {
 
 	volatile u_int	ci_intr_depth;	/* */
 	volatile u_int	ci_softints;
+	volatile uint32_t ci_blocked_pics;
+	volatile uint32_t ci_pending_pics;
+	volatile uint32_t ci_pending_ipls;
 
 	lwp_t *		ci_lastlwp;	/* last lwp */
 

Index: src/sys/arch/arm/pic/pic.c
diff -u src/sys/arch/arm/pic/pic.c:1.70 src/sys/arch/arm/pic/pic.c:1.71
--- src/sys/arch/arm/pic/pic.c:1.70	Sat Mar 27 12:15:09 2021
+++ src/sys/arch/arm/pic/pic.c	Sun Aug  8 19:28:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pic.c,v 1.70 2021/03/27 12:15:09 jmcneill Exp $	*/
+/*	$NetBSD: pic.c,v 1.71 2021/08/08 19:28:08 skrll Exp $	*/
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.70 2021/03/27 12:15:09 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.71 2021/08/08 19:28:08 skrll Exp $");
 
 #include 
 #include 
@@ -65,37 +65,15 @@ __KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.70
  * come from the same CPU.  In other words, interrupts from a single PIC will
  * not be distributed among multiple CPUs.
  */
-struct pic_pending {
-	volatile uint32_t blocked_pics;
-	volatile uint32_t pending_pics;
-	volatile uint32_t pending_ipls;
-};
 static uint32_t
 	pic_find_pending_irqs_by_ipl(struct pic_softc *, size_t, uint32_t, int);
 static struct pic_softc *
-	pic_list_find_pic_by_pending_ipl(struct pic_pending *, uint32_t);
+	pic_list_find_pic_by_pending_ipl(struct cpu_info *, uint32_t);
 static void
-	pic_deliver_irqs(struct pic_pending *, struct pic_softc *, int, void *);
+	pic_deliver_irqs(struct cpu_info *, struct pic_softc *, int, void *);
 static void
-	pic_list_deliver_irqs(struct pic_pending *, register_t, int, void *);
+	pic_list_deliver_irqs(struct cpu_info *, register_t, int, void *);
 
-#ifdef MULTIPROCESSOR
-percpu_t *pic_pending_percpu;
-static struct pic_pending *
-pic_pending_get(void)
-{
-	return percpu_getref(pic_pending_percpu);
-}
-static void
-pic_pending_put(struct pic_pending *pend)
-{
-	percpu_putref(pic_pending_percpu);
-}
-#else
-struct pic_pending pic_pending;
-#define	pic_pending_get()	(_pending)
-#define	pic_pending_put(pend)	__nothing
-#endif /* MULTIPROCESSOR */
 #endif /* __HAVE_PIC_PENDING_INTRS */
 
 struct pic_softc *pic_list[PIC_MAXPICS];
@@ -264,15 +242,14 @@ void
 pic_mark_pending_source(struct pic_softc *pic, struct intrsource *is)
 {
 	const uint32_t ipl_mask = __BIT(is->is_ipl);
+	struct cpu_info * const ci = curcpu();
 
 	atomic_or_32(>pic_pending_irqs[is->is_irq >> 5],
 	__BIT(is->is_irq & 0x1f));
 
 	atomic_or_32(>pic_pending_ipls, ipl_mask);
-	struct pic_pending *pend = pic_pending_get();
-	atomic_or_32(>pending_ipls, ipl_mask);
-	atomic_or_32(>pending_pics, __BIT(pic->pic_id));
-	pic_pending_put(pend);
+	ci->ci_pending_ipls |= ipl_mask;
+	ci->ci_pending_pics |= __BIT(pic->pic_id);
 }
 
 void
@@ -288,9 +265,10 @@ 

CVS commit: src/sys/arch/arm/broadcom

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 18:55:12 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom: bcm2835_com_acpi.c

Log Message:
Adjust register base and size


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/broadcom/bcm2835_com_acpi.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/arm/broadcom/bcm2835_com_acpi.c
diff -u src/sys/arch/arm/broadcom/bcm2835_com_acpi.c:1.1 src/sys/arch/arm/broadcom/bcm2835_com_acpi.c:1.2
--- src/sys/arch/arm/broadcom/bcm2835_com_acpi.c:1.1	Sun Aug  8 18:43:21 2021
+++ src/sys/arch/arm/broadcom/bcm2835_com_acpi.c	Sun Aug  8 18:55:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_com_acpi.c,v 1.1 2021/08/08 18:43:21 jmcneill Exp $ */
+/* $NetBSD: bcm2835_com_acpi.c,v 1.2 2021/08/08 18:55:12 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2021 Jared McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_com_acpi.c,v 1.1 2021/08/08 18:43:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_com_acpi.c,v 1.2 2021/08/08 18:55:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -100,8 +100,8 @@ bcmcom_acpi_attach(device_t parent, devi
 	}
 
 	iot = aa->aa_memt;
-	base = mem->ar_base;
-	size = mem->ar_length;
+	base = mem->ar_base + 0x40;
+	size = mem->ar_length - 0x40;
 
 	irq = acpi_res_irq(, 0);
 	if (irq == NULL) {



CVS commit: src/sys/arch/arm/broadcom

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 18:43:21 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835
Added Files:
src/sys/arch/arm/broadcom: bcm2835_com_acpi.c

Log Message:
broadcom: ACPI: Add support for mini UART in ACPI mode.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2835_com_acpi.c
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/arm/broadcom/files.bcm2835

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/arm/broadcom/files.bcm2835
diff -u src/sys/arch/arm/broadcom/files.bcm2835:1.41 src/sys/arch/arm/broadcom/files.bcm2835:1.42
--- src/sys/arch/arm/broadcom/files.bcm2835:1.41	Sun Aug  8 10:32:26 2021
+++ src/sys/arch/arm/broadcom/files.bcm2835	Sun Aug  8 18:43:21 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.bcm2835,v 1.41 2021/08/08 10:32:26 jmcneill Exp $
+#	$NetBSD: files.bcm2835,v 1.42 2021/08/08 18:43:21 jmcneill Exp $
 #
 # Configuration info for Broadcom BCM2835 ARM Peripherals
 #
@@ -60,6 +60,11 @@ file	arch/arm/broadcom/bcm2835_aux.c		bc
 attach	com at fdt with bcmcom
 file	arch/arm/broadcom/bcm2835_com.c		bcmcom
 
+ifdef acpinodebus
+attach	com at acpinodebus with bcmcom_acpi
+file	arch/arm/broadcom/bcm2835_com_acpi.c	bcmcom_acpi
+endif
+
 # External Mass Media Controller (BCM2835_EMMC_BASE)
 attach	sdhc at fdt with bcmemmc
 file	arch/arm/broadcom/bcm2835_emmc.c	bcmemmc

Added files:

Index: src/sys/arch/arm/broadcom/bcm2835_com_acpi.c
diff -u /dev/null src/sys/arch/arm/broadcom/bcm2835_com_acpi.c:1.1
--- /dev/null	Sun Aug  8 18:43:21 2021
+++ src/sys/arch/arm/broadcom/bcm2835_com_acpi.c	Sun Aug  8 18:43:21 2021
@@ -0,0 +1,168 @@
+/* $NetBSD: bcm2835_com_acpi.c,v 1.1 2021/08/08 18:43:21 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 2021 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_com_acpi.c,v 1.1 2021/08/08 18:43:21 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+static int	bcmcom_acpi_match(device_t, cfdata_t , void *);
+static void	bcmcom_acpi_attach(device_t, device_t, void *);
+
+static u_int	bcmcom_acpi_get_clockrate(device_t);
+
+struct vcmbox_clockrate_request {
+	struct vcprop_buffer_hdr	vb_hdr;
+	struct vcprop_tag_clockrate	vbt_clockrate;
+	struct vcprop_tag end;
+} __packed;
+
+CFATTACH_DECL_NEW(bcmcom_acpi, sizeof(struct com_softc), bcmcom_acpi_match,
+bcmcom_acpi_attach, NULL, NULL);
+
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "BCM2836",		.value = COM_TYPE_BCMAUXUART },
+	DEVICE_COMPAT_EOL
+};
+
+static int
+bcmcom_acpi_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct acpi_attach_args *aa = aux;
+
+	return acpi_compatible_match(aa, compat_data);
+}
+
+static void
+bcmcom_acpi_attach(device_t parent, device_t self, void *aux)
+{
+	struct com_softc *sc = device_private(self);
+	struct acpi_attach_args *aa = aux;
+	const struct device_compatible_entry *dce;
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	struct acpi_irq *irq;
+	bus_space_tag_t iot;
+	bus_space_handle_t ioh;
+	bus_addr_t base;
+	bus_size_t size;
+	ACPI_STATUS rv;
+	void *ih;
+
+	sc->sc_dev = self;
+
+	rv = acpi_resource_parse(sc->sc_dev, aa->aa_node->ad_handle, "_CRS",
+	, _resource_parse_ops_default);
+	if (ACPI_FAILURE(rv)) {
+		return;
+	}
+
+	mem = acpi_res_mem(, 0);
+	if (mem == NULL) {
+		aprint_error_dev(self, "couldn't find mem resource\n");
+		goto cleanup;
+	}
+
+	iot = aa->aa_memt;
+	base = mem->ar_base;
+	size = mem->ar_length;
+
+	irq = acpi_res_irq(, 0);
+	if (irq == NULL) {
+		aprint_error_dev(self, "couldn't find irq resource\n");
+	

CVS commit: src/sys/arch/arm/arm

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 13:43:09 UTC 2021

Modified Files:
src/sys/arch/arm/arm: smccc.c

Log Message:
fix armv7 build


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/arm/smccc.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/arm/arm/smccc.c
diff -u src/sys/arch/arm/arm/smccc.c:1.2 src/sys/arch/arm/arm/smccc.c:1.3
--- src/sys/arch/arm/arm/smccc.c:1.2	Sat Aug  7 21:21:49 2021
+++ src/sys/arch/arm/arm/smccc.c	Sun Aug  8 13:43:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: smccc.c,v 1.2 2021/08/07 21:21:49 jmcneill Exp $ */
+/* $NetBSD: smccc.c,v 1.3 2021/08/08 13:43:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: smccc.c,v 1.2 2021/08/07 21:21:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smccc.c,v 1.3 2021/08/08 13:43:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -35,6 +35,12 @@ __KERNEL_RCSID(0, "$NetBSD: smccc.c,v 1.
 #include 
 #include 
 
+#if defined(__arm__)
+#define	SMCCC_ARCH_ATTRIBUTE  __attribute__ ((target("arch=armv7ve")))
+#else
+#define	SMCCC_ARCH_ATTRIBUTE
+#endif
+
 /* Minimum supported PSCI version for SMCCC discovery */
 #define	PSCI_VERSION_1_0	0x1
 
@@ -89,7 +95,7 @@ smccc_version(void)
  *
  *	Generic call interface for SMC/HVC calls.
  */
-int
+SMCCC_ARCH_ATTRIBUTE int
 smccc_call(uint32_t fid,
 register_t arg1, register_t arg2, register_t arg3, register_t arg4,
 register_t *res0, register_t *res1, register_t *res2, register_t *res3)



CVS commit: src/sys/arch/evbarm/conf

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 12:31:43 UTC 2021

Modified Files:
src/sys/arch/evbarm/conf: std.generic64

Log Message:
Enable options PCI_SMCCC on 64-bit Arm.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/conf/std.generic64

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/evbarm/conf/std.generic64
diff -u src/sys/arch/evbarm/conf/std.generic64:1.13 src/sys/arch/evbarm/conf/std.generic64:1.14
--- src/sys/arch/evbarm/conf/std.generic64:1.13	Tue Sep  8 17:39:04 2020
+++ src/sys/arch/evbarm/conf/std.generic64	Sun Aug  8 12:31:42 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.generic64,v 1.13 2020/09/08 17:39:04 jakllsch Exp $
+#	$NetBSD: std.generic64,v 1.14 2021/08/08 12:31:42 jmcneill Exp $
 #
 #	generic NetBSD/evbarm64 with FDT support
 
@@ -19,6 +19,7 @@ options 	FPU_VFP
 options 	MODULAR
 options 	MODULAR_DEFAULT_AUTOLOAD
 options 	PCI_NETBSD_CONFIGURE
+options 	PCI_SMCCC		# Arm PCI Conf Access Firmware Interface
 options 	_ARM32_NEED_BUS_DMA_BOUNCE
 options 	__HAVE_GENERIC_CPU_INITCLOCKS
 options 	__HAVE_PCI_CONF_HOOK



CVS commit: src/sys/arch/arm/acpi

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 12:09:52 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Install the shared PCI INTx interrupt handler at IPL_VM to workaround a
possible interrupt storm at boot. Need to revisit this.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpi_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/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.19 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.20
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.19	Sat Aug  7 21:27:53 2021
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sun Aug  8 12:09:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.20 2021/08/08 12:09:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.20 2021/08/08 12:09:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -536,7 +536,7 @@ acpi_pci_md_intr_establish(void *v, pci_
 		pi->pi_pic.pic_ops = _pci_pic_ops;
 		pi->pi_irqbase = pic_add(>pi_pic, PIC_IRQBASE_ALLOC);
 		TAILQ_INSERT_TAIL(_pci_intrs, pi, pi_list);
-		pi->pi_ih = intr_establish_xname(irq, IPL_SCHED, IST_LEVEL | IST_MPSAFE,
+		pi->pi_ih = intr_establish_xname(irq, IPL_VM, IST_LEVEL | IST_MPSAFE,
 		pic_handle_intr, >pi_pic, device_xname(ap->ap_dev));
 	}
 	if (pi->pi_ih == NULL)



CVS commit: src/sys/arch/arm/broadcom

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 10:59:27 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom: bcm2838_emmc2_acpi.c

Log Message:
disable DMA for now...


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.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/arm/broadcom/bcm2838_emmc2_acpi.c
diff -u src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c:1.1 src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c:1.2
--- src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c:1.1	Sun Aug  8 10:32:26 2021
+++ src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c	Sun Aug  8 10:59:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcm2838_emmc2_acpi.c,v 1.1 2021/08/08 10:32:26 jmcneill Exp $	*/
+/*	$NetBSD: bcm2838_emmc2_acpi.c,v 1.2 2021/08/08 10:59:27 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2021 Jared McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcm2838_emmc2_acpi.c,v 1.1 2021/08/08 10:32:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2838_emmc2_acpi.c,v 1.2 2021/08/08 10:59:27 jmcneill Exp $");
 
 #include 
 #include 
@@ -119,8 +119,10 @@ bcmemmc2_acpi_attach(device_t parent, de
 	 * disable UHS modes.
 	 */
 	sc->sc.sc_flags = SDHC_FLAG_32BIT_ACCESS |
+#if notyet
 			  SDHC_FLAG_USE_DMA |
 			  SDHC_FLAG_USE_ADMA2 |
+#endif
 			  SDHC_FLAG_NO_1_8_V;
 
 	sc->sc_ih = acpi_intr_establish(self,



CVS commit: src/sys/arch/arm/broadcom

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 10:32:27 UTC 2021

Modified Files:
src/sys/arch/arm/broadcom: files.bcm2835
Added Files:
src/sys/arch/arm/broadcom: bcm2838_emmc2_acpi.c

Log Message:
bcm2838: Add ACPI support for the EMMC2 SDHCI controller.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/arm/broadcom/files.bcm2835

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/arm/broadcom/files.bcm2835
diff -u src/sys/arch/arm/broadcom/files.bcm2835:1.40 src/sys/arch/arm/broadcom/files.bcm2835:1.41
--- src/sys/arch/arm/broadcom/files.bcm2835:1.40	Wed Mar 10 11:03:48 2021
+++ src/sys/arch/arm/broadcom/files.bcm2835	Sun Aug  8 10:32:26 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.bcm2835,v 1.40 2021/03/10 11:03:48 mlelstv Exp $
+#	$NetBSD: files.bcm2835,v 1.41 2021/08/08 10:32:26 jmcneill Exp $
 #
 # Configuration info for Broadcom BCM2835 ARM Peripherals
 #
@@ -67,6 +67,8 @@ file	arch/arm/broadcom/bcm2835_emmc.c	bc
 ifdef acpinodebus
 attach	sdhc at acpinodebus with bcmemmc_acpi
 file	arch/arm/broadcom/bcm2835_emmc_acpi.c	bcmemmc_acpi
+attach	sdhc at acpinodebus with bcmemmc2_acpi
+file	arch/arm/broadcom/bcm2838_emmc2_acpi.c	bcmemmc2_acpi
 endif
 
 # SD Host Controller (BCM2835_SDHOST_BASE)

Added files:

Index: src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c
diff -u /dev/null src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c:1.1
--- /dev/null	Sun Aug  8 10:32:27 2021
+++ src/sys/arch/arm/broadcom/bcm2838_emmc2_acpi.c	Sun Aug  8 10:32:26 2021
@@ -0,0 +1,164 @@
+/*	$NetBSD: bcm2838_emmc2_acpi.c,v 1.1 2021/08/08 10:32:26 jmcneill Exp $	*/
+
+/*
+ * Copyright (c) 2021 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: bcm2838_emmc2_acpi.c,v 1.1 2021/08/08 10:32:26 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define _COMPONENT	ACPI_RESOURCE_COMPONENT
+ACPI_MODULE_NAME	("bcmemmc2_acpi")
+
+static int	bcmemmc2_acpi_match(device_t, cfdata_t, void *);
+static void	bcmemmc2_acpi_attach(device_t, device_t, void *);
+static void	bcmemmc2_acpi_attach1(device_t);
+
+static const char * const compatible[] = {
+	"BRCME88C",
+	NULL
+};
+
+struct bcmemmc2_acpi_softc {
+	struct sdhc_softc sc;
+	bus_space_tag_t sc_memt;
+	bus_space_handle_t sc_memh;
+	bus_size_t sc_memsize;
+	void *sc_ih;
+	struct sdhc_host *sc_hosts[1];
+};
+
+CFATTACH_DECL_NEW(bcmemmc2_acpi, sizeof(struct bcmemmc2_acpi_softc),
+bcmemmc2_acpi_match, bcmemmc2_acpi_attach, NULL, NULL);
+
+static int
+bcmemmc2_acpi_match(device_t parent, cfdata_t match, void *opaque)
+{
+	struct acpi_attach_args *aa = opaque;
+
+	if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+		return 0;
+
+	return acpi_match_hid(aa->aa_node->ad_devinfo, compatible);
+}
+
+static void
+bcmemmc2_acpi_attach(device_t parent, device_t self, void *opaque)
+{
+	struct bcmemmc2_acpi_softc *sc = device_private(self);
+	struct acpi_attach_args *aa = opaque;
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	struct acpi_irq *irq;
+	ACPI_STATUS rv;
+
+	sc->sc.sc_dev = self;
+	sc->sc.sc_dmat = aa->aa_dmat;
+	sc->sc.sc_host = sc->sc_hosts;
+	sc->sc_memt = aa->aa_memt;
+
+	rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
+	, _resource_parse_ops_default);
+	if (ACPI_FAILURE(rv))
+		return;
+
+	mem = acpi_res_mem(, 0);
+	irq = acpi_res_irq(, 0);
+	if (mem == NULL || irq == NULL) {
+		aprint_error_dev(self, "incomplete resources\n");
+		goto cleanup;
+	}
+	if (mem->ar_length == 0) {
+		aprint_error_dev(self, "zero length memory resource\n");
+		goto 

CVS commit: src/sys/arch/arm/acpi

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 10:28:26 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
arm: ACPI: Add support for simple sharing of platform interrupts

Allow sharing of platform interrupts provided that the type, ipl, and
mpsafe-ness are the same.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/acpi/acpi_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/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.24 src/sys/arch/arm/acpi/acpi_machdep.c:1.25
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.24	Sat Aug  7 18:40:45 2021
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Sun Aug  8 10:28:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.25 2021/08/08 10:28:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.25 2021/08/08 10:28:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -63,6 +63,27 @@ extern struct bus_space arm_generic_bs_t
 extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 
+struct acpi_intrhandler {
+	int(*ah_fn)(void *);
+	void*ah_arg;
+	TAILQ_ENTRY(acpi_intrhandler)	ah_list;
+};
+
+struct acpi_intrvec {
+	intai_irq;
+	intai_ipl;
+	intai_type;
+	boolai_mpsafe;
+	intai_refcnt;
+	void*ai_arg;
+	void*ai_ih;
+	TAILQ_HEAD(, acpi_intrhandler)	ai_handlers;
+	TAILQ_ENTRY(acpi_intrvec)	ai_list;
+};
+
+static TAILQ_HEAD(, acpi_intrvec) acpi_intrvecs =
+TAILQ_HEAD_INITIALIZER(acpi_intrvecs);
+
 bus_dma_tag_t	arm_acpi_dma32_tag(struct acpi_softc *, struct acpi_devnode *);
 bus_dma_tag_t	arm_acpi_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
 
@@ -256,28 +277,128 @@ acpi_md_OsDisableInterrupt(void)
 	cpsid(I32_bit);
 }
 
+static struct acpi_intrvec *
+acpi_md_intr_lookup(int irq)
+{
+	struct acpi_intrvec *ai;
+
+	TAILQ_FOREACH(ai, _intrvecs, ai_list) {
+		if (ai->ai_irq == irq) {
+			return ai;
+		}
+	}
+
+	return NULL;
+}
+
+static int
+acpi_md_intr(void *arg)
+{
+	struct acpi_intrvec *ai = arg;
+	struct acpi_intrhandler *ah;
+	int rv = 0;
+
+	TAILQ_FOREACH(ah, >ai_handlers, ah_list) {
+		rv += ah->ah_fn(ah->ah_arg);
+	}
+
+	return rv;
+}
+
 void *
 acpi_md_intr_establish(uint32_t irq, int ipl, int type, int (*handler)(void *), void *arg, bool mpsafe, const char *xname)
 {
-	return intr_establish_xname(irq, ipl, type | (mpsafe ? IST_MPSAFE : 0), handler, arg, xname);
+	struct acpi_intrvec *ai;
+	struct acpi_intrhandler *ah;
+
+	ai = acpi_md_intr_lookup(irq);
+	if (ai == NULL) {
+		ai = kmem_zalloc(sizeof(*ai), KM_SLEEP);
+		ai->ai_refcnt = 0;
+		ai->ai_irq = irq;
+		ai->ai_ipl = ipl;
+		ai->ai_type = type;
+		ai->ai_mpsafe = mpsafe;
+		ai->ai_arg = arg;
+		TAILQ_INIT(>ai_handlers);
+		if (arg == NULL) {
+			ai->ai_ih = intr_establish_xname(irq, ipl,
+			type | (mpsafe ? IST_MPSAFE : 0), handler, NULL,
+			xname);
+		} else {
+			ai->ai_ih = intr_establish_xname(irq, ipl,
+			type | (mpsafe ? IST_MPSAFE : 0), acpi_md_intr, ai,
+			xname);
+		}
+		if (ai->ai_ih == NULL) {
+			kmem_free(ai, sizeof(*ai));
+			return NULL;
+		}
+		TAILQ_INSERT_TAIL(_intrvecs, ai, ai_list);
+	} else {
+		if (ai->ai_arg == NULL) {
+			printf("ACPI: cannot share irq with NULL arg\n");
+			return NULL;
+		}
+		if (ai->ai_ipl != ipl) {
+			printf("ACPI: cannot share irq with different ipl\n");
+			return NULL;
+		}
+		if (ai->ai_type != type) {
+			printf("ACPI: cannot share edge and level interrupts\n");
+			return NULL;
+		}
+		if (ai->ai_mpsafe != mpsafe) {
+			printf("ACPI: cannot share between mpsafe/non-mpsafe\n");
+			return NULL;
+		}
+	}
+
+	ai->ai_refcnt++;
+
+	ah = kmem_zalloc(sizeof(*ah), KM_SLEEP);
+	ah->ah_fn = handler;
+	ah->ah_arg = arg;
+	TAILQ_INSERT_TAIL(>ai_handlers, ah, ah_list);
+
+	return ai->ai_ih;
 }
 
 void
-acpi_md_intr_mask(void *ih)
+acpi_md_intr_disestablish(void *ih)
 {
-	intr_mask(ih);
+	struct acpi_intrvec *ai;
+	struct acpi_intrhandler *ah;
+
+	TAILQ_FOREACH(ai, _intrvecs, ai_list) {
+		if (ai->ai_ih == ih) {
+			KASSERT(ai->ai_refcnt > 0);
+			if (ai->ai_refcnt > 1) {
+panic("%s: cannot disestablish shared irq", __func__);
+			}
+
+			TAILQ_REMOVE(_intrvecs, ai, ai_list);
+			ah = TAILQ_FIRST(>ai_handlers);
+			kmem_free(ah, sizeof(*ah));
+			intr_disestablish(ai->ai_ih);
+			kmem_free(ai, sizeof(*ai));
+			return;
+		}
+	}
+
+	panic("%s: interrupt not established", __func__);
 }
 
 void
-acpi_md_intr_unmask(void *ih)
+acpi_md_intr_mask(void *ih)
 {
-	intr_unmask(ih);
+	intr_mask(ih);
 }
 
 void
-acpi_md_intr_disestablish(void *ih)
+acpi_md_intr_unmask(void *ih)

CVS commit: src/sys/arch

2021-08-07 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Aug  8 00:53:39 UTC 2021

Modified Files:
src/sys/arch/macppc/include: types.h
src/sys/arch/sparc64/include: types.h

Log Message:
Define preprocessor symbols (__HAVE_OPENFIRMWARE_VARIANT_AAPL and
__HAVE_OPENFIRMWARE_VARIANT_SUNW) that lets generic OpenFirmware
code deal with differences / quirks among implementation variants.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/macppc/include/types.h
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/include/types.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/macppc/include/types.h
diff -u src/sys/arch/macppc/include/types.h:1.14 src/sys/arch/macppc/include/types.h:1.15
--- src/sys/arch/macppc/include/types.h:1.14	Sun Jul 17 23:23:53 2011
+++ src/sys/arch/macppc/include/types.h	Sun Aug  8 00:53:39 2021
@@ -1,5 +1,6 @@
-/*	$NetBSD: types.h,v 1.14 2011/07/17 23:23:53 dyoung Exp $	*/
+/*	$NetBSD: types.h,v 1.15 2021/08/08 00:53:39 thorpej Exp $	*/
 
 #include 
 
 #define	__HAVE_NEW_STYLE_BUS_H
+#define	__HAVE_OPENFIRMWARE_VARIANT_AAPL

Index: src/sys/arch/sparc64/include/types.h
diff -u src/sys/arch/sparc64/include/types.h:1.28 src/sys/arch/sparc64/include/types.h:1.29
--- src/sys/arch/sparc64/include/types.h:1.28	Sat Apr  6 03:06:27 2019
+++ src/sys/arch/sparc64/include/types.h	Sun Aug  8 00:53:39 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: types.h,v 1.28 2019/04/06 03:06:27 thorpej Exp $*/
+/*   $NetBSD: types.h,v 1.29 2021/08/08 00:53:39 thorpej Exp $*/
 
 #ifndef _SPARC64_TYPES_H_
 #define	_SPARC64_TYPES_H_
@@ -11,5 +11,6 @@
 
 #define	__HAVE_COMPAT_NETBSD32
 #define	__HAVE_UCAS_FULL
+#define	__HAVE_OPENFIRMWARE_VARIANT_SUNW
 
 #endif



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:27:53 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c
files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_pci_smccc.c

Log Message:
arm: acpi: Add support for SMCCC based PCI config access.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_pci_smccc.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/acpi/files.acpi

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/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.18 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.19
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.18	Wed Jun 17 06:45:09 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sat Aug  7 21:27:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.18 2020/06/17 06:45:09 thorpej Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -29,10 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_pci.h"
+
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.18 2020/06/17 06:45:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,6 +62,10 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 #include 
 #include 
 
+#ifdef PCI_SMCCC
+#include 
+#endif
+
 #include 
 
 struct acpi_pci_prt {
@@ -94,7 +100,7 @@ struct acpi_pci_intr {
 static TAILQ_HEAD(, acpi_pci_intr) acpi_pci_intrs =
 TAILQ_HEAD_INITIALIZER(acpi_pci_intrs);
 
-static const struct acpi_pci_quirk acpi_pci_quirks[] = {
+static const struct acpi_pci_quirk acpi_pci_mcfg_quirks[] = {
 	/* OEM ID	OEM Table ID	Revision	Seg	Func */
 	{ "AMAZON",	"GRAVITON",	0,		-1,	acpi_pci_graviton_init },
 	{ "ARMLTD",	"ARMN1SDP",	0x20181101,	0,	acpi_pci_n1sdp_init },
@@ -102,6 +108,13 @@ static const struct acpi_pci_quirk acpi_
 	{ "NXP   ", "LX2160  ", 0,  -1,	acpi_pci_layerscape_gen4_init },
 };
 
+#ifdef PCI_SMCCC
+static const struct acpi_pci_quirk acpi_pci_smccc_quirk = {
+	.q_segment = -1,
+	.q_init = acpi_pci_smccc_init,
+};
+#endif
+
 pci_chipset_tag_t acpi_pci_md_get_chipset_tag(struct acpi_softc *, int, int);
 
 static void	acpi_pci_md_attach_hook(device_t, device_t,
@@ -554,11 +567,19 @@ acpi_pci_md_find_quirk(int seg)
 	u_int n;
 
 	rv = AcpiGetTable(ACPI_SIG_MCFG, 0, (ACPI_TABLE_HEADER **));
-	if (ACPI_FAILURE(rv))
+	if (ACPI_FAILURE(rv)) {
+#ifdef PCI_SMCCC
+		uint32_t ver = pci_smccc_version();
+		aprint_debug("%s: SMCCC version %#x\n", __func__, ver);
+		if (PCI_SMCCC_SUCCESS(ver)) {
+			return _pci_smccc_quirk;
+		}
+#endif
 		return NULL;
+	}
 
-	for (n = 0; n < __arraycount(acpi_pci_quirks); n++) {
-		const struct acpi_pci_quirk *q = _pci_quirks[n];
+	for (n = 0; n < __arraycount(acpi_pci_mcfg_quirks); n++) {
+		const struct acpi_pci_quirk *q = _pci_mcfg_quirks[n];
 		if (memcmp(q->q_oemid, mcfg->Header.OemId, ACPI_OEM_ID_SIZE) == 0 &&
 		memcmp(q->q_oemtableid, mcfg->Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE) == 0 &&
 		q->q_oemrevision == mcfg->Header.OemRevision &&
@@ -589,6 +610,7 @@ acpi_pci_md_get_chipset_tag(struct acpi_
 		pct->pct_ap.ap_pc.pc_intr_v = >pct_ap;
 		pct->pct_ap.ap_seg = seg;
 		pct->pct_ap.ap_bus = bbn;
+		pct->pct_ap.ap_maxbus = -1;
 		pct->pct_ap.ap_bst = acpi_softc->sc_memt;
 
 		q = acpi_pci_md_find_quirk(seg);

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.h
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.7 src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.8
--- src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.7	Sat Feb  1 13:26:43 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.h	Sat Aug  7 21:27:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.h,v 1.7 2020/02/01 13:26:43 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.h,v 1.8 2021/08/07 21:27:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,12 +39,15 @@ struct acpi_pci_context {
 	device_t ap_dev;
 	u_int ap_seg;
 	int ap_bus;
+	int ap_maxbus;
 	bus_space_tag_t ap_bst;
 	bus_space_handle_t ap_conf_bsh;
 	int (*ap_conf_read)(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
 	int (*ap_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
 	void *ap_conf_priv;
 	int ap_pciflags_clear;
+	u_int ap_flags;
+#define	ACPI_PCI_FLAG_NO_MCFG		__BIT(0)	/* ignore MCFG table */
 };
 
 struct acpi_pci_quirk {
@@ -57,6 +60,7 @@ struct acpi_pci_quirk {
 
 const struct acpi_pci_quirk *	acpi_pci_md_find_quirk(int);
 
+void	acpi_pci_smccc_init(struct acpi_pci_context *);
 void	

CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:24:56 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
acpi: call smccc_probe() after PSCI init


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/acpi/acpi_platform.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/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.27 src/sys/arch/arm/acpi/acpi_platform.c:1.28
--- src/sys/arch/arm/acpi/acpi_platform.c:1.27	Fri Aug  6 19:38:53 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sat Aug  7 21:24:56 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.27 2021/08/06 19:38:53 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.27 2021/08/06 19:38:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $");
 
 #include 
 #include 
@@ -253,6 +253,7 @@ acpi_platform_startup(void)
 			} else {
 psci_init(psci_call_smc);
 			}
+			smccc_probe();
 		}
 		acpi_table_unmap((ACPI_TABLE_HEADER *)fadt);
 	}



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

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:23:37 UTC 2021

Modified Files:
src/sys/arch/arm/pci: files.pci
Added Files:
src/sys/arch/arm/pci: pci_smccc.c pci_smccc.h

Log Message:
arm: PCI: Add support for Arm PCI Config Space Access Firmware Interface

This adds basic support for the PCI Config Access interface defined in
Arm DEN0115.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/pci/pci_smccc.c \
src/sys/arch/arm/pci/pci_smccc.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/arm/pci/files.pci
diff -u src/sys/arch/arm/pci/files.pci:1.1 src/sys/arch/arm/pci/files.pci:1.2
--- src/sys/arch/arm/pci/files.pci:1.1	Sun Oct 21 00:42:06 2018
+++ src/sys/arch/arm/pci/files.pci	Sat Aug  7 21:23:37 2021
@@ -1,4 +1,8 @@
-# $NetBSD: files.pci,v 1.1 2018/10/21 00:42:06 jmcneill Exp $
+# $NetBSD: files.pci,v 1.2 2021/08/07 21:23:37 jmcneill Exp $
 
 # PCI MSI/MSI-X support
 file	arch/arm/pci/pci_msi_machdep.c		pci & __have_pci_msi_msix
+
+# Arm PCI Configuration Space Access Firmware Interface (DEN0115)
+defflag	opt_pci.h	PCI_SMCCC
+file	arch/arm/pci/pci_smccc.c		pci_smccc

Added files:

Index: src/sys/arch/arm/pci/pci_smccc.c
diff -u /dev/null src/sys/arch/arm/pci/pci_smccc.c:1.1
--- /dev/null	Sat Aug  7 21:23:37 2021
+++ src/sys/arch/arm/pci/pci_smccc.c	Sat Aug  7 21:23:37 2021
@@ -0,0 +1,122 @@
+/* $NetBSD: pci_smccc.c,v 1.1 2021/08/07 21:23:37 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: pci_smccc.c,v 1.1 2021/08/07 21:23:37 jmcneill Exp $");
+
+#include 
+#include 
+
+#include 
+#include 
+
+/* Minimum SMCCC version required for PCI_VERSION call. */
+#define	SMCCC_VERSION_1_1	0x10001
+
+/* PCI Configuration Space Access ABI functions */
+#define	PCI_VERSION		0x84000130
+#define	PCI_FEATURES		0x84000131
+#define	PCI_READ		0x84000132
+#define	PCI_WRITE		0x84000133
+#define	PCI_GET_SEG_INFO	0x84000134
+#define	 GET_SEG_INFO_BUS_START		__BITS(7,0)
+#define	 GET_SEG_INFO_BUS_END		__BITS(15,8)
+
+static int
+pci_smccc_call(uint32_t fid,
+register_t arg1, register_t arg2, register_t arg3, register_t arg4,
+register_t *res0, register_t *res1, register_t *res2, register_t *res3)
+{
+	static int smccc_ver;
+
+	if (smccc_ver == 0) {
+		smccc_ver = smccc_version();
+	}
+	if (smccc_ver < SMCCC_VERSION_1_1) {
+		return SMCCC_NOT_SUPPORTED;
+	}
+
+	return smccc_call(fid, arg1, arg2, arg3, arg4,
+			  res0, res1, res2, res3);
+}
+
+int
+pci_smccc_version(void)
+{
+	return pci_smccc_call(PCI_VERSION, 0, 0, 0, 0,
+			  NULL, NULL, NULL, NULL);
+}
+
+int
+pci_smccc_features(uint32_t fid)
+{
+	return pci_smccc_call(PCI_FEATURES, fid, 0, 0, 0,
+			  NULL, NULL, NULL, NULL);
+}
+
+int
+pci_smccc_read(uint32_t sbdf, uint32_t offset, uint32_t access_size,
+uint32_t *data)
+{
+	register_t value;
+	int status;
+
+	status = pci_smccc_call(PCI_READ, sbdf, offset, access_size, 0,
+NULL, , NULL, NULL);
+	if (status == SMCCC_SUCCESS) {
+		*data = value;
+	}
+
+	return status;
+}
+
+int
+pci_smccc_write(uint32_t sbdf, uint32_t offset, uint32_t access_size,
+uint32_t data)
+{
+	return pci_smccc_call(PCI_WRITE, sbdf, offset, access_size, data,
+			  NULL, NULL, NULL, NULL);
+}
+
+int
+pci_smccc_get_seg_info(uint16_t seg, uint8_t *bus_start, uint8_t *bus_end,
+uint16_t *next_seg)
+{
+	register_t res1, res2;
+	int status;
+
+	status = pci_smccc_call(PCI_GET_SEG_INFO, seg, 0, 0, 0,
+NULL, , , NULL);
+	if (status == SMCCC_SUCCESS) {
+		

CVS commit: src/sys/arch/arm/arm

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:21:49 UTC 2021

Modified Files:
src/sys/arch/arm/arm: smccc.c smccc.h

Log Message:
arm: SMCCC: Add return values to smccc_call


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/arm/smccc.c \
src/sys/arch/arm/arm/smccc.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/arm/arm/smccc.c
diff -u src/sys/arch/arm/arm/smccc.c:1.1 src/sys/arch/arm/arm/smccc.c:1.2
--- src/sys/arch/arm/arm/smccc.c:1.1	Fri Aug  6 19:38:53 2021
+++ src/sys/arch/arm/arm/smccc.c	Sat Aug  7 21:21:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: smccc.c,v 1.1 2021/08/06 19:38:53 jmcneill Exp $ */
+/* $NetBSD: smccc.c,v 1.2 2021/08/07 21:21:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: smccc.c,v 1.1 2021/08/06 19:38:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smccc.c,v 1.2 2021/08/07 21:21:49 jmcneill Exp $");
 
 #include 
 #include 
@@ -42,7 +42,10 @@ __KERNEL_RCSID(0, "$NetBSD: smccc.c,v 1.
 #define	SMCCC_VERSION		0x8000
 
 /* True if SMCCC is detected. */
-static bool	smccc_present;
+static bool			smccc_present;
+
+/* SMCCC conduit (SMC or HVC) */
+static enum psci_conduit	smccc_conduit = PSCI_CONDUIT_NONE;
 
 /*
  * smccc_probe --
@@ -58,6 +61,13 @@ smccc_probe(void)
 		}
 
 		smccc_present = psci_features(SMCCC_VERSION) == PSCI_SUCCESS;
+		if (smccc_present) {
+			smccc_conduit = psci_conduit();
+
+			aprint_debug("SMCCC: Version %#x (%s)\n",
+			smccc_version(),
+			smccc_conduit == PSCI_CONDUIT_SMC ? "SMC" : "HVC");
+		}
 	}
 	return smccc_present;
 }
@@ -70,7 +80,8 @@ smccc_probe(void)
 int
 smccc_version(void)
 {
-	return smccc_call(SMCCC_VERSION, 0, 0, 0);
+	return smccc_call(SMCCC_VERSION, 0, 0, 0, 0,
+			  NULL, NULL, NULL, NULL);
 }
 
 /*
@@ -79,11 +90,54 @@ smccc_version(void)
  *	Generic call interface for SMC/HVC calls.
  */
 int
-smccc_call(register_t fid, register_t arg1, register_t arg2, register_t arg3)
+smccc_call(uint32_t fid,
+register_t arg1, register_t arg2, register_t arg3, register_t arg4,
+register_t *res0, register_t *res1, register_t *res2, register_t *res3)
 {
+	register_t args[5] = { fid, arg1, arg2, arg3, arg4 };
+
+	register register_t r0 asm ("r0");
+	register register_t r1 asm ("r1");
+	register register_t r2 asm ("r2");
+	register register_t r3 asm ("r3");
+	register register_t r4 asm ("r4");
+
 	if (!smccc_present) {
 		return SMCCC_NOT_SUPPORTED;
 	}
 
-	return psci_call(fid, arg1, arg2, arg3);
+	KASSERT(smccc_conduit != PSCI_CONDUIT_NONE);
+
+	r0 = args[0];
+	r1 = args[1];
+	r2 = args[2];
+	r3 = args[3];
+	r4 = args[4];
+
+	if (smccc_conduit == PSCI_CONDUIT_SMC) {
+		asm volatile ("smc #0" :
+			  "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3) :
+			  "r" (r0), "r" (r1), "r" (r2), "r" (r3), "r" (r4) :
+			  "memory");
+	} else {
+		asm volatile ("hvc #0" :
+			  "=r" (r0), "=r" (r1), "=r" (r2), "=r" (r3) :
+			  "r" (r0), "r" (r1), "r" (r2), "r" (r3), "r" (r4) :
+			  "memory");
+	}
+	
+	if (res0) {
+		*res0 = r0;
+	}
+	if (res1) {
+		*res1 = r1;
+	}
+	if (res2) {
+		*res2 = r2;
+	}
+	if (res3) {
+		*res3 = r3;
+	}
+
+	return r0;
 }
Index: src/sys/arch/arm/arm/smccc.h
diff -u src/sys/arch/arm/arm/smccc.h:1.1 src/sys/arch/arm/arm/smccc.h:1.2
--- src/sys/arch/arm/arm/smccc.h:1.1	Fri Aug  6 19:38:53 2021
+++ src/sys/arch/arm/arm/smccc.h	Sat Aug  7 21:21:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: smccc.h,v 1.1 2021/08/06 19:38:53 jmcneill Exp $ */
+/* $NetBSD: smccc.h,v 1.2 2021/08/07 21:21:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -50,6 +50,7 @@ int	smccc_version(void);
 /*
  * Call an SMC/HVC service.
  */
-int	smccc_call(register_t, register_t, register_t, register_t);
+int	smccc_call(uint32_t, register_t, register_t, register_t, register_t,
+		   register_t *, register_t *, register_t *, register_t *);
 
 #endif /* _ARM_SMCCC_H */



CVS commit: src/sys/arch/arm/arm

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:20:14 UTC 2021

Modified Files:
src/sys/arch/arm/arm: psci.c psci.h

Log Message:
arm: PSCI: Add a function to return the PSCI conduit.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/arm/psci.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/arm/psci.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/arm/arm/psci.c
diff -u src/sys/arch/arm/arm/psci.c:1.6 src/sys/arch/arm/arm/psci.c:1.7
--- src/sys/arch/arm/arm/psci.c:1.6	Fri Aug  6 19:38:53 2021
+++ src/sys/arch/arm/arm/psci.c	Sat Aug  7 21:20:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: psci.c,v 1.6 2021/08/06 19:38:53 jmcneill Exp $ */
+/* $NetBSD: psci.c,v 1.7 2021/08/07 21:20:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.6 2021/08/06 19:38:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.7 2021/08/07 21:20:14 jmcneill Exp $");
 
 #include 
 #include 
@@ -68,6 +68,18 @@ psci_call(register_t fid, register_t arg
 	return psci_call_fn(fid, arg1, arg2, arg3);
 }
 
+enum psci_conduit
+psci_conduit(void)
+{
+	if (psci_call_fn == psci_call_smc) {
+		return PSCI_CONDUIT_SMC;
+	} else if (psci_call_fn == psci_call_hvc) {
+		return PSCI_CONDUIT_HVC;
+	} else {
+		return PSCI_CONDUIT_NONE;
+	}
+}
+
 uint32_t
 psci_version(void)
 {

Index: src/sys/arch/arm/arm/psci.h
diff -u src/sys/arch/arm/arm/psci.h:1.3 src/sys/arch/arm/arm/psci.h:1.4
--- src/sys/arch/arm/arm/psci.h:1.3	Fri Aug  6 19:38:53 2021
+++ src/sys/arch/arm/arm/psci.h	Sat Aug  7 21:20:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: psci.h,v 1.3 2021/08/06 19:38:53 jmcneill Exp $ */
+/* $NetBSD: psci.h,v 1.4 2021/08/07 21:20:14 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -42,6 +42,15 @@ enum psci_function {
 };
 
 /*
+ * Possible PSCI conduits.
+ */
+enum psci_conduit {
+	PSCI_CONDUIT_NONE,
+	PSCI_CONDUIT_SMC,
+	PSCI_CONDUIT_HVC,
+};
+
+/*
  * PSCI error codes
  */
 #define	PSCI_SUCCESS		0
@@ -71,6 +80,11 @@ void	psci_init(psci_fn);
 bool	psci_available(void);
 
 /*
+ * Return the PSCI conduit type.
+ */
+enum psci_conduit psci_conduit(void);
+
+/*
  * PSCI call methods, implemented in psci.S
  */
 int	psci_call_smc(register_t, register_t, register_t, register_t);



CVS commit: src/sys/arch/sparc/sparc

2021-08-07 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Aug  7 19:23:03 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: pmap.c

Log Message:
sp_tlb_flush - consistent whitespace in inline asm.


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/sys/arch/sparc/sparc/pmap.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/sparc/sparc/pmap.c
diff -u src/sys/arch/sparc/sparc/pmap.c:1.373 src/sys/arch/sparc/sparc/pmap.c:1.374
--- src/sys/arch/sparc/sparc/pmap.c:1.373	Sun Jan 24 07:36:54 2021
+++ src/sys/arch/sparc/sparc/pmap.c	Sat Aug  7 19:23:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.373 2021/01/24 07:36:54 mrg Exp $ */
+/*	$NetBSD: pmap.c,v 1.374 2021/08/07 19:23:03 uwe Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.373 2021/01/24 07:36:54 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.374 2021/08/07 19:23:03 uwe Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -663,13 +663,13 @@ sp_tlb_flush(int va, int ctx, int lvl)
 	opsr = getpsr();	/* KDASSERT(opsr & PSR_ET); */
 	__asm volatile ("wr %0, %1, %%psr"
 			:: "r"(opsr), "n"(PSR_ET) : "memory");
-	__asm volatile ("nop; nop;nop");
+	__asm volatile ("nop; nop; nop");
 
 	octx = getcontext4m();	/* save context */
 
 	/* Do the TLB flush in "ctx" */
 	setcontext4m(ctx);
-	__asm volatile("sta %%g0, [%0]%1" :: "r"(va), "n"(ASI_SRMMUFP));
+	__asm volatile ("sta %%g0, [%0]%1" :: "r"(va), "n"(ASI_SRMMUFP));
 
 	setcontext4m(octx);	/* restore context */
 	setpsr(opsr);		/* turn traps on again */



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 18:40:45 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
acpi: DMA: Use acpi_resource_parse_any to parse _DMA resources

_DMA resources really should be marked ResourceProducer, so use
acpi_resource_parse_any to pick these up.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/acpi/acpi_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/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.23 src/sys/arch/arm/acpi/acpi_machdep.c:1.24
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.23	Sat Aug  7 16:18:42 2021
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Sat Aug  7 18:40:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.23 2021/08/07 16:18:42 thorpej Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.23 2021/08/07 16:18:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -417,7 +417,7 @@ default_tag:
 		return;
 	}
 
-	rv = acpi_resource_parse(sc->sc_dev, module, "_DMA", ,
+	rv = acpi_resource_parse_any(sc->sc_dev, module, "_DMA", ,
 	_resource_parse_ops_quiet);
 	if (ACPI_FAILURE(rv)) {
 		aprint_error_dev(sc->sc_dev,



CVS commit: src/sys/arch/arm/sunxi

2021-08-07 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug  7 15:41:01 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sun8i_crypto.c

Log Message:
sun8icrypto(4): Call crypto_unblock when a task completes.

Otherwise under load this would presumably just hang after returning
ERESTART to opencrypto.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/sunxi/sun8i_crypto.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/arm/sunxi/sun8i_crypto.c
diff -u src/sys/arch/arm/sunxi/sun8i_crypto.c:1.25 src/sys/arch/arm/sunxi/sun8i_crypto.c:1.26
--- src/sys/arch/arm/sunxi/sun8i_crypto.c:1.25	Wed Apr 28 16:57:05 2021
+++ src/sys/arch/arm/sunxi/sun8i_crypto.c	Sat Aug  7 15:41:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sun8i_crypto.c,v 1.25 2021/04/28 16:57:05 bad Exp $	*/
+/*	$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.25 2021/04/28 16:57:05 bad Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.26 2021/08/07 15:41:00 riastradh Exp $");
 
 #include 
 #include 
@@ -211,7 +211,7 @@ static void	sun8i_crypto_timeout(void *)
 static int	sun8i_crypto_intr(void *);
 static void	sun8i_crypto_schedule_worker(struct sun8i_crypto_softc *);
 static void	sun8i_crypto_worker(struct work *, void *);
-static void	sun8i_crypto_chan_done(struct sun8i_crypto_softc *, unsigned,
+static bool	sun8i_crypto_chan_done(struct sun8i_crypto_softc *, unsigned,
 		int);
 
 static int	sun8i_crypto_allocbuf(struct sun8i_crypto_softc *, size_t,
@@ -1051,6 +1051,7 @@ sun8i_crypto_worker(struct work *wk, voi
 	struct sun8i_crypto_softc *sc = cookie;
 	uint32_t done, esr, esr_chan;
 	unsigned i, now;
+	bool unblock = false;
 	int error;
 
 	/*
@@ -1084,7 +1085,8 @@ sun8i_crypto_worker(struct work *wk, voi
 			if ((sc->sc_chan[i].cc_task != NULL) &&
 			((now - sc->sc_chan[i].cc_starttime) >=
 SUN8I_CRYPTO_TIMEOUT))
-sun8i_crypto_chan_done(sc, i, ETIMEDOUT);
+unblock |= sun8i_crypto_chan_done(sc, i,
+ETIMEDOUT);
 			continue;
 		}
 
@@ -1112,11 +1114,23 @@ sun8i_crypto_worker(struct work *wk, voi
 		 * Notify the task of completion.  May release the lock
 		 * to invoke a callback.
 		 */
-		sun8i_crypto_chan_done(sc, i, error);
+		unblock |= sun8i_crypto_chan_done(sc, i, error);
 	}
 
 	/* All one; release the lock one last time.  */
 	mutex_exit(>sc_lock);
+
+	/*
+	 * If we cleared any channels, it is time to allow opencrypto
+	 * to issue new operations.  Asymmetric operations (which we
+	 * don't support, at the moment, but we could) and symmetric
+	 * operations (which we do) use the same task channels, so we
+	 * unblock both kinds.
+	 */
+	if (unblock) {
+		crypto_unblock(sc->sc_opencrypto.co_driverid,
+		CRYPTO_SYMQ|CRYPTO_ASYMQ);
+	}
 }
 
 /*
@@ -1125,7 +1139,7 @@ sun8i_crypto_worker(struct work *wk, voi
  *	Notify the callback for the task on channel i, if there is one,
  *	of the specified error, or 0 for success.
  */
-static void
+static bool
 sun8i_crypto_chan_done(struct sun8i_crypto_softc *sc, unsigned i, int error)
 {
 	struct sun8i_crypto_task *task;
@@ -1140,7 +1154,8 @@ sun8i_crypto_chan_done(struct sun8i_cryp
 	if ((task = sc->sc_chan[i].cc_task) == NULL) {
 		device_printf(sc->sc_dev, "channel %u: no task but error=%d\n",
 		i, error);
-		return;
+		/* We did not clear a channel.  */
+		return false;
 	}
 	sc->sc_chan[i].cc_task = NULL;
 
@@ -1183,6 +1198,9 @@ sun8i_crypto_chan_done(struct sun8i_cryp
 	SDT_PROBE2(sdt, sun8i_crypto, task, done,  task, error);
 	(*task->ct_callback)(sc, task, task->ct_cookie, error);
 	mutex_enter(>sc_lock);
+
+	/* We cleared a channel.  */
+	return true;
 }
 
 /*
@@ -1811,7 +1829,7 @@ sun8i_crypto_register1(struct sun8i_cryp
  *	Called by opencrypto to allocate a new session.  We don't keep
  *	track of sessions, since there are no persistent keys in the
  *	hardware that we take advantage of, so this only validates the
- *	crypto operations and returns a zero session id.
+ *	crypto operations and returns a dummy session id of 1.
  */
 static int
 sun8i_crypto_newsession(void *cookie, uint32_t *sidp, struct cryptoini *cri)
@@ -1823,7 +1841,7 @@ sun8i_crypto_newsession(void *cookie, ui
 
 	/*
 	 * No variation of rounds is supported here.  (XXX Unused and
-	 * unimplemented in opencrypto(9) altogether?
+	 * unimplemented in opencrypto(9) altogether?)
 	 */
 	if (cri->cri_rnd)
 		return EINVAL;



CVS commit: src/sys/arch/macppc/dev

2021-08-07 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Aug  7 06:04:26 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: pmu.c

Log Message:
pass sensor locations to i2c devices if we can find them
tested on 2nd gen Mini


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/macppc/dev/pmu.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/macppc/dev/pmu.c
diff -u src/sys/arch/macppc/dev/pmu.c:1.37 src/sys/arch/macppc/dev/pmu.c:1.38
--- src/sys/arch/macppc/dev/pmu.c:1.37	Sat Apr 24 23:36:41 2021
+++ src/sys/arch/macppc/dev/pmu.c	Sat Aug  7 06:04:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $ */
+/*	$NetBSD: pmu.c,v 1.38 2021/08/07 06:04:26 macallan Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.37 2021/04/24 23:36:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.38 2021/08/07 06:04:26 macallan Exp $");
 
 #include 
 #include 
@@ -340,7 +340,7 @@ pmu_attach(device_t parent, device_t sel
 			goto next;
 
 		if (strncmp(name, "pmu-i2c", 8) == 0) {
-			int devs;
+			int devs, sensors;
 			uint32_t addr;
 			char compat[256];
 			prop_array_t cfg;
@@ -372,6 +372,20 @@ pmu_attach(device_t parent, device_t sel
 prop_object_release(data);
 prop_dictionary_set_uint32(dev, "addr", addr);
 prop_dictionary_set_uint64(dev, "cookie", devs);
+sensors = OF_child(devs);
+while (sensors != 0) {
+	int reg;
+	char loc[64];
+	char pname[8];
+	if (OF_getprop(sensors, "reg", , 4) != 4)
+		goto nope;
+	if (OF_getprop(sensors, "location", loc, 63) <= 0)
+		goto nope;
+	snprintf(pname, 7, "s%02x", reg);
+	prop_dictionary_set_string(dev, pname, loc);
+nope:
+	sensors = OF_peer(sensors);
+}
 prop_array_add(cfg, dev);
 prop_object_release(dev);
 			skip:
@@ -818,7 +832,7 @@ pmu_poweroff(void)
 	if (pmu_send(sc, PMU_POWER_OFF, 4, cmd, 16, resp) >= 0)
 		while (1);
 }
-
+	
 void
 pmu_restart(void)
 {



CVS commit: src/sys/arch

2021-08-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Aug  6 19:38:54 UTC 2021

Modified Files:
src/sys/arch/aarch64/conf: files.aarch64
src/sys/arch/arm/acpi: acpi_platform.c
src/sys/arch/arm/arm: psci.c psci.h
src/sys/arch/arm/conf: files.arm
src/sys/arch/arm/fdt: psci_fdt.c
Added Files:
src/sys/arch/arm/arm: smccc.c smccc.h

Log Message:
Arm: Add support for SMC Calling Convention

Arm DEN0028 defines a calling mechanism used with Secure Monitor Call (SMC)
and Hypervisor Call (HVC) instructions. To discover SMCCC, we must:

 1) Find the PSCI conduit (either via ACPI FADT, or Device Tree)
 2) Use PSCI_VERSION to determine whether PSCI_FEATURES is supported
 3) Call PSCI_FEATURES with SMCCC_VERSION to determine the implementation
version.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/aarch64/conf/files.aarch64
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/acpi/acpi_platform.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm/psci.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/arm/psci.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/arm/smccc.c \
src/sys/arch/arm/arm/smccc.h
cvs rdiff -u -r1.164 -r1.165 src/sys/arch/arm/conf/files.arm
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/fdt/psci_fdt.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/aarch64/conf/files.aarch64
diff -u src/sys/arch/aarch64/conf/files.aarch64:1.31 src/sys/arch/aarch64/conf/files.aarch64:1.32
--- src/sys/arch/aarch64/conf/files.aarch64:1.31	Sat Jul 24 23:38:41 2021
+++ src/sys/arch/aarch64/conf/files.aarch64	Fri Aug  6 19:38:53 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.aarch64,v 1.31 2021/07/24 23:38:41 jmcneill Exp $
+#	$NetBSD: files.aarch64,v 1.32 2021/08/06 19:38:53 jmcneill Exp $
 
 defflag opt_cpuoptions.h	AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h	AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -33,11 +33,15 @@ defparam opt_console.h		CONSPEED
 defparam opt_console.h		CONMODE
 defparam opt_console.h		CONADDR
 
-# Power State Coordination Interface (PSCI)
 # FP support
 file	arch/aarch64/aarch64/fpu.c
 
-device	psci
+# SMC Calling Convention
+define	smccc
+file	arch/arm/arm/smccc.c			smccc
+
+# Power State Coordination Interface (PSCI)
+device	psci: smccc
 file	arch/arm/arm/psci.c			psci
 file	arch/arm/arm/psci_arm.S			psci
 

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.26 src/sys/arch/arm/acpi/acpi_platform.c:1.27
--- src/sys/arch/arm/acpi/acpi_platform.c:1.26	Wed May 12 23:22:32 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Fri Aug  6 19:38:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.26 2021/05/12 23:22:32 thorpej Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.27 2021/08/06 19:38:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.26 2021/05/12 23:22:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.27 2021/08/06 19:38:53 jmcneill Exp $");
 
 #include 
 #include 
@@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 #include 
 
+#include 
 #include 
 #include 
 

Index: src/sys/arch/arm/arm/psci.c
diff -u src/sys/arch/arm/arm/psci.c:1.5 src/sys/arch/arm/arm/psci.c:1.6
--- src/sys/arch/arm/arm/psci.c:1.5	Sat Jan 16 23:51:50 2021
+++ src/sys/arch/arm/arm/psci.c	Fri Aug  6 19:38:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: psci.c,v 1.5 2021/01/16 23:51:50 chs Exp $ */
+/* $NetBSD: psci.c,v 1.6 2021/08/06 19:38:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.5 2021/01/16 23:51:50 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.6 2021/08/06 19:38:53 jmcneill Exp $");
 
 #include 
 #include 
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: psci.c,v 1.5
 #else
 #define	PSCI_CPU_ON		0x8403
 #endif
+#define	PSCI_FEATURES		0x840a
 
 static psci_fn psci_call_fn;
 
@@ -53,9 +54,10 @@ static uint32_t psci_functions[PSCI_FUNC
 [PSCI_FUNC_SYSTEM_OFF] = PSCI_SYSTEM_OFF,
 	[PSCI_FUNC_SYSTEM_RESET] = PSCI_SYSTEM_RESET,
 	[PSCI_FUNC_CPU_ON] = PSCI_CPU_ON,
+	[PSCI_FUNC_FEATURES] = PSCI_FEATURES,
 };
 
-static int
+int
 psci_call(register_t fid, register_t arg1, register_t arg2, register_t arg3)
 {
 	KASSERT(psci_call_fn != NULL);
@@ -98,6 +100,15 @@ psci_system_reset(void)
 	psci_call(psci_functions[PSCI_FUNC_SYSTEM_RESET], 0, 0, 0);
 }
 
+int
+psci_features(uint32_t fid)
+{
+	if (psci_functions[PSCI_FUNC_FEATURES] == 0) {
+		return PSCI_NOT_SUPPORTED;
+	}
+	return psci_call(psci_functions[PSCI_FUNC_FEATURES], fid, 0, 0);
+}
+
 void
 psci_init(psci_fn fn)
 {

Index: src/sys/arch/arm/arm/psci.h
diff -u src/sys/arch/arm/arm/psci.h:1.2 src/sys/arch/arm/arm/psci.h:1.3
--- src/sys/arch/arm/arm/psci.h:1.2	Sat Oct 13 00:07:55 2018
+++ 

CVS commit: src/sys/arch/arm/xscale

2021-08-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Aug  6 09:01:36 UTC 2021

Modified Files:
src/sys/arch/arm/xscale: i80321_icu.c i80321var.h

Log Message:
Simplify i80321_intr_calculate_masks().

G/C unused members of struct intrq.

No functional changes intended.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/xscale/i80321_icu.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/xscale/i80321var.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/arm/xscale/i80321_icu.c
diff -u src/sys/arch/arm/xscale/i80321_icu.c:1.26 src/sys/arch/arm/xscale/i80321_icu.c:1.27
--- src/sys/arch/arm/xscale/i80321_icu.c:1.26	Fri Nov 20 18:49:45 2020
+++ src/sys/arch/arm/xscale/i80321_icu.c	Fri Aug  6 09:01:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i80321_icu.c,v 1.26 2020/11/20 18:49:45 thorpej Exp $	*/
+/*	$NetBSD: i80321_icu.c,v 1.27 2021/08/06 09:01:36 rin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2006 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i80321_icu.c,v 1.26 2020/11/20 18:49:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i80321_icu.c,v 1.27 2021/08/06 09:01:36 rin Exp $");
 
 #ifndef EVBARM_SPL_NOINLINE
 #define	EVBARM_SPL_NOINLINE
@@ -166,26 +166,22 @@ i80321_intr_calculate_masks(void)
 	struct intrhand *ih;
 	int irq, ipl;
 
-	/* First, figure out which IPLs each IRQ has. */
+	/* Disable all IRQs. */
+	for (irq = 0; irq < NIRQ; irq++)
+		i80321_disable_irq(irq);
+
+	/* Figure out which IRQs are used by each IPL. */
+	for (ipl = 0; ipl < NIPL; ipl++)
+		i80321_imask[ipl] = 0;
 	for (irq = 0; irq < NIRQ; irq++) {
-		int levels = 0;
 		iq = [irq];
-		i80321_disable_irq(irq);
-		for (ih = TAILQ_FIRST(>iq_list); ih != NULL;
-		 ih = TAILQ_NEXT(ih, ih_list))
-			levels |= (1U << ih->ih_ipl);
-		iq->iq_levels = levels;
+		TAILQ_FOREACH(ih, >iq_list, ih_list)
+			i80321_imask[ih->ih_ipl] |= (1U << irq);
 	}
 
-	/* Next, figure out which IRQs are used by each IPL. */
-	for (ipl = 0; ipl < NIPL; ipl++) {
-		int irqs = 0;
-		for (irq = 0; irq < NIRQ; irq++) {
-			if (intrq[irq].iq_levels & (1U << ipl))
-irqs |= (1U << irq);
-		}
-		i80321_imask[ipl] = irqs;
-	}
+	/* All IPLs block everything blocked by any lower IPL. */
+	for (ipl = 1; ipl < NIPL; ipl++)
+		i80321_imask[ipl] |= i80321_imask[ipl - 1];
 
 	KASSERT(i80321_imask[IPL_NONE] == 0);
 	KASSERT(i80321_imask[IPL_SOFTCLOCK] == 0);
@@ -193,38 +189,11 @@ i80321_intr_calculate_masks(void)
 	KASSERT(i80321_imask[IPL_SOFTNET] == 0);
 	KASSERT(i80321_imask[IPL_SOFTSERIAL] == 0);
 
-	/*
-	 * Enforce a hierarchy that gives "slow" device (or devices with
-	 * limited input buffer space/"real-time" requirements) a better
-	 * chance at not dropping data.
-	 */
-
-#if 0
-	/*
-	 * This assert might be useful, but only after some interrupts
-	 * are configured.  As it stands now, it will always fire early
-	 * in the initialization phase.  If it's useful enough to re-
-	 * enable, it should be conditionalized on something else like
-	 * having at least something in the levels/irqs above.
-	 */
-	KASSERT(i80321_imask[IPL_VM] != 0);
-#endif
-	i80321_imask[IPL_SCHED] |= i80321_imask[IPL_VM];
-	i80321_imask[IPL_HIGH] |= i80321_imask[IPL_SCHED];
-
-	/*
-	 * Now compute which IRQs must be blocked when servicing any
-	 * given IRQ.
-	 */
+	/* Enable IRQs in use. */
 	for (irq = 0; irq < NIRQ; irq++) {
-		int irqs = (1U << irq);
 		iq = [irq];
-		if (TAILQ_FIRST(>iq_list) != NULL)
+		if (!TAILQ_EMPTY(>iq_list))
 			i80321_enable_irq(irq);
-		for (ih = TAILQ_FIRST(>iq_list); ih != NULL;
-		 ih = TAILQ_NEXT(ih, ih_list))
-			irqs |= i80321_imask[ih->ih_ipl];
-		iq->iq_mask = irqs;
 	}
 }
 

Index: src/sys/arch/arm/xscale/i80321var.h
diff -u src/sys/arch/arm/xscale/i80321var.h:1.13 src/sys/arch/arm/xscale/i80321var.h:1.14
--- src/sys/arch/arm/xscale/i80321var.h:1.13	Sun Feb 12 16:31:01 2012
+++ src/sys/arch/arm/xscale/i80321var.h	Fri Aug  6 09:01:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i80321var.h,v 1.13 2012/02/12 16:31:01 matt Exp $	*/
+/*	$NetBSD: i80321var.h,v 1.14 2021/08/06 09:01:36 rin Exp $	*/
 
 /*
  * Copyright (c) 2002, 2003 Wasabi Systems, Inc.
@@ -59,8 +59,6 @@ struct intrhand {
 struct intrq {
 	TAILQ_HEAD(, intrhand) iq_list;	/* handler list */
 	struct evcnt iq_ev;		/* event counter */
-	int iq_mask;			/* IRQs to mask while handling */
-	int iq_levels;			/* IPL_*'s this IRQ has */
 	int iq_ist;			/* share type */
 };
 



CVS commit: src/sys/arch/arm/xscale

2021-08-06 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Aug  6 08:58:42 UTC 2021

Modified Files:
src/sys/arch/arm/xscale: i80321_intr.h

Log Message:
Do *NOT* lower IPL in i80321_splraise().

Fix various strange crashes for DIAGNOSTIC kernel on evbarm/HDL_G,
including one worked around by if_wm.c rev 1.706:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/pci/if_wm.c#rev1.706


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/xscale/i80321_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/arm/xscale/i80321_intr.h
diff -u src/sys/arch/arm/xscale/i80321_intr.h:1.12 src/sys/arch/arm/xscale/i80321_intr.h:1.13
--- src/sys/arch/arm/xscale/i80321_intr.h:1.12	Wed Jan 24 09:04:45 2018
+++ src/sys/arch/arm/xscale/i80321_intr.h	Fri Aug  6 08:58:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: i80321_intr.h,v 1.12 2018/01/24 09:04:45 skrll Exp $	*/
+/*	$NetBSD: i80321_intr.h,v 1.13 2021/08/06 08:58:42 rin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2006 Wasabi Systems, Inc.
@@ -95,10 +95,15 @@ static inline int __attribute__((__unuse
 i80321_splraise(int ipl)
 {
 	int old = curcpl();
-	set_curcpl(ipl);
 
-	/* Don't let the compiler re-order this code with subsequent code */
-	__insn_barrier();
+	if (ipl > old) {
+		set_curcpl(ipl);
+		/*
+		 * Don't let the compiler re-order this code with
+		 * subsequent code
+		 */
+		__insn_barrier();
+	}
 
 	return (old);
 }



CVS commit: src/sys/arch/news68k/news68k

2021-08-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Aug  6 05:53:50 UTC 2021

Modified Files:
src/sys/arch/news68k/news68k: machdep.c

Log Message:
Fix mm_md_physacc() to allow only accesses to a region of RAMs.

Note on NetBSD/news68k RAMs reserved by the PROM (at the end of the RAM)
are not managed.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/news68k/news68k/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/news68k/news68k/machdep.c
diff -u src/sys/arch/news68k/news68k/machdep.c:1.108 src/sys/arch/news68k/news68k/machdep.c:1.109
--- src/sys/arch/news68k/news68k/machdep.c:1.108	Thu Jun 11 19:20:44 2020
+++ src/sys/arch/news68k/news68k/machdep.c	Fri Aug  6 05:53:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.108 2020/06/11 19:20:44 ad Exp $	*/
+/*	$NetBSD: machdep.c,v 1.109 2021/08/06 05:53:50 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.108 2020/06/11 19:20:44 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.109 2021/08/06 05:53:50 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -992,8 +992,17 @@ consinit(void)
 int
 mm_md_physacc(paddr_t pa, vm_prot_t prot)
 {
+	paddr_t memend;
 
-	return (pa < lowram || pa >= 0xfffc) ? EFAULT : 0;
+	/*
+	 * news68k has one contiguous memory segment.
+	 */
+	memend = lowram + ctob(physmem);
+
+	if (lowram <= pa && pa < memend) 
+		return 0;
+
+	return EFAULT;
 }
 
 int



CVS commit: src/sys/arch/hp300/hp300

2021-08-05 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Aug  6 05:22:21 UTC 2021

Modified Files:
src/sys/arch/hp300/hp300: machdep.c

Log Message:
Add comments how mm_md_physacc() for hp300 works.

mm_md_physacc() for all other hp300 pmap based m68k ports that copied
hp300 implemantation should have been fixed properly.

XXX: no mm(9) man pages that describe MD implementation API definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sys/arch/hp300/hp300/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/hp300/hp300/machdep.c
diff -u src/sys/arch/hp300/hp300/machdep.c:1.234 src/sys/arch/hp300/hp300/machdep.c:1.235
--- src/sys/arch/hp300/hp300/machdep.c:1.234	Thu Jun 11 19:20:43 2020
+++ src/sys/arch/hp300/hp300/machdep.c	Fri Aug  6 05:22:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.234 2020/06/11 19:20:43 ad Exp $	*/
+/*	$NetBSD: machdep.c,v 1.235 2021/08/06 05:22:21 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.234 2020/06/11 19:20:43 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.235 2021/08/06 05:22:21 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -1164,6 +1164,10 @@ int
 mm_md_physacc(paddr_t pa, vm_prot_t prot)
 {
 
+	/*
+	 * On the hp300, physical RAM is always located at the end of
+	 * the physical address space, i.e. from 0x to lowram.
+	 */
 	return (pa < lowram || pa >= 0xfffc) ? EFAULT : 0;
 }
 



CVS commit: src/sys/arch/x68k/x68k

2021-08-05 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Fri Aug  6 04:21:56 UTC 2021

Modified Files:
src/sys/arch/x68k/x68k: machdep.c

Log Message:
Fix broken mm_md_physacc().
- Fix access to main memory and extended memory.
  This makes /dev/mem work again.
- Introduce kauth(9) to access unmanaged memory area.
  Now you can read/write the internal I/O space via /dev/mem when
  securelevel = -1.
Thanks ryo@, tsutsui@ for advices and reviews.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/arch/x68k/x68k/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/x68k/x68k/machdep.c
diff -u src/sys/arch/x68k/x68k/machdep.c:1.205 src/sys/arch/x68k/x68k/machdep.c:1.206
--- src/sys/arch/x68k/x68k/machdep.c:1.205	Thu Feb 11 02:37:11 2021
+++ src/sys/arch/x68k/x68k/machdep.c	Fri Aug  6 04:21:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.205 2021/02/11 02:37:11 tsutsui Exp $	*/
+/*	$NetBSD: machdep.c,v 1.206 2021/08/06 04:21:56 isaki Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.205 2021/02/11 02:37:11 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.206 2021/08/06 04:21:56 isaki Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1252,15 +1252,28 @@ cpu_intr_p(void)
 int
 mm_md_physacc(paddr_t pa, vm_prot_t prot)
 {
-	uvm_physseg_t i;
+	int i;
 
-	for (i = uvm_physseg_get_first(); uvm_physseg_valid_p(i); i = uvm_physseg_get_next(i)) {
-		if (uvm_physseg_valid_p(i) == false)
-			break;
+	/* Main memory */
+	if (phys_basemem_seg.start <= pa && pa < phys_basemem_seg.end)
+		return 0;
 
-		if (ctob(uvm_physseg_get_start(i)) <= pa &&
-		pa < ctob(uvm_physseg_get_end(i)))
+#ifdef EXTENDED_MEMORY
+	for (i = 0; i < EXTMEM_SEGS; i++) {
+		if (phys_extmem_seg[i].start == phys_extmem_seg[i].end)
+			continue;
+		if (phys_extmem_seg[i].start <= pa &&
+		pa < phys_extmem_seg[i].end) {
 			return 0;
+		}
 	}
+#endif
+
+	/* I/O space */
+	if (INTIOBASE <= pa && pa < INTIOTOP) {
+		return kauth_authorize_machdep(kauth_cred_get(),
+		KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL);
+	}
+
 	return EFAULT;
 }



CVS commit: src/sys/arch/sparc/sparc

2021-07-31 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Jul 31 16:54:37 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
s/propective/prospective


To generate a diff of this commit:
cvs rdiff -u -r1.267 -r1.268 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.267 src/sys/arch/sparc/sparc/autoconf.c:1.268
--- src/sys/arch/sparc/sparc/autoconf.c:1.267	Sat Jul 31 10:07:22 2021
+++ src/sys/arch/sparc/sparc/autoconf.c	Sat Jul 31 16:54:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $ */
+/*	$NetBSD: autoconf.c,v 1.268 2021/07/31 16:54:37 andvar Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.268 2021/07/31 16:54:37 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -2009,7 +2009,7 @@ bootinfo_relocate(void *newloc)
 		(size_t)cp < (size_t)bootinfo + BOOTINFO_SIZE);
 
 	/*
-	 * Check propective gains.
+	 * Check prospective gains.
 	 */
 	if ((int)bootinfo - (int)newloc < bi_size)
 		/* Don't bother */



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

2021-07-31 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jul 31 14:51:25 UTC 2021

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

Log Message:
Fix a silly mistake (missing return) in the DEBUG case of the kernel pmap
case of pmap_extract().


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/sys/arch/alpha/alpha/pmap.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/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.299 src/sys/arch/alpha/alpha/pmap.c:1.300
--- src/sys/arch/alpha/alpha/pmap.c:1.299	Mon Jul 19 16:31:19 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sat Jul 31 14:51:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.299 2021/07/19 16:31:19 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.300 2021/07/31 14:51:25 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.299 2021/07/19 16:31:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.300 2021/07/31 14:51:25 thorpej Exp $");
 
 #include 
 #include 
@@ -2587,6 +2587,7 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 printf("failed (kernel vtophys)\n");
 			}
 		}
+		return address_is_valid;
 #else
 		return vtophys_internal(va, pap);
 #endif



CVS commit: src/sys/arch/arm/sunxi

2021-07-31 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sat Jul 31 11:34:40 UTC 2021

Modified Files:
src/sys/arch/arm/sunxi: sunxi_platform.c

Log Message:
sunxi_platform: declare UART FIFO sizes for SoCs we support


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/sunxi/sunxi_platform.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/arm/sunxi/sunxi_platform.c
diff -u src/sys/arch/arm/sunxi/sunxi_platform.c:1.44 src/sys/arch/arm/sunxi/sunxi_platform.c:1.45
--- src/sys/arch/arm/sunxi/sunxi_platform.c:1.44	Fri Jul 30 12:46:46 2021
+++ src/sys/arch/arm/sunxi/sunxi_platform.c	Sat Jul 31 11:34:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $ */
+/* $NetBSD: sunxi_platform.c,v 1.45 2021/07/31 11:34:40 tnn Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -31,7 +31,7 @@
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.44 2021/07/30 12:46:46 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_platform.c,v 1.45 2021/07/31 11:34:40 tnn Exp $");
 
 #include 
 #include 
@@ -241,11 +241,23 @@ sunxi_platform_device_register(device_t 
 
 	if (device_is_a(self, "com")) {
 		static const struct device_compatible_entry compat_data[] = {
-			{ .compat = "allwinner,sun7i-a20" },
+			{ .compat = "allwinner,sun4i-a10",	.value = 64 },
+			{ .compat = "allwinner,sun5i-a13",	.value = 64 },
+			{ .compat = "allwinner,sun6i-a31",	.value = 64 },
+			{ .compat = "allwinner,sun7i-a20",	.value = 64 },
+			{ .compat = "allwinner,sun8i-h2-plus",	.value = 64 },
+			{ .compat = "allwinner,sun8i-h3",	.value = 64 },
+			{ .compat = "allwinner,sun8i-a83t",	.value = 64 },
+			{ .compat = "allwinner,sun9i-a80",	.value = 64 },
+			{ .compat = "allwinner,sun50i-a64",	.value = 64 },
+			{ .compat = "allwinner,sun50i-h5",	.value = 64 },
+			{ .compat = "allwinner,sun50i-h6",	.value = 256 },
 			DEVICE_COMPAT_EOL
 		};
-		if (of_compatible_match(OF_finddevice("/"), compat_data))
-			prop_dictionary_set_uint(prop, "fifolen", 64);
+		const struct device_compatible_entry *dce =
+		of_compatible_lookup(OF_finddevice("/"), compat_data);
+		if (dce != NULL)
+			prop_dictionary_set_uint(prop, "fifolen", dce->value);
 	}
 }
 



CVS commit: src/sys/arch/sparc/sparc

2021-07-31 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Jul 31 10:07:23 UTC 2021

Modified Files:
src/sys/arch/sparc/sparc: autoconf.c

Log Message:
fix typos in comments


To generate a diff of this commit:
cvs rdiff -u -r1.266 -r1.267 src/sys/arch/sparc/sparc/autoconf.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/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.266 src/sys/arch/sparc/sparc/autoconf.c:1.267
--- src/sys/arch/sparc/sparc/autoconf.c:1.266	Mon May 10 23:53:44 2021
+++ src/sys/arch/sparc/sparc/autoconf.c	Sat Jul 31 10:07:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.266 2021/05/10 23:53:44 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.266 2021/05/10 23:53:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.267 2021/07/31 10:07:22 andvar Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1114,7 +1114,7 @@ mainbus_attach(device_t parent, device_t
 		const char *const dev;
 #define BS_EARLY	1	/* attach device early */
 #define	BS_IGNORE	2	/* ignore root device */
-#define	BS_OPTIONAL	4	/* device not alwas present */
+#define	BS_OPTIONAL	4	/* device not always present */
 		unsigned int flags;
 	};
 



CVS commit: src/sys/arch/macppc/dev

2021-07-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jul 30 22:07:14 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h fcu.c

Log Message:
make thermal zone parameters configurable by sysctl


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fancontrol.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/macppc/dev/fcu.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/macppc/dev/fancontrol.c
diff -u src/sys/arch/macppc/dev/fancontrol.c:1.2 src/sys/arch/macppc/dev/fancontrol.c:1.3
--- src/sys/arch/macppc/dev/fancontrol.c:1.2	Wed Jul 28 00:36:00 2021
+++ src/sys/arch/macppc/dev/fancontrol.c	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 Michael Lorenz
@@ -27,13 +27,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.3 2021/07/30 22:07:14 macallan Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -60,6 +61,10 @@ fancontrol_adjust_zone(fancontrol_zone_t
 		return -1;
 	}
 
+	if (z->Tmin < 30) z->Tmin = 30;
+	if (z->Tmin > 60) z->Tmin = 60;
+	if (z->Tmax > 95) z->Tmax = 95;
+	if (z->Tmax < (z->Tmin + 10)) z->Tmax = z->Tmin + 10;
 	temp = (temp - 27315) / 100;
 	diff = temp - z->Tmin;
 	DPRINTF("%s %d %d\n", z->name, temp, z->Tmin);
@@ -76,3 +81,39 @@ fancontrol_adjust_zone(fancontrol_zone_t
 	}
 	return 0;
 }
+
+int
+fancontrol_init_zone(fancontrol_zone_t *z, struct sysctlnode *me)
+{
+	struct sysctlnode *zone_node, *node;
+
+	if (z->nfans <= 0) return 0;
+
+	sysctl_createv(NULL, 0, NULL, (void *) _node,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_NODE, z->name, NULL,
+	NULL, 0, NULL, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, (void *) ,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_INT, "Tmin", "minimum temperature",
+	NULL, 0, (void *)>Tmin, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	zone_node->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	sysctl_createv(NULL, 0, NULL, (void *) ,
+	CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	CTLTYPE_INT, "Tmax", "maximum temperature",
+	NULL, 0, (void *)>Tmax, 0,
+	CTL_MACHDEP,
+	me->sysctl_num,
+	zone_node->sysctl_num,
+	CTL_CREATE, CTL_EOL);
+
+	return 0;
+}

Index: src/sys/arch/macppc/dev/fancontrolvar.h
diff -u src/sys/arch/macppc/dev/fancontrolvar.h:1.1 src/sys/arch/macppc/dev/fancontrolvar.h:1.2
--- src/sys/arch/macppc/dev/fancontrolvar.h:1.1	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fancontrolvar.h	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fancontrolvar.h,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrolvar.h,v 1.2 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2021 Michael Lorenz
@@ -48,5 +48,6 @@ typedef struct _fancontrol_zone {
 } fancontrol_zone_t; 
 
 int fancontrol_adjust_zone(fancontrol_zone_t *);
+int fancontrol_init_zone(fancontrol_zone_t *, struct sysctlnode *);
 
 #endif /* FANCONTROLVAR_H */

Index: src/sys/arch/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.3 src/sys/arch/macppc/dev/fcu.c:1.4
--- src/sys/arch/macppc/dev/fcu.c:1.3	Wed Jul 28 00:59:10 2021
+++ src/sys/arch/macppc/dev/fcu.c	Fri Jul 30 22:07:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.4 2021/07/30 22:07:14 macallan Exp $");
 
 #include 
 #include 
@@ -35,6 +35,7 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -78,8 +79,8 @@ struct fcu_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_i2c;
 	i2c_addr_t	sc_addr;
-
-	struct sysmon_envsys *sc_sme;
+	struct sysctlnode 	*sc_sysctl_me;
+	struct sysmon_envsys	*sc_sme;
 	envsys_data_t		sc_sensors[32];
 	int			sc_nsensors;
 	fancontrol_zone_t	sc_zones[FCU_ZONE_COUNT];
@@ -132,7 +133,7 @@ fcu_attach(device_t parent, device_t sel
 {
 	struct fcu_softc *sc = device_private(self);
 	struct i2c_attach_args *ia = aux;
-	int have_eeprom1 = 1;
+	int have_eeprom1 = 1, i;
 
 	sc->sc_dev = self;
 	sc->sc_i2c = ia->ia_tag;
@@ -141,6 +142,12 @@ fcu_attach(device_t parent, device_t sel
 	aprint_naive("\n");
 	aprint_normal(": Fan Control Unit\n");
 
+	sysctl_createv(NULL, 0, NULL, (void *) >sc_sysctl_me,
+	CTLFLAG_READWRITE,
+	CTLTYPE_NODE, 

CVS commit: src/sys/arch/xen/xen

2021-07-28 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jul 28 22:17:49 UTC 2021

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
fix off-by-one check in another KASSERT() for bcount

still related to PR port-xen/56328


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.98 src/sys/arch/xen/xen/xbdback_xenbus.c:1.99
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.98	Wed Jul 28 21:38:50 2021
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Wed Jul 28 22:17:49 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.98 2021/07/28 21:38:50 jdolecek Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.99 2021/07/28 22:17:49 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.98 2021/07/28 21:38:50 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.99 2021/07/28 22:17:49 jdolecek Exp $");
 
 #include 
 #include 
@@ -1311,7 +1311,7 @@ xbdback_co_io_gotio(struct xbdback_insta
 
 	KASSERT(bcount <= MAXPHYS);
 	KASSERT(xbd_io->xio_start_offset < PAGE_SIZE);
-	KASSERT(bcount + xbd_io->xio_start_offset < VBD_VA_SIZE);
+	KASSERT(bcount + xbd_io->xio_start_offset <= VBD_VA_SIZE);
 
 	/* Fill-in the buf */
 	if (xbdi->xbdi_xen_req.operation == BLKIF_OP_WRITE) {



CVS commit: src/sys/arch/xen/xen

2021-07-28 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Wed Jul 28 21:38:50 UTC 2021

Modified Files:
src/sys/arch/xen/xen: xbdback_xenbus.c

Log Message:
fix intentional, but eventually faulty off-by-one for the maximum number
of segments for I/O - this was supposed to allow MAXPHYS-size I/O even
with page offset, but actually ended up letting through I/O up to
MAXPHYS+PAGE_SIZE

the KASSERT(bcount < MAXPHYS) is kept as-is, since at that place the number
of segments should already be validated, so it's kernel bug if the size
is still too big there

fixes PR port-xen/56328 by Greg Oster


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/arch/xen/xen/xbdback_xenbus.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/xen/xen/xbdback_xenbus.c
diff -u src/sys/arch/xen/xen/xbdback_xenbus.c:1.97 src/sys/arch/xen/xen/xbdback_xenbus.c:1.98
--- src/sys/arch/xen/xen/xbdback_xenbus.c:1.97	Sun Feb 21 20:02:25 2021
+++ src/sys/arch/xen/xen/xbdback_xenbus.c	Wed Jul 28 21:38:50 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: xbdback_xenbus.c,v 1.97 2021/02/21 20:02:25 jdolecek Exp $  */
+/*  $NetBSD: xbdback_xenbus.c,v 1.98 2021/07/28 21:38:50 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.97 2021/02/21 20:02:25 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.98 2021/07/28 21:38:50 jdolecek Exp $");
 
 #include 
 #include 
@@ -71,8 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: xbdback_xenb
 #define VBD_BSIZE 512
 #define VBD_MAXSECT ((PAGE_SIZE / VBD_BSIZE) - 1)
 
-/* Need to alloc one extra page to account for possible mapping offset */
-#define VBD_VA_SIZE	(MAXPHYS + PAGE_SIZE)
+#define VBD_VA_SIZE			MAXPHYS
 #define VBD_MAX_INDIRECT_SEGMENTS	VBD_VA_SIZE >> PAGE_SHIFT
 
 CTASSERT(XENSHM_MAX_PAGES_PER_REQUEST >= VBD_MAX_INDIRECT_SEGMENTS);



CVS commit: src/sys/arch/macppc/dev

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:59:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fcu.c

Log Message:
check temperatures a bit more often
while there, explain why the delay is variable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fcu.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/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.2 src/sys/arch/macppc/dev/fcu.c:1.3
--- src/sys/arch/macppc/dev/fcu.c:1.2	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fcu.c	Wed Jul 28 00:59:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
 
 #include 
 #include 
@@ -490,7 +490,13 @@ fcu_adjust(void *cookie)
 		sc->sc_pwm = FALSE;
 		for (i = 0; i < FCU_ZONE_COUNT; i++)
 			fancontrol_adjust_zone(>sc_zones[i]);
-		kpause("fanctrl", true, mstohz(sc->sc_pwm ? 1000 : 5000), NULL);
+		/*
+		 * take a shorter nap if we're in the proccess of adjusting a
+		 * PWM fan, which relies on measuring speed and then changing
+		 * its duty cycle until we're reasonable close to the target
+		 * speed
+		 */
+		kpause("fanctrl", true, mstohz(sc->sc_pwm ? 1000 : 2000), NULL);
 	}
 	kthread_exit(0);
 }



CVS commit: src/sys/arch/macppc/dev

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:36:00 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c

Log Message:
adjust comments, break a long line
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrol.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/macppc/dev/fancontrol.c
diff -u src/sys/arch/macppc/dev/fancontrol.c:1.1 src/sys/arch/macppc/dev/fancontrol.c:1.2
--- src/sys/arch/macppc/dev/fancontrol.c:1.1	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fancontrol.c	Wed Jul 28 00:36:00 2021
@@ -1,7 +1,7 @@
-/* $NetBSD: fancontrol.c,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
 
 /*-
- * Copyright (c) 2018 Michael Lorenz
+ * Copyright (c) 2021 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.1 2021/07/27 23:38:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
 
 #include 
 #include 
@@ -66,11 +66,12 @@ fancontrol_adjust_zone(fancontrol_zone_t
 	if (diff < 0) diff = 0;
 	diff = (100 * diff) / (z->Tmax - z->Tmin);
 
-	/* now adjust each fan to the new duty cycle */
+	/* now adjust each fan to the new speed */
 	for (i = 0; i < z->nfans; i++) {
 		step = (z->fans[i].max_rpm - z->fans[i].min_rpm) / 100;
 		speed = z->fans[i].min_rpm + diff * step;
-		DPRINTF("diff %d base %d %d sp %d\n", diff, z->fans[i].min_rpm, z->fans[i].max_rpm, speed);
+		DPRINTF("diff %d base %d %d sp %d\n",
+		diff, z->fans[i].min_rpm, z->fans[i].max_rpm, speed);
 		z->set_rpm(z->cookie, z->fans[i].num, speed);
 	}
 	return 0;



CVS commit: src/sys/arch/macppc

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jul 27 23:38:42 UTC 2021

Modified Files:
src/sys/arch/macppc/conf: files.macppc
src/sys/arch/macppc/dev: fcu.c
Added Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h

Log Message:
first step towards abstracting thermal zone management out of the fcu driver
( and eventually, the smu driver )
todo:
- add sysctl()s to set zone parameters
- handle envsys
- adapt smu


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/fancontrol.c \
src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fcu.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/macppc/conf/files.macppc
diff -u src/sys/arch/macppc/conf/files.macppc:1.120 src/sys/arch/macppc/conf/files.macppc:1.121
--- src/sys/arch/macppc/conf/files.macppc:1.120	Tue Jul 27 20:23:41 2021
+++ src/sys/arch/macppc/conf/files.macppc	Tue Jul 27 23:38:42 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.120 2021/07/27 20:23:41 macallan Exp $
+#	$NetBSD: files.macppc,v 1.121 2021/07/27 23:38:42 macallan Exp $
 #
 # macppc-specific configuration info
 
@@ -176,7 +176,11 @@ device zstty: tty
 attach zstty at zsc
 file dev/ic/z8530tty.czstty needs-flag
 
-device smu { }
+define fancontrol
+file arch/macppc/dev/fancontrol.c		fancontrol
+defflag	opt_fancontrol.h	FANCONTROL_DEBUG
+
+device smu { } : fancontrol
 attach smu at mainbus
 file arch/macppc/dev/smu.c			smu needs-flag
 defflag	opt_smu.h	SMU_DEBUG
@@ -328,6 +332,6 @@ file	arch/macppc/dev/lmu.clmu
 defflag opt_lmu.h LMU_DEBUG
 
 # Apple Fan Control Unit found in some G5
-device	fcu: sysmon_envsys
+device	fcu: sysmon_envsys, fancontrol
 attach	fcu at iic
 file	arch/macppc/dev/fcu.cfcu	needs-flag

Index: src/sys/arch/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.1 src/sys/arch/macppc/dev/fcu.c:1.2
--- src/sys/arch/macppc/dev/fcu.c:1.1	Tue Jul 27 20:23:41 2021
+++ src/sys/arch/macppc/dev/fcu.c	Tue Jul 27 23:38:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.1 2021/07/27 20:23:41 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 2021/07/27 20:23:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $");
 
 #include 
 #include 
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 
 
 #include 
 
+#include 
+
 //#define FCU_DEBUG
 #ifdef FCU_DEBUG
 #define DPRINTF printf
@@ -58,14 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 
 #define FCU_PWM_ACTIVE	0x2d
 #define FCU_PWMREAD(x)	0x30 + (x)*2
 
-#define FCU_MAX_FANS 10
-
-typedef struct _fcu_zone {
-	bool (*filter)(const envsys_data_t *);
-	int nfans;
-	int fans[FCU_MAX_FANS];
-	int threshold;
-} fcu_zone_t; 
 
 typedef struct _fcu_fan {
 	int target;
@@ -86,15 +80,15 @@ struct fcu_softc {
 	i2c_addr_t	sc_addr;
 
 	struct sysmon_envsys *sc_sme;
-	envsys_data_t	sc_sensors[32];
-	int		sc_nsensors;
-	fcu_zone_t	sc_zones[FCU_ZONE_COUNT];
-	fcu_fan_t	sc_fans[FCU_MAX_FANS];
-	int		sc_nfans;
-	lwp_t		*sc_thread;
-	bool		sc_dying, sc_pwm;
-	uint8_t		sc_eeprom0[160];
-	uint8_t		sc_eeprom1[160];
+	envsys_data_t		sc_sensors[32];
+	int			sc_nsensors;
+	fancontrol_zone_t	sc_zones[FCU_ZONE_COUNT];
+	fcu_fan_t		sc_fans[FANCONTROL_MAX_FANS];
+	int			sc_nfans;
+	lwp_t			*sc_thread;
+	bool			sc_dying, sc_pwm;
+	uint8_t			sc_eeprom0[160];
+	uint8_t			sc_eeprom1[160];
 };
 
 static int	fcu_match(device_t, cfdata_t, void *);
@@ -106,8 +100,8 @@ static bool is_cpu(const envsys_data_t *
 static bool is_case(const envsys_data_t *);
 static bool is_drive(const envsys_data_t *);
 
-static void fcu_set_fan_rpm(struct fcu_softc *, fcu_fan_t *, int);
-static void fcu_adjust_zone(struct fcu_softc *, int);
+static int fcu_set_rpm(void *, int, int);
+static int fcu_get_rpm(void *, int);
 static void fcu_adjust(void *);
 
 CFATTACH_DECL_NEW(fcu, sizeof(struct fcu_softc),
@@ -160,14 +154,29 @@ fcu_attach(device_t parent, device_t sel
 		have_eeprom1 = 0;
 
 	/* init zones */
+	sc->sc_zones[FCU_ZONE_CPU].name = "CPUs";
 	sc->sc_zones[FCU_ZONE_CPU].filter = is_cpu;
-	sc->sc_zones[FCU_ZONE_CPU].threshold = 50;
+	sc->sc_zones[FCU_ZONE_CPU].cookie = sc;
+	sc->sc_zones[FCU_ZONE_CPU].get_rpm = fcu_get_rpm;
+	sc->sc_zones[FCU_ZONE_CPU].set_rpm = fcu_set_rpm;
+	sc->sc_zones[FCU_ZONE_CPU].Tmin = 50;
+	sc->sc_zones[FCU_ZONE_CPU].Tmax = 85;
 	sc->sc_zones[FCU_ZONE_CPU].nfans = 0;
+	sc->sc_zones[FCU_ZONE_CASE].name = "Slots";
 	sc->sc_zones[FCU_ZONE_CASE].filter = is_case;
-	sc->sc_zones[FCU_ZONE_CASE].threshold = 50;
+	sc->sc_zones[FCU_ZONE_CASE].Tmin = 50;
+	sc->sc_zones[FCU_ZONE_CASE].cookie = sc;
+	sc->sc_zones[FCU_ZONE_CASE].get_rpm = fcu_get_rpm;
+	

CVS commit: src/sys/arch/evbarm/ifpga

2021-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 27 21:13:41 UTC 2021

Modified Files:
src/sys/arch/evbarm/ifpga: plcom_ifpga.c plmmc_ifpga.c

Log Message:
KNF and remove #include 

Fixes the build - prompted by cjep.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/ifpga/plcom_ifpga.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/ifpga/plmmc_ifpga.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/evbarm/ifpga/plcom_ifpga.c
diff -u src/sys/arch/evbarm/ifpga/plcom_ifpga.c:1.17 src/sys/arch/evbarm/ifpga/plcom_ifpga.c:1.18
--- src/sys/arch/evbarm/ifpga/plcom_ifpga.c:1.17	Tue Oct 23 09:15:36 2018
+++ src/sys/arch/evbarm/ifpga/plcom_ifpga.c	Tue Jul 27 21:13:41 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: plcom_ifpga.c,v 1.17 2018/10/23 09:15:36 jmcneill Exp $ */
+/*  $NetBSD: plcom_ifpga.c,v 1.18 2021/07/27 21:13:41 skrll Exp $ */
 
 /*
  * Copyright (c) 2001 ARM Ltd
@@ -32,18 +32,17 @@
 /* Interface to plcom (PL010) serial driver. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom_ifpga.c,v 1.17 2018/10/23 09:15:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom_ifpga.c,v 1.18 2021/07/27 21:13:41 skrll Exp $");
 
+#include 
 #include 
+
+#include 
 #include 
 #include 
-#include 
-#include 
-
 #include 
 
 #include 
-#include 
 
 #include 
 #include 

Index: src/sys/arch/evbarm/ifpga/plmmc_ifpga.c
diff -u src/sys/arch/evbarm/ifpga/plmmc_ifpga.c:1.1 src/sys/arch/evbarm/ifpga/plmmc_ifpga.c:1.2
--- src/sys/arch/evbarm/ifpga/plmmc_ifpga.c:1.1	Tue Jan 27 16:34:34 2015
+++ src/sys/arch/evbarm/ifpga/plmmc_ifpga.c	Tue Jul 27 21:13:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: plmmc_ifpga.c,v 1.1 2015/01/27 16:34:34 jmcneill Exp $ */
+/* $NetBSD: plmmc_ifpga.c,v 1.2 2021/07/27 21:13:41 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,18 +27,17 @@
  */
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: plmmc_ifpga.c,v 1.1 2015/01/27 16:34:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plmmc_ifpga.c,v 1.2 2021/07/27 21:13:41 skrll Exp $");
 
+#include 
 #include 
+
+#include 
 #include 
 #include 
-#include 
-#include 
-
 #include 
 
 #include 
-#include 
 
 #include 
 #include 



CVS commit: src/sys/arch/sh3/sh3

2021-07-26 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Jul 26 21:43:11 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: exception_vector.S pmap.c

Log Message:
Revert rename back to OFSET, since the name follows historical PGOFSET 
definition. Noted by tsutsui.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/sh3/sh3/exception_vector.S
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sh3/sh3/pmap.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/sh3/sh3/exception_vector.S
diff -u src/sys/arch/sh3/sh3/exception_vector.S:1.52 src/sys/arch/sh3/sh3/exception_vector.S:1.53
--- src/sys/arch/sh3/sh3/exception_vector.S:1.52	Sat Jul 24 21:31:35 2021
+++ src/sys/arch/sh3/sh3/exception_vector.S	Mon Jul 26 21:43:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: exception_vector.S,v 1.52 2021/07/24 21:31:35 andvar Exp $	*/
+/*	$NetBSD: exception_vector.S,v 1.53 2021/07/26 21:43:11 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2019 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
 #define _ALIGN_TEXT	.align 5
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: exception_vector.S,v 1.52 2021/07/24 21:31:35 andvar Exp $")
+__KERNEL_RCSID(0, "$NetBSD: exception_vector.S,v 1.53 2021/07/26 21:43:11 andvar Exp $")
 
 
 /*
@@ -220,7 +220,7 @@ NENTRY(sh3_vector_tlbmiss)
 	bt/s	.L3_call_tlb_exception
 	 mov	#-(PGSHIFT - 2), r1
 
-	!! __PMAP_PTP_OFFSET(vpn) - except we pre-shift 2 bits left to
+	!! __PMAP_PTP_OFSET(vpn) - except we pre-shift 2 bits left to
 	!! get the array offset directly, as we know bits 10 and 11
 	!! are zero (we cleaned them in r5 to get 4K aligned VPN)
 	shld	r1, r2		! vpn >> (PGSHIFT - 2)

Index: src/sys/arch/sh3/sh3/pmap.c
diff -u src/sys/arch/sh3/sh3/pmap.c:1.84 src/sys/arch/sh3/sh3/pmap.c:1.85
--- src/sys/arch/sh3/sh3/pmap.c:1.84	Sat Jul 24 21:31:35 2021
+++ src/sys/arch/sh3/sh3/pmap.c	Mon Jul 26 21:43:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.84 2021/07/24 21:31:35 andvar Exp $	*/
+/*	$NetBSD: pmap.c,v 1.85 2021/07/26 21:43:11 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.84 2021/07/24 21:31:35 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.85 2021/07/26 21:43:11 andvar Exp $");
 
 #include 
 #include 
@@ -55,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.8
 	(((va) + (1 << __PMAP_PTP_SHIFT) - 1) & ~((1 << __PMAP_PTP_SHIFT) - 1))
 #define	__PMAP_PTP_PG_N		(PAGE_SIZE / sizeof(pt_entry_t))
 #define	__PMAP_PTP_INDEX(va)	(((va) >> __PMAP_PTP_SHIFT) & (__PMAP_PTP_N - 1))
-#define	__PMAP_PTP_OFFSET(va)	((va >> PGSHIFT) & (__PMAP_PTP_PG_N - 1))
+#define	__PMAP_PTP_OFSET(va)	((va >> PGSHIFT) & (__PMAP_PTP_PG_N - 1))
 
 struct pmap __pmap_kernel;
 struct pmap *const kernel_pmap_ptr = &__pmap_kernel;
@@ -966,7 +966,7 @@ __pmap_pte_alloc(pmap_t pmap, vaddr_t va
 	ptp = (pt_entry_t *)SH3_PHYS_TO_P1SEG(VM_PAGE_TO_PHYS(pg));
 	pmap->pm_ptp[__PMAP_PTP_INDEX(va)] = ptp;
 
-	return (ptp + __PMAP_PTP_OFFSET(va));
+	return (ptp + __PMAP_PTP_OFSET(va));
 }
 
 /*
@@ -986,7 +986,7 @@ __pmap_pte_lookup(pmap_t pmap, vaddr_t v
 	if (ptp == NULL)
 		return (NULL);
 
-	return (ptp + __PMAP_PTP_OFFSET(va));
+	return (ptp + __PMAP_PTP_OFSET(va));
 }
 
 /*
@@ -1002,7 +1002,7 @@ __pmap_kpte_lookup(vaddr_t va)
 	if (ptp == NULL)
 		return NULL;
 
-	return (ptp + __PMAP_PTP_OFFSET(va));
+	return (ptp + __PMAP_PTP_OFSET(va));
 }
 
 /*



CVS commit: src/sys/arch/arm/rockchip

2021-07-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jul 25 11:14:16 UTC 2021

Modified Files:
src/sys/arch/arm/rockchip: rk_anxdp.c

Log Message:
rockchip: edp: Force VOPB as CRTC for eDP.

Fixes display init on Pinebook Pro w/ U-Boot 2021.07.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/rockchip/rk_anxdp.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/arm/rockchip/rk_anxdp.c
diff -u src/sys/arch/arm/rockchip/rk_anxdp.c:1.3 src/sys/arch/arm/rockchip/rk_anxdp.c:1.4
--- src/sys/arch/arm/rockchip/rk_anxdp.c:1.3	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/rockchip/rk_anxdp.c	Sun Jul 25 11:14:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: rk_anxdp.c,v 1.3 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: rk_anxdp.c,v 1.4 2021/07/25 11:14:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jonathan A. Kollasch 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rk_anxdp.c,v 1.3 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk_anxdp.c,v 1.4 2021/07/25 11:14:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -172,7 +172,7 @@ rk_anxdp_ep_activate(device_t dev, struc
 		break;
 	}
 
-	sc->sc_encoder.possible_crtcs = 0x3; /* XXX */
+	sc->sc_encoder.possible_crtcs = 0x2; /* VOPB only */
 	drm_encoder_init(crtc->dev, >sc_encoder, _anxdp_encoder_funcs,
 	DRM_MODE_ENCODER_TMDS);
 	drm_encoder_helper_add(>sc_encoder, _anxdp_encoder_helper_funcs);



CVS commit: src/sys/arch/aarch64

2021-07-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul 24 23:38:41 UTC 2021

Modified Files:
src/sys/arch/aarch64/conf: files.aarch64
Removed Files:
src/sys/arch/aarch64/aarch64: cctr_machdep.c

Log Message:
aarch64: Remove empty source file and references to it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r0 src/sys/arch/aarch64/aarch64/cctr_machdep.c
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/aarch64/conf/files.aarch64

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/aarch64/conf/files.aarch64
diff -u src/sys/arch/aarch64/conf/files.aarch64:1.30 src/sys/arch/aarch64/conf/files.aarch64:1.31
--- src/sys/arch/aarch64/conf/files.aarch64:1.30	Wed Oct 21 13:31:50 2020
+++ src/sys/arch/aarch64/conf/files.aarch64	Sat Jul 24 23:38:41 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.aarch64,v 1.30 2020/10/21 13:31:50 christos Exp $
+#	$NetBSD: files.aarch64,v 1.31 2021/07/24 23:38:41 jmcneill Exp $
 
 defflag opt_cpuoptions.h	AARCH64_ALIGNMENT_CHECK
 defflag opt_cpuoptions.h	AARCH64_EL0_STACK_ALIGNMENT_CHECK
@@ -53,7 +53,6 @@ defflag opt_pmapboot.h		PMAPBOOT_DEBUG
 
 # MI support
 file	dev/cons.c
-#file	kern/kern_cctr.c
 
 # DDB
 file	arch/aarch64/aarch64/db_disasm.c		ddb
@@ -117,11 +116,6 @@ file	uvm/pmap/pmap_pvt.c
 # EFI runtime (machdep)
 file	arch/aarch64/aarch64/efi_machdep.c		efi_runtime
 
-# cyclecounter
-#file	arch/aarch64/aarch64/cctr_machdep.c
-#file	kern/kern_cctr.c
-
-
 # NetBSD 32-bit binary compatibility
 include "compat/netbsd32/files.netbsd32"
 file	arch/aarch64/aarch64/netbsd32_machdep.c		compat_netbsd32



CVS commit: src/sys/arch/x86/x86

2021-07-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul 24 20:45:45 UTC 2021

Modified Files:
src/sys/arch/x86/x86: bios32.c

Log Message:
Build fix: vtophys takes vaddr_t, not a ptr


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/x86/x86/bios32.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/x86/x86/bios32.c
diff -u src/sys/arch/x86/x86/bios32.c:1.6 src/sys/arch/x86/x86/bios32.c:1.7
--- src/sys/arch/x86/x86/bios32.c:1.6	Sat Jul 24 11:39:19 2021
+++ src/sys/arch/x86/x86/bios32.c	Sat Jul 24 20:45:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios32.c,v 1.6 2021/07/24 11:39:19 jmcneill Exp $	*/
+/*	$NetBSD: bios32.c,v 1.7 2021/07/24 20:45:45 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.6 2021/07/24 11:39:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.7 2021/07/24 20:45:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -252,7 +252,7 @@ smbios2_map_kva(const uint8_t *p)
 	if (eva == 0)
 		return;
 
-	smbios_entry.hdrphys = vtophys(p);
+	smbios_entry.hdrphys = vtophys((vaddr_t)p);
 	smbios_entry.tabphys = sh->addr;
 	smbios_entry.addr = (uint8_t *)(eva + (sh->addr & PGOFSET));
 	smbios_entry.len = sh->size;
@@ -287,7 +287,7 @@ smbios3_map_kva(const uint8_t *p)
 	if (eva == 0)
 		return;
 
-	smbios_entry.hdrphys = vtophys(p);
+	smbios_entry.hdrphys = vtophys((vaddr_t)p);
 	smbios_entry.tabphys = sh->addr;
 	smbios_entry.addr = (uint8_t *)(eva + ((vaddr_t)sh->addr & PGOFSET));
 	smbios_entry.len = sh->size;



CVS commit: src/sys/arch/epoc32/epoc32

2021-07-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul 24 07:59:10 UTC 2021

Modified Files:
src/sys/arch/epoc32/epoc32: intr.c

Log Message:
#include  for COHERENCY_UNIT


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/epoc32/epoc32/intr.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/epoc32/epoc32/intr.c
diff -u src/sys/arch/epoc32/epoc32/intr.c:1.2 src/sys/arch/epoc32/epoc32/intr.c:1.3
--- src/sys/arch/epoc32/epoc32/intr.c:1.2	Sun Aug 18 21:57:01 2013
+++ src/sys/arch/epoc32/epoc32/intr.c	Sat Jul 24 07:59:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.2 2013/08/18 21:57:01 matt Exp $	*/
+/*	$NetBSD: intr.c,v 1.3 2021/07/24 07:59:10 skrll Exp $	*/
 /*
  * Copyright (c) 2012 KIYOHARA Takashi
  * All rights reserved.
@@ -26,8 +26,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.2 2013/08/18 21:57:01 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.3 2021/07/24 07:59:10 skrll Exp $");
 
+#include 
 #include 
 #include 
 



CVS commit: src/sys/arch/arm/fdt

2021-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 23 21:33:35 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c

Log Message:
smbios: Support SMBIOS 2.x tables.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/fdt/acpi_fdt.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/arm/fdt/acpi_fdt.c
diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.20 src/sys/arch/arm/fdt/acpi_fdt.c:1.21
--- src/sys/arch/arm/fdt/acpi_fdt.c:1.20	Thu Jul 22 00:47:55 2021
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Fri Jul 23 21:33:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.21 2021/07/23 21:33:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_efi.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.21 2021/07/23 21:33:35 jmcneill Exp $");
 
 #include 
 #include 
@@ -140,11 +140,36 @@ acpi_fdt_poweroff(device_t dev)
 		psci_system_off();
 }
 
+static int
+acpi_fdt_smbios_version(void)
+{
+	uint8_t *hdr;
+	int smbver;
+
+	if (smbios_table == 0) {
+		return 0;
+	}
+
+	hdr = AcpiOsMapMemory(smbios_table, 24);
+	if (hdr == NULL) {
+		return 0;
+	}
+	if (smbios3_check_header(hdr)) {
+		smbver = 3;
+	} else if (smbios2_check_header(hdr)) {
+		smbver = 2;
+	} else {
+		smbver = 0;
+	}
+	AcpiOsUnmapMemory(hdr, 24);
+	return smbver;
+}
+
 static void
 acpi_fdt_smbios_init(device_t dev)
 {
-	struct smb3hdr *sh;
 	uint8_t *ptr;
+	int smbver;
 
 	const int chosen = OF_finddevice("/chosen");
 	if (chosen >= 0) {
@@ -154,29 +179,48 @@ acpi_fdt_smbios_init(device_t dev)
 		return;
 	}
 
-	sh = AcpiOsMapMemory(smbios_table, sizeof(*sh));
-	if (sh == NULL) {
-		return;
-	}
-	if (!smbios3_check_header((uint8_t *)sh)) {
-		AcpiOsUnmapMemory(sh, sizeof(*sh));
-		return;
-	}
+	smbver = acpi_fdt_smbios_version();
+	if (smbver == 3) {
+		struct smb3hdr *sh = AcpiOsMapMemory(smbios_table, sizeof(*sh));
+		if (sh == NULL) {
+			return;
+		}
+
+		ptr = AcpiOsMapMemory(sh->addr, sh->size);
+		if (ptr != NULL) {
+			smbios_entry.addr = ptr;
+			smbios_entry.len = sh->size;
+			smbios_entry.rev = sh->eprev;
+			smbios_entry.mjr = sh->majrev;
+			smbios_entry.min = sh->minrev;
+			smbios_entry.doc = sh->docrev;
+			smbios_entry.count = UINT16_MAX;
+		}
 
-	ptr = AcpiOsMapMemory(sh->addr, sh->size);
-	if (ptr != NULL) {
-		smbios_entry.addr = ptr;
-		smbios_entry.len = sh->size;
-		smbios_entry.rev = sh->eprev;
-		smbios_entry.mjr = sh->majrev;
-		smbios_entry.min = sh->minrev;
-		smbios_entry.doc = sh->docrev;
-		smbios_entry.count = UINT16_MAX;
-
-		device_printf(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n",
+		aprint_normal_dev(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n",
 		sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr);
+		AcpiOsUnmapMemory(sh, sizeof(*sh));
+	} else if (smbver == 2) {
+		struct smbhdr *sh = AcpiOsMapMemory(smbios_table, sizeof(*sh));
+		if (sh == NULL) {
+			return;
+		}
+
+		ptr = AcpiOsMapMemory(sh->addr, sh->size);
+		if (ptr != NULL) {
+			smbios_entry.addr = ptr;
+			smbios_entry.len = sh->size;
+			smbios_entry.rev = 0;
+			smbios_entry.mjr = sh->majrev;
+			smbios_entry.min = sh->minrev;
+			smbios_entry.doc = 0;
+			smbios_entry.count = sh->count;
+		}
+
+		aprint_normal_dev(dev, "SMBIOS rev. %d.%d @ 0x%lx (%d entries)\n",
+		sh->majrev, sh->minrev, (u_long)sh->addr, sh->count);
+		AcpiOsUnmapMemory(sh, sizeof(*sh));
 	}
-	AcpiOsUnmapMemory(sh, sizeof(*sh));
 }
 
 static void



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

2021-07-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 23 14:38:58 UTC 2021

Modified Files:
src/sys/arch/alpha/conf: GENERIC INSTALL

Log Message:
Use wildcard matches more consistently, and attach pci, eisa, isa, and
usb to their interface attributes, which makes for easier trimming-down
with "no" directives.


To generate a diff of this commit:
cvs rdiff -u -r1.412 -r1.413 src/sys/arch/alpha/conf/GENERIC
cvs rdiff -u -r1.117 -r1.118 src/sys/arch/alpha/conf/INSTALL

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/conf/GENERIC
diff -u src/sys/arch/alpha/conf/GENERIC:1.412 src/sys/arch/alpha/conf/GENERIC:1.413
--- src/sys/arch/alpha/conf/GENERIC:1.412	Tue Jun 29 10:22:34 2021
+++ src/sys/arch/alpha/conf/GENERIC	Fri Jul 23 14:38:58 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.412 2021/06/29 10:22:34 nia Exp $
+# $NetBSD: GENERIC,v 1.413 2021/07/23 14:38:58 thorpej Exp $
 #
 # This machine description file is used to generate the default NetBSD
 # kernel.
@@ -19,7 +19,7 @@ include 	"arch/alpha/conf/std.alpha"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-ident		"GENERIC-$Revision: 1.412 $"
+ident		"GENERIC-$Revision: 1.413 $"
 
 maxusers 32
 
@@ -184,11 +184,11 @@ config		netbsd	root on ? type ?
 #config		netbsd	root on ? type nfs
 
 mainbus0 at	root
-cpu*	at	mainbus0
-qemu*	at	mainbus0
+cpu*	at	mainbus?
+qemu*	at	mainbus?
 
 # TurboLaser bus support and devices
-tlsb*	at	mainbus0
+tlsb*	at	mainbus?
 gbus*	at	tlsb? node ? offset ?
 tlsbmem* at	tlsb? node ? offset ?
 kft*	at	tlsb? node ? offset ?
@@ -197,19 +197,19 @@ kft*	at	tlsb? node ? offset ?
 mcclock* at	gbus? offset ?
 
 # MCBUS bus support
-mcbus*	at	mainbus0
+mcbus*	at	mainbus?
 mcmem*	at	mcbus? mid ?
 
 #i2c	at	mcbus?
 
 #EV6 Tsunami Core Logic
 
-tsc*	at	mainbus0
+tsc*	at	mainbus?
 tsciic* 	at	tsc?
 iic* 	at	tsciic?
 
 # DECpc AXP150 (Jensen) internal bus support
-jensenio* at	mainbus0
+jensenio* at	mainbus?
 
 com*	at	jensenio? port ?
 lpt*	at	jensenio? port ?
@@ -217,7 +217,7 @@ mcclock* at	jensenio? port ?
 pckbc*	at	jensenio? port ?
 
 # TURBOchannel host bus adapter support
-tcasic*	at	mainbus0
+tcasic*	at	mainbus?
 
 # TURBOchannel bus support
 tc*	at	tcasic?
@@ -269,18 +269,10 @@ pckbc*	at	sableio? port ?
 fdc*	at	sableio? port ?
 
 # PCI bus support
-pci*	at	apecs?
-pci*	at	cia?
-pci*	at	irongate?
-pci*	at	lca?
-pci*	at	ppb?
-pci*	at	dwlpx?
-pci*	at	mcpcia?
-pci*	at	tsp?
-pci*	at	ttwopci?
+pci*	at	pcibus?			# "pcibus" interface attribute
 
 # AGP support
-agp*	at	irongate?
+agp*	at	agpbus?			# "agpbus" interface attribute
 
 # PCI devices
 
@@ -404,11 +396,8 @@ tqphy*	at mii? phy ?			# TDK Semiconduct
 ukphy*	at mii? phy ?			# generic unknown PHYs
 
 # ISA/EISA bus support
-isa*	at	jensenio?
-eisa*	at	jensenio?
-isa*	at	pceb?
-eisa*	at	pceb?
-isa*	at	sio?
+isa*	at	isabus?			# "isabus" interface attribute
+eisa*	at	eisabus?		# "eisabus" interface attribute
 #isapnp*	at	isa?
 
 # ISA devices
@@ -550,11 +539,7 @@ iic* 	at alipm?
 slhci*	at pcmcia? function ?			# ScanLogic SL811HS
 
 # USB bus support
-usb*	at xhci?
-usb*	at ehci?
-usb*	at ohci?
-usb*	at slhci?
-usb*	at uhci?
+usb*	at usbus?			# "usbus" interface attribute
 
 # USB Hubs
 uhub*	at usb?

Index: src/sys/arch/alpha/conf/INSTALL
diff -u src/sys/arch/alpha/conf/INSTALL:1.117 src/sys/arch/alpha/conf/INSTALL:1.118
--- src/sys/arch/alpha/conf/INSTALL:1.117	Mon Sep 28 03:48:12 2020
+++ src/sys/arch/alpha/conf/INSTALL	Fri Jul 23 14:38:58 2021
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.117 2020/09/28 03:48:12 thorpej Exp $
+# $NetBSD: INSTALL,v 1.118 2021/07/23 14:38:58 thorpej Exp $
 #
 # Alpha INSTALL kernel.
 
@@ -86,11 +86,11 @@ options 	WSEMUL_VT100
 config		netbsd	root on ? type ?
 
 mainbus0 at	root
-cpu*	at	mainbus0
-qemu*	at	mainbus0
+cpu*	at	mainbus?
+qemu*	at	mainbus?
 
 # TurboLaser bus support and devices
-tlsb*	at	mainbus0
+tlsb*	at	mainbus?
 gbus*	at	tlsb? node ? offset ?
 tlsbmem* at	tlsb? node ? offset ?
 kft*	at	tlsb? node ? offset ?
@@ -99,15 +99,15 @@ kft*	at	tlsb? node ? offset ?
 mcclock* at	gbus? offset ?
 
 # MCBUS bus support
-mcbus*	at	mainbus0
+mcbus*	at	mainbus?
 mcmem*	at	mcbus? mid ?
 
 #EV6 Tsunami Core Logic
 
-tsc*	at	mainbus0
+tsc*	at	mainbus?
 
 # DECpc AXP150 (Jensen) internal bus support
-jensenio* at	mainbus0
+jensenio* at	mainbus?
 
 com*	at	jensenio? port ?
 lpt*	at	jensenio? port ?
@@ -115,7 +115,7 @@ mcclock* at	jensenio? port ?
 pckbc*	at	jensenio? port ?
 
 # TURBOchannel host bus adapter support
-tcasic*	at	mainbus0
+tcasic*	at	mainbus?
 
 # TURBOchannel bus support
 tc*	at	tcasic?
@@ -164,18 +164,10 @@ pckbc*	at	sableio? port ?
 fdc*	at	sableio? port ?
 
 # PCI bus support
-pci*	at	apecs?
-pci*	at	cia?
-pci*	at	irongate?
-pci*	at	lca?
-pci*	at	ppb?
-pci*	at	dwlpx?
-pci*	at	mcpcia?
-pci*	at	tsp?
-pci*	at	ttwopci?
+pci*	at	pcibus?			# "pcibus" interface attribute
 
 # AGP support
-agp*	at	

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

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

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

Log Message:
Emulate the IEEE flavors of the FIX extension instructions:
- FTOIS, FTOIT
- ITOFS, ITOFT
- SRQTS, SQRTT

Left out for now are the VAX FP flavors:
- ITOFF
- SQRTF, SQRTG


To generate a diff of this commit:
cvs rdiff -u -r1.137 -r1.138 src/sys/arch/alpha/alpha/trap.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/trap.c
diff -u src/sys/arch/alpha/alpha/trap.c:1.137 src/sys/arch/alpha/alpha/trap.c:1.138
--- src/sys/arch/alpha/alpha/trap.c:1.137	Tue Jul 20 01:56:06 2021
+++ src/sys/arch/alpha/alpha/trap.c	Fri Jul 23 04:19:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.137 2021/07/20 01:56:06 thorpej Exp $ */
+/* $NetBSD: trap.c,v 1.138 2021/07/23 04:19:50 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001, 2021 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.137 2021/07/20 01:56:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.138 2021/07/23 04:19:50 thorpej Exp $");
 
 #include 
 #include 
@@ -383,6 +383,8 @@ trap(const u_long a0, const u_long a1, c
 ksi.ksi_code = SEGV_MAPERR;
 			else if (i == SIGILL)
 ksi.ksi_code = ILL_ILLOPC;
+			else if (i == SIGFPE)
+ksi.ksi_code = alpha_ucode_to_ksiginfo(ucode);
 			ksi.ksi_signo = i;
 			ksi.ksi_addr =
 (void *)l->l_md.md_tf->tf_regs[FRAME_PC];
@@ -961,6 +963,128 @@ unaligned_fixup(u_long va, u_long opcode
 	return (signo);
 }
 
+#define	EMUL_COUNT(ev)	atomic_inc_64(&(ev).ev_count)
+
+static struct evcnt emul_fix_ftoit =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "ftoit");
+static struct evcnt emul_fix_ftois =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "ftois");
+static struct evcnt emul_fix_itofs =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "itofs");
+#if 0
+static struct evcnt emul_fix_itoff =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "itoff");
+#endif
+static struct evcnt emul_fix_itoft =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "itoft");
+static struct evcnt emul_fix_sqrtt =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "sqrtt");
+static struct evcnt emul_fix_sqrts =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul fix", "sqrts");
+
+EVCNT_ATTACH_STATIC(emul_fix_ftoit);
+EVCNT_ATTACH_STATIC(emul_fix_ftois);
+EVCNT_ATTACH_STATIC(emul_fix_itofs);
+#if 0
+EVCNT_ATTACH_STATIC(emul_fix_itoff);
+#endif
+EVCNT_ATTACH_STATIC(emul_fix_itoft);
+EVCNT_ATTACH_STATIC(emul_fix_sqrtt);
+EVCNT_ATTACH_STATIC(emul_fix_sqrts);
+
+static void
+emul_fix(struct lwp *l, const alpha_instruction *inst)
+{
+	union {
+		f_float f;
+		s_float s;
+		t_float t;
+	} fmem;
+	register_t *regptr;
+
+	KASSERT(l == curlwp);
+
+	/*
+	 * FIX instructions don't cause any exceptions, including
+	 * MM exceptions.  However, they are equivalent in result
+	 * to e.g. STL,LDF.  We will just assume that we can access
+	 * our kernel stack, and thus no exception checks are
+	 * required.
+	 */
+
+	kpreempt_disable();
+	if ((l->l_md.md_flags & MDLWP_FPACTIVE) == 0) {
+		fpu_load();
+	}
+	alpha_pal_wrfen(1);
+
+	if (inst->float_format.opcode == op_intmisc) {
+		regptr = irp(l, inst->float_format.fc);
+		switch (inst->float_format.function) {
+		case op_ftoit:
+			EMUL_COUNT(emul_fix_ftoit);
+			alpha_stt(inst->float_format.fa, );
+			if (regptr != NULL) {
+*regptr = fmem.t.i;
+			}
+			break;
+
+		case op_ftois:
+			EMUL_COUNT(emul_fix_ftois);
+			alpha_sts(inst->float_format.fa, );
+			if (regptr != NULL) {
+*regptr = (int32_t)fmem.s.i;
+			}
+			break;
+
+		default:
+			panic("%s: bad intmisc function=0x%x\n", __func__,
+			inst->float_format.function);
+		}
+	} else if (inst->float_format.opcode == op_fix_float) {
+		regptr = irp(l, inst->float_format.fa);
+		register_t regval = (regptr != NULL) ? *regptr : 0;
+
+		switch (inst->float_format.function) {
+		case op_itofs:
+			EMUL_COUNT(emul_fix_itofs);
+			fmem.s.i = (uint32_t)regval;
+			alpha_lds(inst->float_format.fc, );
+			break;
+
+		/*
+		 * The Book says about ITOFF:
+		 *
+		 *	ITOFF is equivalent to the following sequence,
+		 *	except that the word swapping that LDF normally
+		 *	performs is not performed by ITOFF.
+		 *
+		 *		STL
+		 *		LDF
+		 *
+		 * ...implying that we can't actually use LDF here ??? So
+		 * we'll skip it for now.
+		 */
+
+		case op_itoft:
+			EMUL_COUNT(emul_fix_itoft);
+			fmem.t.i = regval;
+			alpha_ldt(inst->float_format.fc, );
+			break;
+
+		default:
+			panic("%s: bad fix_float function=0x%x\n", __func__,
+			inst->float_format.function);
+		}
+	} else {
+		panic("%s: bad opcode=0x%02x", __func__,
+		inst->float_format.opcode);
+	}
+
+	alpha_pal_wrfen(0);
+	kpreempt_enable();
+}
+
 static struct evcnt 

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

2021-07-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 23 03:57:06 UTC 2021

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

Log Message:
IEEE SQRTS / SQRTT is fix_float opclass 11, not fix_float opclass 10
(which is VAX SQRTF / SQRTG).


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/alpha/alpha/fp_complete.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/fp_complete.c
diff -u src/sys/arch/alpha/alpha/fp_complete.c:1.26 src/sys/arch/alpha/alpha/fp_complete.c:1.27
--- src/sys/arch/alpha/alpha/fp_complete.c:1.26	Fri Jul 23 03:50:32 2021
+++ src/sys/arch/alpha/alpha/fp_complete.c	Fri Jul 23 03:57:06 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fp_complete.c,v 1.26 2021/07/23 03:50:32 thorpej Exp $ */
+/* $NetBSD: fp_complete.c,v 1.27 2021/07/23 03:57:06 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2001 Ross Harvey
@@ -37,7 +37,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.26 2021/07/23 03:50:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.27 2021/07/23 03:57:06 thorpej Exp $");
 
 #include 
 #include 
@@ -588,7 +588,7 @@ alpha_fp_interpret(unsigned long pc, str
 		switch(inst.float_detail.src) {
 		case op_src_sf:
 			sts(inst.float_detail.fb, , l);
-			if (inst.float_detail.opclass == 10)
+			if (inst.float_detail.opclass == 11)
 sfc.i = float32_sqrt(sfb.i);
 			else if (inst.float_detail.opclass & ~3) {
 this_cannot_happen(1, inst.bits);
@@ -607,7 +607,7 @@ alpha_fp_interpret(unsigned long pc, str
 inst.bits, l);
 			else {
 stt(inst.float_detail.fb, , l);
-if (inst.float_detail.opclass == 10)
+if (inst.float_detail.opclass == 11)
 	tfc.i = float64_sqrt(tfb.i);
 else {
 	stt(inst.float_detail.fa, , l);



CVS commit: src/sys/arch/alpha

2021-07-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jul 23 03:50:32 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: fp_complete.c
src/sys/arch/alpha/include: alpha.h

Log Message:
- Expose alpha_fp_complete_at() to callers outside fp_complete.c.
- Use ufetch_32() instead of copyin() to fetch the instruction.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/alpha/alpha/fp_complete.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/alpha/include/alpha.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/fp_complete.c
diff -u src/sys/arch/alpha/alpha/fp_complete.c:1.25 src/sys/arch/alpha/alpha/fp_complete.c:1.26
--- src/sys/arch/alpha/alpha/fp_complete.c:1.25	Thu Jul 22 01:39:18 2021
+++ src/sys/arch/alpha/alpha/fp_complete.c	Fri Jul 23 03:50:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fp_complete.c,v 1.25 2021/07/22 01:39:18 thorpej Exp $ */
+/* $NetBSD: fp_complete.c,v 1.26 2021/07/23 03:50:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2001 Ross Harvey
@@ -37,7 +37,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.25 2021/07/22 01:39:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.26 2021/07/23 03:50:32 thorpej Exp $");
 
 #include 
 #include 
@@ -522,13 +522,13 @@ float64_unk(float64 a, float64 b)
  */
 
 static void
-print_fp_instruction(alpha_instruction *pc, struct lwp *l, uint32_t bits)
+print_fp_instruction(unsigned long pc, struct lwp *l, uint32_t bits)
 {
 #if defined(DDB)
 	char buf[32];
 	struct alpha_print_instruction_context ctx = {
 		.insn.bits = bits,
-		.pc = (unsigned long)pc,
+		.pc = pc,
 		.buf = buf,
 		.bufsize = sizeof(buf),
 	};
@@ -553,7 +553,7 @@ print_fp_instruction(alpha_instruction *
 }
 
 static void
-alpha_fp_interpret(alpha_instruction *pc, struct lwp *l, uint32_t bits)
+alpha_fp_interpret(unsigned long pc, struct lwp *l, uint32_t bits)
 {
 	s_float sfa, sfb, sfc;
 	t_float tfa, tfb, tfc;
@@ -624,16 +624,15 @@ alpha_fp_interpret(alpha_instruction *pc
 	}
 }
 
-static int
-alpha_fp_complete_at(alpha_instruction *trigger_pc, struct lwp *l,
-uint64_t *ucode)
+int
+alpha_fp_complete_at(unsigned long trigger_pc, struct lwp *l, uint64_t *ucode)
 {
 	int needsig;
 	alpha_instruction inst;
 	uint64_t rm, fpcr, orig_fpcr;
 	uint64_t orig_flags, new_flags, changed_flags, md_flags;
 
-	if (__predict_false(copyin(trigger_pc, , sizeof inst))) {
+	if (__predict_false(ufetch_32((void *)trigger_pc, ))) {
 		this_cannot_happen(6, -1);
 		return SIGSEGV;
 	}
@@ -712,7 +711,8 @@ alpha_fp_complete(u_long a0, u_long a1, 
 	if (cpu_amask & ALPHA_AMASK_PAT) {
 		if ((a0 & (ALPHA_AESR_SWC | ALPHA_AESR_INV)) != 0 ||
 		alpha_fp_sync_complete) {
-			sig = alpha_fp_complete_at(trigger_pc, l, ucode);
+			sig = alpha_fp_complete_at((u_long)trigger_pc, l,
+			ucode);
 			goto resolved;
 		}
 	}
@@ -773,7 +773,7 @@ alpha_fp_complete(u_long a0, u_long a1, 
 		alpha_shadow.max = t;
 	if (__predict_true(trigger_pc != 0 && a1 == 0)) {
 		++alpha_shadow.resolved;
-		sig = alpha_fp_complete_at(trigger_pc, l, ucode);
+		sig = alpha_fp_complete_at((u_long)trigger_pc, l, ucode);
 		goto resolved;
 	} else {
 		++alpha_shadow.unresolved;

Index: src/sys/arch/alpha/include/alpha.h
diff -u src/sys/arch/alpha/include/alpha.h:1.46 src/sys/arch/alpha/include/alpha.h:1.47
--- src/sys/arch/alpha/include/alpha.h:1.46	Tue Jul 20 05:43:10 2021
+++ src/sys/arch/alpha/include/alpha.h	Fri Jul 23 03:50:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: alpha.h,v 1.46 2021/07/20 05:43:10 thorpej Exp $ */
+/* $NetBSD: alpha.h,v 1.47 2021/07/23 03:50:32 thorpej Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -178,6 +178,7 @@ uint64_t alpha_read_fp_c(struct lwp *);
 void alpha_write_fp_c(struct lwp *, uint64_t);
 
 int alpha_fp_complete(u_long, u_long, struct lwp *, uint64_t *);
+int alpha_fp_complete_at(u_long, struct lwp *, uint64_t *);
 
 /* Security sensitive rate limiting printf */
 



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

2021-07-22 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 15:48:40 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: locore.s

Log Message:
It's unlikely that a process will be using restartable atomic sequences
on Alpha, and furthermore it's unlikely that any given context switch
will be returning to one even if the process has them.  So, re-arrange
the RAS processing in cpu_switchto() so that the most likely code paths
are predicted by the branch predictor.  On an EV4-class processor, this
will save ~4-6 cycles on just about every context switch.


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/sys/arch/alpha/alpha/locore.s

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/locore.s
diff -u src/sys/arch/alpha/alpha/locore.s:1.140 src/sys/arch/alpha/alpha/locore.s:1.141
--- src/sys/arch/alpha/alpha/locore.s:1.140	Sun Jul 11 01:55:51 2021
+++ src/sys/arch/alpha/alpha/locore.s	Thu Jul 22 15:48:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.140 2021/07/11 01:55:51 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.141 2021/07/22 15:48:40 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.140 2021/07/11 01:55:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.141 2021/07/22 15:48:40 thorpej Exp $");
 
 #include "assym.h"
 
@@ -844,14 +844,7 @@ LEAF(cpu_switchto, 0)
 	 */
 	ldq	a0, L_PROC(s2)			/* first ras_lookup() arg */
 	ldq	t0, P_RASLIST(a0)		/* any RAS entries? */
-	beq	t0, 2f/* no, skip */
-	ldq	s1, L_MD_TF(s2)			/* s1 = l->l_md.md_tf */
-	ldq	a1, (FRAME_PC*8)(s1)		/* second ras_lookup() arg */
-	CALL(ras_lookup)			/* ras_lookup(p, PC) */
-	addq	v0, 1, t0			/* -1 means "not in ras" */
-	beq	t0, 2f
-	stq	v0, (FRAME_PC*8)(s1)
-
+	bne	t0, 4f/* yes, go deal with it */
 2:
 	mov	s4, v0/* return the old lwp */
 	/*
@@ -883,6 +876,16 @@ LEAF(cpu_switchto, 0)
 	stq	sp, PCB_HWPCB_KSP(a3)		/* save old SP */
 	ldq	sp, PCB_HWPCB_KSP(a2)		/* restore new SP */
 	br	1b/* finish up */
+
+4:
+	ldq	s1, L_MD_TF(s2)			/* s1 = l->l_md.md_tf */
+	ldq	a1, (FRAME_PC*8)(s1)		/* second ras_lookup() arg */
+	CALL(ras_lookup)			/* ras_lookup(p, PC) */
+	addq	v0, 1, t0			/* -1 means "not in ras" */
+	beq	t0, 2b/* not in ras? return */
+	stq	v0, (FRAME_PC*8)(s1)		/* in ras? fix up PC */
+	br	2b/* finish up */
+
 	END(cpu_switchto)
 
 /*



CVS commit: src/sys/arch/alpha

2021-07-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 01:39:18 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: fp_complete.c machdep.c
src/sys/arch/alpha/include: cpu.h fpu.h

Log Message:
Various minor cleanups and bug fixes to the FP software completion code:
- Use __CTASSERT() instead of rolling our own compile-time assertion
  using cpp.
- Use __BIT()  instead of rolling our own.
- Improve some comments.
- Define a default FP_C and FPCR value that is self-consistent, and
  initialize it properly at process creation time.
- Fix signal information when the trap shadow cannot be resolved.
- Use defined constants rather than magic numbers for the exception
  summary bits.
- Add a machdep sysctl to enable FP software-completion debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/alpha/alpha/fp_complete.c
cvs rdiff -u -r1.374 -r1.375 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/alpha/include/cpu.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/include/fpu.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/fp_complete.c
diff -u src/sys/arch/alpha/alpha/fp_complete.c:1.24 src/sys/arch/alpha/alpha/fp_complete.c:1.25
--- src/sys/arch/alpha/alpha/fp_complete.c:1.24	Tue Sep  1 08:22:36 2020
+++ src/sys/arch/alpha/alpha/fp_complete.c	Thu Jul 22 01:39:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fp_complete.c,v 1.24 2020/09/01 08:22:36 thorpej Exp $ */
+/* $NetBSD: fp_complete.c,v 1.25 2021/07/22 01:39:18 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2001 Ross Harvey
@@ -33,9 +33,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_ddb.h"
+
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.24 2020/09/01 08:22:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.25 2021/07/22 01:39:18 thorpej Exp $");
 
 #include 
 #include 
@@ -51,6 +53,30 @@ __KERNEL_RCSID(0, "$NetBSD: fp_complete.
 
 #include 
 
+/*
+ * Validate our assumptions about bit positions.
+ */
+__CTASSERT(ALPHA_AESR_INV == (FP_X_INV << 1));
+__CTASSERT(ALPHA_AESR_DZE == (FP_X_DZ  << 1));
+__CTASSERT(ALPHA_AESR_OVF == (FP_X_OFL << 1));
+__CTASSERT(ALPHA_AESR_UNF == (FP_X_UFL << 1));
+__CTASSERT(ALPHA_AESR_INE == (FP_X_IMP << 1));
+__CTASSERT(ALPHA_AESR_IOV == (FP_X_IOV << 1));
+
+__CTASSERT(IEEE_TRAP_ENABLE_INV == (FP_X_INV << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_DZE == (FP_X_DZ  << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_OVF == (FP_X_OFL << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_UNF == (FP_X_UFL << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_INE == (FP_X_IMP << 1));
+
+__CTASSERT((uint64_t)FP_X_IMP << (61 - 3) == FPCR_INED);
+__CTASSERT((uint64_t)FP_X_UFL << (61 - 3) == FPCR_UNFD);
+__CTASSERT((uint64_t)FP_X_OFL << (49 - 0) == FPCR_OVFD);
+__CTASSERT((uint64_t)FP_X_DZ  << (49 - 0) == FPCR_DZED);
+__CTASSERT((uint64_t)FP_X_INV << (49 - 0) == FPCR_INVD);
+
+__CTASSERT(FP_C_ALLBITS == MDLWP_FP_C);
+
 #define	TSWINSIZE 4	/* size of trap shadow window in uint32_t units */
 
 /*	Set Name		Opcodes			AARM C.* Symbols  */
@@ -351,11 +377,12 @@ fp_c_to_fpcr_1(uint64_t fpcr, uint64_t f
 	 * it is necessary to initially set a sticky bit.
 	 */
 
-	fpcr &= FPCR_DYN(3);
+	fpcr &= FPCR_DYN_RM;
 
 	/*
-	 * enable traps = case where flag bit is clear OR program wants a trap
-	 * enables = ~flags | mask
+	 * enable traps = case where flag bit is clear AND program wants a trap
+	 *
+	 * enables = ~flags & mask
 	 * disables = ~(~flags | mask)
 	 * disables = flags & ~mask. Thank you, Augustus De Morgan (1806-1871)
 	 */
@@ -364,18 +391,6 @@ fp_c_to_fpcr_1(uint64_t fpcr, uint64_t f
 	fpcr |= (disables & (FP_X_IMP | FP_X_UFL)) << (61 - 3);
 	fpcr |= (disables & (FP_X_OFL | FP_X_DZ | FP_X_INV)) << (49 - 0);
 
-#	if !(FP_X_INV == 1 && FP_X_DZ == 2 && FP_X_OFL == 4 &&		\
-	FP_X_UFL == 8 && FP_X_IMP == 16 && FP_X_IOV == 32 &&	\
-	FP_X_UFL << (61 - 3) == FPCR_UNFD &&			\
-	FP_X_IMP << (61 - 3) == FPCR_INED &&			\
-	FP_X_OFL << (49 - 0) == FPCR_OVFD)
-#		error "Assertion failed"
-	/*
-	 * We don't care about the other built-in bit numbers because they
-	 * have been architecturally specified.
-	 */
-#	endif
-
 	fpcr |= fp_c & FP_C_MIRRORED << (FPCR_MIR_START - FP_C_MIR_START);
 	fpcr |= (fp_c & IEEE_MAP_DMZ) << 36;
 	if (fp_c & FP_C_MIRRORED)
@@ -407,6 +422,11 @@ alpha_write_fp_c(struct lwp *l, uint64_t
 		alpha_pal_wrfen(1);
 		fp_c_to_fpcr(l);
 		alpha_pal_wrfen(0);
+	} else {
+		struct pcb *pcb = l->l_addr;
+
+		pcb->pcb_fp.fpr_cr =
+		fp_c_to_fpcr_1(pcb->pcb_fp.fpr_cr, l->l_md.md_flags);
 	}
 	kpreempt_enable();
 }
@@ -502,12 +522,47 @@ float64_unk(float64 a, float64 b)
  */
 
 static void
+print_fp_instruction(alpha_instruction *pc, struct lwp *l, uint32_t bits)
+{
+#if defined(DDB)
+	char buf[32];
+	struct alpha_print_instruction_context ctx = {
+		.insn.bits = bits,
+		.pc = (unsigned long)pc,
+		.buf = buf,

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

2021-07-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 01:31:55 UTC 2021

Modified Files:
src/sys/arch/alpha/include: proc.h

Log Message:
Use __BITS() to define MDLWP_FP_C.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/include/proc.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/include/proc.h
diff -u src/sys/arch/alpha/include/proc.h:1.22 src/sys/arch/alpha/include/proc.h:1.23
--- src/sys/arch/alpha/include/proc.h:1.22	Fri May 16 19:18:21 2014
+++ src/sys/arch/alpha/include/proc.h	Thu Jul 22 01:31:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.22 2014/05/16 19:18:21 matt Exp $ */
+/* $NetBSD: proc.h,v 1.23 2021/07/22 01:31:55 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -61,7 +61,7 @@ struct mdlwp {
  * 	C99 API's, the use of the MDLWP_FP_C bits is defined variously in
  * 	ieeefp.h and fpu.h.
  */
-#define	MDLWP_FP_C	0x007e	/* Extended FP_C Quadword bits */
+#define	MDLWP_FP_C	__BITS(1,22)	/* Extended FP_C Quadword bits */
 #define	MDLWP_FPACTIVE	__BIT(63)	/* FPU is active on LWP's PCU CPU */
 
 /*



CVS commit: src/sys/arch/arm/fdt

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 22 00:47:56 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c files.fdt

Log Message:
Expose SMBIOS tables using sysctl machdep.dmi.*, same as x86.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/acpi_fdt.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/fdt/files.fdt

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/arm/fdt/acpi_fdt.c
diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.19 src/sys/arch/arm/fdt/acpi_fdt.c:1.20
--- src/sys/arch/arm/fdt/acpi_fdt.c:1.19	Sat Apr 24 23:36:26 2021
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Thu Jul 22 00:47:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_efi.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $");
 
 #include 
 #include 
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -61,6 +62,7 @@ static void	acpi_fdt_attach(device_t, de
 
 static void	acpi_fdt_poweroff(device_t);
 
+static void	acpi_fdt_smbios_init(device_t);
 static void	acpi_fdt_sysctl_init(void);
 
 extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
@@ -89,18 +91,24 @@ acpi_fdt_match(device_t parent, cfdata_t
 static void
 acpi_fdt_attach(device_t parent, device_t self, void *aux)
 {
+	extern void platform_init(void); /* XXX */
 	struct fdt_attach_args * const faa = aux;
 	struct acpibus_attach_args aa;
 
 	aprint_naive("\n");
 	aprint_normal("\n");
 
+	acpi_fdt_smbios_init(self);
+	platform_init();
+
 	fdtbus_register_power_controller(self, faa->faa_phandle,
 	_fdt_power_funcs);
 
 	if (!acpi_probe())
 		panic("ACPI subsystem failed to initialize");
 
+	platform_init();
+
 	memset(, 0, sizeof(aa));
 #if NPCI > 0
 	aa.aa_pciflags =
@@ -133,26 +141,64 @@ acpi_fdt_poweroff(device_t dev)
 }
 
 static void
+acpi_fdt_smbios_init(device_t dev)
+{
+	struct smb3hdr *sh;
+	uint8_t *ptr;
+
+	const int chosen = OF_finddevice("/chosen");
+	if (chosen >= 0) {
+		of_getprop_uint64(chosen, "netbsd,smbios-table", _table);
+	}
+	if (smbios_table == 0) {
+		return;
+	}
+
+	sh = AcpiOsMapMemory(smbios_table, sizeof(*sh));
+	if (sh == NULL) {
+		return;
+	}
+	if (!smbios3_check_header((uint8_t *)sh)) {
+		AcpiOsUnmapMemory(sh, sizeof(*sh));
+		return;
+	}
+
+	ptr = AcpiOsMapMemory(sh->addr, sh->size);
+	if (ptr != NULL) {
+		smbios_entry.addr = ptr;
+		smbios_entry.len = sh->size;
+		smbios_entry.rev = sh->eprev;
+		smbios_entry.mjr = sh->majrev;
+		smbios_entry.min = sh->minrev;
+		smbios_entry.doc = sh->docrev;
+		smbios_entry.count = UINT16_MAX;
+
+		device_printf(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n",
+		sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr);
+	}
+	AcpiOsUnmapMemory(sh, sizeof(*sh));
+}
+
+static void
 acpi_fdt_sysctl_init(void)
 {
 	const struct sysctlnode *rnode;
 	int error;
 
-	const int chosen = OF_finddevice("/chosen");
-	if (chosen >= 0)
-		of_getprop_uint64(chosen, "netbsd,smbios-table", _table);
+	if (smbios_table == 0) {
+		return;
+	}
 
 	error = sysctl_createv(NULL, 0, NULL, ,
 	CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
 	NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
-	if (error)
+	if (error) {
 		return;
-
-	if (smbios_table != 0) {
-		(void)sysctl_createv(NULL, 0, , NULL,
-		CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD,
-		"smbios", SYSCTL_DESCR("SMBIOS table pointer"),
-		NULL, 0, _table, sizeof(smbios_table),
-		CTL_CREATE, CTL_EOL);
 	}
+
+	(void)sysctl_createv(NULL, 0, , NULL,
+	CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD,
+	"smbios", SYSCTL_DESCR("SMBIOS table pointer"),
+	NULL, 0, _table, sizeof(smbios_table),
+	CTL_CREATE, CTL_EOL);
 }

Index: src/sys/arch/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.33 src/sys/arch/arm/fdt/files.fdt:1.34
--- src/sys/arch/arm/fdt/files.fdt:1.33	Mon Apr 26 14:44:16 2021
+++ src/sys/arch/arm/fdt/files.fdt	Thu Jul 22 00:47:55 2021
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.33 2021/04/26 14:44:16 thorpej Exp $
+# $NetBSD: files.fdt,v 1.34 2021/07/22 00:47:55 jmcneill Exp $
 
 include	"dev/pckbport/files.pckbport"
 
@@ -75,6 +75,7 @@ file	arch/arm/fdt/pmu_fdt.c			pmu_fdt
 attach	genfb at fdt with plfb_fdt: fdt_display_timing
 file	arch/arm/fdt/plfb_fdt.c			plfb_fdt
 
-device	acpifdt: acpibus
+device	acpifdt: acpibus, smbios
 attach	acpifdt at fdt with acpi_fdt
 file	arch/arm/fdt/acpi_fdt.c			acpi_fdt
+file	dev/smbios_platform.c			acpi_fdt



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

2021-07-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jul 20 05:43:10 UTC 2021

Modified Files:
src/sys/arch/alpha/include: alpha.h

Log Message:
Define the f_float in-memory format.  Line of the fields in s_float and
t_float.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/alpha/include/alpha.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/include/alpha.h
diff -u src/sys/arch/alpha/include/alpha.h:1.45 src/sys/arch/alpha/include/alpha.h:1.46
--- src/sys/arch/alpha/include/alpha.h:1.45	Wed May  5 15:36:17 2021
+++ src/sys/arch/alpha/include/alpha.h	Tue Jul 20 05:43:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: alpha.h,v 1.45 2021/05/05 15:36:17 thorpej Exp $ */
+/* $NetBSD: alpha.h,v 1.46 2021/07/20 05:43:10 thorpej Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -41,18 +41,26 @@
 #ifndef _ALPHA_H_
 #define _ALPHA_H_
 
+typedef union alpha_f_float {
+	uint32_t i;
+	uint32_t frac_hi:  7,
+		 exp:  8,
+		sign:  1,
+		 frac_lo: 16;
+} f_float;
+
 typedef union alpha_s_float {
 	uint32_t i;
 	uint32_t frac: 23,
-		  exp:   8,
-		  sign:  1;
+		  exp:  8,
+		 sign:  1;
 } s_float;
 
 typedef union alpha_t_float {
 	uint64_t i;
 	uint64_t frac: 52,
-		  exp:  11,
-		  sign:  1;
+		  exp: 11,
+		 sign:  1;
 } t_float;
 
 #ifdef _KERNEL
@@ -73,6 +81,7 @@ extern u_long cpu_implver;		/* from IMPL
 extern u_long cpu_amask;		/* from AMASK instruction */
 extern int bootdev_debug;
 extern int alpha_fp_sync_complete;
+extern int alpha_fp_complete_debug;
 extern int alpha_unaligned_print, alpha_unaligned_fix, alpha_unaligned_sigbus;
 extern void (*alpha_delay_fn)(unsigned long);
 



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

2021-07-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jul 20 02:42:10 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: db_instruction.h

Log Message:
Define the FIX float function codes (ITOFF, ITOFS, ITOFT).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/alpha/db_instruction.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/db_instruction.h
diff -u src/sys/arch/alpha/alpha/db_instruction.h:1.12 src/sys/arch/alpha/alpha/db_instruction.h:1.13
--- src/sys/arch/alpha/alpha/db_instruction.h:1.12	Mon Jun 21 02:10:46 2021
+++ src/sys/arch/alpha/alpha/db_instruction.h	Tue Jul 20 02:42:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: db_instruction.h,v 1.12 2021/06/21 02:10:46 thorpej Exp $ */
+/* $NetBSD: db_instruction.h,v 1.13 2021/07/20 02:42:10 thorpej Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -445,6 +445,11 @@ typedef union {
 #define	op_cvtql_v	0x130
 #define	op_cvtql_sv	0x530
 
+		/* FIX FLOAT, "function" opcodes (bits 5..11)  */
+
+#define	op_itofs	0x004
+#define	op_itoff	0x014
+#define	op_itoft	0x024
 
 		/* ieee FLOAT, "function" opcodes (bits 5..11)  */
 



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

2021-07-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jul 20 01:56:06 UTC 2021

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

Log Message:
Emulate the CIX extension instructions (CTPOP, CTTZ, CTLZ).


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/alpha/alpha/trap.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/trap.c
diff -u src/sys/arch/alpha/alpha/trap.c:1.136 src/sys/arch/alpha/alpha/trap.c:1.137
--- src/sys/arch/alpha/alpha/trap.c:1.136	Mon Jul 19 22:21:36 2021
+++ src/sys/arch/alpha/alpha/trap.c	Tue Jul 20 01:56:06 2021
@@ -1,7 +1,7 @@
-/* $NetBSD: trap.c,v 1.136 2021/07/19 22:21:36 thorpej Exp $ */
+/* $NetBSD: trap.c,v 1.137 2021/07/20 01:56:06 thorpej Exp $ */
 
 /*-
- * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
+ * Copyright (c) 2000, 2001, 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -95,7 +95,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.136 2021/07/19 22:21:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.137 2021/07/20 01:56:06 thorpej Exp $");
 
 #include 
 #include 
@@ -106,6 +106,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.1
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -980,6 +981,17 @@ EVCNT_ATTACH_STATIC(emul_bwx_stw);
 EVCNT_ATTACH_STATIC(emul_bwx_sextb);
 EVCNT_ATTACH_STATIC(emul_bwx_sextw);
 
+static struct evcnt emul_cix_ctpop =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul cix", "ctpop");
+static struct evcnt emul_cix_ctlz =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul cix", "ctlz");
+static struct evcnt emul_cix_cttz =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul cix", "cttz");
+
+EVCNT_ATTACH_STATIC(emul_cix_ctpop);
+EVCNT_ATTACH_STATIC(emul_cix_ctlz);
+EVCNT_ATTACH_STATIC(emul_cix_cttz);
+
 #define	EMUL_COUNT(ev)	atomic_inc_64(&(ev).ev_count)
 
 /*
@@ -1129,6 +1141,60 @@ handle_opdec(struct lwp *l, u_long *ucod
 *regptr = w;
 			break;
 		}
+		if (inst.operate_reg_format.function == op_ctpop &&
+		inst.operate_reg_format.zero == 0 &&
+		inst.operate_reg_format.sbz == 0 &&
+		inst.operate_reg_format.ra == 31) {
+			unsigned long val;
+			unsigned int res;
+
+			EMUL_COUNT(emul_cix_ctpop);
+			regptr = irp(l, inst.operate_reg_format.rb);
+			val = (regptr != NULL) ? *regptr : 0;
+			res = popcount64(val);
+			regptr = irp(l, inst.operate_reg_format.rc);
+			if (regptr != NULL) {
+*regptr = res;
+			}
+			break;
+		}
+		if (inst.operate_reg_format.function == op_ctlz &&
+		inst.operate_reg_format.zero == 0 &&
+		inst.operate_reg_format.sbz == 0 &&
+		inst.operate_reg_format.ra == 31) {
+			unsigned long val;
+			unsigned int res;
+
+			EMUL_COUNT(emul_cix_ctlz);
+			regptr = irp(l, inst.operate_reg_format.rb);
+			val = (regptr != NULL) ? *regptr : 0;
+			res = fls64(val);
+			res = (res == 0) ? 64 : 64 - res;
+			regptr = irp(l, inst.operate_reg_format.rc);
+			if (regptr != NULL) {
+*regptr = res;
+			}
+			break;
+		}
+		if (inst.operate_reg_format.function == op_cttz &&
+		inst.operate_reg_format.zero == 0 &&
+		inst.operate_reg_format.sbz == 0 &&
+		inst.operate_reg_format.ra == 31) {
+			unsigned long val;
+			unsigned int res;
+
+			EMUL_COUNT(emul_cix_cttz);
+			regptr = irp(l, inst.operate_reg_format.rb);
+			val = (regptr != NULL) ? *regptr : 0;
+			res = ffs64(val);
+			res = (res == 0) ? 64 : res - 1;
+			regptr = irp(l, inst.operate_reg_format.rc);
+			if (regptr != NULL) {
+*regptr = res;
+			}
+			break;
+		}
+
 		goto sigill;
 
 	default:



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

2021-07-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jul 19 22:21:36 UTC 2021

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

Log Message:
- In unaligned_fixup(), use defined constants for opcodes, not magic numbers.

- In handle_opdec(), use ufetch_int() to fetch the instruction and
  _u{fetch,store}_{8,16}() when emulating BWX instructions rather
  than copyin() / copyout() (they're faster).

- Add event counters for BWX instruction emulation.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/arch/alpha/alpha/trap.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/trap.c
diff -u src/sys/arch/alpha/alpha/trap.c:1.135 src/sys/arch/alpha/alpha/trap.c:1.136
--- src/sys/arch/alpha/alpha/trap.c:1.135	Thu Nov 21 19:23:58 2019
+++ src/sys/arch/alpha/alpha/trap.c	Mon Jul 19 22:21:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.135 2019/11/21 19:23:58 ad Exp $ */
+/* $NetBSD: trap.c,v 1.136 2021/07/19 22:21:36 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -87,13 +87,15 @@
  * rights to redistribute these changes.
  */
 
+#define	__UFETCHSTORE_PRIVATE	/* see handle_opdec() */
+
 #include "opt_fix_unaligned_vax_fp.h"
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.135 2019/11/21 19:23:58 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.136 2021/07/19 22:21:36 thorpej Exp $");
 
 #include 
 #include 
@@ -875,65 +877,65 @@ unaligned_fixup(u_long va, u_long opcode
 	signo = SIGSEGV;
 	if (dofix && selected_tab->fixable) {
 		switch (opcode) {
-		case 0x0c:			/* ldwu */
+		case op_ldwu:
 			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
 			unaligned_load_integer(worddata);
 			break;
 
-		case 0x0d:			/* stw */
+		case op_stw:
 			/* XXX ONLY WORKS ON LITTLE-ENDIAN ALPHA */
 			unaligned_store_integer(worddata);
 			break;
 
 #ifdef FIX_UNALIGNED_VAX_FP
-		case 0x20:			/* ldf */
+		case op_ldf:
 			unaligned_load_floating(intdata, Ffloat_to_reg);
 			break;
 
-		case 0x21:			/* ldg */
+		case op_ldg:
 			unaligned_load_floating(longdata, Gfloat_reg_cvt);
 			break;
 #endif
 
-		case 0x22:			/* lds */
+		case op_lds:
 			unaligned_load_floating(intdata, Sfloat_to_reg);
 			break;
 
-		case 0x23:			/* ldt */
+		case op_ldt:
 			unaligned_load_floating(longdata, Tfloat_reg_cvt);
 			break;
 
 #ifdef FIX_UNALIGNED_VAX_FP
-		case 0x24:			/* stf */
+		case op_stf:
 			unaligned_store_floating(intdata, reg_to_Ffloat);
 			break;
 
-		case 0x25:			/* stg */
+		case op_stg:
 			unaligned_store_floating(longdata, Gfloat_reg_cvt);
 			break;
 #endif
 
-		case 0x26:			/* sts */
+		case op_sts:
 			unaligned_store_floating(intdata, reg_to_Sfloat);
 			break;
 
-		case 0x27:			/* stt */
+		case op_stt:
 			unaligned_store_floating(longdata, Tfloat_reg_cvt);
 			break;
 
-		case 0x28:			/* ldl */
+		case op_ldl:
 			unaligned_load_integer(intdata);
 			break;
 
-		case 0x29:			/* ldq */
+		case op_ldq:
 			unaligned_load_integer(longdata);
 			break;
 
-		case 0x2c:			/* stl */
+		case op_stl:
 			unaligned_store_integer(intdata);
 			break;
 
-		case 0x2d:			/* stq */
+		case op_stq:
 			unaligned_store_integer(longdata);
 			break;
 
@@ -958,6 +960,28 @@ unaligned_fixup(u_long va, u_long opcode
 	return (signo);
 }
 
+static struct evcnt emul_bwx_ldbu =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul bwx", "ldbu");
+static struct evcnt emul_bwx_ldwu =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul bwx", "ldwu");
+static struct evcnt emul_bwx_stb =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul bwx", "stb");
+static struct evcnt emul_bwx_stw =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul bwx", "stw");
+static struct evcnt emul_bwx_sextb =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul bwx", "sextb");
+static struct evcnt emul_bwx_sextw =
+EVCNT_INITIALIZER(EVCNT_TYPE_TRAP, NULL, "emul bwx", "sextw");
+
+EVCNT_ATTACH_STATIC(emul_bwx_ldbu);
+EVCNT_ATTACH_STATIC(emul_bwx_ldwu);
+EVCNT_ATTACH_STATIC(emul_bwx_stb);
+EVCNT_ATTACH_STATIC(emul_bwx_stw);
+EVCNT_ATTACH_STATIC(emul_bwx_sextb);
+EVCNT_ATTACH_STATIC(emul_bwx_sextw);
+
+#define	EMUL_COUNT(ev)	atomic_inc_64(&(ev).ev_count)
+
 /*
  * Reserved/unimplemented instruction (opDec fault) handler
  *
@@ -986,7 +1010,7 @@ handle_opdec(struct lwp *l, u_long *ucod
 	l->l_md.md_tf->tf_regs[FRAME_SP] = alpha_pal_rdusp();
 
 	inst_pc = memaddr = l->l_md.md_tf->tf_regs[FRAME_PC] - 4;
-	if (copyin((void *)inst_pc, , sizeof (inst)) != 0) {
+	if (ufetch_int((void *)inst_pc, ) != 0) {
 		/*
 		 * really, this should never happen, but in case it
 		 * does we handle it.
@@ -1012,6 +1036,11 @@ handle_opdec(struct lwp *l, u_long *ucod
 		if (inst.mem_format.opcode == op_ldwu ||
 		inst.mem_format.opcode == op_stw) {
 			if (memaddr & 0x01) {
+if (inst.mem_format.opcode == 

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

2021-07-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jul 19 16:31:19 UTC 2021

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

Log Message:
Re-arrange the kernel pmap fast-path in pmap_extract() so that
when DEBUG is not enabled, the compiler can emit a tail-call to
vtophys_internal().


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/sys/arch/alpha/alpha/pmap.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/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.298 src/sys/arch/alpha/alpha/pmap.c:1.299
--- src/sys/arch/alpha/alpha/pmap.c:1.298	Fri Jul 16 19:02:22 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Mon Jul 19 16:31:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.298 2021/07/16 19:02:22 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.299 2021/07/19 16:31:19 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.298 2021/07/16 19:02:22 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.299 2021/07/19 16:31:19 thorpej Exp $");
 
 #include 
 #include 
@@ -2578,18 +2578,18 @@ pmap_extract(pmap_t pmap, vaddr_t va, pa
 	 * handles K0SEG.
 	 */
 	if (__predict_true(pmap == pmap_kernel())) {
-		if (__predict_true(vtophys_internal(va, pap))) {
 #ifdef DEBUG
-			if (pmapdebug & PDB_FOLLOW)
+		bool address_is_valid = vtophys_internal(va, pap);
+		if (pmapdebug & PDB_FOLLOW) {
+			if (address_is_valid) {
 printf("0x%lx (kernel vtophys)\n", *pap);
-#endif
-			return true;
+			} else {
+printf("failed (kernel vtophys)\n");
+			}
 		}
-#ifdef DEBUG
-		if (pmapdebug & PDB_FOLLOW)
-			printf("failed (kernel vtophys)\n");
+#else
+		return vtophys_internal(va, pap);
 #endif
-		return false;
 	}
 
 	pt_entry_t * const lev1map = pmap_lev1map(pmap);



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

2021-07-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jul 19 16:25:54 UTC 2021

Modified Files:
src/sys/arch/alpha/common: bus_dma.c sgmap_typedep.c

Log Message:
There is already a fast-path in pmap_extract() for the kernel pmap, so
don't bother doing a conditional for kernel vs. user-space here.

KASSERT() that pmap_extract() succeeds; it is a programming error if
it does not, and it's not a great idea to insert a garbage address
into the SGMAP page table.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/alpha/common/bus_dma.c
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/alpha/common/sgmap_typedep.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/common/bus_dma.c
diff -u src/sys/arch/alpha/common/bus_dma.c:1.72 src/sys/arch/alpha/common/bus_dma.c:1.73
--- src/sys/arch/alpha/common/bus_dma.c:1.72	Fri May  7 16:58:33 2021
+++ src/sys/arch/alpha/common/bus_dma.c	Mon Jul 19 16:25:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.72 2021/05/07 16:58:33 thorpej Exp $ */
+/* $NetBSD: bus_dma.c,v 1.73 2021/07/19 16:25:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.72 2021/05/07 16:58:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.73 2021/07/19 16:25:54 thorpej Exp $");
 
 #include 
 #include 
@@ -138,6 +138,7 @@ _bus_dmamap_load_buffer_direct(bus_dma_t
 	bus_addr_t curaddr, lastaddr, baddr, bmask;
 	vaddr_t vaddr = (vaddr_t)buf;
 	int seg;
+	bool address_is_valid __diagused;
 
 	lastaddr = *lastaddrp;
 	bmask = ~(map->_dm_boundary - 1);
@@ -146,10 +147,9 @@ _bus_dmamap_load_buffer_direct(bus_dma_t
 		/*
 		 * Get the physical address for this segment.
 		 */
-		if (!VMSPACE_IS_KERNEL_P(vm))
-			(void) pmap_extract(vm->vm_map.pmap, vaddr, );
-		else
-			curaddr = vtophys(vaddr);
+		address_is_valid =
+		pmap_extract(vm->vm_map.pmap, vaddr, );
+		KASSERT(address_is_valid);
 
 		/*
 		 * If we're beyond the current DMA window, indicate

Index: src/sys/arch/alpha/common/sgmap_typedep.c
diff -u src/sys/arch/alpha/common/sgmap_typedep.c:1.43 src/sys/arch/alpha/common/sgmap_typedep.c:1.44
--- src/sys/arch/alpha/common/sgmap_typedep.c:1.43	Sun Jul 18 05:12:27 2021
+++ src/sys/arch/alpha/common/sgmap_typedep.c	Mon Jul 19 16:25:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.44 2021/07/19 16:25:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.44 2021/07/19 16:25:54 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -74,6 +74,7 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag
 	bus_size_t sgvalen, extra_sgvalen, boundary, alignment;
 	SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
 	int pteidx, error, spill, seg = *segp;
+	bool address_is_valid __diagused;
 
 	/* Initialize the spill page PTE if it hasn't been already. */
 	if (__C(SGMAP_TYPE,_prefetch_spill_page_pte) == 0)
@@ -268,10 +269,8 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag
 	for (; va < endva; va += PAGE_SIZE, pteidx++,
 	 pte = _table[pteidx * SGMAP_PTE_SPACING]) {
 		/* Get the physical address for this segment. */
-		if (!VMSPACE_IS_KERNEL_P(vm))
-			(void) pmap_extract(vm->vm_map.pmap, va, );
-		else
-			pa = vtophys(va);
+		address_is_valid = pmap_extract(vm->vm_map.pmap, va, );
+		KASSERT(address_is_valid);
 
 		/* Load the current PTE with this page. */
 		*pte = (pa >> SGPTE_PGADDR_SHIFT) | SGPTE_VALID;
@@ -289,10 +288,8 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag
 
 		/* va == endva == address of extra page */
 		KASSERT(va == endva);
-		if (!VMSPACE_IS_KERNEL_P(vm))
-			(void) pmap_extract(vm->vm_map.pmap, va, );
-		else
-			pa = vtophys(va);
+		address_is_valid = pmap_extract(vm->vm_map.pmap, va, );
+		KASSERT(address_is_valid);
 
 		/*
 		 * If a spill page is needed, the previous segment will



CVS commit: src/sys/arch/powerpc/oea

2021-07-19 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Jul 19 14:49:45 UTC 2021

Modified Files:
src/sys/arch/powerpc/oea: pmap.c

Log Message:
there is no need to keep pvos for unmanaged mappings on a hidden p/v list,
since "unmanaged" means that we don't want to find such pvos on any p/v list.
instead, just don't put such pvos on any p/v list at all and remove
the two hidden p/v lists for unmanaged mappings.  code mostly from martin,
to implement rin's suggestion of unifying the two hidden lists.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/arch/powerpc/oea/pmap.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/powerpc/oea/pmap.c
diff -u src/sys/arch/powerpc/oea/pmap.c:1.106 src/sys/arch/powerpc/oea/pmap.c:1.107
--- src/sys/arch/powerpc/oea/pmap.c:1.106	Sun Jun 27 12:26:33 2021
+++ src/sys/arch/powerpc/oea/pmap.c	Mon Jul 19 14:49:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.106 2021/06/27 12:26:33 martin Exp $	*/
+/*	$NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $	*/
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.106 2021/06/27 12:26:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.107 2021/07/19 14:49:45 chs Exp $");
 
 #define	PMAP_NOOPNAMES
 
@@ -328,8 +328,6 @@ struct pvo_entry {
 
 TAILQ_HEAD(pvo_tqhead, pvo_entry);
 struct pvo_tqhead *pmap_pvo_table;	/* pvo entries by ptegroup index */
-static struct pvo_head pmap_pvo_kunmanaged = LIST_HEAD_INITIALIZER(pmap_pvo_kunmanaged);	/* list of unmanaged pages */
-static struct pvo_head pmap_pvo_unmanaged = LIST_HEAD_INITIALIZER(pmap_pvo_unmanaged);	/* list of unmanaged pages */
 
 struct pool pmap_pool;		/* pool for pmap structures */
 struct pool pmap_pvo_pool;	/* pool for pvo entries */
@@ -652,7 +650,7 @@ pa_to_pvoh(paddr_t pa, struct vm_page **
 	if (pg_p != NULL)
 		*pg_p = pg;
 	if (pg == NULL)
-		return _pvo_unmanaged;
+		return NULL;
 	md = VM_PAGE_TO_MD(pg);
 	return >mdpg_pvoh;
 }
@@ -1410,22 +1408,19 @@ pmap_pvo_check(const struct pvo_entry *p
 
 	if (PVO_MANAGED_P(pvo)) {
 		pvo_head = pa_to_pvoh(pvo->pvo_pte.pte_lo & PTE_RPGN, NULL);
-	} else {
-		if (pvo->pvo_vaddr < VM_MIN_KERNEL_ADDRESS) {
-			printf("pmap_pvo_check: pvo %p: non kernel address "
-			"on kernel unmanaged list\n", pvo);
+		LIST_FOREACH(pvo0, pvo_head, pvo_vlink) {
+			if (pvo0 == pvo)
+break;
+		}
+		if (pvo0 == NULL) {
+			printf("pmap_pvo_check: pvo %p: not present "
+			   "on its vlist head %p\n", pvo, pvo_head);
 			failed = 1;
 		}
-		pvo_head = _pvo_kunmanaged;
-	}
-	LIST_FOREACH(pvo0, pvo_head, pvo_vlink) {
-		if (pvo0 == pvo)
-			break;
-	}
-	if (pvo0 == NULL) {
-		printf("pmap_pvo_check: pvo %p: not present "
-		"on its vlist head %p\n", pvo, pvo_head);
-		failed = 1;
+	} else {
+		KASSERT(pvo->pvo_vaddr >= VM_MIN_KERNEL_ADDRESS);
+		if (__predict_false(pvo->pvo_vaddr < VM_MIN_KERNEL_ADDRESS))
+			failed = 1;
 	}
 	if (pvo != pmap_pvo_find_va(pvo->pvo_pmap, pvo->pvo_vaddr, NULL)) {
 		printf("pmap_pvo_check: pvo %p: not present "
@@ -1620,7 +1615,7 @@ pmap_pvo_enter(pmap_t pm, struct pool *p
 	}
 	if (flags & PMAP_WIRED)
 		pvo->pvo_vaddr |= PVO_WIRED;
-	if (pvo_head != _pvo_kunmanaged) {
+	if (pvo_head != NULL) {
 		pvo->pvo_vaddr |= PVO_MANAGED; 
 		PMAPCOUNT(mappings);
 	} else {
@@ -1628,7 +1623,8 @@ pmap_pvo_enter(pmap_t pm, struct pool *p
 	}
 	pmap_pte_create(>pvo_pte, pm, va, pa | pte_lo);
 
-	LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink);
+	if (pvo_head != NULL)
+		LIST_INSERT_HEAD(pvo_head, pvo, pvo_vlink);
 	if (PVO_WIRED_P(pvo))
 		pvo->pvo_pmap->pm_stats.wired_count++;
 	pvo->pvo_pmap->pm_stats.resident_count++;
@@ -1728,7 +1724,9 @@ pmap_pvo_remove(struct pvo_entry *pvo, i
 		pvo->pvo_pmap->pm_stats.wired_count--;
 
 	/*
-	 * Save the REF/CHG bits into their cache if the page is managed.
+	 * If the page is managed:
+	 * Save the REF/CHG bits into their cache.
+	 * Remove the PVO from the P/V list.
 	 */
 	if (PVO_MANAGED_P(pvo)) {
 		register_t ptelo = pvo->pvo_pte.pte_lo;
@@ -1760,15 +1758,15 @@ pmap_pvo_remove(struct pvo_entry *pvo, i
 
 			pmap_attr_save(pg, ptelo & (PTE_REF|PTE_CHG));
 		}
+		LIST_REMOVE(pvo, pvo_vlink);
 		PMAPCOUNT(unmappings);
 	} else {
 		PMAPCOUNT(kernel_unmappings);
 	}
 
 	/*
-	 * Remove the PVO from its lists and return it to the pool.
+	 * Remove the PVO from its list and return it to the pool.
 	 */
-	LIST_REMOVE(pvo, pvo_vlink);
 	TAILQ_REMOVE(_pvo_table[ptegidx], pvo, pvo_olink);
 	if (pvol) {
 		LIST_INSERT_HEAD(pvol, pvo, pvo_vlink);
@@ -1861,9 +1859,10 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 	PMAP_LOCK();
 
 	if (__predict_false(!pmap_initialized)) {
-		pvo_head = _pvo_kunmanaged;
+		pvo_head = NULL;
 		pg = NULL;
 		was_exec = PTE_EXEC;
+
 	} else {
 		pvo_head = pa_to_pvoh(pa, );
 	}
@@ -1952,7 +1951,6 @@ pmap_enter(pmap_t pm, 

CVS commit: src/sys/arch

2021-07-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jul 19 10:28:58 UTC 2021

Modified Files:
src/sys/arch/alpha/include: param.h
src/sys/arch/arm/include: param.h
src/sys/arch/riscv/include: param.h

Log Message:
Remove definitions for CACHE_LINE_SIZE and COHERENCY_UNIT which are the same
as the default.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/alpha/include/param.h
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/include/param.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/riscv/include/param.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/include/param.h
diff -u src/sys/arch/alpha/include/param.h:1.49 src/sys/arch/alpha/include/param.h:1.50
--- src/sys/arch/alpha/include/param.h:1.49	Tue Jul  6 08:20:52 2021
+++ src/sys/arch/alpha/include/param.h	Mon Jul 19 06:28:58 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.49 2021/07/06 12:20:52 thorpej Exp $ */
+/* $NetBSD: param.h,v 1.50 2021/07/19 10:28:58 christos Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -84,8 +84,6 @@
  * EV4 (21064) and EV5 (21164) have a 32-byte cache line size.
  * EV6 (21264) and EV7 (21364) have a 64-byte cache line size.
  */
-#define	COHERENCY_UNIT	64
-#define	CACHE_LINE_SIZE	64
 
 /*
  * Constants related to network buffer management.

Index: src/sys/arch/arm/include/param.h
diff -u src/sys/arch/arm/include/param.h:1.23 src/sys/arch/arm/include/param.h:1.24
--- src/sys/arch/arm/include/param.h:1.23	Sun Aug 16 05:37:30 2020
+++ src/sys/arch/arm/include/param.h	Mon Jul 19 06:28:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.23 2020/08/16 09:37:30 skrll Exp $	*/
+/*	$NetBSD: param.h,v 1.24 2021/07/19 10:28:58 christos Exp $	*/
 
 /*
  * Copyright (c) 1994,1995 Mark Brinicombe.
@@ -186,7 +186,4 @@
 #endif
 #endif /* _KERNEL */
 
-#define COHERENCY_UNIT		64
-#define CACHE_LINE_SIZE		64
-
 #endif /* _ARM_PARAM_H_ */

Index: src/sys/arch/riscv/include/param.h
diff -u src/sys/arch/riscv/include/param.h:1.5 src/sys/arch/riscv/include/param.h:1.6
--- src/sys/arch/riscv/include/param.h:1.5	Mon May 31 10:38:57 2021
+++ src/sys/arch/riscv/include/param.h	Mon Jul 19 06:28:58 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.5 2021/05/31 14:38:57 simonb Exp $ */
+/* $NetBSD: param.h,v 1.6 2021/07/19 10:28:58 christos Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -96,9 +96,6 @@
 #define MSGBUFSIZE		65536	/* default message buffer size */
 #endif
 
-#define COHERENCY_UNIT		64
-#define CACHE_LINE_SIZE		64
-
 #define MAXCPUS			32
 
 #ifdef _KERNEL



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

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

Modified Files:
src/sys/arch/alpha/common: sgmap_common.c sgmap_typedep.c
src/sys/arch/alpha/include: bus_defs.h
src/sys/arch/alpha/tc: tc_dma.c tc_dma_3000_500.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/alpha/common/sgmap_common.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/alpha/common/sgmap_typedep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/include/bus_defs.h
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/alpha/tc/tc_dma.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/alpha/tc/tc_dma_3000_500.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/common/sgmap_common.c
diff -u src/sys/arch/alpha/common/sgmap_common.c:1.28 src/sys/arch/alpha/common/sgmap_common.c:1.29
--- src/sys/arch/alpha/common/sgmap_common.c:1.28	Sun Jul  4 22:42:35 2021
+++ src/sys/arch/alpha/common/sgmap_common.c	Sun Jul 18 05:12:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_common.c,v 1.28 2021/07/04 22:42:35 thorpej Exp $ */
+/* $NetBSD: sgmap_common.c,v 1.29 2021/07/18 05:12:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.28 2021/07/04 22:42:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.29 2021/07/18 05:12:27 thorpej Exp $");
 
 #include 
 #include 
@@ -68,6 +68,14 @@ alpha_sgmap_init(bus_dma_tag_t t, struct
 		goto die;
 	}
 
+	/*
+	 * If we don't yet have a minimum SGVA alignment, default
+	 * to the system page size.
+	 */
+	if (t->_sgmap_minalign < PAGE_SIZE) {
+		t->_sgmap_minalign = PAGE_SIZE;
+	}
+
 	sgmap->aps_wbase = wbase;
 	sgmap->aps_sgvabase = sgvabase;
 	sgmap->aps_sgvasize = sgvasize;

Index: src/sys/arch/alpha/common/sgmap_typedep.c
diff -u src/sys/arch/alpha/common/sgmap_typedep.c:1.42 src/sys/arch/alpha/common/sgmap_typedep.c:1.43
--- src/sys/arch/alpha/common/sgmap_typedep.c:1.42	Thu Jun 24 16:41:16 2021
+++ src/sys/arch/alpha/common/sgmap_typedep.c	Sun Jul 18 05:12:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.42 2021/06/24 16:41:16 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.42 2021/06/24 16:41:16 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.43 2021/07/18 05:12:27 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -130,7 +130,8 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag
 	const vm_flag_t vmflags = VM_INSTANTFIT |
 	((flags & BUS_DMA_NOWAIT) ? VM_NOSLEEP : VM_SLEEP);
 
-	alignment = PAGE_SIZE;
+	KASSERT(t->_sgmap_minalign != 0);
+	alignment = t->_sgmap_minalign;
 	sgvalen = (endva - va);
 
 	SGMAP_PTE_TYPE spill_pte_v = __C(SGMAP_TYPE,_prefetch_spill_page_pte);
@@ -193,13 +194,16 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag
 		 * ARGH!  If the addition of the spill page bumped us
 		 * over our boundary, we have to 2x the boundary limit.
 		 * To compensate (and enforce the original boundary
-		 * constraint), we force our alignment to be the previous
-		 * boundary, thus ensuring that the only boundary violation
-		 * is the pre-fetch that the SGMAP controller performs that
-		 * necessitates the spill page in the first place.
+		 * constraint), we force our alignment to be at least the
+		 * previous boundary, thus ensuring that the only boundary
+		 * violation is the pre-fetch that the SGMAP controller
+		 * performs that necessitates the spill page in the first
+		 * place.
 		 */
 		if (boundary && boundary < sgvalen) {
-			alignment = boundary;
+			if (alignment < boundary) {
+alignment = boundary;
+			}
 			do {
 boundary <<= 1;
 			} while (boundary < sgvalen);

Index: src/sys/arch/alpha/include/bus_defs.h
diff -u src/sys/arch/alpha/include/bus_defs.h:1.5 src/sys/arch/alpha/include/bus_defs.h:1.6
--- src/sys/arch/alpha/include/bus_defs.h:1.5	Mon Sep 23 16:17:54 2019
+++ src/sys/arch/alpha/include/bus_defs.h	Sun Jul 18 05:12:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_defs.h,v 1.5 2019/09/23 16:17:54 skrll Exp $ */
+/* $NetBSD: bus_defs.h,v 1.6 2021/07/18 05:12:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -364,6 +364,12 @@ struct alpha_bus_dma_tag {
 	struct alpha_sgmap *_sgmap;
 
 	/*
+	 * Some chipsets may want to enforce a minimum alignment
+	 * constraint for SGMAP DMA addresses.
+	 */
+	bus_size_t _sgmap_minalign;
+
+	/*
 	 * The SGMAP MMU implements a prefetch FIFO to keep data
 	 * moving down the pipe, when doing host->bus DMA writes.
 	 * 

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/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/sys/arch/landisk/dev

2021-07-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Jul 15 05:07:50 UTC 2021

Modified Files:
src/sys/arch/landisk/dev: btn_obio.c button.c buttonvar.h

Log Message:
Migrate btn_init() from btnopen() (with RUN_ONCE) to btn_obio_attach().

Fix uninitialized use of btn_event_list_lock in btn_event_register().

Found by LOCKDEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/landisk/dev/btn_obio.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/landisk/dev/button.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/landisk/dev/buttonvar.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/landisk/dev/btn_obio.c
diff -u src/sys/arch/landisk/dev/btn_obio.c:1.6 src/sys/arch/landisk/dev/btn_obio.c:1.7
--- src/sys/arch/landisk/dev/btn_obio.c:1.6	Sat Jan 21 19:44:29 2012
+++ src/sys/arch/landisk/dev/btn_obio.c	Thu Jul 15 05:07:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: btn_obio.c,v 1.6 2012/01/21 19:44:29 nonaka Exp $	*/
+/*	$NetBSD: btn_obio.c,v 1.7 2021/07/15 05:07:50 rin Exp $	*/
 
 /*-
  * Copyright (C) 2005 NONAKA Kimihiro 
@@ -28,7 +28,7 @@
 #include "pwrsw_obio.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: btn_obio.c,v 1.6 2012/01/21 19:44:29 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btn_obio.c,v 1.7 2021/07/15 05:07:50 rin Exp $");
 
 #include 
 #include 
@@ -141,6 +141,7 @@ btn_obio_attach(device_t parent, device_
 	}
 	sc->sc_mask |= BTN_RESET_BIT;
 
+	btn_init();
 	for (i = 0; i < NBUTTON; i++) {
 		int idx = btnlist[i].idx;
 		sc->sc_bev[idx].bev_name = btnlist[i].name;

Index: src/sys/arch/landisk/dev/button.c
diff -u src/sys/arch/landisk/dev/button.c:1.10 src/sys/arch/landisk/dev/button.c:1.11
--- src/sys/arch/landisk/dev/button.c:1.10	Sat Dec 19 21:25:03 2020
+++ src/sys/arch/landisk/dev/button.c	Thu Jul 15 05:07:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: button.c,v 1.10 2020/12/19 21:25:03 thorpej Exp $	*/
+/*	$NetBSD: button.c,v 1.11 2021/07/15 05:07:50 rin Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.10 2020/12/19 21:25:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: button.c,v 1.11 2021/07/15 05:07:50 rin Exp $");
 
 #include 
 #include 
@@ -59,7 +59,6 @@ __KERNEL_RCSID(0, "$NetBSD: button.c,v 1
 /*
  * event handler
  */
-static ONCE_DECL(btn_once);
 static LIST_HEAD(, btn_event) btn_event_list;
 static kmutex_t btn_event_list_lock;
 
@@ -105,7 +104,7 @@ const struct cdevsw button_cdevsw = {
 	.d_flag = 0
 };
 
-static int
+int
 btn_init(void)
 {
 
@@ -161,11 +160,6 @@ btnopen(dev_t dev, int flag, int mode, s
 {
 	int error;
 
-	error = RUN_ONCE(_once, btn_init);
-	if (error) {
-		return error;
-	}
-
 	if (minor(dev) != 0) {
 		return (ENODEV);
 	}

Index: src/sys/arch/landisk/dev/buttonvar.h
diff -u src/sys/arch/landisk/dev/buttonvar.h:1.1 src/sys/arch/landisk/dev/buttonvar.h:1.2
--- src/sys/arch/landisk/dev/buttonvar.h:1.1	Fri Sep  1 21:26:18 2006
+++ src/sys/arch/landisk/dev/buttonvar.h	Thu Jul 15 05:07:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: buttonvar.h,v 1.1 2006/09/01 21:26:18 uwe Exp $	*/
+/*	$NetBSD: buttonvar.h,v 1.2 2021/07/15 05:07:50 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 Zembu Labs, Inc.
@@ -45,6 +45,8 @@ struct btn_event {
 	LIST_ENTRY(btn_event) bev_list;
 };
 
+int	btn_init(void);
+
 void	btn_settype(const char *type);
 
 int	btn_event_register(struct btn_event *bev);



CVS commit: src/sys/arch/sh3/sh3

2021-07-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Jul 15 04:58:33 UTC 2021

Modified Files:
src/sys/arch/sh3/sh3: locore_subr.S

Log Message:
For cpu_switchto(), inherit PSL_IMASK field of SR between lwp's.

Otherwise, IPL is lost during context switch, which allows improper
interrupts when, e.g., spin mutexes are hold.

With this fix, full ATF is successfully completed on DIAGNOSTIC
kernel (with one KASSERT in uvm_map.c, which triggers kern/51254,
converted to printf).

Thanks uwe@ for review and suggesting optimization.

Also thanks ad@ for useful comment, and ryo@ for giving me reference
manuals of SH-4!


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/sh3/sh3/locore_subr.S

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/sh3/sh3/locore_subr.S
diff -u src/sys/arch/sh3/sh3/locore_subr.S:1.60 src/sys/arch/sh3/sh3/locore_subr.S:1.61
--- src/sys/arch/sh3/sh3/locore_subr.S:1.60	Mon Aug  3 16:43:44 2020
+++ src/sys/arch/sh3/sh3/locore_subr.S	Thu Jul 15 04:58:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore_subr.S,v 1.60 2020/08/03 16:43:44 uwe Exp $	*/
+/*	$NetBSD: locore_subr.S,v 1.61 2021/07/15 04:58:33 rin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
 #include 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.60 2020/08/03 16:43:44 uwe Exp $")
+__KERNEL_RCSID(0, "$NetBSD: locore_subr.S,v 1.61 2021/07/15 04:58:33 rin Exp $")
 
 
 /*
@@ -140,7 +140,22 @@ ENTRY(cpu_switchto)
 	mov	r10, r1		! >l_md.md_pcb->pcb_sf
 	mov	r9, r0		! return olwp (we are about to clobber r9)
 	ldc.l	@r1+, gbr
-	ldc.l	@r1+, sr
+
+	/*
+	 * We cannot simply pop SR here; PSL_IMASK field should be
+	 * inherited to nlwp. Otherwise, IPL is lost during context
+	 * switch, which allows improper interrupts when, e.g.,
+	 * spin mutexes are hold.
+	 */
+	mov.l	@r1+, r8	! r8  = new SR
+	mov	#0x78, r9
+	shll	r9		! r9  =  PSL_IMASK
+	not	r9, r10		! r10 = ~PSL_IMASK
+	and	r9, r11		! r11 = old SR & PSL_IMASK
+	and	r10, r8
+	or	r11, r8
+	ldc	r8, sr
+
 	lds.l	@r1+, pr
 	mov.l	@r1+, r8
 	mov.l	@r1+, r9



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

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

Modified Files:
src/sys/arch/alpha/jensenio: jensenio_intr.c

Log Message:
- Use defined constants for PIC registers, not magic numbers (XXX except
  for the ELCR register; need a new header file).
- In jensenio_specific_eoi(), actually issue a specific EOI (the code
  was erroneously issuing a non-specific EOI).
- In jensenio_pic_init(), ensure all IRQs are initialized to EDGE trigger.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/alpha/jensenio/jensenio_intr.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/jensenio/jensenio_intr.c
diff -u src/sys/arch/alpha/jensenio/jensenio_intr.c:1.17 src/sys/arch/alpha/jensenio/jensenio_intr.c:1.18
--- src/sys/arch/alpha/jensenio/jensenio_intr.c:1.17	Sun Jul  4 22:42:35 2021
+++ src/sys/arch/alpha/jensenio/jensenio_intr.c	Thu Jul 15 01:43:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: jensenio_intr.c,v 1.17 2021/07/04 22:42:35 thorpej Exp $ */
+/* $NetBSD: jensenio_intr.c,v 1.18 2021/07/15 01:43:54 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: jensenio_intr.c,v 1.17 2021/07/04 22:42:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: jensenio_intr.c,v 1.18 2021/07/15 01:43:54 thorpej Exp $");
 
 #include 
 #include 
@@ -44,6 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: jensenio_int
 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -97,11 +99,12 @@ static inline void
 jensenio_specific_eoi(int irq)
 {
 
-	if (irq > 7)
-		bus_space_write_1(pic_iot, pic_ioh[1],
-		0, 0x20 | (irq & 0x07));
-	bus_space_write_1(pic_iot, pic_ioh[0],
-	0, 0x20 | (irq > 7 ? 2 : irq));
+	if (irq > 7) {
+		bus_space_write_1(pic_iot, pic_ioh[1], PIC_OCW2,
+		OCW2_EOI | OCW2_SL | (irq & 0x07));
+	}
+	bus_space_write_1(pic_iot, pic_ioh[0], PIC_OCW2,
+	OCW2_EOI | OCW2_SL | (irq > 7 ? 2 : irq));
 }
 
 void
@@ -341,12 +344,12 @@ jensenio_enable_intr(int irq, int onoff)
 	pic = irq >> 3;
 	bit = 1 << (irq & 0x7);
 
-	mask = bus_space_read_1(pic_iot, pic_ioh[pic], 1);
+	mask = bus_space_read_1(pic_iot, pic_ioh[pic], PIC_OCW1);
 	if (onoff)
 		mask &= ~bit;
 	else
 		mask |= bit;
-	bus_space_write_1(pic_iot, pic_ioh[pic], 1, mask);
+	bus_space_write_1(pic_iot, pic_ioh[pic], PIC_OCW1, mask);
 }
 
 void
@@ -378,12 +381,15 @@ jensenio_pic_init(void)
 	for (pic = 0; pic < 2; pic++) {
 		if (bus_space_map(pic_iot, picaddr[pic], 2, 0, _ioh[pic]))
 			panic("jensenio_init_intr: unable to map PIC %d", pic);
-		bus_space_write_1(pic_iot, pic_ioh[pic], 1, 0xff);
+		bus_space_write_1(pic_iot, pic_ioh[pic], PIC_OCW1, 0xff);
 	}
 
 	/*
-	 * Map the ELCR registers.
+	 * Map the ELCR registers and initialize all interrupts to EDGE
+	 * trigger.
 	 */
 	if (bus_space_map(pic_iot, 0x4d0, 2, 0, _elcr_ioh))
 		panic("jensenio_init_intr: unable to map ELCR registers");
+	bus_space_write_1(pic_iot, pic_elcr_ioh, 0, 0);
+	bus_space_write_1(pic_iot, pic_elcr_ioh, 1, 0);
 }



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

2021-07-14 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jul 14 13:32:37 UTC 2021

Modified Files:
src/sys/arch/cobalt/conf: std.cobalt
src/sys/arch/pmax/conf: std.pmax std.pmax64

Log Message:
Enable VMSWAP_DEFAULT_PLAINTEXT as default.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/cobalt/conf/std.cobalt
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/pmax/conf/std.pmax
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/pmax/conf/std.pmax64

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/cobalt/conf/std.cobalt
diff -u src/sys/arch/cobalt/conf/std.cobalt:1.15 src/sys/arch/cobalt/conf/std.cobalt:1.16
--- src/sys/arch/cobalt/conf/std.cobalt:1.15	Sun Feb 20 07:54:10 2011
+++ src/sys/arch/cobalt/conf/std.cobalt	Wed Jul 14 13:32:37 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.cobalt,v 1.15 2011/02/20 07:54:10 matt Exp $
+#	$NetBSD: std.cobalt,v 1.16 2021/07/14 13:32:37 thorpej Exp $
 
 machine cobalt mips
 include		"conf/std"	# MI standard options
@@ -9,4 +9,7 @@ options 	MIPS3_ENABLE_CLOCK_INTR
 options 	EXEC_ELF32	# exec ELF32 binaries
 options 	EXEC_SCRIPT	# exec #! scripts
 
+options		VMSWAP_DEFAULT_PLAINTEXT	# do not encrypt swap by
+		# default (slow cpu)
+
 makeoptions	DEFTEXTADDR="0x80001000"

Index: src/sys/arch/pmax/conf/std.pmax
diff -u src/sys/arch/pmax/conf/std.pmax:1.18 src/sys/arch/pmax/conf/std.pmax:1.19
--- src/sys/arch/pmax/conf/std.pmax:1.18	Sun Dec 11 12:18:36 2005
+++ src/sys/arch/pmax/conf/std.pmax	Wed Jul 14 13:32:37 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.pmax,v 1.18 2005/12/11 12:18:36 christos Exp $
+#	$NetBSD: std.pmax,v 1.19 2021/07/14 13:32:37 thorpej Exp $
 # standard, required pmax info
 
 machine pmax mips
@@ -9,4 +9,7 @@ makeoptions	MACHINE_ARCH="mipsel"
 options 	EXEC_ELF32	# 32-bit ELF support (native format)
 options 	EXEC_SCRIPT	# exec of #! scripts
 
+options		VMSWAP_DEFAULT_PLAINTEXT	# do not encrypt swap by
+		# default (slow cpu)
+
 makeoptions	DEFTEXTADDR="0x8003"

Index: src/sys/arch/pmax/conf/std.pmax64
diff -u src/sys/arch/pmax/conf/std.pmax64:1.2 src/sys/arch/pmax/conf/std.pmax64:1.3
--- src/sys/arch/pmax/conf/std.pmax64:1.2	Mon Dec 14 00:46:10 2009
+++ src/sys/arch/pmax/conf/std.pmax64	Wed Jul 14 13:32:37 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.pmax64,v 1.2 2009/12/14 00:46:10 matt Exp $
+#	$NetBSD: std.pmax64,v 1.3 2021/07/14 13:32:37 thorpej Exp $
 # standard, required pmax info
 
 machine pmax mips
@@ -11,5 +11,8 @@ options 	EXEC_ELF32	# 32-bit ELF support
 options 	EXEC_SCRIPT	# exec of #! scripts
 options 	COMPAT_NETBSD32	# exec NetBSD 32-bit binaries
 
+options		VMSWAP_DEFAULT_PLAINTEXT	# do not encrypt swap by
+		# default (slow cpu)
+
 makeoptions	DEFTEXTADDR="0x8003"
 makeoptions	LP64="yes"



CVS commit: src/sys/arch

2021-07-14 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jul 14 13:28:40 UTC 2021

Modified Files:
src/sys/arch/alpha/conf: std.alpha
src/sys/arch/shark/conf: std.ofwgencfg std.shark

Log Message:
Enable VMSWAP_DEFAULT_PLAINTEXT as default.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/alpha/conf/std.alpha
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/shark/conf/std.ofwgencfg
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/shark/conf/std.shark

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/conf/std.alpha
diff -u src/sys/arch/alpha/conf/std.alpha:1.27 src/sys/arch/alpha/conf/std.alpha:1.28
--- src/sys/arch/alpha/conf/std.alpha:1.27	Sat Sep 19 03:27:42 2020
+++ src/sys/arch/alpha/conf/std.alpha	Wed Jul 14 13:28:40 2021
@@ -1,4 +1,4 @@
-# $NetBSD: std.alpha,v 1.27 2020/09/19 03:27:42 thorpej Exp $
+# $NetBSD: std.alpha,v 1.28 2021/07/14 13:28:40 thorpej Exp $
 #
 # Standard/required configuration info for NetBSD/alpha.
 
@@ -15,5 +15,9 @@ options 	EXEC_SCRIPT	# shell script supp
 
 options 	MULTIPROCESSOR		# include multiprocessor support
 
+# Don't encrypt swap by default.  The systems most likely to heavily use
+# swap space have slow CPUs by modern standards.
+options		VMSWAP_DEFAULT_PLAINTEXT
+
 # Atheros HAL options
 include "external/isc/atheros_hal/conf/std.ath_hal"

Index: src/sys/arch/shark/conf/std.ofwgencfg
diff -u src/sys/arch/shark/conf/std.ofwgencfg:1.1 src/sys/arch/shark/conf/std.ofwgencfg:1.2
--- src/sys/arch/shark/conf/std.ofwgencfg:1.1	Sun Feb 10 01:57:04 2002
+++ src/sys/arch/shark/conf/std.ofwgencfg	Wed Jul 14 13:28:40 2021
@@ -1,7 +1,10 @@
-#	$NetBSD: std.ofwgencfg,v 1.1 2002/02/10 01:57:04 thorpej Exp $
+#	$NetBSD: std.ofwgencfg,v 1.2 2021/07/14 13:28:40 thorpej Exp $
 #
 # Configuration options for generic OpenFirmware configurations.
 #
 
+options		VMSWAP_DEFAULT_PLAINTEXT	# do not encrypt swap by
+		# default (slow cpu)
+
 # Pull in OFWGENCFG config definitions.
 include "arch/arm/ofw/files.ofwgencfg"

Index: src/sys/arch/shark/conf/std.shark
diff -u src/sys/arch/shark/conf/std.shark:1.11 src/sys/arch/shark/conf/std.shark:1.12
--- src/sys/arch/shark/conf/std.shark:1.11	Wed Jan 17 20:30:17 2018
+++ src/sys/arch/shark/conf/std.shark	Wed Jul 14 13:28:40 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: std.shark,v 1.11 2018/01/17 20:30:17 skrll Exp $
+#	$NetBSD: std.shark,v 1.12 2021/07/14 13:28:40 thorpej Exp $
 #
 # standard NetBSD/shark options
 
@@ -10,6 +10,9 @@ options 	EXEC_AOUT
 options 	EXEC_ELF32
 options 	EXEC_SCRIPT
 
+options		VMSWAP_DEFAULT_PLAINTEXT	# do not encrypt swap by
+		# default (slow cpu)
+
 # To support easy transit to ../arch/arm/arm32
 options 	ARM32
 options 	_ARM32_NEED_BUS_DMA_BOUNCE



CVS commit: src/sys/arch/alpha

2021-07-13 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jul 14 02:18:10 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: lock_stubs.s
src/sys/arch/alpha/include: mutex.h

Log Message:
Disable the mutex_spin_{enter,exit}() fast-path stubs while I investigate
some an odd IPL-related panic that seems to be related (that I can fairly
reliabily reproduce on an LCA45).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/alpha/lock_stubs.s
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/alpha/include/mutex.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/lock_stubs.s
diff -u src/sys/arch/alpha/alpha/lock_stubs.s:1.8 src/sys/arch/alpha/alpha/lock_stubs.s:1.9
--- src/sys/arch/alpha/alpha/lock_stubs.s:1.8	Tue Jul 13 13:58:30 2021
+++ src/sys/arch/alpha/alpha/lock_stubs.s	Wed Jul 14 02:18:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.8 2021/07/13 13:58:30 thorpej Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.9 2021/07/14 02:18:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.8 2021/07/13 13:58:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.9 2021/07/14 02:18:10 thorpej Exp $");
 
 #include "assym.h"
 
@@ -114,6 +114,7 @@ LEAF(mutex_exit, 1)
 	br	1b
 	END(mutex_exit)
 
+#if 0 /* XXX disabled for now XXX */
 /*
  * void mutex_spin_enter(kmutex_t *mtx);
  */
@@ -227,6 +228,7 @@ LEAF(mutex_spin_exit, 1)
 1:
 	RET
 	END(mutex_spin_exit)
+#endif /* XXX disabled for now XXX */
 
 /*
  * void rw_enter(krwlock_t *rwl, krw_t op);
@@ -399,8 +401,10 @@ lock_stub_patch_table:
 #if !defined(LOCKDEBUG)
 	.quad	.L_mutex_enter_mb_1
 	.quad	.L_mutex_exit_mb_1
+#if 0 /* XXX disabled for now XXX */
 	.quad	.L_mutex_spin_enter_mb_1
 	.quad	.L_mutex_spin_exit_mb_1
+#endif /* XXX disabled for now XXX */
 	.quad	.L_rw_enter_mb_1
 	.quad	.L_rw_enter_mb_2
 	.quad	.L_rw_tryenter_mb_1

Index: src/sys/arch/alpha/include/mutex.h
diff -u src/sys/arch/alpha/include/mutex.h:1.9 src/sys/arch/alpha/include/mutex.h:1.10
--- src/sys/arch/alpha/include/mutex.h:1.9	Mon Jul 12 15:21:51 2021
+++ src/sys/arch/alpha/include/mutex.h	Wed Jul 14 02:18:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mutex.h,v 1.9 2021/07/12 15:21:51 thorpej Exp $	*/
+/*	$NetBSD: mutex.h,v 1.10 2021/07/14 02:18:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@ struct kmutex {
 
 #define	__HAVE_SIMPLE_MUTEXES		1
 #define	__HAVE_MUTEX_STUBS		1
-#define	__HAVE_SPIN_MUTEX_STUBS		1
+/* XXX #define	__HAVE_SPIN_MUTEX_STUBS		1 XXX */
 
 #define	MUTEX_CAS(p, o, n)		_lock_cas((p), (o), (n))
 



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

2021-07-13 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jul 13 13:58:30 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: lock_stubs.s

Log Message:
Fix non-MULTIPROCESSOR build (e.g. INSTALL kernel).


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

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/lock_stubs.s
diff -u src/sys/arch/alpha/alpha/lock_stubs.s:1.7 src/sys/arch/alpha/alpha/lock_stubs.s:1.8
--- src/sys/arch/alpha/alpha/lock_stubs.s:1.7	Tue Jul 13 01:59:10 2021
+++ src/sys/arch/alpha/alpha/lock_stubs.s	Tue Jul 13 13:58:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.7 2021/07/13 01:59:10 thorpej Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.8 2021/07/13 13:58:30 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.7 2021/07/13 01:59:10 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.8 2021/07/13 13:58:30 thorpej Exp $");
 
 #include "assym.h"
 
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: lock_stubs.s
  */
 #define	MB(label)	label: unop
 #else
-#define	MB		/* nothing */
+#define	MB(label)	/* nothing */
 #endif
 
 /*



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

2021-07-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue Jul 13 01:59:10 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: lock_stubs.s patch.c

Log Message:
As with membar_producer() and membar_sync(), initialize the fast-path
lock stubs with "unop" isns where memory barriers need to be, and if
we detect a multiprocessor system, patch those locations with "mb" insns.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/alpha/alpha/lock_stubs.s \
src/sys/arch/alpha/alpha/patch.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/lock_stubs.s
diff -u src/sys/arch/alpha/alpha/lock_stubs.s:1.6 src/sys/arch/alpha/alpha/lock_stubs.s:1.7
--- src/sys/arch/alpha/alpha/lock_stubs.s:1.6	Mon Jul 12 15:21:51 2021
+++ src/sys/arch/alpha/alpha/lock_stubs.s	Tue Jul 13 01:59:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.6 2021/07/12 15:21:51 thorpej Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.7 2021/07/13 01:59:10 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
@@ -34,12 +34,16 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.6 2021/07/12 15:21:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.7 2021/07/13 01:59:10 thorpej Exp $");
 
 #include "assym.h"
 
 #if defined(MULTIPROCESSOR)
-#define	MB		mb
+/*
+ * These 'unop' insns will be patched with 'mb' insns at run-time if
+ * the system has more than one processor.
+ */
+#define	MB(label)	label: unop
 #else
 #define	MB		/* nothing */
 #endif
@@ -55,11 +59,11 @@ LEAF(_lock_cas, 3)
 	beq	t1, 2f
 	stq_c	v0, 0(a0)
 	beq	v0, 3f
-	MB	
+	MB(.L__lock_cas_mb_1)
 	RET
 2:
 	mov	zero, v0
-	MB
+	MB(.L__lock_cas_mb_2)
 	RET
 3:
 	br	1b
@@ -79,7 +83,7 @@ LEAF(mutex_enter, 1)
 	bne	t2, 2f
 	stq_c	t1, 0(a0)
 	beq	t1, 3f
-	MB
+	MB(.L_mutex_enter_mb_1)
 	RET
 2:
 	lda	t12, mutex_vector_enter
@@ -93,7 +97,7 @@ LEAF(mutex_enter, 1)
  */
 LEAF(mutex_exit, 1)
 	LDGP(pv)
-	MB
+	MB(.L_mutex_exit_mb_1)
 	GET_CURLWP	/* Note: GET_CURLWP clobbers v0, t0, t8...t11. */
 	mov	zero, t3
 1:
@@ -179,7 +183,7 @@ LEAF(mutex_spin_enter, 1);
 	bne	t0, 2f			/* contended */
 	stl_c	t1, MUTEX_SIMPLELOCK(a1)
 	beq	t1, 2f			/* STL_C failed; consider contended */
-	MB
+	MB(.L_mutex_spin_enter_mb_1)
 	RET
 2:
 	mov	a1, a0			/* restore first argument */
@@ -192,7 +196,7 @@ LEAF(mutex_spin_enter, 1);
  */
 LEAF(mutex_spin_exit, 1)
 	LDGP(pv);
-	MB
+	MB(.L_mutex_spin_exit_mb_1)
 
 	/*
 	 * STEP 1: __cpu_simple_unlock(>mtx_lock)
@@ -247,7 +251,7 @@ LEAF(rw_enter, 2)
 	bne	t1, 4f		/* contended */
 	stq_c	t2, 0(a0)
 	beq	t2, 2f		/* STQ_C failed; retry */
-	MB
+	MB(.L_rw_enter_mb_1)
 	RET
 
 2:	br	1b
@@ -259,7 +263,7 @@ LEAF(rw_enter, 2)
 	bne	t0, 4f		/* contended */
 	stq_c	t2, 0(a0)
 	beq	t2, 4f		/* STQ_C failed; consider it contended */
-	MB
+	MB(.L_rw_enter_mb_2)
 	RET
 
 4:	lda	pv, rw_vector_enter
@@ -284,7 +288,7 @@ LEAF(rw_tryenter, 2)
 	bne	t1, 4f		/* contended */
 	stq_c	v0, 0(a0)
 	beq	v0, 2f		/* STQ_C failed; retry */
-	MB
+	MB(.L_rw_tryenter_mb_1)
 	RET			/* v0 contains non-zero LOCK_FLAG from STQ_C */
 
 2:	br	1b
@@ -302,7 +306,7 @@ LEAF(rw_tryenter, 2)
 	 * in the failure case because we expect it to be rare and it saves
 	 * a branch-not-taken instruction in the success case.
 	 */
-	MB
+	MB(.L_rw_tryenter_mb_2)
 	RET
 
 4:	mov	zero, v0	/* return 0 (failure) */
@@ -316,7 +320,7 @@ LEAF(rw_tryenter, 2)
  */
 LEAF(rw_exit, 1)
 	LDGP(pv)
-	MB
+	MB(.L_rw_exit_mb_1)
 
 	/*
 	 * Check for write-lock release, and get the owner/count field
@@ -381,3 +385,27 @@ LEAF(rw_exit, 1)
 	END(rw_exit)
 
 #endif	/* !LOCKDEBUG */
+
+#if defined(MULTIPROCESSOR)
+/*
+ * Table of locations to patch with MB instructions on multiprocessor
+ * systems.
+ */
+	.section ".rodata"
+	.globl	lock_stub_patch_table
+lock_stub_patch_table:
+	.quad	.L__lock_cas_mb_1
+	.quad	.L__lock_cas_mb_2
+#if !defined(LOCKDEBUG)
+	.quad	.L_mutex_enter_mb_1
+	.quad	.L_mutex_exit_mb_1
+	.quad	.L_mutex_spin_enter_mb_1
+	.quad	.L_mutex_spin_exit_mb_1
+	.quad	.L_rw_enter_mb_1
+	.quad	.L_rw_enter_mb_2
+	.quad	.L_rw_tryenter_mb_1
+	.quad	.L_rw_tryenter_mb_2
+	.quad	.L_rw_exit_mb_1
+#endif /* ! LOCKDEBUG */
+	.quad	0		/* NULL terminator */
+#endif /* MULTIPROCESSOR */
Index: src/sys/arch/alpha/alpha/patch.c
diff -u src/sys/arch/alpha/alpha/patch.c:1.6 src/sys/arch/alpha/alpha/patch.c:1.7
--- src/sys/arch/alpha/alpha/patch.c:1.6	Wed Jul  7 03:30:35 2021
+++ src/sys/arch/alpha/alpha/patch.c	Tue Jul 13 01:59:10 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: patch.c,v 1.6 2021/07/07 03:30:35 thorpej Exp $	*/
+/*	$NetBSD: patch.c,v 1.7 2021/07/13 01:59:10 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: patch.c,v 

CVS commit: src/sys/arch/alpha

2021-07-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jul 12 15:21:51 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: genassym.cf lock_stubs.s
src/sys/arch/alpha/include: mutex.h

Log Message:
Optimized fast-paths for mutex_spin_enter() and mutex_spin_exit().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/alpha/alpha/genassym.cf
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/alpha/lock_stubs.s
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/alpha/include/mutex.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/genassym.cf
diff -u src/sys/arch/alpha/alpha/genassym.cf:1.29 src/sys/arch/alpha/alpha/genassym.cf:1.30
--- src/sys/arch/alpha/alpha/genassym.cf:1.29	Sun Jul 11 01:58:41 2021
+++ src/sys/arch/alpha/alpha/genassym.cf	Mon Jul 12 15:21:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.29 2021/07/11 01:58:41 thorpej Exp $
+# $NetBSD: genassym.cf,v 1.30 2021/07/12 15:21:51 thorpej Exp $
 
 #
 # Copyright (c) 1982, 1990, 1993
@@ -67,6 +67,7 @@
 #
 
 quote #define __RWLOCK_PRIVATE
+quote #define __MUTEX_PRIVATE
 
 include 
 include 
@@ -75,6 +76,7 @@ include 
 include 
 include 
 include 
+include 
 include 
 
 include 
@@ -198,6 +200,7 @@ define	CPU_INFO_CURLWP		offsetof(struct 
 define	CPU_INFO_IDLE_LWP	offsetof(struct cpu_info, ci_data.cpu_idlelwp)
 define	CPU_INFO_SSIR		offsetof(struct cpu_info, ci_ssir)
 define	CPU_INFO_MTX_COUNT	offsetof(struct cpu_info, ci_mtx_count)
+define	CPU_INFO_MTX_OLDSPL	offsetof(struct cpu_info, ci_mtx_oldspl)
 define	CPU_INFO_SIZEOF		sizeof(struct cpu_info)
 
 # Bits in lock fields
@@ -205,3 +208,6 @@ define	RW_WRITE_WANTED		RW_WRITE_WANTED
 define	RW_WRITE_LOCKED		RW_WRITE_LOCKED
 define	RW_READ_INCR		RW_READ_INCR
 define	RW_READ_COUNT_SHIFT	RW_READ_COUNT_SHIFT
+define	MUTEX_IPL		offsetof(struct kmutex, mtx_ipl)
+define	MUTEX_SIMPLELOCK	offsetof(struct kmutex, mtx_lock)
+define	__SIMPLELOCK_LOCKED	__SIMPLELOCK_LOCKED

Index: src/sys/arch/alpha/alpha/lock_stubs.s
diff -u src/sys/arch/alpha/alpha/lock_stubs.s:1.5 src/sys/arch/alpha/alpha/lock_stubs.s:1.6
--- src/sys/arch/alpha/alpha/lock_stubs.s:1.5	Sun Jul 11 01:58:41 2021
+++ src/sys/arch/alpha/alpha/lock_stubs.s	Mon Jul 12 15:21:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock_stubs.s,v 1.5 2021/07/11 01:58:41 thorpej Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.6 2021/07/12 15:21:51 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.5 2021/07/11 01:58:41 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.6 2021/07/12 15:21:51 thorpej Exp $");
 
 #include "assym.h"
 
@@ -111,6 +111,120 @@ LEAF(mutex_exit, 1)
 	END(mutex_exit)
 
 /*
+ * void mutex_spin_enter(kmutex_t *mtx);
+ */
+LEAF(mutex_spin_enter, 1);
+	LDGP(pv)
+
+	/*
+	 * STEP 1: Perform the MUTEX_SPIN_SPLRAISE() function.
+	 * (see sys/kern/kern_mutex.c)
+	 *
+	 *	s = splraise(mtx->mtx_ipl);
+	 *	if (curcpu->ci_mtx_count-- == 0)
+	 *		curcpu->ci_mtx_oldspl = s;
+	 */
+
+	call_pal PAL_OSF1_rdps		/* clobbers v0, t0, t8..t11 */
+	/* v0 = cur_ipl */
+#ifdef __BWX__
+	mov	a0, a1			/* a1 = mtx */
+	ldbu	a0, MUTEX_IPL(a0)	/* a0 = new_ipl */
+	mov	v0, a4			/* save cur_ipl in a4 */
+#else
+	mov	a0, a1			/* a1 = mtx */
+	ldq_u	a2, MUTEX_IPL(a0)
+	mov	v0, a4			/* save cur_ipl in a4 */
+	extbl	a2, MUTEX_IPL, a0	/* a0 = new_ipl */
+#endif /* __BWX__ */
+	cmplt	v0, a0, a3		/* a3 = (cur_ipl < new_ipl) */
+	GET_CURLWP	/* Note: GET_CURLWP clobbers v0, t0, t8...t11. */
+	mov	v0, a5			/* save curlwp in a5 */
+	/*
+	 * The forward-branch over the SWPIPL call is correctly predicted
+	 * not-taken by the CPU because it's rare for a code path to acquire
+	 * 2 spin mutexes.
+	 */
+	beq	a3, 1f			/*  no? -> skip... */
+	call_pal PAL_OSF1_swpipl	/* clobbers v0, t0, t8..t11 */
+	/*
+	 * v0 returns the old_ipl, which will be the same as the
+	 * cur_ipl we squirreled away in a4 earlier.
+	 */
+1:
+	/*
+	 * curlwp->l_cpu is now stable.  Update the counter and
+	 * stash the old_ipl.  Just in case it's not clear what's
+	 * going on, we:
+	 *
+	 *	- Load previous value of mtx_oldspl into t1.
+	 *	- Conditionally move old_ipl into t1 if mtx_count == 0.
+	 *	- Store t1 back to mtx_oldspl; if mtx_count != 0,
+	 *	  the store is redundant, but it's faster than a forward
+	 *	  branch.
+	 */
+	ldq	a3, L_CPU(a5)		/* a3 = curlwp->l_cpu (curcpu) */
+	ldl	t0, CPU_INFO_MTX_COUNT(a3)
+	ldl	t1, CPU_INFO_MTX_OLDSPL(a3)
+	cmoveq	t0, a4, t1		/* mtx_count == 0? -> t1 = old_ipl */
+	subl	t0, 1, t2		/* mtx_count-- */
+	stl	t1, CPU_INFO_MTX_OLDSPL(a3)
+	stl	t2, CPU_INFO_MTX_COUNT(a3)
+
+	/*
+	 * STEP 2: __cpu_simple_lock_try(>mtx_lock)
+	 */
+	ldl_l	t0, MUTEX_SIMPLELOCK(a1)
+	ldiq	t1, __SIMPLELOCK_LOCKED
+	bne	t0, 2f			/* contended */
+	stl_c	t1, MUTEX_SIMPLELOCK(a1)
+	beq	t1, 2f			/* STL_C failed; consider contended */
+	MB
+	RET
+2:
+	mov	

CVS commit: src/sys/arch/hppa/dev

2021-07-11 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jul 11 13:36:02 UTC 2021

Modified Files:
src/sys/arch/hppa/dev: sti_sgc.c

Log Message:
Fix silent freeze on probing sti(4) framebuffer on 712/60.  PR/52162

Ok'ed by skrll@.
Should be pulled up to netbsd-9 and netbsd-8.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/dev/sti_sgc.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/hppa/dev/sti_sgc.c
diff -u src/sys/arch/hppa/dev/sti_sgc.c:1.2 src/sys/arch/hppa/dev/sti_sgc.c:1.3
--- src/sys/arch/hppa/dev/sti_sgc.c:1.2	Mon Apr 15 20:40:37 2019
+++ src/sys/arch/hppa/dev/sti_sgc.c	Sun Jul 11 13:36:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti_sgc.c,v 1.2 2019/04/15 20:40:37 skrll Exp $	*/
+/*	$NetBSD: sti_sgc.c,v 1.3 2021/07/11 13:36:02 tsutsui Exp $	*/
 
 /*	$OpenBSD: sti_sgc.c,v 1.38 2009/02/06 22:51:04 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.2 2019/04/15 20:40:37 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti_sgc.c,v 1.3 2021/07/11 13:36:02 tsutsui Exp $");
 
 #include "opt_cputype.h"
 
@@ -73,6 +73,16 @@ extern int stidebug;
 #define	STI_ROMSIZE	(sizeof(struct sti_dd) * 4)
 #define	STI_ID_FDDI	0x280b31af	/* Medusa FDDI ROM id */
 
+/*
+ * hpa addresses to check on-board variants
+ * XXX should check via device_register(9)?
+ * 
+ * 0xf400: HPA1991AC19 on 715/33, 715/50
+ * 0xf800: HPA1439A on 735/99, HPA208LCxxx on 715/80, 715/100, 712
+ */
+#define	STI_ONBOARD_HPA0	0xf400
+#define	STI_ONBOARD_HPA1	0xf800
+
 /* gecko optional graphics */
 #define	STI_GOPT1_REV	0x17
 #define	STI_GOPT2_REV	0x70
@@ -118,7 +128,9 @@ sti_sgc_getrom(struct confargs *ca)
 	rom = PAGE0->pd_resv2[1];
 	hppa_pagezero_unmap(pagezero_cookie);
 
-	if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC) {
+	if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
+	ca->ca_hpa != STI_ONBOARD_HPA0 &&
+	ca->ca_hpa != STI_ONBOARD_HPA1) {
 		int i;
 		for (i = sizeof(sti_sgc_opt); i--; )
 			if (sti_sgc_opt[i] == ca->ca_type.iodc_revision)



CVS commit: src/sys/arch/hp300/dev

2021-07-11 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jul 11 13:00:53 UTC 2021

Modified Files:
src/sys/arch/hp300/dev: rd.c rdreg.h

Log Message:
Add Device and drive info of 2202A, 7908A, 7911A, and 7941A.

Geometries and description info are taken from hpdrive.ini.sample
in HPDrive.  Briefly tested on HPDisk.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/sys/arch/hp300/dev/rd.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hp300/dev/rdreg.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/hp300/dev/rd.c
diff -u src/sys/arch/hp300/dev/rd.c:1.108 src/sys/arch/hp300/dev/rd.c:1.109
--- src/sys/arch/hp300/dev/rd.c:1.108	Fri Jul  9 17:05:33 2021
+++ src/sys/arch/hp300/dev/rd.c	Sun Jul 11 13:00:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rd.c,v 1.108 2021/07/09 17:05:33 tsutsui Exp $	*/
+/*	$NetBSD: rd.c,v 1.109 2021/07/11 13:00:52 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -72,7 +72,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.108 2021/07/09 17:05:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rd.c,v 1.109 2021/07/11 13:00:52 tsutsui Exp $");
 
 #include "opt_useleds.h"
 
@@ -355,6 +355,42 @@ static const struct rdidentinfo rdidenti
 		.ri_ntpc = NRD2203ATRK,
 		.ri_ncyl = 1449,
 		.ri_nblocks = 1309896
+	},
+
+	[RD2202A] = {
+		.ri_hwid = RD2202AID,
+		.ri_desc = "2202A",
+		.ri_nbpt = NRD2202ABPT,
+		.ri_ntpc = NRD2202ATRK,
+		.ri_ncyl = 1449,
+		.ri_nblocks = 1309896
+	},
+
+	[RD7908A] = {
+		.ri_hwid = RD7908AID,
+		.ri_desc = "7908A",
+		.ri_nbpt = NRD7908ABPT,
+		.ri_ntpc = NRD7908ATRK,
+		.ri_ncyl = 185,
+		.ri_nblocks = 32375
+	},
+
+	[RD7911A] = {
+		.ri_hwid = RD7911AID,
+		.ri_desc = "7911A",
+		.ri_nbpt = NRD7911ABPT,
+		.ri_ntpc = NRD7911ATRK,
+		.ri_ncyl = 572,
+		.ri_nblocks = 54912
+	},
+
+	[RD7941A] = {
+		.ri_hwid = RD7946AID,
+		.ri_desc = "7941A",
+		.ri_nbpt = NRD7941ABPT,
+		.ri_ntpc = NRD7941ATRK,
+		.ri_ncyl = 968,
+		.ri_nblocks = 46464
 	}
 };
 static const int numrdidentinfo = __arraycount(rdidentinfo);
@@ -380,7 +416,11 @@ static const struct rdname2id rdname2id[
 	{ RD7958BNAME,	RD7958B },
 	{ RD7959BNAME,	RD7959B },
 	{ RD2200ANAME,	RD2200A },
-	{ RD2203ANAME,	RD2203A }
+	{ RD2203ANAME,	RD2203A },
+	{ RD2202ANAME,	RD2202A },
+	{ RD7908ANAME,	RD7908A },
+	{ RD7911ANAME,	RD7911A },
+	{ RD7941ANAME,	RD7941A }
 };
 static const int numrdname2id = __arraycount(rdname2id);
 
@@ -618,7 +658,7 @@ rdident(device_t parent, struct rd_softc
 
 	/*
 	 * Take care of a couple of anomolies:
-	 * 1. 7945A and 7946A both return same HW id
+	 * 1. 7945A, 7946A, and 7941A all return same HW id
 	 * 2. 9122S and 9134D both return same HW id
 	 * 3. 9122D and 9134L both return same HW id
 	 */
@@ -626,6 +666,8 @@ rdident(device_t parent, struct rd_softc
 	case RD7946AID:
 		if (memcmp(name, RD7945ANAME, RDNAMELEN) == 0)
 			id = RD7945A;
+		else if (memcmp(name, RD7941ANAME, RDNAMELEN) == 0)
+			id = RD7941A;
 		else
 			id = RD7946A;
 		break;

Index: src/sys/arch/hp300/dev/rdreg.h
diff -u src/sys/arch/hp300/dev/rdreg.h:1.16 src/sys/arch/hp300/dev/rdreg.h:1.17
--- src/sys/arch/hp300/dev/rdreg.h:1.16	Fri Jul  9 17:05:33 2021
+++ src/sys/arch/hp300/dev/rdreg.h	Sun Jul 11 13:00:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rdreg.h,v 1.16 2021/07/09 17:05:33 tsutsui Exp $	*/
+/*	$NetBSD: rdreg.h,v 1.17 2021/07/11 13:00:52 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -104,7 +104,7 @@ struct	rd_clearcmd {
 } __attribute__((__packed__));
 
 /* HW ids */
-#define	RD7946AID	0x220	/* also 7945A */
+#define	RD7946AID	0x220	/* also 7945A and 7941A */
 #define	RD9134DID	0x221	/* also 9122S */
 #define	RD9134LID	0x222	/* also 9122D */
 #define	RD7912PID	0x209
@@ -120,6 +120,9 @@ struct	rd_clearcmd {
 #define	RD7959BID	0x22E	/* another guess based on 7958B */
 #define	RD2200AID	0x22F
 #define	RD2203AID	0x230	/* yet another guess */
+#define	RD2202AID	0x231	/* from hpdrive.ini.sample */
+#define	RD7908AID	0x200	/* from hpdrive.ini.sample */
+#define	RD7911AID	0x204	/* from hpdrive.ini.sample */
 
 /* Drive names -- per identify description structure */
 #define	RD7945ANAME	"079450"
@@ -140,6 +143,10 @@ struct	rd_clearcmd {
 #define	RD7959BNAME	"079591"
 #define	RD2200ANAME	"022000"
 #define	RD2203ANAME	"022030"
+#define	RD2202ANAME	"022020"
+#define	RD7908ANAME	"079080"
+#define	RD7911ANAME	"079110"
+#define	RD7941ANAME	"079410"
 
 #define	RDNAMELEN	6
 
@@ -163,6 +170,10 @@ struct	rd_clearcmd {
 #define	RD7959B		16
 #define	RD2200A		17
 #define	RD2203A		18
+#define	RD2202A		19
+#define	RD7908A		20
+#define	RD7911A		21
+#define	RD7941A		22
 
 #define	NRD7945ABPT	16
 #define	NRD7945ATRK	7
@@ -178,6 +189,10 @@ struct	rd_clearcmd {
 #define	NRD7933HTRK	13
 #define	NRD9134LBPT	16
 #define	NRD9134LTRK	5
+#define	NRD7911ABPT	32
+#define	NRD7911ATRK	3
+#define	NRD7941ABPT	16
+#define	NRD7941ATRK	3
 
 /*
  * Several HP 

CVS commit: src/sys/arch/alpha

2021-07-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 11 01:58:41 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: genassym.cf lock_stubs.s machdep.c
src/sys/arch/alpha/include: rwlock.h

Log Message:
Optimized fast-paths for rw_enter() / rw_tryenter() / rw_exit().


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/alpha/alpha/genassym.cf
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/alpha/alpha/lock_stubs.s
cvs rdiff -u -r1.373 -r1.374 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/alpha/include/rwlock.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/genassym.cf
diff -u src/sys/arch/alpha/alpha/genassym.cf:1.28 src/sys/arch/alpha/alpha/genassym.cf:1.29
--- src/sys/arch/alpha/alpha/genassym.cf:1.28	Sun Jul 11 01:54:42 2021
+++ src/sys/arch/alpha/alpha/genassym.cf	Sun Jul 11 01:58:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.28 2021/07/11 01:54:42 thorpej Exp $
+# $NetBSD: genassym.cf,v 1.29 2021/07/11 01:58:41 thorpej Exp $
 
 #
 # Copyright (c) 1982, 1990, 1993
@@ -66,12 +66,15 @@
 #	from: @(#)genassym.c	8.3 (Berkeley) 1/4/94
 #
 
+quote #define __RWLOCK_PRIVATE
+
 include 
 include 
 include 
 include 
 include 
 include 
+include 
 include 
 
 include 
@@ -196,3 +199,9 @@ define	CPU_INFO_IDLE_LWP	offsetof(struct
 define	CPU_INFO_SSIR		offsetof(struct cpu_info, ci_ssir)
 define	CPU_INFO_MTX_COUNT	offsetof(struct cpu_info, ci_mtx_count)
 define	CPU_INFO_SIZEOF		sizeof(struct cpu_info)
+
+# Bits in lock fields
+define	RW_WRITE_WANTED		RW_WRITE_WANTED
+define	RW_WRITE_LOCKED		RW_WRITE_LOCKED
+define	RW_READ_INCR		RW_READ_INCR
+define	RW_READ_COUNT_SHIFT	RW_READ_COUNT_SHIFT

Index: src/sys/arch/alpha/alpha/lock_stubs.s
diff -u src/sys/arch/alpha/alpha/lock_stubs.s:1.4 src/sys/arch/alpha/alpha/lock_stubs.s:1.5
--- src/sys/arch/alpha/alpha/lock_stubs.s:1.4	Fri Sep  4 02:54:56 2020
+++ src/sys/arch/alpha/alpha/lock_stubs.s	Sun Jul 11 01:58:41 2021
@@ -1,11 +1,11 @@
-/*	$NetBSD: lock_stubs.s,v 1.4 2020/09/04 02:54:56 thorpej Exp $	*/
+/*	$NetBSD: lock_stubs.s,v 1.5 2021/07/11 01:58:41 thorpej Exp $	*/
 
 /*-
- * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2021 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Andrew Doran.
+ * by Andrew Doran, and by Jason R. Thorpe.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -34,7 +34,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.4 2020/09/04 02:54:56 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lock_stubs.s,v 1.5 2021/07/11 01:58:41 thorpej Exp $");
 
 #include "assym.h"
 
@@ -63,7 +63,7 @@ LEAF(_lock_cas, 3)
 	RET
 3:
 	br	1b
-END(_lock_cas)
+	END(_lock_cas)
 
 #if !defined(LOCKDEBUG)
 
@@ -72,7 +72,7 @@ END(_lock_cas)
  */
 LEAF(mutex_enter, 1)
 	LDGP(pv)
-	GET_CURLWP
+	GET_CURLWP	/* Note: GET_CURLWP clobbers v0, t0, t8...t11. */
 1:
 	mov	v0, t1
 	ldq_l	t2, 0(a0)
@@ -86,7 +86,7 @@ LEAF(mutex_enter, 1)
 	jmp	(t12)
 3:
 	br	1b
-END(mutex_enter)
+	END(mutex_enter)
 
 /*
  * void mutex_exit(kmutex_t *mtx);
@@ -94,7 +94,7 @@ END(mutex_enter)
 LEAF(mutex_exit, 1)
 	LDGP(pv)
 	MB
-	GET_CURLWP
+	GET_CURLWP	/* Note: GET_CURLWP clobbers v0, t0, t8...t11. */
 	mov	zero, t3
 1:
 	ldq_l	t2, 0(a0)
@@ -108,6 +108,162 @@ LEAF(mutex_exit, 1)
 	jmp	(t12)
 3:
 	br	1b
-END(mutex_exit)
+	END(mutex_exit)
+
+/*
+ * void rw_enter(krwlock_t *rwl, krw_t op);
+ *
+ * Acquire one hold on a RW lock.
+ */
+LEAF(rw_enter, 2)
+	LDGP(pv)
+
+	/*
+	 * RW_READER == 0 (we have a compile-time assert in machdep.c
+	 * to ensure this).
+	 *
+	 * Acquire for read is the most common case.
+	 */
+	bne	a1, 3f
+
+	/* Acquiring for read. */
+1:	ldq_l	t0, 0(a0)
+	and	t0, (RW_WRITE_LOCKED|RW_WRITE_WANTED), t1
+	addq	t0, RW_READ_INCR, t2
+	bne	t1, 4f		/* contended */
+	stq_c	t2, 0(a0)
+	beq	t2, 2f		/* STQ_C failed; retry */
+	MB
+	RET
+
+2:	br	1b
+
+3:	/* Acquiring for write. */
+	GET_CURLWP	/* Note: GET_CURLWP clobbers v0, t0, t8...t11. */
+	ldq_l	t0, 0(a0)
+	or	v0, RW_WRITE_LOCKED, t2
+	bne	t0, 4f		/* contended */
+	stq_c	t2, 0(a0)
+	beq	t2, 4f		/* STQ_C failed; consider it contended */
+	MB
+	RET
+
+4:	lda	pv, rw_vector_enter
+	jmp	(pv)
+	END(rw_enter)
+
+/*
+ * int rw_tryenter(krwlock_t *rwl, krw_t op);
+ *
+ * Try to acquire one hold on a RW lock.
+ */
+LEAF(rw_tryenter, 2)
+	LDGP(pv)
+
+	/* See above. */
+	bne	a1, 3f
+
+	/* Acquiring for read. */
+1:	ldq_l	t0, 0(a0)
+	and	t0, (RW_WRITE_LOCKED|RW_WRITE_WANTED), t1
+	addq	t0, RW_READ_INCR, v0
+	bne	t1, 4f		/* contended */
+	stq_c	v0, 0(a0)
+	beq	v0, 2f		/* STQ_C failed; retry */
+	MB
+	RET			/* v0 contains non-zero LOCK_FLAG from STQ_C */
+
+2:	br	1b
+
+	/* Acquiring for write. */
+3:	GET_CURLWP	/* Note: GET_CURLWP clobbers v0, t0, 

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

2021-07-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 11 01:55:51 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: locore.s

Log Message:
Pull in pmap_subr.s (missed in prior commit).


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/sys/arch/alpha/alpha/locore.s

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/locore.s
diff -u src/sys/arch/alpha/alpha/locore.s:1.139 src/sys/arch/alpha/alpha/locore.s:1.140
--- src/sys/arch/alpha/alpha/locore.s:1.139	Wed Jul  7 03:30:35 2021
+++ src/sys/arch/alpha/alpha/locore.s	Sun Jul 11 01:55:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.139 2021/07/07 03:30:35 thorpej Exp $ */
+/* $NetBSD: locore.s,v 1.140 2021/07/11 01:55:51 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.139 2021/07/07 03:30:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.140 2021/07/11 01:55:51 thorpej Exp $");
 
 #include "assym.h"
 
@@ -217,6 +217,15 @@ NESTED_NOPROFILE(locorestart,1,0,ra,0,0)
 
 /**/
 
+/*
+ * Pull in optimized pmap subroutines.
+ */
+#include 
+
+/**/
+
+/**/
+
 	.text
 .stabs	__FILE__,132,0,0,backtolocore1	/* done with includes */
 .loc	1 __LINE__



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

2021-07-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jul 11 01:54:42 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: genassym.cf

Log Message:
Define ALPHA_PGBYTES (missed in prior commit).


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

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/genassym.cf
diff -u src/sys/arch/alpha/alpha/genassym.cf:1.27 src/sys/arch/alpha/alpha/genassym.cf:1.28
--- src/sys/arch/alpha/alpha/genassym.cf:1.27	Sat Sep 19 01:24:31 2020
+++ src/sys/arch/alpha/alpha/genassym.cf	Sun Jul 11 01:54:42 2021
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.27 2020/09/19 01:24:31 thorpej Exp $
+# $NetBSD: genassym.cf,v 1.28 2021/07/11 01:54:42 thorpej Exp $
 
 #
 # Copyright (c) 1982, 1990, 1993
@@ -84,6 +84,7 @@ include 
 
 # general constants 
 define	VM_MAX_ADDRESS		VM_MAX_ADDRESS
+define	ALPHA_PGBYTES		ALPHA_PGBYTES
 
 # Register offsets, for stack frames.
 define	FRAME_V0		FRAME_V0



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

2021-07-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jul 10 20:22:38 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: pmap.c
Added Files:
src/sys/arch/alpha/alpha: pmap_subr.s

Log Message:
Move the optimized pmap_zero_page() from pmap.c to a new pmap_subr.s,
and optimize it a teeny bit little more.  Provide an optimized (for 21164,
anyway) pmap_copy_page() as well.


To generate a diff of this commit:
cvs rdiff -u -r1.296 -r1.297 src/sys/arch/alpha/alpha/pmap.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/alpha/pmap_subr.s

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/pmap.c
diff -u src/sys/arch/alpha/alpha/pmap.c:1.296 src/sys/arch/alpha/alpha/pmap.c:1.297
--- src/sys/arch/alpha/alpha/pmap.c:1.296	Mon Jul  5 15:12:00 2021
+++ src/sys/arch/alpha/alpha/pmap.c	Sat Jul 10 20:22:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.296 2021/07/05 15:12:00 thorpej Exp $ */
+/* $NetBSD: pmap.c,v 1.297 2021/07/10 20:22:37 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.296 2021/07/05 15:12:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.297 2021/07/10 20:22:37 thorpej Exp $");
 
 #include 
 #include 
@@ -2758,85 +2758,9 @@ pmap_deactivate(struct lwp *l)
 	pmap_destroy(pmap);
 }
 
-/*
- * pmap_zero_page:		[ INTERFACE ]
- *
- *	Zero the specified (machine independent) page by mapping the page
- *	into virtual memory and clear its contents, one machine dependent
- *	page at a time.
- *
- *	Note: no locking is necessary in this function.
- */
-void
-pmap_zero_page(paddr_t phys)
-{
-	u_long *p0, *p1, *pend;
-
-#ifdef DEBUG
-	if (pmapdebug & PDB_FOLLOW)
-		printf("pmap_zero_page(%lx)\n", phys);
-#endif
-
-	p0 = (u_long *)ALPHA_PHYS_TO_K0SEG(phys);
-	p1 = NULL;
-	pend = (u_long *)((u_long)p0 + PAGE_SIZE);
-
-	/*
-	 * Unroll the loop a bit, doing 16 quadwords per iteration.
-	 * Do only 8 back-to-back stores, and alternate registers.
-	 */
-	do {
-		__asm volatile(
-		"# BEGIN loop body\n"
-		"	addq	%2, (8 * 8), %1		\n"
-		"	stq	$31, (0 * 8)(%0)	\n"
-		"	stq	$31, (1 * 8)(%0)	\n"
-		"	stq	$31, (2 * 8)(%0)	\n"
-		"	stq	$31, (3 * 8)(%0)	\n"
-		"	stq	$31, (4 * 8)(%0)	\n"
-		"	stq	$31, (5 * 8)(%0)	\n"
-		"	stq	$31, (6 * 8)(%0)	\n"
-		"	stq	$31, (7 * 8)(%0)	\n"
-		"	\n"
-		"	addq	%3, (8 * 8), %0		\n"
-		"	stq	$31, (0 * 8)(%1)	\n"
-		"	stq	$31, (1 * 8)(%1)	\n"
-		"	stq	$31, (2 * 8)(%1)	\n"
-		"	stq	$31, (3 * 8)(%1)	\n"
-		"	stq	$31, (4 * 8)(%1)	\n"
-		"	stq	$31, (5 * 8)(%1)	\n"
-		"	stq	$31, (6 * 8)(%1)	\n"
-		"	stq	$31, (7 * 8)(%1)	\n"
-		"	# END loop body"
-		: "=r" (p0), "=r" (p1)
-		: "0" (p0), "1" (p1)
-		: "memory");
-	} while (p0 < pend);
-}
-
-/*
- * pmap_copy_page:		[ INTERFACE ]
- *
- *	Copy the specified (machine independent) page by mapping the page
- *	into virtual memory and using memcpy to copy the page, one machine
- *	dependent page at a time.
- *
- *	Note: no locking is necessary in this function.
- */
-void
-pmap_copy_page(paddr_t src, paddr_t dst)
-{
-	const void *s;
-	void *d;
+/* pmap_zero_page() is in pmap_subr.s */
 
-#ifdef DEBUG
-	if (pmapdebug & PDB_FOLLOW)
-		printf("pmap_copy_page(%lx, %lx)\n", src, dst);
-#endif
-	s = (const void *)ALPHA_PHYS_TO_K0SEG(src);
-	d = (void *)ALPHA_PHYS_TO_K0SEG(dst);
-	memcpy(d, s, PAGE_SIZE);
-}
+/* pmap_copy_page() is in pmap_subr.s */
 
 /*
  * pmap_pageidlezero:		[ INTERFACE ]

Added files:

Index: src/sys/arch/alpha/alpha/pmap_subr.s
diff -u /dev/null src/sys/arch/alpha/alpha/pmap_subr.s:1.1
--- /dev/null	Sat Jul 10 20:22:38 2021
+++ src/sys/arch/alpha/alpha/pmap_subr.s	Sat Jul 10 20:22:37 2021
@@ -0,0 +1,165 @@
+/* $NetBSD: pmap_subr.s,v 1.1 2021/07/10 20:22:37 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * 

CVS commit: src/sys/arch/x86/x86

2021-07-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 10 17:33:28 UTC 2021

Modified Files:
src/sys/arch/x86/x86: procfs_machdep.c

Log Message:
 Add v_spec_ctrl, avx512_fp16, sme, sev and sev_es. Tested by nonaka@.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/x86/x86/procfs_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/x86/x86/procfs_machdep.c
diff -u src/sys/arch/x86/x86/procfs_machdep.c:1.40 src/sys/arch/x86/x86/procfs_machdep.c:1.41
--- src/sys/arch/x86/x86/procfs_machdep.c:1.40	Mon Nov 30 00:04:02 2020
+++ src/sys/arch/x86/x86/procfs_machdep.c	Sat Jul 10 17:33:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: procfs_machdep.c,v 1.40 2020/11/30 00:04:02 msaitoh Exp $ */
+/*	$NetBSD: procfs_machdep.c,v 1.41 2021/07/10 17:33:28 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.40 2020/11/30 00:04:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.41 2021/07/10 17:33:28 msaitoh Exp $");
 
 #include 
 #include 
@@ -82,11 +82,13 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (3) Linux mapping */
-	"cxmmx", NULL, "cyrix_arr", "centaur_mcr", NULL,
-	"constant_tsc", NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
+	"cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr", NULL, NULL, NULL, NULL,
+	"constant_tsc", "up", "art", "arch_perfmon",
+	"pebs", "bts", NULL, NULL,
+	"rep_good", NULL, NULL, "acc_power",
+	"nopl", NULL, "xtopology", "tsc_reliable",
+	"nonstop_tsc", "cpuid", "extd_apicid", "amd_dcm",
+	"aperfmperf", "rapl", "nonstop_tsc_s3", "tsc_known_freq"},
 
 	{ /* (4) Intel-defined: 0x0001 ecx */
 	"pni", "pclmulqdq", "dtes64", "monitor", "ds_cpl", "vmx", "smx", "est",
@@ -112,7 +114,7 @@ static const char * const x86_features[]
 
 	{ /* (7) Linux mapping */
 	NULL, NULL, "cpb", "ebp", NULL, "pln", "pts", "dtherm",
-	"hw_pstate", "proc_feedback", "sme", NULL,
+	"hw_pstate", "proc_feedback", NULL, NULL,
 	NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, "ibrs", "ibpb", "stibp", NULL, NULL, NULL, NULL},
@@ -165,12 +167,12 @@ static const char * const x86_features[]
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
-	{ /* (15) 0x800a edx */
+	{ /* (15) AMD 0x800a edx */
 	"npt", "lbrv", "svm_lock", "nrip_save",
 	"tsc_scale", "vmcb_clean", "flushbyasid", "decodeassists",
 	NULL, NULL, "pausefilter", NULL, "pfthreshold", "avic", NULL,
 	"v_vmsave_vmload",
-	"vgif", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	"vgif", NULL, NULL, NULL, "v_spec_ctrl", NULL, NULL, NULL,
 	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 
 	{ /* (16) 0x0007:0 ecx */
@@ -190,9 +192,15 @@ static const char * const x86_features[]
 	{ /* (18) Intel 0x0007 edx */
 	NULL, NULL, "avx512_4vnniw", "avx512_4fmaps", "fsrm", NULL, NULL, NULL,
 	"vp2intersect", NULL, "md_clear", NULL, NULL, NULL, "serialize", NULL,
-	"tsxldtrk", NULL, "pconfig", NULL, NULL, NULL, NULL, NULL,
+	"tsxldtrk", NULL, "pconfig", NULL, NULL, NULL, NULL, "avx512_fp16",
 	NULL, NULL, NULL, NULL,
 	"flush_l1d", "arch_capabilities", NULL, "ssbd"},
+
+	{ /* (19) AMD 0x801f eax */
+	"sme", "sev", NULL, "sev_es", NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
 };
 
 static int	procfs_getonecpu(int, struct cpu_info *, char *, size_t *);
@@ -354,6 +362,14 @@ procfs_getonecpufeatures(struct cpu_info
 		diff = last - *left;
 	}
 
+	if ((cpu_vendor == CPUVENDOR_AMD)
+	&& (ci->ci_max_ext_cpuid >= 0x8019)) {
+		x86_cpuid(0x801f, descs);
+		procfs_getonefeatreg(descs[0], x86_features[19], p + diff,
+		left);
+		diff = last - *left;
+	}
+
 	return 0; /* XXX */
 }
 



CVS commit: src/sys/arch/x86/include

2021-07-10 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 10 17:08:37 UTC 2021

Modified Files:
src/sys/arch/x86/include: specialreg.h

Log Message:
Add some definitions from Intel SDM:

 - CPUID leaf 7:0 %ecx bit 13 TME_EN (Total Memory Encryption)
 - CPUID leaf 7:0 %edx bit 18 PCONFIG (Platform CONFIGuration)


To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/arch/x86/include/specialreg.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/x86/include/specialreg.h
diff -u src/sys/arch/x86/include/specialreg.h:1.176 src/sys/arch/x86/include/specialreg.h:1.177
--- src/sys/arch/x86/include/specialreg.h:1.176	Tue Nov 24 00:46:28 2020
+++ src/sys/arch/x86/include/specialreg.h	Sat Jul 10 17:08:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: specialreg.h,v 1.176 2020/11/24 00:46:28 msaitoh Exp $	*/
+/*	$NetBSD: specialreg.h,v 1.177 2021/07/10 17:08:37 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2014-2020 The NetBSD Foundation, Inc.
@@ -458,6 +458,7 @@
 #define CPUID_SEF_VPCLMULQDQ	__BIT(10)
 #define CPUID_SEF_AVX512_VNNI	__BIT(11) /* Vector neural Network Instruction */
 #define CPUID_SEF_AVX512_BITALG	__BIT(12)
+#define CPUID_SEF_TME_EN	__BIT(13) /* Total Memory Encryption */
 #define CPUID_SEF_AVX512_VPOPCNTDQ __BIT(14)
 #define CPUID_SEF_LA57		__BIT(16) /* 57bit linear addr & 5LVL paging */
 #define CPUID_SEF_MAWAU		__BITS(21, 17) /* MAWAU for BND{LD,ST}X */
@@ -473,7 +474,7 @@
 	"b\0PREFETCHWT1\0" "b\1AVX512_VBMI\0" "b\2UMIP\0" "b\3PKU\0"	\
 	"b\4OSPKE\0"	"b\5WAITPKG\0"	"b\6AVX512_VBMI2\0" "b\7CET_SS\0" \
 	"b\10GFNI\0"	"b\11VAES\0"	"b\12VPCLMULQDQ\0" "b\13AVX512_VNNI\0"\
-	"b\14AVX512_BITALG\0"		"b\16AVX512_VPOPCNTDQ\0"	\
+	"b\14AVX512_BITALG\0" "b\15TME_EN\0" "b\16AVX512_VPOPCNTDQ\0"	\
 	"b\20LA57\0"			\
 	"f\21\5MAWAU\0"			"b\26RDPID\0"	"b\27KL\0"	\
 			"b\31CLDEMOTE\0"		"b\33MOVDIRI\0"	\
@@ -490,6 +491,7 @@
 #define CPUID_SEF_SERIALIZE	__BIT(14) /* SERIALIZE instruction */
 #define CPUID_SEF_HYBRID	__BIT(15) /* Hybrid part */
 #define CPUID_SEF_TSXLDTRK	__BIT(16) /* TSX suspend load addr tracking */
+#define CPUID_SEF_PCONFIG	__BIT(18) /* Platform CONFIGuration */
 #define CPUID_SEF_CET_IBT	__BIT(20) /* CET Indirect Branch Tracking */
 #define CPUID_SEF_IBRS		__BIT(26) /* IBRS / IBPB Speculation Control */
 #define CPUID_SEF_STIBP		__BIT(27) /* STIBP Speculation Control */
@@ -503,7 +505,7 @@
 	"\5" "FSREP_MOV"		\
 	"\11VP2INTERSECT" "\12SRBDS_CTRL" "\13MD_CLEAR"			\
 			"\16TSX_FORCE_ABORT" "\17SERIALIZE" "\20HYBRID"	\
-	"\21" "TSXLDTRK"		\
+	"\21" "TSXLDTRK"		"\23" "PCONFIG"			\
 	"\25" "CET_IBT"			\
 	"\33" "IBRS"	"\34" "STIBP"	\
 	"\35" "L1D_FLUSH" "\36" "ARCH_CAP" "\37CORE_CAP"	"\40" "SSBD"



CVS commit: src/sys/arch/hp300/stand

2021-07-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Jul  9 17:44:28 UTC 2021

Modified Files:
src/sys/arch/hp300/stand: Makefile.buildboot

Log Message:
Specify -fno-unwind-tables to shrink binaries.

Before:
   textdata bss dec hex filename
  779024328  137120  219350   358d6 uboot
After:
   textdata bss dec hex filename
  641864328  137120  205634   32342 uboot


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/hp300/stand/Makefile.buildboot

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/hp300/stand/Makefile.buildboot
diff -u src/sys/arch/hp300/stand/Makefile.buildboot:1.36 src/sys/arch/hp300/stand/Makefile.buildboot:1.37
--- src/sys/arch/hp300/stand/Makefile.buildboot:1.36	Sat Apr  8 19:53:20 2017
+++ src/sys/arch/hp300/stand/Makefile.buildboot	Fri Jul  9 17:44:28 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.buildboot,v 1.36 2017/04/08 19:53:20 christos Exp $
+#	$NetBSD: Makefile.buildboot,v 1.37 2021/07/09 17:44:28 tsutsui Exp $
 
 # RELOC=FFF0 allows for boot prog up to FF000 (1044480) bytes long
 RELOC=	FFF0
@@ -20,7 +20,7 @@ CLEANFILES+=	${PROGAOUT}
 CPPFLAGS+=	-I${.CURDIR}/../../.. -I${.CURDIR}/../../../..  -I${.OBJDIR}
 CPPFLAGS+=	-Wno-main
 CPPFLAGS+=	-D__daddr_t=int32_t
-CFLAGS=		-Os -msoft-float -ffreestanding
+CFLAGS=		-Os -fno-unwind-tables -msoft-float -ffreestanding
 
 # XXX SHOULD NOT NEED TO DEFINE THESE!
 LIBCRT0=



  1   2   3   4   5   6   7   8   9   10   >