CVS commit: src/sys/arch/sparc64/doc

2021-07-05 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Jul  5 16:59:54 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update status on S7 systems


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.43 src/sys/arch/sparc64/doc/TODO:1.44
--- src/sys/arch/sparc64/doc/TODO:1.43	Fri Jun 25 19:13:12 2021
+++ src/sys/arch/sparc64/doc/TODO	Mon Jul  5 16:59:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.43 2021/06/25 19:13:12 palle Exp $ */
+/* $NetBSD: TODO,v 1.44 2021/07/05 16:59:54 palle Exp $ */
 
 Things to be done:
 
@@ -12,7 +12,7 @@ sun4u:
 
 sun4v:
  - current status
- T5 ldom with 2 VCPU and 4GB:
+ T5 ldom with 2 VCPU and 4GB  (primary ldom is Solaris 11.4 SRU30)::
- kernel boots from miniroot.fs via ldom fisk (vdsk)
 	   - ldom virtual network interface (vnet) is working
 	 (verified by exiting sysinst and issuing a ping command)
@@ -24,9 +24,8 @@ sun4v:
 		 unpacked, but the system hangs afterwards when running the makedev script.
 	 T2000 ldom with 8 VCPU and 4GB:
 	   - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
-	 S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):
-	   - during autoconfiguration of vnet devices the call to hv_vintr_setenabled()
-	 returns error code 7 (EBADTRAP?)
+	 S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU33):
+	   - same status as T5 ldom
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm



CVS commit: src/sys/arch/sparc64/sparc64

2021-07-03 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Jul  3 19:39:07 UTC 2021

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

Log Message:
sun4v: request hypervisor api major version 3 for the interrupt group - should 
solve issues when setting up interrupts on S7 systems


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.232 src/sys/arch/sparc64/sparc64/autoconf.c:1.233
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.232	Sat Jul  3 19:18:55 2021
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Jul  3 19:39:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $ */
+/*	$NetBSD: autoconf.c,v 1.233 2021/07/03 19:39:07 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.233 2021/07/03 19:39:07 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -189,9 +189,9 @@ void	sun4v_set_soft_state(int, const cha
 char sun4v_soft_state_booting[] __align32 = "NetBSD booting";
 char sun4v_soft_state_running[] __align32 = "NetBSD running";
 
+void	sun4v_interrupt_init(void);
 #if 0
 XXX notyet		
-void	sun4v_interrupt_init(void);
 void	sun4v_sdio_init(void);
 #endif
 #endif
@@ -378,9 +378,9 @@ die_old_boot_loader:
 	if (CPU_ISSUN4V) {
 		sun4v_soft_state_init();
 		sun4v_set_soft_state(SIS_TRANSITION, sun4v_soft_state_booting);
+		sun4v_interrupt_init();
 #if 0
 XXX notyet		
-		sun4v_interrupt_init();
 		sun4v_sdio_init();
 #endif 
 	}
@@ -570,8 +570,6 @@ sun4v_set_soft_state(int state, const ch
 		printf("soft_state_set: %d\n", err);
 }
 
-#if 0
-XXX notyet		
 void
 sun4v_interrupt_init(void)
 {
@@ -582,7 +580,6 @@ sun4v_interrupt_init(void)
 
 	sun4v_group_interrupt_major = 3;
 }
-#endif
 
 #if 0
 XXX notyet		



CVS commit: src/sys/arch/sparc64

2021-07-03 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Jul  3 19:18:56 UTC 2021

Modified Files:
src/sys/arch/sparc64/include: hypervisor.h sparc64.h
src/sys/arch/sparc64/sparc64: autoconf.c intr.c ofw_machdep.c

Log Message:
sun4v: add support for hypervisor soft state - from OpenBSD


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sparc64/include/hypervisor.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/include/sparc64.h
cvs rdiff -u -r1.231 -r1.232 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.69 -r1.70 src/sys/arch/sparc64/sparc64/intr.c
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/sparc64/sparc64/ofw_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/sparc64/include/hypervisor.h
diff -u src/sys/arch/sparc64/include/hypervisor.h:1.7 src/sys/arch/sparc64/include/hypervisor.h:1.8
--- src/sys/arch/sparc64/include/hypervisor.h:1.7	Tue Apr 27 19:09:56 2021
+++ src/sys/arch/sparc64/include/hypervisor.h	Sat Jul  3 19:18:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.7 2021/04/27 19:09:56 palle Exp $ */
+/*	$NetBSD: hypervisor.h,v 1.8 2021/07/03 19:18:55 palle Exp $ */
 /*	$OpenBSD: hypervisor.h,v 1.14 2011/06/26 17:23:46 kettenis Exp $	*/
 
 /*
@@ -391,4 +391,15 @@ int64_t	hv_rng_data_read(paddr_t raddr, 
 #define H_ETOOMANY	15
 #define H_ECHANNEL	16
 
+#ifndef _LOCORE
+extern uint64_t sun4v_group_interrupt_major;
+extern uint64_t sun4v_group_sdio_major;
+
+int64_t sun4v_intr_devino_to_sysino(uint64_t, uint64_t, uint64_t *);
+int64_t sun4v_intr_setcookie(uint64_t, uint64_t, uint64_t);
+int64_t sun4v_intr_setenabled(uint64_t, uint64_t, uint64_t);
+int64_t	sun4v_intr_setstate(uint64_t, uint64_t, uint64_t);
+int64_t	sun4v_intr_settarget(uint64_t, uint64_t, uint64_t);
+#endif
+
 #endif	/* _HYPERVISOR_H_ */

Index: src/sys/arch/sparc64/include/sparc64.h
diff -u src/sys/arch/sparc64/include/sparc64.h:1.13 src/sys/arch/sparc64/include/sparc64.h:1.14
--- src/sys/arch/sparc64/include/sparc64.h:1.13	Sat Sep  6 20:56:39 2014
+++ src/sys/arch/sparc64/include/sparc64.h	Sat Jul  3 19:18:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sparc64.h,v 1.13 2014/09/06 20:56:39 palle Exp $	*/
+/*	$NetBSD: sparc64.h,v 1.14 2021/07/03 19:18:55 palle Exp $	*/
 
 /*
  * Copyright (C) 1996 Wolfgang Solfrank.
@@ -59,5 +59,7 @@ int  prom_stop_other(u_int);
 bool prom_has_stop_other(void);
 void prom_startcpu(u_int, void *, u_long);
 int prom_startcpu_by_cpuid(u_int, void *, u_long arg);
+uint64_t prom_set_sun4v_api_version(uint64_t, uint64_t, uint64_t, uint64_t *);
+void prom_sun4v_soft_state_supported(void);
 
 #endif	/* _MACHINE_SPARC64_H_ */

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.231 src/sys/arch/sparc64/sparc64/autoconf.c:1.232
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.231	Wed May 12 23:22:33 2021
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Jul  3 19:18:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.231 2021/05/12 23:22:33 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.231 2021/05/12 23:22:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.232 2021/07/03 19:18:55 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -181,6 +181,21 @@ struct intrmap intrmap[] = {
 	{ NULL,		0 }
 };
 
+#ifdef SUN4V
+void	sun4v_soft_state_init(void);
+void	sun4v_set_soft_state(int, const char *);
+
+#define __align32 __attribute__((__aligned__(32)))
+char sun4v_soft_state_booting[] __align32 = "NetBSD booting";
+char sun4v_soft_state_running[] __align32 = "NetBSD running";
+
+#if 0
+XXX notyet		
+void	sun4v_interrupt_init(void);
+void	sun4v_sdio_init(void);
+#endif
+#endif
+
 int console_node, console_instance;
 struct genfb_colormap_callback gfb_cb;
 static void of_set_palette(void *, int, int, int, int);
@@ -358,6 +373,18 @@ die_old_boot_loader:
 
 	get_ncpus();
 	pmap_bootstrap(KERNBASE, bi_kend->addr);
+
+#ifdef SUN4V
+	if (CPU_ISSUN4V) {
+		sun4v_soft_state_init();
+		sun4v_set_soft_state(SIS_TRANSITION, sun4v_soft_state_booting);
+#if 0
+XXX notyet		
+		sun4v_interrupt_init();
+		sun4v_sdio_init();
+#endif 
+	}
+#endif
 }
 
 /*
@@ -499,7 +526,79 @@ cpu_configure(void)
 setpstate(getpstate()|PSTATE_IE);
 
 	(void)spl0();
+
+#ifdef SUN4V
+	if (CPU_ISSUN4V)
+		sun4v_set_soft_state(SIS_NORMAL, sun4v_soft_state_running);
+#endif
+}
+
+#ifdef SUN4V
+
+#define HSVC_GROUP_INTERRUPT	0x002
+#define HSVC_GROUP_SOFT_STATE	0x003
+#define HSVC_GROUP_SDIO		0x108
+
+int sun4v_soft_state_initialized = 0;
+
+void
+sun4v_soft_state_init(void)
+{
+	uint64_t minor;
+
+	if (prom_set_sun4v_api_version(HSVC_GROUP_SOFT_STATE, 1, 0, ))
+		return;
+
+	prom_sun4v_soft_state_supported();
+	sun4v_soft_state_initialized = 1;
+}
+
+void
+sun4v_set_soft_state(int state, 

CVS commit: src/sys/arch/sparc64/doc

2021-06-25 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Jun 25 19:13:12 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO file with current sun4v progress


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.42 src/sys/arch/sparc64/doc/TODO:1.43
--- src/sys/arch/sparc64/doc/TODO:1.42	Sun Jun 13 17:02:14 2021
+++ src/sys/arch/sparc64/doc/TODO	Fri Jun 25 19:13:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.42 2021/06/13 17:02:14 palle Exp $ */
+/* $NetBSD: TODO,v 1.43 2021/06/25 19:13:12 palle Exp $ */
 
 Things to be done:
 
@@ -20,9 +20,8 @@ sun4v:
 	 but the process crashes when selecting network installation method.
 		 The %i,%l and %o registers are corrupted, after a call to the libcurses
 		 wrefresh() function.
-		 If the sysinst insallation source is local directory, an error in the
-		 ldsk device driver is triggered when a DATA/NACK/DRING_DATA event is received.
-		 The current implementation does not hande this exception properly.
+		 If the sysinst insallation source is local directory, the sets are properly
+		 unpacked, but the system hangs afterwards when running the makedev script.
 	 T2000 ldom with 8 VCPU and 4GB:
 	   - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 	 S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):



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

2021-06-25 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Jun 25 19:10:50 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vdsk.c

Log Message:
sun4v: vdsk - restart the ldc state machine when the ldc endpoint resets the 
link or a DATA/NACK/DRING_DATA message is received. These changes make the 
driver more robust. In a ldom with Solaris 11.4 SRU30 as primary domain (T5 
host system) frequent resets and NACK messages are observed.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/vdsk.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/sparc64/dev/vdsk.c
diff -u src/sys/arch/sparc64/dev/vdsk.c:1.6 src/sys/arch/sparc64/dev/vdsk.c:1.7
--- src/sys/arch/sparc64/dev/vdsk.c:1.6	Sat Apr 24 23:36:49 2021
+++ src/sys/arch/sparc64/dev/vdsk.c	Fri Jun 25 19:10:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vdsk.c,v 1.6 2021/04/24 23:36:49 thorpej Exp $	*/
+/*	$NetBSD: vdsk.c,v 1.7 2021/06/25 19:10:50 palle Exp $	*/
 /*	$OpenBSD: vdsk.c,v 1.46 2015/01/25 21:42:13 kettenis Exp $	*/
 /*
  * Copyright (c) 2009, 2011 Mark Kettenis
@@ -492,6 +492,7 @@ vdsk_rx_intr(void *arg)
 			break;
 		case LDC_CHANNEL_RESET:
 			DPRINTF(("Rx link reset\n"));
+			ldc_send_vers(lc);
 			break;
 		}
 		lc->lc_rx_state = rx_state;
@@ -773,6 +774,8 @@ vdsk_rx_vio_dring_data(struct vdsk_softc
 
 		case VIO_SUBTYPE_NACK:
 			DPRINTF(("DATA/NACK/DRING_DATA\n"));
+			struct ldc_conn *lc = >sc_lc;
+			ldc_send_vers(lc);
 			break;
 
 		default:



CVS commit: src/sys/arch/sparc64/doc

2021-06-13 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Jun 13 17:02:14 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO file with current sun4v state


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.41 src/sys/arch/sparc64/doc/TODO:1.42
--- src/sys/arch/sparc64/doc/TODO:1.41	Sat Apr  3 17:02:31 2021
+++ src/sys/arch/sparc64/doc/TODO	Sun Jun 13 17:02:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.41 2021/04/03 17:02:31 palle Exp $ */
+/* $NetBSD: TODO,v 1.42 2021/06/13 17:02:14 palle Exp $ */
 
 Things to be done:
 
@@ -17,7 +17,12 @@ sun4v:
 	   - ldom virtual network interface (vnet) is working
 	 (verified by exiting sysinst and issuing a ping command)
 	   - the sysinst tool starts, disk setup is working,
-	 but the process crashes when selecting network installation method (trap 0x34 ALIGN is received)
+	 but the process crashes when selecting network installation method.
+		 The %i,%l and %o registers are corrupted, after a call to the libcurses
+		 wrefresh() function.
+		 If the sysinst insallation source is local directory, an error in the
+		 ldsk device driver is triggered when a DATA/NACK/DRING_DATA event is received.
+		 The current implementation does not hande this exception properly.
 	 T2000 ldom with 8 VCPU and 4GB:
 	   - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 	 S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):



CVS commit: src/sys/arch/sparc64/sparc64

2021-05-10 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Tue May 11 03:43:30 UTC 2021

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

Log Message:
All of the OFW-enumerated busses now associate the OFW node with the
device at config_found() time, so we can remove all of the stuff from
device_register() that does it, leaving only the @pci case to fix that
up (similar situation with ACPI on ARM and x86).

Adapt the boot device matching code to use the devhandle from the
device_t rather than the previous mechanism, and add some comments
explaining what's going on and some assertions to validate the
comments.

Collapse the sun4v vdsk boot device detection into the normal "sd"
case because it's almost identical to the normal "sd" case anyhow.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.229 src/sys/arch/sparc64/sparc64/autoconf.c:1.230
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.229	Mon May 10 23:53:44 2021
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Tue May 11 03:43:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.229 2021/05/10 23:53:44 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.229 2021/05/10 23:53:44 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.230 2021/05/11 03:43:30 thorpej Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -144,7 +144,6 @@ int kgdb_break_at_attach;
 #endif
 
 #define	OFPATHLEN	128
-#define	OFNODEKEY	"OFpnode"
 
 char	machine_banner[100];
 char	machine_model[100];
@@ -997,62 +996,25 @@ dev_bi_unit_drive_match(device_t dev, in
 }
 
 /*
- * Get the firmware package handle from a device_t.
- * Assuming we have previously stored it in the device properties
- * dictionary.
- */
-static int
-device_ofnode(device_t dev)
-{
-	prop_dictionary_t props;
-	prop_object_t obj;
-
-	if (dev == NULL)
-		return 0;
-	props = device_properties(dev);
-	if (props == NULL)
-		return 0;
-	obj = prop_dictionary_get(props, OFNODEKEY);
-	if (obj == NULL)
-		return 0;
-
-	return prop_number_signed_value(obj);
-}
-
-/*
- * Save the firmware package handle inside the properties dictionary
- * of a device_t.
- */
-static void
-device_setofnode(device_t dev, int node)
-{
-	prop_dictionary_t props;
-	prop_object_t obj;
-
-	if (dev == NULL)
-		return;
-	props = device_properties(dev);
-	if (props == NULL)
-		return;
-	obj = prop_number_create_signed(node);
-	if (obj == NULL)
-		return;
-	prop_dictionary_set(props, OFNODEKEY, obj);
-	prop_object_release(obj);
-	DPRINTF(ACDB_BOOTDEV, (" [device %s has node %x] ",
-	device_xname(dev), node));
-}
-
-/*
  * Called back during autoconfiguration for each device found
  */
 void
 device_register(device_t dev, void *aux)
 {
 	device_t busdev = device_parent(dev);
+	devhandle_t devhandle;
 	int ofnode = 0;
 
 	/*
+	 * If the device has a valid OpenFirmware node association,
+	 * grab it now.
+	 */
+	devhandle = device_handle(dev);
+	if (devhandle_type(devhandle) == DEVHANDLE_TYPE_OF) {
+		ofnode = devhandle_to_of(devhandle);
+	}
+
+	/*
 	 * We don't know the type of 'aux' - it depends on the
 	 * bus this device attaches to. We are only interested in
 	 * certain bus types, this only is used to find the boot
@@ -1063,23 +1025,18 @@ device_register(device_t dev, void *aux)
 		 * Ignore mainbus0 itself, it certainly is not a boot
 		 * device.
 		 */
-	} else if (device_is_a(busdev, "mainbus")) {
-		struct mainbus_attach_args *ma = aux;
-
-		ofnode = ma->ma_node;
 	} else if (device_is_a(busdev, "pci")) {
 		struct pci_attach_args *pa = aux;
 
-		ofnode = PCITAG_NODE(pa->pa_tag);
-	} else if (device_is_a(busdev, "sbus") || device_is_a(busdev, "dma")
-	|| device_is_a(busdev, "ledma")) {
-		struct sbus_attach_args *sa = aux;
-
-		ofnode = sa->sa_node;
-	} else if (device_is_a(busdev, "ebus")) {
-		struct ebus_attach_args *ea = aux;
-
-		ofnode = ea->ea_node;
+		/*
+		 * XXX PCI devices don't currently get their devhandles
+		 * set when the PCI layer attaches them, so we need to
+		 * do it here.  (It's not just us; ACPI has the same
+		 * problem...)
+		 */
+		ofnode = (int)PCITAG_NODE(pa->pa_tag);
+		devhandle = devhandle_from_of(ofnode);
+		device_set_handle(dev, devhandle);
 	} else if (device_is_a(busdev, "iic")) {
 		struct i2c_attach_args *ia = aux;
 
@@ -1098,6 +1055,7 @@ device_register(device_t dev, void *aux)
 add_gpio_props_e250(dev, aux);
 			}
 		} 
+		return;
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;
@@ -1121,9 +1079,37 @@ device_register(device_t dev, void *aux)
 

CVS commit: src/sys/arch/sparc64

2021-04-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Apr 27 19:09:56 UTC 2021

Modified Files:
src/sys/arch/sparc64/include: hypervisor.h
src/sys/arch/sparc64/sparc64: hvcall.S

Log Message:
sun4v: add missing method to set hypervisor api version + add defintion for the 
interrupt hypervisor api group (to be used)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/include/hypervisor.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/hvcall.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/sparc64/include/hypervisor.h
diff -u src/sys/arch/sparc64/include/hypervisor.h:1.6 src/sys/arch/sparc64/include/hypervisor.h:1.7
--- src/sys/arch/sparc64/include/hypervisor.h:1.6	Fri Feb 10 23:26:23 2017
+++ src/sys/arch/sparc64/include/hypervisor.h	Tue Apr 27 19:09:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hypervisor.h,v 1.6 2017/02/10 23:26:23 palle Exp $ */
+/*	$NetBSD: hypervisor.h,v 1.7 2021/04/27 19:09:56 palle Exp $ */
 /*	$OpenBSD: hypervisor.h,v 1.14 2011/06/26 17:23:46 kettenis Exp $	*/
 
 /*
@@ -36,7 +36,13 @@
 
 #ifndef _LOCORE
 int64_t	hv_api_get_version(uint64_t api_group,
-	uint64_t *major_number, uint64_t *minor_number);
+		   uint64_t *major_number,
+		   uint64_t *minor_number);
+int64_t	hv_api_set_version(uint64_t api_group,
+		   uint64_t major_number,
+		   uint64_t req_minor_number,
+		   uint64_t* actual_minor_number);
+#define HV_API_GROUP_INTERRUPT 0x002
 #endif
 /*
  * Domain services

Index: src/sys/arch/sparc64/sparc64/hvcall.S
diff -u src/sys/arch/sparc64/sparc64/hvcall.S:1.4 src/sys/arch/sparc64/sparc64/hvcall.S:1.5
--- src/sys/arch/sparc64/sparc64/hvcall.S:1.4	Sun Jun  8 17:33:24 2014
+++ src/sys/arch/sparc64/sparc64/hvcall.S	Tue Apr 27 19:09:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvcall.S,v 1.4 2014/06/08 17:33:24 palle Exp $ */
+/*	$NetBSD: hvcall.S,v 1.5 2021/04/27 19:09:56 palle Exp $ */
 /*	$OpenBSD: hvcall.S,v 1.10 2011/06/25 20:45:00 kettenis Exp $	*/
 
 /*
@@ -151,6 +151,13 @@ ENTRY(hv_api_get_version)
 	retl
 	 stx	%o2, [%o4]
 
+ENTRY(hv_api_set_version)
+	mov	%o3, %o4
+	mov	API_SET_VERSION, %o5
+	ta	ST_CORE_TRAP
+	retl
+	 stx	%o1, [%o4]
+	
 ENTRY(hv_mach_desc)
 	mov	%o1, %o2
 	ldx	[%o2], %o1



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

2021-04-26 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Apr 26 07:18:01 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: iommu.c iommuvar.h

Log Message:
iommu_enter() and iommu_remove() are static to iommu.c.


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sparc64/dev/iommuvar.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/sparc64/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.115 src/sys/arch/sparc64/dev/iommu.c:1.116
--- src/sys/arch/sparc64/dev/iommu.c:1.115	Sat Feb  9 11:27:05 2019
+++ src/sys/arch/sparc64/dev/iommu.c	Mon Apr 26 07:18:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.115 2019/02/09 11:27:05 mrg Exp $	*/
+/*	$NetBSD: iommu.c,v 1.116 2021/04/26 07:18:01 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.115 2019/02/09 11:27:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.116 2021/04/26 07:18:01 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -289,7 +289,7 @@ iommu_reset(struct iommu_state *is)
  * Here are the iommu control routines.
  */
 
-void
+static void
 iommu_enter(struct strbuf_ctl *sb, vaddr_t va, int64_t pa, int flags)
 {
 	DPRINTF(IDB_IOMMU, ("iommu_enter: va %lx pa %lx flags %x\n",
@@ -389,8 +389,7 @@ iommu_extract(struct iommu_state *is, va
  * XXX: this function needs better internal error checking.
  */
 
-
-void
+static void
 iommu_remove(struct iommu_state *is, vaddr_t va, size_t len)
 {
 	DPRINTF(IDB_IOMMU, ("iommu_remove: va %lx len %zu\n", va, len));

Index: src/sys/arch/sparc64/dev/iommuvar.h
diff -u src/sys/arch/sparc64/dev/iommuvar.h:1.23 src/sys/arch/sparc64/dev/iommuvar.h:1.24
--- src/sys/arch/sparc64/dev/iommuvar.h:1.23	Sat Feb  9 11:27:05 2019
+++ src/sys/arch/sparc64/dev/iommuvar.h	Mon Apr 26 07:18:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommuvar.h,v 1.23 2019/02/09 11:27:05 mrg Exp $	*/
+/*	$NetBSD: iommuvar.h,v 1.24 2021/04/26 07:18:01 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -72,8 +72,6 @@ struct iommu_state {
 /* interfaces for PCI/SBUS code */
 void	iommu_init(char *, struct iommu_state *, int, uint32_t);
 void	iommu_reset(struct iommu_state *);
-voidiommu_enter(struct strbuf_ctl *, vaddr_t, int64_t, int);
-voidiommu_remove(struct iommu_state *, vaddr_t, size_t);
 paddr_t iommu_extract(struct iommu_state *, vaddr_t);
 
 int	iommu_dvmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,



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

2021-04-25 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Apr 25 13:22:49 UTC 2021

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64

Log Message:
PCI busses do not attach to "ebus", therefore there is no need for
it to carry the "pcibus" interface attribute.

Fixes kern/56124.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/sys/arch/sparc64/conf/files.sparc64

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/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.164 src/sys/arch/sparc64/conf/files.sparc64:1.165
--- src/sys/arch/sparc64/conf/files.sparc64:1.164	Thu Mar  4 20:17:00 2021
+++ src/sys/arch/sparc64/conf/files.sparc64	Sun Apr 25 13:22:49 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.164 2021/03/04 20:17:00 palle Exp $
+#	$NetBSD: files.sparc64,v 1.165 2021/04/25 13:22:49 thorpej Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -67,7 +67,7 @@ file	arch/sparc64/dev/iommu.c		sbus | ps
 
 include "dev/ata/files.ata"
 
-device ebus {[addr = -1]}: pcibus
+device ebus {[addr = -1]}
 attach ebus at pci
 file	arch/sparc64/dev/ebus.c			ebus
 attach ebus at mainbus with ebus_mainbus



CVS commit: src/sys/arch/sparc64/sparc64

2021-04-06 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Apr  6 15:55:26 UTC 2021

Modified Files:
src/sys/arch/sparc64/sparc64: db_disasm.c

Log Message:
Fix a typo, remove a useless blank line.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc64/sparc64/db_disasm.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/sparc64/sparc64/db_disasm.c
diff -u src/sys/arch/sparc64/sparc64/db_disasm.c:1.18 src/sys/arch/sparc64/sparc64/db_disasm.c:1.19
--- src/sys/arch/sparc64/sparc64/db_disasm.c:1.18	Sun Oct  4 08:16:14 2015
+++ src/sys/arch/sparc64/sparc64/db_disasm.c	Tue Apr  6 15:55:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.18 2015/10/04 08:16:14 joerg Exp $ */
+/*	$NetBSD: db_disasm.c,v 1.19 2021/04/06 15:55:26 simonb Exp $ */
 
 /*
  * Copyright (c) 1994 David S. Miller, da...@nadzieja.rutgers.edu
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.18 2015/10/04 08:16:14 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.19 2021/04/06 15:55:26 simonb Exp $");
 
 #include 
 #include 
@@ -223,7 +223,7 @@ struct sparc_insn sparc_i[] = {
 	/* Note: if imm22 is zero then this is actually a "nop" grrr... */
 	{(FORMAT2(0, 0x4)), "sethi", "Cd"},
 
-	/* Branch on Integer Co`ndition Codes "Bicc" */
+	/* Branch on Integer Condition Codes "Bicc" */
 	{(FORMAT2(0, 2) | COND(8)), "ba", "a,m"},
 	{(FORMAT2(0, 2) | COND(0)), "bn", "a,m"},
 	{(FORMAT2(0, 2) | COND(9)), "bne", "a,m"},
@@ -1121,4 +1121,3 @@ db_disasm(db_addr_t loc, bool altfmt)
 
 	return (loc + 4);
 }
-



CVS commit: src/sys/arch/sparc64

2021-04-05 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Mon Apr  5 22:36:27 UTC 2021

Modified Files:
src/sys/arch/sparc64/include: cpu.h
src/sys/arch/sparc64/sparc64: cpu.c

Log Message:
Fix build w/o options SUN4V.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/sparc64/include/cpu.h
cvs rdiff -u -r1.139 -r1.140 src/sys/arch/sparc64/sparc64/cpu.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/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.131 src/sys/arch/sparc64/include/cpu.h:1.132
--- src/sys/arch/sparc64/include/cpu.h:1.131	Sat Apr  3 17:01:24 2021
+++ src/sys/arch/sparc64/include/cpu.h	Mon Apr  5 22:36:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.131 2021/04/03 17:01:24 palle Exp $ */
+/*	$NetBSD: cpu.h,v 1.132 2021/04/05 22:36:27 nakayama Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -198,7 +198,7 @@ struct cpu_info {
 
 	/* TSB description (sun4v). */
 	struct tsb_desc *ci_tsb_desc;
-	
+
 	/* MMU Fault Status Area (sun4v).
 	 * Will be initialized to the physical address of the bottom of
 	 * the interrupt stack.
@@ -440,9 +440,6 @@ void	switchtoctx_usiii(int);
 void	next_tick(long);
 void	next_stick(long);
 void	next_stick_init(void);
-#ifdef SUN4V
-voidcpu_idle_sun4v(void);
-#endif
 /* trap.c */
 void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
 int	rwindow_save(struct lwp *);

Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.139 src/sys/arch/sparc64/sparc64/cpu.c:1.140
--- src/sys/arch/sparc64/sparc64/cpu.c:1.139	Sat Apr  3 17:01:24 2021
+++ src/sys/arch/sparc64/sparc64/cpu.c	Mon Apr  5 22:36:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $ */
+/*	$NetBSD: cpu.c,v 1.140 2021/04/05 22:36:27 nakayama Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.140 2021/04/05 22:36:27 nakayama Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -95,6 +95,7 @@ struct cpu_bootargs *cpu_args;	/* alloca
 struct pool_cache *fpstate_cache;
 
 static struct cpu_info *alloc_cpuinfo(u_int);
+static void cpu_idle_sun4v(void);
 
 /* The following are used externally (sysctl_hw). */
 char	machine[] = MACHINE;		/* from  */
@@ -700,16 +701,15 @@ cpu_attach(device_t parent, device_t dev
 	 * cpu_idle setup (currently only necessary for sun4v)
 	 */
 	if (CPU_ISSUN4V) {
-	  ci->ci_idlespin = cpu_idle_sun4v;
+		ci->ci_idlespin = cpu_idle_sun4v;
 	}
 }
 
-#ifdef SUN4V
-void cpu_idle_sun4v(void)
+static void
+cpu_idle_sun4v(void)
 {
-  hv_cpu_yield();
+	hv_cpu_yield();
 }
-#endif
 
 int
 cpu_myid(void)



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

2021-04-05 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Apr  5 12:19:22 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: ldc.c

Log Message:
sun4v: Ignore spurious ldc CTRL/ACK/VERS messages (do not reset the connection 
anymore). Fixes occationals stalls when vdsk uses the ldc service. Observed on 
both T2000 and T5 host systems


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/ldc.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/sparc64/dev/ldc.c
diff -u src/sys/arch/sparc64/dev/ldc.c:1.6 src/sys/arch/sparc64/dev/ldc.c:1.7
--- src/sys/arch/sparc64/dev/ldc.c:1.6	Tue Oct 15 00:13:52 2019
+++ src/sys/arch/sparc64/dev/ldc.c	Mon Apr  5 12:19:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ldc.c,v 1.6 2019/10/15 00:13:52 chs Exp $	*/
+/*	$NetBSD: ldc.c,v 1.7 2021/04/05 12:19:22 palle Exp $	*/
 /*	$OpenBSD: ldc.c,v 1.12 2015/03/21 18:02:58 kettenis Exp $	*/
 /*
  * Copyright (c) 2009 Mark Kettenis
@@ -76,24 +76,25 @@ ldc_rx_ctrl_vers(struct ldc_conn *lc, st
 {
 	switch (lp->stype) {
 	case LDC_INFO:
-		DPRINTF(("CTRL/INFO/VERS\n"));
+		DPRINTF(("CTRL/INFO/VERS major %d minor %d\n", lp->major, lp->minor));
 		if (lp->major == LDC_VERSION_MAJOR &&
 		lp->minor == LDC_VERSION_MINOR)
 			ldc_send_ack(lc);
 		else {
 			/* XXX do nothing for now. */
+			DPRINTF(("CTRL/INFO/VERS unsupported major/minor\n"));
 		}
 		break;
 
 	case LDC_ACK:
+		DPRINTF(("CTRL/ACK/VERS\n"));
 		if (lc->lc_state != LDC_SND_VERS) {
-			DPRINTF(("Spurious CTRL/ACK/VERS: state %d\n",
-			lc->lc_state));
-			ldc_reset(lc);
-			return;
+			DPRINTF(("Spurious CTRL/ACK/VERS: state %d major %d minor %d (ignored)\n",
+	 lc->lc_state, lp->major, lp->minor));
+		}
+		else {		
+			ldc_send_rts(lc);
 		}
-		DPRINTF(("CTRL/ACK/VERS\n"));
-		ldc_send_rts(lc);
 		break;
 
 	case LDC_NACK:
@@ -263,6 +264,7 @@ ldc_send_vers(struct ldc_conn *lc)
 	lp->ctrl = LDC_VERS;
 	lp->major = 1;
 	lp->minor = 0;
+	DPRINTF(("ldc_send_vers() major %d minor %d\n", lp->major, lp->minor));
 
 	tx_tail += sizeof(*lp);
 	tx_tail &= ((lc->lc_txq->lq_nentries * sizeof(*lp)) - 1);
@@ -274,6 +276,7 @@ ldc_send_vers(struct ldc_conn *lc)
 	}
 
 	lc->lc_state = LDC_SND_VERS;
+	DPRINTF(("ldc_send_vers() setting lc->lc_state to %d\n", lc->lc_state));
 	mutex_exit(>lc_txq->lq_mtx);
 }
 
@@ -309,6 +312,7 @@ ldc_send_ack(struct ldc_conn *lc)
 	}
 
 	lc->lc_state = LDC_RCV_VERS;
+	DPRINTF(("ldc_send_ack() setting lc->lc_state to %d\n", lc->lc_state));
 	mutex_exit(>lc_txq->lq_mtx);
 }
 
@@ -344,6 +348,7 @@ ldc_send_rts(struct ldc_conn *lc)
 	}
 
 	lc->lc_state = LDC_SND_RTS;
+	DPRINTF(("ldc_send_rts() setting lc->lc_state to %d\n", lc->lc_state));
 	mutex_exit(>lc_txq->lq_mtx);
 }
 
@@ -379,6 +384,7 @@ ldc_send_rtr(struct ldc_conn *lc)
 	}
 
 	lc->lc_state = LDC_SND_RTR;
+	DPRINTF(("ldc_send_rtr() setting lc->lc_state to %d\n", lc->lc_state));
 	mutex_exit(>lc_txq->lq_mtx);
 }
 
@@ -414,6 +420,7 @@ ldc_send_rdx(struct ldc_conn *lc)
 	}
 
 	lc->lc_state = LDC_SND_RDX;
+	DPRINTF(("ldc_send_rdx() setting lc->lc_state to %d\n", lc->lc_state));
 	mutex_exit(>lc_txq->lq_mtx);
 }
 



CVS commit: src/sys/arch/sparc64/doc

2021-04-03 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Apr  3 17:02:32 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
update TODO after cpu_idle() has been improved (sun4v only for now)


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.40 src/sys/arch/sparc64/doc/TODO:1.41
--- src/sys/arch/sparc64/doc/TODO:1.40	Tue Mar 30 20:23:45 2021
+++ src/sys/arch/sparc64/doc/TODO	Sat Apr  3 17:02:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.40 2021/03/30 20:23:45 palle Exp $ */
+/* $NetBSD: TODO,v 1.41 2021/04/03 17:02:31 palle Exp $ */
 
 Things to be done:
 
@@ -23,7 +23,6 @@ sun4v:
 	 S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):
 	   - during autoconfiguration of vnet devices the call to hv_vintr_setenabled()
 	 returns error code 7 (EBADTRAP?)
-- idle handling - call hypervisor trap (openbsd code...??)	   
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm



CVS commit: src/sys/arch/sparc64

2021-04-03 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Apr  3 17:01:24 UTC 2021

Modified Files:
src/sys/arch/sparc64/include: cpu.h
src/sys/arch/sparc64/sparc64: cpu.c genassym.cf locore.s

Log Message:
Improve cpu_idle() by allowing a platform specific implementaion (same logic as 
the sparc implementation) - currently only used by sun4v


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/sparc64/include/cpu.h
cvs rdiff -u -r1.138 -r1.139 src/sys/arch/sparc64/sparc64/cpu.c
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/sparc64/sparc64/genassym.cf
cvs rdiff -u -r1.426 -r1.427 src/sys/arch/sparc64/sparc64/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/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.130 src/sys/arch/sparc64/include/cpu.h:1.131
--- src/sys/arch/sparc64/include/cpu.h:1.130	Tue Mar 10 03:49:56 2020
+++ src/sys/arch/sparc64/include/cpu.h	Sat Apr  3 17:01:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.130 2020/03/10 03:49:56 christos Exp $ */
+/*	$NetBSD: cpu.h,v 1.131 2021/04/03 17:01:24 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -212,12 +212,14 @@ struct cpu_info {
 	paddr_t			ci_devmq;  /* device mondo queue address */
 	paddr_t			ci_cpuset; /* mondo recipient address */ 
 	paddr_t			ci_mondo;  /* mondo message address */
-	
+
 	/* probe fault in PCI config space reads */
 	bool			ci_pci_probe;
 	bool			ci_pci_fault;
 
 	volatile void		*ci_ddb_regs;	/* DDB regs */
+
+	void (*ci_idlespin)(void);
 };
 
 #endif /* _KERNEL || _KMEMUSER */
@@ -438,6 +440,9 @@ void	switchtoctx_usiii(int);
 void	next_tick(long);
 void	next_stick(long);
 void	next_stick_init(void);
+#ifdef SUN4V
+voidcpu_idle_sun4v(void);
+#endif
 /* trap.c */
 void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
 int	rwindow_save(struct lwp *);

Index: src/sys/arch/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.138 src/sys/arch/sparc64/sparc64/cpu.c:1.139
--- src/sys/arch/sparc64/sparc64/cpu.c:1.138	Fri Aug  7 14:20:08 2020
+++ src/sys/arch/sparc64/sparc64/cpu.c	Sat Apr  3 17:01:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.138 2020/08/07 14:20:08 fcambus Exp $ */
+/*	$NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.138 2020/08/07 14:20:08 fcambus Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.139 2021/04/03 17:01:24 palle Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -695,9 +695,22 @@ cpu_attach(device_t parent, device_t dev
 		ci->ci_cpuset = pa;
 		pa += 64;
 	}
-	
+
+	/*
+	 * cpu_idle setup (currently only necessary for sun4v)
+	 */
+	if (CPU_ISSUN4V) {
+	  ci->ci_idlespin = cpu_idle_sun4v;
+	}
 }
 
+#ifdef SUN4V
+void cpu_idle_sun4v(void)
+{
+  hv_cpu_yield();
+}
+#endif
+
 int
 cpu_myid(void)
 {

Index: src/sys/arch/sparc64/sparc64/genassym.cf
diff -u src/sys/arch/sparc64/sparc64/genassym.cf:1.84 src/sys/arch/sparc64/sparc64/genassym.cf:1.85
--- src/sys/arch/sparc64/sparc64/genassym.cf:1.84	Mon Feb 17 09:09:49 2020
+++ src/sys/arch/sparc64/sparc64/genassym.cf	Sat Apr  3 17:01:24 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: genassym.cf,v 1.84 2020/02/17 09:09:49 skrll Exp $
+#	$NetBSD: genassym.cf,v 1.85 2021/04/03 17:01:24 palle Exp $
 
 #
 # Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -183,6 +183,7 @@ define	CI_DEVMQ	offsetof(struct cpu_info
 ifdef MULTIPROCESSOR
 define	CI_IPIEVC	offsetof(struct cpu_info, ci_ipi_evcnt[0].ev_count)
 endif
+define	CI_IDLESPIN offsetof(struct cpu_info, ci_idlespin)
 
 # CPU boot arguments structure
 define	CBA_NODE	offsetof(struct cpu_bootargs, cb_node)

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.426 src/sys/arch/sparc64/sparc64/locore.s:1.427
--- src/sys/arch/sparc64/sparc64/locore.s:1.426	Tue Mar 30 20:03:14 2021
+++ src/sys/arch/sparc64/sparc64/locore.s	Sat Apr  3 17:01:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.426 2021/03/30 20:03:14 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.427 2021/04/03 17:01:24 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -6619,11 +6619,19 @@ ENTRY(getfp)
 	 mov %fp, %o0
 
 /*
- * nothing MD to do in the idle loop
+ * Call optional cpu_idle handler if provided
  */
 ENTRY(cpu_idle)
-	retl
+	set	CPUINFO_VA, %o0
+	LDPTR	[%o0 + CI_IDLESPIN], %o1
+	tst	%o1
+	bz	1f
+	 nop
+	jmp	%o1
 	 nop
+1:
+	retl
+	nop
 
 /*
  * cpu_switchto() switches to an lwp to run and runs it, saving the



CVS commit: src/sys/arch/sparc64/doc

2021-03-30 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Mar 30 20:23:45 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO after pcb spill improvements and status when running on a S7 
host


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.39 src/sys/arch/sparc64/doc/TODO:1.40
--- src/sys/arch/sparc64/doc/TODO:1.39	Tue Mar 23 19:13:46 2021
+++ src/sys/arch/sparc64/doc/TODO	Tue Mar 30 20:23:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.39 2021/03/23 19:13:46 palle Exp $ */
+/* $NetBSD: TODO,v 1.40 2021/03/30 20:23:45 palle Exp $ */
 
 Things to be done:
 
@@ -17,11 +17,12 @@ sun4v:
 	   - ldom virtual network interface (vnet) is working
 	 (verified by exiting sysinst and issuing a ping command)
 	   - the sysinst tool starts, disk setup is working,
-	 but the process crashes when selecting network installation method
-		 (the pcbspill function in locore.s incorrectly only spills one register
-		 window even if more than one is are present)
+	 but the process crashes when selecting network installation method (trap 0x34 ALIGN is received)
 	 T2000 ldom with 8 VCPU and 4GB:
-	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
+	   - crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
+	 S7 ldom with 8 VCPU and 16GB (primary ldom is Solaris 11.4 SRU30):
+	   - during autoconfiguration of vnet devices the call to hv_vintr_setenabled()
+	 returns error code 7 (EBADTRAP?)
 - idle handling - call hypervisor trap (openbsd code...??)	   
 - 64-bit kernel support
 - 32-bit kernel support



CVS commit: src/sys/arch/sparc64/sparc64

2021-03-30 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Mar 30 20:03:15 UTC 2021

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

Log Message:
sun4v: handle spill trap properly when trap level is 1 and otherwin is non-zero 
- ensure that all windows are spilled to the pcb like the sun4u winfixsave code 
path


To generate a diff of this commit:
cvs rdiff -u -r1.425 -r1.426 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.425 src/sys/arch/sparc64/sparc64/locore.s:1.426
--- src/sys/arch/sparc64/sparc64/locore.s:1.425	Mon Feb 22 09:56:42 2021
+++ src/sys/arch/sparc64/sparc64/locore.s	Tue Mar 30 20:03:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.426 2021/03/30 20:03:14 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -234,7 +234,7 @@
 	.endm
 
 	.macro sun4v_tl1_uspill_other
-	ba,a,pt	%xcc, pcbspill_others
+	ba,a,pt	%xcc, pcbspill_other
 	 nop
 	.align 128
 	.endm
@@ -3485,6 +3485,77 @@ pcbspill_fail:
 	Debugger()
 	NOTREACHED
 
+
+pcbspill_other:
+	
+	set	CPUINFO_VA, %g6
+	ldx	[%g6 + CI_CPCB], %g6
+	
+	GET_CTXBUSY %g1
+
+	ldx	[%g1], %g1! kernel pmap is ctx 0
+	
+	srlx	%g6, STSHIFT, %g7
+	and	%g7, STMASK, %g7
+	sll	%g7, 3, %g7! byte offset into ctxbusy
+	add	%g7, %g1, %g1
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1		! Load pointer to directory
+
+	srlx	%g6, PDSHIFT, %g7			! Do page directory
+	and	%g7, PDMASK, %g7
+	sll	%g7, 3, %g7
+	brz,pn	%g1, pcbspill_other_fail
+	 add	%g7, %g1, %g1
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1
+	srlx	%g6, PTSHIFT, %g7			! Convert to ptab offset
+	and	%g7, PTMASK, %g7
+	brz	%g1, pcbspill_other_fail
+	 sll	%g7, 3, %g7
+	add	%g1, %g7, %g7
+	ldxa	[%g7] ASI_PHYS_CACHED, %g7		! This one is not
+	brgez	%g7, pcbspill_other_fail
+	 srlx	%g7, PGSHIFT, %g7			! Isolate PA part
+	sll	%g6, 32-PGSHIFT, %g6			! And offset
+	sllx	%g7, PGSHIFT+8, %g7			! There are 8 bits to the left of the PA in the TTE
+	srl	%g6, 32-PGSHIFT, %g6
+	srax	%g7, 8, %g7
+	or	%g7, %g6, %g6! Then combine them to form PA
+
+	wr	%g0, ASI_PHYS_CACHED, %asi		! Use ASI_PHYS_CACHED to prevent possible page faults
+
+	lduba	[%g6 + PCB_NSAVED] %asi, %g7		! Fetch current nsaved from the pcb
+	sllx	%g7, 7, %g5! 8+8 registers each 8 bytes = 128 bytes (2^7)
+	add	%g6, %g5, %g5! Offset into pcb_rw
+1:	
+	SPILL	stxa, %g5 + PCB_RW, 8, %asi		! Store the locals and ins
+
+	add	%g5, 16*8, %g5! Next location for saved register windows
+
+	stxa	%o6, [%g5 + PCB_RW + (14*8)] %asi	! Save %sp so we can write these all out
+	
+	saved		! Increments %cansave and decrements %otherwin
+	
+	rdpr	%cwp, %g1! shift register window forward
+	inc	%g1
+	wrpr	%g1, %cwp
+
+
+	inc	%g7	! increment number of saved register windows
+
+	rdpr	%otherwin, %g1! Check to see if done spill'ing otherwin
+	brnz,pt	%g1, 1b
+	 nop
+	
+	stba	%g7, [%g6 + PCB_NSAVED] %asi
+
+	retry
+	NOTREACHED
+
+pcbspill_other_fail:
+	Debugger()
+	NOTREACHED
+
+
 spill_normal_to_user_stack:
 	mov	%sp, %g6		! calculate virtual address of destination stack
 	add	%g6, BIAS, %g6



CVS commit: src/sys/arch/sparc64/doc

2021-03-23 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Mar 23 19:13:46 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO with findings related to crashes in user processes (pcbspill)


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.38 src/sys/arch/sparc64/doc/TODO:1.39
--- src/sys/arch/sparc64/doc/TODO:1.38	Tue Mar 16 20:11:30 2021
+++ src/sys/arch/sparc64/doc/TODO	Tue Mar 23 19:13:46 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.38 2021/03/16 20:11:30 palle Exp $ */
+/* $NetBSD: TODO,v 1.39 2021/03/23 19:13:46 palle Exp $ */
 
 Things to be done:
 
@@ -17,8 +17,9 @@ sun4v:
 	   - ldom virtual network interface (vnet) is working
 	 (verified by exiting sysinst and issuing a ping command)
 	   - the sysinst tool starts, disk setup is working,
-	 but the process crashes when selecting network installtion method
-		 (probably due to trashing of user proces registers)
+	 but the process crashes when selecting network installation method
+		 (the pcbspill function in locore.s incorrectly only spills one register
+		 window even if more than one is are present)
 	 T2000 ldom with 8 VCPU and 4GB:
 	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 - idle handling - call hypervisor trap (openbsd code...??)	   



CVS commit: src/sys/arch/sparc64/doc

2021-03-16 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Mar 16 20:11:30 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO - update status after hacking on ldom virtual network 
interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.37 src/sys/arch/sparc64/doc/TODO:1.38
--- src/sys/arch/sparc64/doc/TODO:1.37	Thu Mar  4 20:00:51 2021
+++ src/sys/arch/sparc64/doc/TODO	Tue Mar 16 20:11:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.37 2021/03/04 20:00:51 palle Exp $ */
+/* $NetBSD: TODO,v 1.38 2021/03/16 20:11:30 palle Exp $ */
 
 Things to be done:
 
@@ -13,11 +13,12 @@ sun4u:
 sun4v:
  - current status
  T5 ldom with 2 VCPU and 4GB:
-   The kernel boots and starts userland when booting miniroot.fs.
-   The sysinst tool starts properly and is functional.
-	   Installation is not possible, since no driver currently exists
-	   for the ldom network interfaces, but openbsd vnet and vsw drivers are
-	   possible to integrate and this work is progressing.
+   - kernel boots from miniroot.fs via ldom fisk (vdsk)
+	   - ldom virtual network interface (vnet) is working
+	 (verified by exiting sysinst and issuing a ping command)
+	   - the sysinst tool starts, disk setup is working,
+	 but the process crashes when selecting network installtion method
+		 (probably due to trashing of user proces registers)
 	 T2000 ldom with 8 VCPU and 4GB:
 	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 - idle handling - call hypervisor trap (openbsd code...??)	   



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

2021-03-15 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Mar 15 18:44:05 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: vnet - cleanup of debug code (no functional changes)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.4 src/sys/arch/sparc64/dev/vnet.c:1.5
--- src/sys/arch/sparc64/dev/vnet.c:1.4	Sat Mar 13 20:21:37 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Mon Mar 15 18:44:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.4 2021/03/13 20:21:37 palle Exp $	*/
+/*	$NetBSD: vnet.c,v 1.5 2021/03/15 18:44:04 palle Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -16,14 +16,10 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#if 0
-FIXME openbsd
-#include "bpfilter.h"
-#endif
-
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -31,12 +27,6 @@ FIXME openbsd
 #include 
 #include 
 #include 
-#if 0
-FIXME openbsd
-#include 
-#else
-#include 
-#endif
 
 #include 
 #include 
@@ -58,9 +48,6 @@ FIXME openbsd
 #include 
 #include 
 
-#if 1
-#define VNET_DEBUG
-#endif
 #ifdef VNET_DEBUG
 #define DPRINTF(x)	printf x
 #else
@@ -137,12 +124,7 @@ void	vnet_dring_free(bus_dma_tag_t, stru
 
 struct vnet_soft_desc {
 	int		vsd_map_idx;
-#if 0
-FIXME openbsd		
-	caddr_t		vsd_buf;
-#else		
 	unsigned char *vsd_buf;
-#endif		
 };
 
 struct vnet_softc {
@@ -171,12 +153,7 @@ struct vnet_softc {
 #define VIO_ACK_RDX		0x0400
 #define VIO_RCV_RDX		0x0800
 
-#if 0
-FIXME openbsd		
-	struct timeout	sc_handshake_to;
-#else
 	struct callout	sc_handshake_co;
-#endif		
 
 	uint8_t		sc_xfer_mode;
 
@@ -284,19 +261,6 @@ vnet_attach(struct device *parent, struc
 	hv_ldc_tx_qconf(ca->ca_id, 0, 0);
 	hv_ldc_rx_qconf(ca->ca_id, 0, 0);
 
-#if 0
-FIXME openbsd	
-	sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino,
-	IPL_NET, BUS_INTR_ESTABLISH_MPSAFE, vnet_tx_intr,
-	sc, sc->sc_dv.dv_xname);
-	sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino,
-	IPL_NET, BUS_INTR_ESTABLISH_MPSAFE, vnet_rx_intr,
-	sc, sc->sc_dv.dv_xname);
-	if (sc->sc_tx_ih == NULL || sc->sc_rx_ih == NULL) {
-		printf(", can't establish interrupt\n");
-		return;
-	}
-#else
 	sc->sc_tx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_tx_ino,
 	IPL_NET, vnet_tx_intr, sc);
 	sc->sc_rx_ih = bus_intr_establish(ca->ca_bustag, sc->sc_rx_ino,
@@ -305,7 +269,6 @@ FIXME openbsd	
 		printf(", can't establish interrupts\n");
 		return;
 	}
-#endif	
 
 	lc = >sc_lc;
 	lc->lc_id = ca->ca_id;
@@ -314,28 +277,10 @@ FIXME openbsd	
 	lc->lc_start = vnet_ldc_start;
 	lc->lc_rx_data = vio_rx_data;
 
-#if 0
-FIXME openbsd	
-	timeout_set(>sc_handshake_to, vnet_handshake, sc);
-#else
 	callout_init(>sc_handshake_co, 0);
-/* netbsd callout do silmilar function...*/
-#endif 
-	sc->sc_peer_state = VIO_DP_STOPPED;
 
-#if OPENBSD_BUSDMA
-	lc->lc_txq = ldc_queue_alloc(sc->sc_dmatag, VNET_TX_ENTRIES);
-	if (lc->lc_txq == NULL) {
-		printf(", can't allocate tx queue\n");
-		return;
-	}
+	sc->sc_peer_state = VIO_DP_STOPPED;
 
-	lc->lc_rxq = ldc_queue_alloc(sc->sc_dmatag, VNET_RX_ENTRIES);
-	if (lc->lc_rxq == NULL) {
-		printf(", can't allocate rx queue\n");
-		goto free_txqueue;
-	}
-#else	
 	lc->lc_txq = ldc_queue_alloc(VNET_TX_ENTRIES);
 	if (lc->lc_txq == NULL) {
 		printf(", can't allocate tx queue\n");
@@ -347,7 +292,6 @@ FIXME openbsd	
 		printf(", can't allocate rx queue\n");
 		goto free_txqueue;
 	}
-#endif
 	
 	if (OF_getprop(ca->ca_node, "local-mac-address",
    sc->sc_macaddr, ETHER_ADDR_LEN) > 0) {
@@ -360,63 +304,35 @@ FIXME openbsd	
 	/*
 	 * Each interface gets its own pool.
 	 */
-#if 0
-FIXME openbsd	
-	pool_init(>sc_pool, 2048, 0, IPL_NET, 0, sc->sc_dv.dv_xname, NULL);
-#else
 	pool_init(>sc_pool, 2048, 0, 0, 0, sc->sc_dv.dv_xname, NULL, IPL_NET);
-#endif
  
 	ifp = >sc_ethercom.ec_if;
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-#if 0	
-	ifp->if_link_state = LINK_STATE_DOWN;
-#endif	
 	ifp->if_init = vnet_init;
 	ifp->if_ioctl = vnet_ioctl;
 	ifp->if_start = vnet_start;
 	ifp->if_stop = vnet_stop;
 	ifp->if_watchdog = vnet_watchdog;
 	strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
-#if 0
-FIXME openbsd	
-	ifq_set_maxlen(>if_snd, 31); /* XXX */
-#else 
- IFQ_SET_MAXLEN(>if_snd, 31); /* XXX */
-#endif 
+	IFQ_SET_MAXLEN(>if_snd, 31); /* XXX */
 
 	ifmedia_init(>sc_media, 0, vnet_media_change, vnet_media_status);
 	ifmedia_add(>sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
 	ifmedia_set(>sc_media, IFM_ETHER | IFM_AUTO);
 
-#if 0	
-	int error = if_initialize(ifp);
-	if (error != 0) {
-		printf(", if_initialize() failed\n");
-		return;
-	}
-	ether_ifattach(ifp, sc->sc_macaddr);
-	

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

2021-03-13 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Mar 13 20:21:37 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: vnet - reception and transmission of eternet frames seems to work now 
(it is possible to ping 8.8.8.8 from inside a sun4v ldom). Still cleanup of 
debug code to be done.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.3 src/sys/arch/sparc64/dev/vnet.c:1.4
--- src/sys/arch/sparc64/dev/vnet.c:1.3	Thu Mar 11 19:34:11 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Sat Mar 13 20:21:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $	*/
+/*	$NetBSD: vnet.c,v 1.4 2021/03/13 20:21:37 palle Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -221,6 +221,7 @@ void	vnet_rx_vio_ver_info(struct vnet_so
 void	vnet_rx_vio_attr_info(struct vnet_softc *, struct vio_msg_tag *);
 void	vnet_rx_vio_dring_reg(struct vnet_softc *, struct vio_msg_tag *);
 void	vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *);
+void	vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *);
 void	vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *);
 void	vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *);
 void	vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *);
@@ -655,9 +656,15 @@ vnet_rx_vio_ctrl(struct vnet_softc *sc, 
 	case VIO_RDX:
 		vnet_rx_vio_rdx(sc, tag);
 		break;
+	case VNET_MCAST_INFO:
+		vnet_rx_vio_mcast_info(sc, tag);
+		break;
 	default:
 		printf("%s: CTRL/0x%02x/0x%04x FIXME\n",
  __func__, tag->stype, tag->stype_env);
+#if 0
+		Debugger();
+#endif		
 		break;
 	}
 }
@@ -739,7 +746,9 @@ vnet_rx_vio_attr_info(struct vnet_softc 
 		DPRINTF(("CTRL/INFO/ATTR_INFO\n"));
 #endif		
 		sc->sc_xfer_mode = ai->xfer_mode;
+#if 0		
 		DPRINTF(("sc_xfer_mode %d\n", sc->sc_xfer_mode));
+#endif		
 
 		ai->tag.stype = VIO_SUBTYPE_ACK;
 		ai->tag.sid = sc->sc_local_sid;
@@ -893,6 +902,40 @@ FIXME openbsd	
 }
 
 void
+vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *tag)
+{
+#if 0
+	DPRINTF(("%s: entry\n", __func__));
+#endif	
+
+	switch(tag->stype) {
+			
+		case VIO_SUBTYPE_INFO:
+#if 0
+			DPRINTF(("CTRL/INFO/MCAST_INFO\n"));
+#endif		
+			break;
+
+		case VIO_SUBTYPE_ACK:
+#if 0			
+			DPRINTF(("CTRL/ACK/MCAST_INFO\n"));
+#endif		
+			break;
+
+		case VIO_SUBTYPE_NACK:
+#if 0			
+			DPRINTF(("CTRL/NACK/MCAST_INFO\n"));
+#endif		
+			break;
+			
+		default:
+			printf("%s: CTRL/0x%02x/0x%04x\n",
+   __func__, tag->stype, tag->stype_env);
+			break;
+	}
+}
+
+void
 vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *vm)
 {
 #if 0
@@ -1077,7 +1120,7 @@ FIXME openbsd		
 	switch(tag->stype) {
 	case VIO_SUBTYPE_INFO:
 	{
-#if 0			
+#if 0
 		DPRINTF(("%s: VIO_SUBTYPE_INFO\n", __func__));
 #endif		
 		struct vnet_desc desc;
@@ -1148,9 +1191,9 @@ FIXME openbsd			
 			m->m_len = m->m_pkthdr.len = desc.nbytes;
 #endif			
 			nbytes = roundup(desc.nbytes + VNET_ETHER_ALIGN, 8);
-#if 1
-			DPRINTF(("%s: nbytes %" PRId64 " desc.nbytes %" PRId32 "\n",
-	 __func__, nbytes, desc.nbytes));
+#if 0
+			DPRINTF(("%s: RX frame size %" PRId16 "\n",
+	 __func__, (int)nbytes));
 			uint8_t buf[ETHER_MAX_LEN];
 			pmap_extract(pmap_kernel(), (vaddr_t)buf, );
 			err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN,
@@ -1161,11 +1204,12 @@ FIXME openbsd			
 			}
 			for (int i = 0; i < desc.nbytes; i++) {
 	if (i % 16 == 0) {
-		printf("\n");
+		DPRINTF(("\n"));
 	}
-	printf("%02x ", buf[i]);
+	DPRINTF(("%02x ", buf[i]));
 			}
-			printf("\n");
+			DPRINTF(("\n"));
+			DPRINTF(("\n"));
 #endif			
 #if 1
 			pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, );
@@ -1176,6 +1220,7 @@ FIXME openbsd			
 goto skip;
 			}
 			m->m_data += VNET_ETHER_ALIGN;
+			m_set_rcvif(m, ifp);
 
 #if 0
 FIXME openbsd		
@@ -1224,7 +1269,7 @@ FIXME openbd		
 
 	case VIO_SUBTYPE_ACK:
 	{
-#if 0			
+#if 0
 		DPRINTF(("%s: VIO_SUBTYPE_ACK\n", __func__));
 #endif		
 		struct ldc_map *map = sc->sc_lm;
@@ -1399,6 +1444,12 @@ vnet_send_attr_info(struct vnet_softc *s
 		ai.addr |= sc->sc_macaddr[i];
 	}
 	ai.mtu = ETHER_MAX_LEN - ETHER_CRC_LEN;
+#if 0
+	DPRINTF(("%s: ai.addr %" PRIx64 "\n",
+			 __func__, ai.addr));
+	DPRINTF(("%s: ai.mtu %" PRId64 "\n",
+			 __func__, ai.mtu));
+#endif	
 	vnet_sendmsg(sc, , sizeof(ai));
 
 	sc->sc_vio_state |= VIO_SND_ATTR_INFO;
@@ -1407,7 +1458,7 @@ vnet_send_attr_info(struct vnet_softc *s
 void
 vnet_send_dring_reg(struct vnet_softc *sc)
 {
-#if 1
+#if 0
 	DPRINTF(("%s: entry\n", __func__));
 #endif	
 	
@@ -1433,7 +1484,7 @@ vnet_send_dring_reg(struct vnet_softc *s
 void
 vio_send_rdx(struct vnet_softc *sc)
 {
-#if 1
+#if 0
 	

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

2021-03-11 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Mar 11 19:34:11 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: vnet - reception of ethernet frames seems to work now (WIP and code is  
still full of debug code)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.2 src/sys/arch/sparc64/dev/vnet.c:1.3
--- src/sys/arch/sparc64/dev/vnet.c:1.2	Thu Mar  4 20:59:39 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Thu Mar 11 19:34:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.2 2021/03/04 20:59:39 palle Exp $	*/
+/*	$NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -34,6 +34,8 @@ FIXME openbsd
 #if 0
 FIXME openbsd
 #include 
+#else
+#include 
 #endif
 
 #include 
@@ -56,6 +58,9 @@ FIXME openbsd
 #include 
 #include 
 
+#if 1
+#define VNET_DEBUG
+#endif
 #ifdef VNET_DEBUG
 #define DPRINTF(x)	printf x
 #else
@@ -169,6 +174,8 @@ struct vnet_softc {
 #if 0
 FIXME openbsd		
 	struct timeout	sc_handshake_to;
+#else
+	struct callout	sc_handshake_co;
 #endif		
 
 	uint8_t		sc_xfer_mode;
@@ -230,7 +237,7 @@ void	vnet_send_dring_data(struct vnet_so
 
 void	vnet_start(struct ifnet *);
 void	vnet_start_desc(struct ifnet *);
-int		vnet_ioctl (struct ifnet *, u_long, void *);
+int		vnet_ioctl(struct ifnet *, u_long, void *);
 void	vnet_watchdog(struct ifnet *);
 
 int		vnet_media_change(struct ifnet *);
@@ -240,13 +247,14 @@ void	vnet_link_state(struct vnet_softc *
 
 void	vnet_setmulti(struct vnet_softc *, int);
 
-void	vnet_init(struct ifnet *);
-void	vnet_stop(struct ifnet *);
+int		vnet_init(struct ifnet *);
+void	vnet_stop(struct ifnet *, int);
 
 int vnet_match(device_t parent, cfdata_t match, void *aux)
 {
 
 	struct cbus_attach_args *ca = aux;
+	
 	if (strcmp(ca->ca_name, "network") == 0)
 		return (1);
 
@@ -308,6 +316,9 @@ FIXME openbsd	
 #if 0
 FIXME openbsd	
 	timeout_set(>sc_handshake_to, vnet_handshake, sc);
+#else
+	callout_init(>sc_handshake_co, 0);
+/* netbsd callout do silmilar function...*/
 #endif 
 	sc->sc_peer_state = VIO_DP_STOPPED;
 
@@ -358,9 +369,13 @@ FIXME openbsd	
 	ifp = >sc_ethercom.ec_if;
 	ifp->if_softc = sc;
 	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
+#if 0	
 	ifp->if_link_state = LINK_STATE_DOWN;
+#endif	
+	ifp->if_init = vnet_init;
 	ifp->if_ioctl = vnet_ioctl;
 	ifp->if_start = vnet_start;
+	ifp->if_stop = vnet_stop;
 	ifp->if_watchdog = vnet_watchdog;
 	strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
 #if 0
@@ -374,6 +389,7 @@ FIXME openbsd	
 	ifmedia_add(>sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
 	ifmedia_set(>sc_media, IFM_ETHER | IFM_AUTO);
 
+#if 0	
 	int error = if_initialize(ifp);
 	if (error != 0) {
 		printf(", if_initialize() failed\n");
@@ -381,7 +397,10 @@ FIXME openbsd	
 	}
 	ether_ifattach(ifp, sc->sc_macaddr);
 	if_register(ifp);
-	
+#else
+	if_attach(ifp);
+	ether_ifattach(ifp, sc->sc_macaddr);
+#endif	
 	printf("\n");
 	return;
 free_txqueue:
@@ -424,7 +443,9 @@ vnet_tx_intr(void *arg)
 int
 vnet_rx_intr(void *arg)
 {
+#if 0		
 	DPRINTF(("%s: entry\n", __func__));
+#endif	
 
 	struct vnet_softc *sc = arg;
 	struct ldc_conn *lc = >sc_lc;
@@ -433,34 +454,47 @@ vnet_rx_intr(void *arg)
 	int err;
 
 	err = hv_ldc_rx_get_state(lc->lc_id, _head, _tail, _state);
-	if (err == H_EINVAL)
+	if (err == H_EINVAL) {
+		printf("hv_ldc_rx_get_state failed\n");
 		return (0);
+	}
 	if (err != H_EOK) {
 		printf("hv_ldc_rx_get_state %d\n", err);
 		return (0);
 	}
+#if 0	
+	DPRINTF(("%s: rx_state %" PRId64 "  head %" PRId64 "  tail %" PRId64 "\n",
+			 __func__, rx_state, rx_head, rx_tail));
+#endif	
 
 	if (rx_state != lc->lc_rx_state) {
+#if 0			
+		DPRINTF(("%s: rx_state %" PRId64 " != lc__rx_state %" PRId64 "\n",
+ __func__, rx_state, lc->lc_rx_state));
+#endif		
 		switch (rx_state) {
 		case LDC_CHANNEL_DOWN:
-			DPRINTF(("%s: Rx link down\n", __func__));
 			lc->lc_tx_seqid = 0;
 			lc->lc_state = 0;
 			lc->lc_reset(lc);
 			if (rx_head == rx_tail)
 break;
 			/* Discard and ack pending I/O. */
-			DPRINTF(("setting rx qhead to %lld\n", rx_tail));
+			DPRINTF(("setting rx qhead to %" PRId64 "\n", rx_tail));
 			err = hv_ldc_rx_set_qhead(lc->lc_id, rx_tail);
 			if (err == H_EOK)
 break;
 			printf("%s: hv_ldc_rx_set_qhead %d\n", __func__, err);
 			break;
 		case LDC_CHANNEL_UP:
+#if 0
 			DPRINTF(("%s: Rx link up\n", __func__));
+#endif			
 #if 0
 FIXME openbsd			
 			timeout_add_msec(>sc_handshake_to, 500);
+#else 
+			callout_reset(>sc_handshake_co, hz / 2, vnet_handshake, sc);
 #endif 
 			break;
 		case LDC_CHANNEL_RESET:
@@ -471,37 +505,73 @@ FIXME openbsd			
 #if 0
 FIXME openbsd			
 			

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

2021-03-04 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Mar  4 20:59:39 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: add vnet driver from openbsd - compiles but probably does not work yet - 
still WIP (now with NetBSD cvs tag and compiles for 32-bit SUN4U


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.1 src/sys/arch/sparc64/dev/vnet.c:1.2
--- src/sys/arch/sparc64/dev/vnet.c:1.1	Thu Mar  4 20:17:00 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Thu Mar  4 20:59:39 2021
@@ -1,3 +1,4 @@
+/*	$NetBSD: vnet.c,v 1.2 2021/03/04 20:59:39 palle Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -265,7 +266,7 @@ vnet_attach(struct device *parent, struc
 	sc->sc_tx_ino = ca->ca_tx_ino;
 	sc->sc_rx_ino = ca->ca_rx_ino;
 
-	printf(": ivec 0x%lx, 0x%lx", sc->sc_tx_ino, sc->sc_rx_ino);
+	printf(": ivec 0x%" PRIx64 ", 0x%" PRIx64, sc->sc_tx_ino, sc->sc_rx_ino);
 
 	/*
 	 * Un-configure queues before registering interrupt handlers,
@@ -488,7 +489,7 @@ FIXME openbsd			
 	if (rx_head == rx_tail)
 		return (0);
 
-	lp = (struct ldc_pkt *)(lc->lc_rxq->lq_va + rx_head);
+	lp = (struct ldc_pkt *)(uintptr_t)(lc->lc_rxq->lq_va + rx_head);
 	switch (lp->type) {
 	case LDC_CTRL:
 		ldc_rx_ctrl(lc, lp);



CVS commit: src/sys/arch/sparc64

2021-03-04 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Mar  4 20:17:00 UTC 2021

Modified Files:
src/sys/arch/sparc64/conf: GENERIC files.sparc64
Added Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: add vnet driver from openbsd - compiles but probably does not work yet - 
still WIP


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sys/arch/sparc64/conf/GENERIC
cvs rdiff -u -r1.163 -r1.164 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/vnet.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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.234 src/sys/arch/sparc64/conf/GENERIC:1.235
--- src/sys/arch/sparc64/conf/GENERIC:1.234	Sun Jan 31 08:07:25 2021
+++ src/sys/arch/sparc64/conf/GENERIC	Thu Mar  4 20:17:00 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.234 2021/01/31 08:07:25 martin Exp $
+# $NetBSD: GENERIC,v 1.235 2021/03/04 20:17:00 palle Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.234 $"
+#ident		"GENERIC-$Revision: 1.235 $"
 
 maxusers	64
 
@@ -248,6 +248,7 @@ iic* 	at jbusi2c?
 # Virtual devices for sun4v systems.
 vrtc0	at vbus?
 vdsk*	at cbus?
+vnet*	at cbus?
 
  Serial port configuration
 

Index: src/sys/arch/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.163 src/sys/arch/sparc64/conf/files.sparc64:1.164
--- src/sys/arch/sparc64/conf/files.sparc64:1.163	Wed Oct 21 13:31:52 2020
+++ src/sys/arch/sparc64/conf/files.sparc64	Thu Mar  4 20:17:00 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.163 2020/10/21 13:31:52 christos Exp $
+#	$NetBSD: files.sparc64,v 1.164 2021/03/04 20:17:00 palle Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -332,3 +332,8 @@ file	arch/sparc64/dev/ldc.c			ldc
 device	vdsk: ldc, scsi
 attach	vdsk at cbus
 file	arch/sparc64/dev/vdsk.c			vdsk
+
+# Virtual network
+device	vnet: ldc
+attach	vnet at cbus
+file	arch/sparc64/dev/vnet.c			vnet

Added files:

Index: src/sys/arch/sparc64/dev/vnet.c
diff -u /dev/null src/sys/arch/sparc64/dev/vnet.c:1.1
--- /dev/null	Thu Mar  4 20:17:00 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Thu Mar  4 20:17:00 2021
@@ -0,0 +1,1889 @@
+/*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
+/*
+ * Copyright (c) 2009, 2015 Mark Kettenis
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if 0
+FIXME openbsd
+#include "bpfilter.h"
+#endif
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#if 0
+FIXME openbsd
+#include 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#if NBPFILTER > 0
+#include 
+#endif
+
+#include 
+
+#include 
+#include 
+#include 
+
+#ifdef VNET_DEBUG
+#define DPRINTF(x)	printf x
+#else
+#define DPRINTF(x)
+#endif
+
+#define VNET_TX_ENTRIES		32
+#define VNET_RX_ENTRIES		32
+
+struct vnet_attr_info {
+	struct vio_msg_tag	tag;
+	uint8_t			xfer_mode;
+	uint8_t			addr_type;
+	uint16_t		ack_freq;
+	uint32_t		_reserved1;
+	uint64_t		addr;
+	uint64_t		mtu;
+	uint64_t		_reserved2[3];
+};
+
+/* Address types. */
+#define VNET_ADDR_ETHERMAC	0x01
+
+/* Sub-Type envelopes. */
+#define VNET_MCAST_INFO		0x0101
+
+#define VNET_NUM_MCAST		7
+
+struct vnet_mcast_info {
+	struct vio_msg_tag	tag;
+	uint8_t			set;
+	uint8_t			count;
+	uint8_t			mcast_addr[VNET_NUM_MCAST][ETHER_ADDR_LEN];
+	uint32_t		_reserved;
+};
+
+struct vnet_desc {
+	struct vio_dring_hdr	hdr;
+	uint32_t		nbytes;
+	uint32_t		ncookies;
+	struct ldc_cookie	cookie[2];
+};
+
+struct vnet_desc_msg {
+	struct vio_msg_tag	tag;
+	uint64_t		seq_no;
+	uint64_t		desc_handle;
+	uint32_t		nbytes;
+	uint32_t		ncookies;
+	struct ldc_cookie	cookie[1];
+};
+
+struct vnet_dring {
+	bus_dmamap_t		vd_map;
+	bus_dma_segment_t	vd_seg;
+	struct vnet_desc	*vd_desc;
+	int			vd_nentries;
+};
+
+struct vnet_dring *vnet_dring_alloc(bus_dma_tag_t, int);
+void	vnet_dring_free(bus_dma_tag_t, struct vnet_dring *);
+
+/*
+ * For now, we only support vNet 1.0.
+ */

CVS commit: src/sys/arch/sparc64/doc

2021-03-04 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Mar  4 20:00:51 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO - removed leftover OpenFirmware interface comment and add 
comment on idle handling


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.36 src/sys/arch/sparc64/doc/TODO:1.37
--- src/sys/arch/sparc64/doc/TODO:1.36	Sat Feb 27 18:29:38 2021
+++ src/sys/arch/sparc64/doc/TODO	Thu Mar  4 20:00:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.36 2021/02/27 18:29:38 palle Exp $ */
+/* $NetBSD: TODO,v 1.37 2021/03/04 20:00:51 palle Exp $ */
 
 Things to be done:
 
@@ -18,9 +18,9 @@ sun4v:
 	   Installation is not possible, since no driver currently exists
 	   for the ldom network interfaces, but openbsd vnet and vsw drivers are
 	   possible to integrate and this work is progressing.
-	   OpenBoot (properly trashed registers).
 	 T2000 ldom with 8 VCPU and 4GB:
 	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
+- idle handling - call hypervisor trap (openbsd code...??)	   
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm



CVS commit: src/sys/arch/sparc64/doc

2021-02-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 27 18:29:38 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO file with OpenFirmware interface related improvements


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.35 src/sys/arch/sparc64/doc/TODO:1.36
--- src/sys/arch/sparc64/doc/TODO:1.35	Sat Feb 27 18:19:57 2021
+++ src/sys/arch/sparc64/doc/TODO	Sat Feb 27 18:29:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.35 2021/02/27 18:19:57 palle Exp $ */
+/* $NetBSD: TODO,v 1.36 2021/02/27 18:29:38 palle Exp $ */
 
 Things to be done:
 
@@ -41,6 +41,19 @@ sun4v:
 - vdsk and ldc drivers: code maked with OPENBSD_BUSDMA - make the bus_dma stuff work properly
 - vbus.c: handle prom_getprop() memory leaks
 - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user?
+- openfirmware interface
+bounce handlng could need rework
+  - only #if __arch64__ independent for SUN4V, as OF for all ultrasparcs is
+plain 32bit code too (and this #if only because the point below becomes
+always false otherwise)
+  - only bounce if the address is >= 1UL<<32
+  - perhaps apply the lock to OF calls in general, not only the bounce'd ones
+(in other words: let's protect the OF context with the lock, not
+only the bounce buffer contents).
+	  - Are there any other bounce-worthy OF calls? If so, apply handling 
+	to all of them now
+  - consider method used by Solaris/OpenSolaris/Illumos (look for PROM_32BIT_ADDRS in
+	the Illumos codebase)
  - platforms tested so far:
  -- qemu sun4v/niagara - reaches the point where the kernel needs to mount a root fs
  -- T2000 - mmu fault somewhere



CVS commit: src/sys/arch/sparc64/doc

2021-02-27 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Feb 27 18:19:57 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO file with status on sun4v - kernel and userland runs without 
crashing now - next up is network interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.34 src/sys/arch/sparc64/doc/TODO:1.35
--- src/sys/arch/sparc64/doc/TODO:1.34	Mon Feb 22 10:30:57 2021
+++ src/sys/arch/sparc64/doc/TODO	Sat Feb 27 18:19:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.34 2021/02/22 10:30:57 palle Exp $ */
+/* $NetBSD: TODO,v 1.35 2021/02/27 18:19:57 palle Exp $ */
 
 Things to be done:
 
@@ -14,8 +14,10 @@ sun4v:
  - current status
  T5 ldom with 2 VCPU and 4GB:
The kernel boots and starts userland when booting miniroot.fs.
-   The sysinst tool starts properly and requests terminal type.
-	   Upon entering characters on the console, a crash occurs inside
+   The sysinst tool starts properly and is functional.
+	   Installation is not possible, since no driver currently exists
+	   for the ldom network interfaces, but openbsd vnet and vsw drivers are
+	   possible to integrate and this work is progressing.
 	   OpenBoot (properly trashed registers).
 	 T2000 ldom with 8 VCPU and 4GB:
 	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)



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

2021-02-25 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri Feb 26 02:01:16 UTC 2021

Modified Files:
src/sys/arch/sparc64/include: vmparam.h

Log Message:
Say what 1UL<<39 (MAXDSIZ value) is in the comment.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/sparc64/include/vmparam.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/sparc64/include/vmparam.h
diff -u src/sys/arch/sparc64/include/vmparam.h:1.41 src/sys/arch/sparc64/include/vmparam.h:1.42
--- src/sys/arch/sparc64/include/vmparam.h:1.41	Tue Oct  6 13:42:03 2020
+++ src/sys/arch/sparc64/include/vmparam.h	Fri Feb 26 02:01:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmparam.h,v 1.41 2020/10/06 13:42:03 christos Exp $ */
+/*	$NetBSD: vmparam.h,v 1.42 2021/02/26 02:01:16 simonb Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -112,7 +112,7 @@
 #define	DFLDSIZ		(128UL*1024*1024)	/* initial data size limit */
 #endif
 #ifndef MAXDSIZ
-#define	MAXDSIZ		(1UL<<39)		/* max data size */
+#define	MAXDSIZ		(1UL<<39)		/* 512GB max data size */
 /*
  * For processes not using topdown VA, we need to limit the data size -
  * they probably have not been compiled with the proper compiler memory



CVS commit: src/sys/arch/sparc64/doc

2021-02-22 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Feb 22 10:30:57 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update current status of sun4v


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.33 src/sys/arch/sparc64/doc/TODO:1.34
--- src/sys/arch/sparc64/doc/TODO:1.33	Sun Feb 14 20:30:31 2021
+++ src/sys/arch/sparc64/doc/TODO	Mon Feb 22 10:30:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.33 2021/02/14 20:30:31 palle Exp $ */
+/* $NetBSD: TODO,v 1.34 2021/02/22 10:30:57 palle Exp $ */
 
 Things to be done:
 
@@ -11,23 +11,14 @@ sun4u:
 - GENERIC.UP kernel hangs on v445 (missing interrupt?)
 
 sun4v:
- - current status (verified on T5 ldom with 2 VCPU and 4GB):
- The kernel boots and starts userland.
-	 During the execution of the sysinst process, a sub-process crashes.
-	 The crash happens when a call to sysctl from /bin/sh causes a mmu trap.
-	 Part of the TRAP_SETUP() call in sun4v_datatrap issues a 'save' instruction.
-	 Since %cansave is 0 (%canrestore is 6 and %otherwin is 0) a SPILL trap is generated.
-	 The current code ends up in the pcbspill codepath (which is based on code from openbsd).
-	 This code assumes that it is the register window in the OTHERWIN window that must be spilled
-	 to the pcb.
-	 Since %otherwin in this scenario actually is zero, we end up putting incorrect register
-	 window values to the pcb.
-	 So - this code should not save data to the pcb when %otherwin is 0 - it should spill the
-	 values to the stack of the user process. Special care should be taken here, since we
-	 may end up with a mmu fault again if the stack address is not present in the mmu, so
-	 perhaps spilling to the physical address of the stack will work.
-	 Time will show if this is correct...
-	 Status on T2000 ldom with 8 VCPU and 4GB is that is crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
+ - current status
+ T5 ldom with 2 VCPU and 4GB:
+   The kernel boots and starts userland when booting miniroot.fs.
+   The sysinst tool starts properly and requests terminal type.
+	   Upon entering characters on the console, a crash occurs inside
+	   OpenBoot (properly trashed registers).
+	 T2000 ldom with 8 VCPU and 4GB:
+	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm



CVS commit: src/sys/arch/sparc64/sparc64

2021-02-22 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Mon Feb 22 09:56:42 UTC 2021

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

Log Message:
sun4v: handle spill normal user traps properly when current trap level is 1 - 
registers are spilled to the PA of the stack to avoid further mmu-related 
traps, since sun4v only has 2 trap levels


To generate a diff of this commit:
cvs rdiff -u -r1.424 -r1.425 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.424 src/sys/arch/sparc64/sparc64/locore.s:1.425
--- src/sys/arch/sparc64/sparc64/locore.s:1.424	Sun Dec 20 11:58:58 2020
+++ src/sys/arch/sparc64/sparc64/locore.s	Mon Feb 22 09:56:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -228,7 +228,7 @@
 	.endm
 
 	.macro sun4v_tl1_uspill_normal
-	ba,a,pt	%xcc, pcbspill_normals
+	ba,a,pt	%xcc, spill_normal_to_user_stack
 	 nop
 	.align 128
 	.endm
@@ -3485,6 +3485,58 @@ pcbspill_fail:
 	Debugger()
 	NOTREACHED
 
+spill_normal_to_user_stack:
+	mov	%sp, %g6		! calculate virtual address of destination stack
+	add	%g6, BIAS, %g6
+
+	mov	CTX_SECONDARY, %g2! Is this context ok or should it be CTX_PRIMARY? XXX
+	GET_MMU_CONTEXTID %g3, %g2, %g1
+	sllx	%g3, 3, %g3	! Make it into an offset into ctxbusy (see below)
+	
+	GET_CTXBUSY %g1
+	ldx	[%g1 + %g3], %g1! Fetch pmap for current context id
+
+	! Start of code to extract PA	
+	srlx	%g6, STSHIFT, %g7
+	and	%g7, STMASK, %g7
+	sll	%g7, 3, %g7		! byte offset into ctxbusy
+	add	%g7, %g1, %g1
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1	! Load pointer to directory
+	srlx	%g6, PDSHIFT, %g7			! Do page directory
+	and	%g7, PDMASK, %g7
+	sll	%g7, 3, %g7
+	brz,pn	%g1, spill_normal_to_user_stack_fail
+	 add	%g7, %g1, %g1
+
+	ldxa	[%g1] ASI_PHYS_CACHED, %g1
+	srlx	%g6, PTSHIFT, %g7			! Convert to ptab offset
+	and	%g7, PTMASK, %g7
+	brz	%g1, spill_normal_to_user_stack_fail
+	 sll	%g7, 3, %g7
+	
+	add	%g1, %g7, %g7
+	ldxa	[%g7] ASI_PHYS_CACHED, %g7	! This one is not
+	brgez	%g7, spill_normal_to_user_stack_fail
+	 srlx	%g7, PGSHIFT, %g7			! Isolate PA part
+	
+	sll	%g6, 32-PGSHIFT, %g6			! And offset
+	sllx	%g7, PGSHIFT+8, %g7			! There are 8 bits to the left of the PA in the TTE
+	srl	%g6, 32-PGSHIFT, %g6
+	srax	%g7, 8, %g7
+	or	%g7, %g6, %g6	! Then combine them to form PA
+	! End of code to extract PA
+
+	wr	%g0, ASI_PHYS_CACHED, %asi		! Use ASI_PHYS_CACHED to prevent possible page faults
+	SPILL	stxa, %g6, 8, %asi			! Store the locals and ins
+	saved
+
+	retry
+	NOTREACHED
+
+spill_normal_to_user_stack_fail:
+	sir
+	 nop
+	
 /*
  * End of traps for sun4v.
  */



CVS commit: src/sys/arch/sparc64/doc

2021-02-14 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Feb 14 20:30:31 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO with status of verified systems(T2000, T5 and qemu)


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.32 src/sys/arch/sparc64/doc/TODO:1.33
--- src/sys/arch/sparc64/doc/TODO:1.32	Sun Jan 31 19:08:05 2021
+++ src/sys/arch/sparc64/doc/TODO	Sun Feb 14 20:30:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.32 2021/01/31 19:08:05 palle Exp $ */
+/* $NetBSD: TODO,v 1.33 2021/02/14 20:30:31 palle Exp $ */
 
 Things to be done:
 
@@ -11,7 +11,7 @@ sun4u:
 - GENERIC.UP kernel hangs on v445 (missing interrupt?)
 
 sun4v:
- - current status:
+ - current status (verified on T5 ldom with 2 VCPU and 4GB):
  The kernel boots and starts userland.
 	 During the execution of the sysinst process, a sub-process crashes.
 	 The crash happens when a call to sysctl from /bin/sh causes a mmu trap.
@@ -27,6 +27,7 @@ sun4v:
 	 may end up with a mmu fault again if the stack address is not present in the mmu, so
 	 perhaps spilling to the physical address of the stack will work.
 	 Time will show if this is correct...
+	 Status on T2000 ldom with 8 VCPU and 4GB is that is crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm
@@ -48,6 +49,6 @@ sun4v:
 - vbus.c: handle prom_getprop() memory leaks
 - locore.s: rft_user (sun4v specific manaul fill) - seems to work, but is it good enough (compared to openbsds rft_user?
  - platforms tested so far:
- -- qemu sun4v/niagara - crash in init process relaed to fork (stack?)
+ -- qemu sun4v/niagara - reaches the point where the kernel needs to mount a root fs
  -- T2000 - mmu fault somewhere
  -- T5 - stickcmpr is not properly initialized ???



CVS commit: src/sys/arch/sparc64/sparc64

2021-02-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb  2 08:18:42 UTC 2021

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

Log Message:
Worakround for traps on invalid VAs:
uvm_fault() can not (currently) deal properly with invalid VAs (inside the
VA hole), so do not pass faults for such addresses to it, but instead
either panic (if fault is in kernel) or send a SIGSEGV to userland.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.192 src/sys/arch/sparc64/sparc64/trap.c:1.193
--- src/sys/arch/sparc64/sparc64/trap.c:1.192	Thu Nov 21 19:24:01 2019
+++ src/sys/arch/sparc64/sparc64/trap.c	Tue Feb  2 08:18:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.192 2019/11/21 19:24:01 ad Exp $ */
+/*	$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.192 2019/11/21 19:24:01 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.193 2021/02/02 08:18:42 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1092,6 +1092,25 @@ data_access_fault(struct trapframe64 *tf
 	sticks = p->p_sticks;
 	tstate = tf->tf_tstate;
 
+#ifdef _LP64
+	/* deal with invalid VAs early */
+	if (__predict_false(addr >= (1UL<

CVS commit: src/sys/arch/sparc64/doc

2021-01-31 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Jan 31 19:08:05 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO with analysis of sun4v crashes


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.31 src/sys/arch/sparc64/doc/TODO:1.32
--- src/sys/arch/sparc64/doc/TODO:1.31	Mon Jan  4 15:13:50 2021
+++ src/sys/arch/sparc64/doc/TODO	Sun Jan 31 19:08:05 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.31 2021/01/04 15:13:50 skrll Exp $ */
+/* $NetBSD: TODO,v 1.32 2021/01/31 19:08:05 palle Exp $ */
 
 Things to be done:
 
@@ -11,9 +11,22 @@ sun4u:
 - GENERIC.UP kernel hangs on v445 (missing interrupt?)
 
 sun4v:
- - current status: The kernel boots and starts the init process.
-   The following processes seem to crash on and on so more debugging to be done...
-
+ - current status:
+ The kernel boots and starts userland.
+	 During the execution of the sysinst process, a sub-process crashes.
+	 The crash happens when a call to sysctl from /bin/sh causes a mmu trap.
+	 Part of the TRAP_SETUP() call in sun4v_datatrap issues a 'save' instruction.
+	 Since %cansave is 0 (%canrestore is 6 and %otherwin is 0) a SPILL trap is generated.
+	 The current code ends up in the pcbspill codepath (which is based on code from openbsd).
+	 This code assumes that it is the register window in the OTHERWIN window that must be spilled
+	 to the pcb.
+	 Since %otherwin in this scenario actually is zero, we end up putting incorrect register
+	 window values to the pcb.
+	 So - this code should not save data to the pcb when %otherwin is 0 - it should spill the
+	 values to the stack of the user process. Special care should be taken here, since we
+	 may end up with a mmu fault again if the stack address is not present in the mmu, so
+	 perhaps spilling to the physical address of the stack will work.
+	 Time will show if this is correct...
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm



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

2021-01-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jan 31 08:07:25 UTC 2021

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Allow local builds to add configuration changes via GENERIC.local


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.233 src/sys/arch/sparc64/conf/GENERIC:1.234
--- src/sys/arch/sparc64/conf/GENERIC:1.233	Fri Oct 30 06:44:37 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Sun Jan 31 08:07:25 2021
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.233 2020/10/30 06:44:37 jdc Exp $
+# $NetBSD: GENERIC,v 1.234 2021/01/31 08:07:25 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.233 $"
+#ident		"GENERIC-$Revision: 1.234 $"
 
 maxusers	64
 
@@ -419,6 +419,9 @@ fdc0	at sbus? slot ? offset ?		# SUNW,fd
 #fdc0	at ebus?# fdthree, EXPERIMENTAL
 fd*	at fdc0	# the drive itself
 
+# Pull in optional local configuration
+cinclude "arch/sparc64/conf/GENERIC.local"
+
 #
 # accept filters
 pseudo-device	accf_data		# "dataready" accept filter



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

2021-01-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Jan 17 21:03:27 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Use designated initializers and a consistent termination style in
compat_data[].


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.16 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.17
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.16	Wed Dec 23 07:09:50 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Jan 17 21:03:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.16 2020/12/23 07:09:50 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.17 2021/01/17 21:03:27 thorpej Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.16 2020/12/23 07:09:50 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.17 2021/01/17 21:03:27 thorpej Exp $");
 
 #include 
 #include 
@@ -97,8 +97,9 @@ CFATTACH_DECL3_NEW(ecadc, sizeof(struct 
 	DVF_DETACH_SHUTDOWN);
 
 static const struct device_compatible_entry compat_data[] = {
-	{ "ecadc",		0 },
-	{ NULL,			0 }
+	{ .compat = "ecadc" },
+
+	{ 0 }
 };
 
 static int



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

2021-01-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Jan 17 00:18:28 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: psycho.c pyro.c schizo.c

Log Message:
reduce the scope of 'ci' variable.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/sparc64/dev/psycho.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sparc64/dev/pyro.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/sparc64/dev/schizo.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/sparc64/dev/psycho.c
diff -u src/sys/arch/sparc64/dev/psycho.c:1.131 src/sys/arch/sparc64/dev/psycho.c:1.132
--- src/sys/arch/sparc64/dev/psycho.c:1.131	Thu Jan  7 07:40:39 2021
+++ src/sys/arch/sparc64/dev/psycho.c	Sun Jan 17 00:18:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: psycho.c,v 1.131 2021/01/07 07:40:39 nakayama Exp $	*/
+/*	$NetBSD: psycho.c,v 1.132 2021/01/17 00:18:28 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.131 2021/01/07 07:40:39 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.132 2021/01/17 00:18:28 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -1382,7 +1382,6 @@ psycho_pci_conf_read(pci_chipset_tag_t p
 {
 	struct psycho_pbm *pp = pc->cookie;
 	struct psycho_softc *sc = pp->pp_sc;
-	struct cpu_info *ci = curcpu();
 	pcireg_t val = (pcireg_t)~0;
 	int s;
 
@@ -1397,6 +1396,7 @@ psycho_pci_conf_read(pci_chipset_tag_t p
 			(int)PCITAG_OFFSET(tag) + reg));
 
 		s = splhigh();
+		struct cpu_info *ci = curcpu();
 		ci->ci_pci_probe = true;
 		membar_Sync();
 		val = bus_space_read_4(sc->sc_configtag, sc->sc_configaddr,

Index: src/sys/arch/sparc64/dev/pyro.c
diff -u src/sys/arch/sparc64/dev/pyro.c:1.21 src/sys/arch/sparc64/dev/pyro.c:1.22
--- src/sys/arch/sparc64/dev/pyro.c:1.21	Mon Jan  4 14:48:51 2021
+++ src/sys/arch/sparc64/dev/pyro.c	Sun Jan 17 00:18:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pyro.c,v 1.21 2021/01/04 14:48:51 thorpej Exp $	*/
+/*	$NetBSD: pyro.c,v 1.22 2021/01/17 00:18:28 mrg Exp $	*/
 /*	from: $OpenBSD: pyro.c,v 1.20 2010/12/05 15:15:14 kettenis Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pyro.c,v 1.21 2021/01/04 14:48:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pyro.c,v 1.22 2021/01/17 00:18:28 mrg Exp $");
 
 #include 
 #include 
@@ -283,13 +283,13 @@ pcireg_t
 pyro_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
 {
 	struct pyro_pbm *pp = pc->cookie;
-	struct cpu_info *ci = curcpu();
 	pcireg_t val = (pcireg_t)~0;
 	int s;
 
 	DPRINTF(PDB_CONF, ("%s: tag %lx reg %x ", __func__, (long)tag, reg));
 	if (PCITAG_NODE(tag) != -1 && (unsigned int)reg < PCI_CONF_SIZE) {
 		s = splhigh();
+		struct cpu_info *ci = curcpu();
 		ci->ci_pci_probe = true;
 		membar_Sync();
 		val = bus_space_read_4(pp->pp_cfgt, pp->pp_cfgh,

Index: src/sys/arch/sparc64/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.42 src/sys/arch/sparc64/dev/schizo.c:1.43
--- src/sys/arch/sparc64/dev/schizo.c:1.42	Tue Oct  1 18:00:07 2019
+++ src/sys/arch/sparc64/dev/schizo.c	Sun Jan 17 00:18:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.42 2019/10/01 18:00:07 chs Exp $	*/
+/*	$NetBSD: schizo.c,v 1.43 2021/01/17 00:18:28 mrg Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.42 2019/10/01 18:00:07 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.43 2021/01/17 00:18:28 mrg Exp $");
 
 #include 
 #include 
@@ -526,13 +526,13 @@ pcireg_t
 schizo_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg)
 {
 	struct schizo_pbm *sp = pc->cookie;
-	struct cpu_info *ci = curcpu();
 	pcireg_t val = (pcireg_t)~0;
 	int s;
 
 	DPRINTF(SDB_CONF, ("%s: tag %lx reg %x ", __func__, (long)tag, reg));
 	if (PCITAG_NODE(tag) != -1 && (unsigned int)reg < PCI_CONF_SIZE) {
 		s = splhigh();
+		struct cpu_info *ci = curcpu();
 		ci->ci_pci_probe = true;
 		membar_Sync();
 		val = bus_space_read_4(sp->sp_cfgt, sp->sp_cfgh,



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

2021-01-06 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Thu Jan  7 07:40:39 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: psycho.c

Log Message:
The "available" property requires a variable length buffer, so
leave free(9) until prom_getprop is changed to use kmem_alloc(9)
instead of malloc(9).


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/sys/arch/sparc64/dev/psycho.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/sparc64/dev/psycho.c
diff -u src/sys/arch/sparc64/dev/psycho.c:1.130 src/sys/arch/sparc64/dev/psycho.c:1.131
--- src/sys/arch/sparc64/dev/psycho.c:1.130	Wed Jan  6 20:04:30 2021
+++ src/sys/arch/sparc64/dev/psycho.c	Thu Jan  7 07:40:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: psycho.c,v 1.130 2021/01/06 20:04:30 palle Exp $	*/
+/*	$NetBSD: psycho.c,v 1.131 2021/01/07 07:40:39 nakayama Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.130 2021/01/06 20:04:30 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.131 2021/01/07 07:40:39 nakayama Exp $");
 
 #include "opt_ddb.h"
 
@@ -81,6 +81,7 @@ int psycho_debug = 0x0;
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -769,7 +770,7 @@ psycho_alloc_chipset(struct psycho_pbm *
 static struct extent *
 psycho_alloc_extent(struct psycho_pbm *pp, int node, int ss, const char *name)
 {
-	struct psycho_registers *pa = kmem_zalloc(sizeof *pa, KM_SLEEP);
+	struct psycho_registers *pa = NULL;
 	struct psycho_ranges *pr;
 	struct extent *ex;
 	bus_addr_t baddr, addr;
@@ -833,7 +834,7 @@ psycho_alloc_extent(struct psycho_pbm *p
 
 ret:
 	/* return extent */
-	kmem_free(pa, sizeof(*pa));
+	free(pa, M_DEVBUF);
 	return ex;
 }
 



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

2021-01-06 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Wed Jan  6 20:04:30 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: psycho.c

Log Message:
psycho: explicit allocation of memory using kmem(9) instead of using the buffer 
indirectly allocted in the prom_getprop() function (which is still using 
malloc(9) for memory allocation


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/sparc64/dev/psycho.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/sparc64/dev/psycho.c
diff -u src/sys/arch/sparc64/dev/psycho.c:1.129 src/sys/arch/sparc64/dev/psycho.c:1.130
--- src/sys/arch/sparc64/dev/psycho.c:1.129	Mon Jan  4 14:48:51 2021
+++ src/sys/arch/sparc64/dev/psycho.c	Wed Jan  6 20:04:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: psycho.c,v 1.129 2021/01/04 14:48:51 thorpej Exp $	*/
+/*	$NetBSD: psycho.c,v 1.130 2021/01/06 20:04:30 palle Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.129 2021/01/04 14:48:51 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.130 2021/01/06 20:04:30 palle Exp $");
 
 #include "opt_ddb.h"
 
@@ -769,7 +769,7 @@ psycho_alloc_chipset(struct psycho_pbm *
 static struct extent *
 psycho_alloc_extent(struct psycho_pbm *pp, int node, int ss, const char *name)
 {
-	struct psycho_registers *pa = NULL;
+	struct psycho_registers *pa = kmem_zalloc(sizeof *pa, KM_SLEEP);
 	struct psycho_ranges *pr;
 	struct extent *ex;
 	bus_addr_t baddr, addr;



CVS commit: src/sys/arch/sparc64

2021-01-04 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon Jan  4 14:48:52 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: cbus.c central.c ebus.c ebus_mainbus.c fdc.c
fhc.c pckbc_ebus.c psycho.c pyro.c sbus.c upa.c vbus.c vpci.c
vrtc.c
src/sys/arch/sparc64/sparc64: machdep.c

Log Message:
malloc(9) -> kmem(9) -- just the simple, straightforward conversions for now.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/dev/cbus.c \
src/sys/arch/sparc64/dev/pckbc_ebus.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/central.c \
src/sys/arch/sparc64/dev/vbus.c
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sparc64/dev/ebus.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sparc64/dev/ebus_mainbus.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/sparc64/dev/fdc.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/fhc.c
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/sparc64/dev/psycho.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sparc64/dev/pyro.c
cvs rdiff -u -r1.99 -r1.100 src/sys/arch/sparc64/dev/sbus.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc64/dev/upa.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc64/dev/vpci.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/vrtc.c
cvs rdiff -u -r1.298 -r1.299 src/sys/arch/sparc64/sparc64/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/sparc64/dev/cbus.c
diff -u src/sys/arch/sparc64/dev/cbus.c:1.3 src/sys/arch/sparc64/dev/cbus.c:1.4
--- src/sys/arch/sparc64/dev/cbus.c:1.3	Sun Nov 10 21:16:33 2019
+++ src/sys/arch/sparc64/dev/cbus.c	Mon Jan  4 14:48:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cbus.c,v 1.3 2019/11/10 21:16:33 chs Exp $	*/
+/*	$NetBSD: cbus.c,v 1.4 2021/01/04 14:48:51 thorpej Exp $	*/
 /*	$OpenBSD: cbus.c,v 1.15 2015/09/27 11:29:20 kettenis Exp $	*/
 /*
  * Copyright (c) 2008 Mark Kettenis
@@ -18,7 +18,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -238,7 +238,7 @@ cbus_alloc_bus_tag(struct cbus_softc *sc
 {
 	struct sparc_bus_space_tag *bt;
 
-	bt = malloc(sizeof(*bt), M_DEVBUF, M_WAITOK | M_ZERO);
+	bt = kmem_zalloc(sizeof(*bt), KM_SLEEP);
 	bt->cookie = sc;
 	bt->parent = parent;
 	bt->sparc_bus_map = parent->sparc_bus_map;
Index: src/sys/arch/sparc64/dev/pckbc_ebus.c
diff -u src/sys/arch/sparc64/dev/pckbc_ebus.c:1.3 src/sys/arch/sparc64/dev/pckbc_ebus.c:1.4
--- src/sys/arch/sparc64/dev/pckbc_ebus.c:1.3	Sat Oct 13 20:11:48 2018
+++ src/sys/arch/sparc64/dev/pckbc_ebus.c	Mon Jan  4 14:48:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pckbc_ebus.c,v 1.3 2018/10/13 20:11:48 macallan Exp $ */
+/*	$NetBSD: pckbc_ebus.c,v 1.4 2021/01/04 14:48:51 thorpej Exp $ */
 
 /*
  * Copyright (c) 2002 Valeriy E. Ushakov
@@ -28,13 +28,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pckbc_ebus.c,v 1.3 2018/10/13 20:11:48 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pckbc_ebus.c,v 1.4 2021/01/04 14:48:51 thorpej Exp $");
 
 #include 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -154,8 +154,7 @@ pckbc_ebus_attach(device_t parent, devic
 			return;
 		}
 
-		t = malloc(sizeof(struct pckbc_internal), M_DEVBUF, M_WAITOK);
-		memset(t, 0, sizeof(struct pckbc_internal));
+		t = kmem_zalloc(sizeof(struct pckbc_internal), KM_SLEEP);
 		t->t_iot = iot;
 		t->t_ioh_d = ioh_d;
 		t->t_ioh_c = ioh_c;

Index: src/sys/arch/sparc64/dev/central.c
diff -u src/sys/arch/sparc64/dev/central.c:1.4 src/sys/arch/sparc64/dev/central.c:1.5
--- src/sys/arch/sparc64/dev/central.c:1.4	Sun Nov 10 21:16:33 2019
+++ src/sys/arch/sparc64/dev/central.c	Mon Jan  4 14:48:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: central.c,v 1.4 2019/11/10 21:16:33 chs Exp $	*/
+/*	$NetBSD: central.c,v 1.5 2021/01/04 14:48:51 thorpej Exp $	*/
 /*	$OpenBSD: central.c,v 1.7 2010/11/11 17:58:23 miod Exp $	*/
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: central.c,v 1.4 2019/11/10 21:16:33 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: central.c,v 1.5 2021/01/04 14:48:51 thorpej Exp $");
 
 #include 
 #include 
@@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: central.c,v 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -153,7 +154,7 @@ central_alloc_bus_tag(struct central_sof
 {
 	struct sparc_bus_space_tag *bt;
 
-	bt = malloc(sizeof(*bt), M_DEVBUF, M_WAITOK | M_ZERO);
+	bt = kmem_zalloc(sizeof(*bt), KM_SLEEP);
 	bt->cookie = sc;
 	bt->parent = sc->sc_bt;
 #if 0
Index: src/sys/arch/sparc64/dev/vbus.c
diff -u src/sys/arch/sparc64/dev/vbus.c:1.4 src/sys/arch/sparc64/dev/vbus.c:1.5
--- src/sys/arch/sparc64/dev/vbus.c:1.4	Sun Nov 10 21:16:33 2019
+++ src/sys/arch/sparc64/dev/vbus.c	Mon Jan  4 14:48:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vbus.c,v 1.4 2019/11/10 21:16:33 chs Exp $	*/
+/*	$NetBSD: vbus.c,v 1.5 2021/01/04 14:48:52 thorpej Exp $	*/
 /*	$OpenBSD: vbus.c,v 1.8 2015/09/27 11:29:20 kettenis Exp $	*/
 /*
  * Copyright (c) 2008 Mark Kettenis
@@ -19,6 +19,7 @@
 

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

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:09:50 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Rename the CPU fan to SYS fan to match what the firmware calls it.
Check for fan failure and high temperature events when setting the fan
speed.  If one or both is true, run the fans at full speed.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.15 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.16
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.15	Sun Dec 20 09:08:15 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Wed Dec 23 07:09:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.16 2020/12/23 07:09:50 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.16 2020/12/23 07:09:50 jdc Exp $");
 
 #include 
 #include 
@@ -54,7 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 #define PCF8591_CTRL_OSCILLATOR	0x40
 
 #define PCF8591_TEMP_SENS	0x00
-#define PCF8591_CPU_FAN_CTRL	0x01
+#define PCF8591_SYS_FAN_CTRL	0x01
 
 struct ecadc_channel {
 	u_int		chan_num;
@@ -228,12 +228,12 @@ ecadc_attach(device_t parent, device_t s
 	OF_getprop(node, "cpu-fan-speeds", >sc_cpu_fan_spd,
 	XLATE_MAX) > 0) {
 		sc->sc_channels[sc->sc_nchan].chan_num = 1;
-		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_CPU_FAN_CTRL;
+		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_SYS_FAN_CTRL;
 		sensor = >sc_channels[sc->sc_nchan].chan_sensor;
 		sensor->units = ENVSYS_INTEGER;
 		sensor->flags = ENVSYS_FMONNOTSUPP;
 		sensor->state = ENVSYS_SINVALID;
-		strlcpy(sensor->desc, "CPUFAN", sizeof(sensor->desc));
+		strlcpy(sensor->desc, "SYSFAN", sizeof(sensor->desc));
 		sc->sc_channels[sc->sc_nchan].chan_xlate = sc->sc_cpu_fan_spd;
 		DPRINTF("%s: "
 		"added CPUFAN sensor (chan %d) with cpu-fan xlate\n",
@@ -298,7 +298,7 @@ ecadc_detach(device_t self, int flags)
 	for (i = 0; i < sc->sc_nchan; i++) {
 		struct ecadc_channel *chp = >sc_channels[i];
 
-		if (chp->chan_type == PCF8591_CPU_FAN_CTRL) {
+		if (chp->chan_type == PCF8591_SYS_FAN_CTRL) {
 			/* Loop in case the bus is busy */
 			for (c = 0; c < 5; c++) {
 chp->chan_speed = sc->sc_cpu_fan_spd[0];
@@ -307,8 +307,8 @@ ecadc_detach(device_t self, int flags)
 	return 0;
 delay(1);
 			}
-			aprint_error_dev(sc->sc_dev,
-			"cannot set fan speed (chan %d)\n", chp->chan_num);
+			printf("%s: cannot set fan speed (chan %d)\n",
+			device_xname(sc->sc_dev), chp->chan_num);
 		}
 	}
 
@@ -374,11 +374,10 @@ ecadc_refresh(struct sysmon_envsys *sme,
 			}
 			chp->chan_sensor.flags |= ENVSYS_FMONLIMITS;
 		}
-		if (chp->chan_type == PCF8591_CPU_FAN_CTRL)
+		if (chp->chan_type == PCF8591_SYS_FAN_CTRL)
 			chp->chan_sensor.value_cur = data[1 + chp->chan_num];
 
 		chp->chan_sensor.state = ENVSYS_SVALID;
-		chp->chan_sensor.flags &= ~ENVSYS_FNEED_REFRESH;
 	}
 }
 
@@ -419,6 +418,22 @@ is_cpu_temp(const envsys_data_t *edata)
 	return strncmp(edata->desc, "CPU", 3) == 0;
 }
 
+static bool
+is_high_temp(const envsys_data_t *edata)
+{
+	if (edata->units != ENVSYS_INDICATOR)
+		return false;
+	return strcmp(edata->desc, "high_temp") == 0;
+}
+
+static bool
+is_fan_fail(const envsys_data_t *edata)
+{
+	if (edata->units != ENVSYS_INDICATOR)
+		return false;
+	return strcmp(edata->desc, "fan_fail") == 0;
+}
+
 static int
 ecadc_set_fan_speed(struct ecadc_softc *sc, u_int8_t chan, u_int8_t val)
 {
@@ -428,15 +443,15 @@ ecadc_set_fan_speed(struct ecadc_softc *
 	ctrl |= chan;
 	ret = iic_acquire_bus(sc->sc_tag, 0);
 	if (ret) {
-		aprint_error_dev(sc->sc_dev,
-		"error acquiring i2c bus (ch %d)\n", chan);
+		printf("%s: error acquiring i2c bus (ch %d)\n",
+		device_xname(sc->sc_dev), chan);
 		return ret;
 	}
 	ret = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, , 1, 0);
 	if (ret)
-		aprint_error_dev(sc->sc_dev,
-		"error changing fan speed (ch %d)\n", chan);
+		printf("%s: error changing fan speed (ch %d)\n",
+		device_xname(sc->sc_dev), chan);
 	else
 		DPRINTF("%s changed fan speed (ch %d) to 0x%x\n",
 		device_xname(sc->sc_dev), chan, val);
@@ -448,30 +463,47 @@ static void
 ecadc_fan_adjust(void *v)
 {
 	struct ecadc_softc *sc = v;
+	struct ecadc_channel *chp;
 	int i;
 	u_int8_t temp, speed;
+	u_int32_t htemp, ffail;
 
 	for (i = 0; i < sc->sc_nchan; i++) {
-		struct ecadc_channel *chp = >sc_channels[i];
+		chp = >sc_channels[i];
+		if (chp->chan_type != 

CVS commit: src/sys/arch/sparc64/sparc64

2020-12-22 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Wed Dec 23 07:01:14 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add GPIO pin alert definitions for the E250.
Note, that the front panel also applies to the E450.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/sparc64/ofw_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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6	Thu Oct 29 06:47:38 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Wed Dec 23 07:01:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.7 2020/12/23 07:01:14 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7 2020/12/23 07:01:14 jdc Exp $");
 
 #include 
 
@@ -134,6 +134,16 @@ add_gpio_props_e250(device_t dev, void *
 	prop_array_t pins;
 
 	switch (ia->ia_addr) {
+		case 0x38:	/* interrupt status */
+			pins = prop_array_create();
+			add_gpio_pin(pins, "ALERT high_temp", 1, 0, 30);
+			add_gpio_pin(pins, "ALERT disk_event", 2, 0, 30);
+			add_gpio_pin(pins, "ALERT fan_fail", 4, 0, 30);
+			add_gpio_pin(pins, "ALERT key_event", 5, 0, 30);
+			add_gpio_pin(pins, "ALERT psu_event", 6, 0, 30);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
 		case 0x39:	/* PSU status */
 			pins = prop_array_create();
 			add_gpio_pin(pins, "INDICATOR psu0_present", 0, 0, -1);
@@ -160,7 +170,7 @@ add_gpio_props_e250(device_t dev, void *
 			prop_dictionary_set(dict, "pins", pins);
 			prop_object_release(pins);
 			break;
-		case 0x3e:	/* front panel LEDs */
+		case 0x3e:	/* front panel LEDs (E250/E450) */
 			pins = prop_array_create();
 			add_gpio_pin(pins, "LED disk_fault", 0, 0, -1);
 			add_gpio_pin(pins, "LED psu_fault", 1, 0, -1);



CVS commit: src/sys/arch/sparc64/sparc64

2020-12-20 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sun Dec 20 11:58:58 UTC 2020

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

Log Message:
sun4v: add comment in sun4v_tl1_ptbl_miss code path - no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.423 -r1.424 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.423 src/sys/arch/sparc64/sparc64/locore.s:1.424
--- src/sys/arch/sparc64/sparc64/locore.s:1.423	Wed Jan  8 20:59:20 2020
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Dec 20 11:58:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.423 2020/01/08 20:59:20 skrll Exp $	*/
+/*	$NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3343,6 +3343,8 @@ sun4v_tl1_ptbl_miss:
 	bgeu,pt	%xcc, 1f
 	 nop
 
+	/* We had a miss inside rtf_user_fault_start/rtf_user_fault_end block (FILL)
+	
 	/* Fixup %cwp. */
 	rdpr	%cwp, %g1
 	inc	%g1



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

2020-12-20 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec 20 09:08:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
For the E250:
  set fans to medium speed when attaching and full speed when detaching.
  remove unused PS fan definition.
In general:
  return early from attach if the device isn't present.
  handle errors from sysmon during attach so that detach doesn't crash.
  try to handle errors when acquiring the iic bus during detach.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.14 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.15
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.14	Mon Dec  7 13:24:15 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Dec 20 09:08:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.15 2020/12/20 09:08:15 jdc Exp $");
 
 #include 
 #include 
@@ -55,7 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 
 #define PCF8591_TEMP_SENS	0x00
 #define PCF8591_CPU_FAN_CTRL	0x01
-#define PCF8591_PS_FAN_CTRL	0x02
 
 struct ecadc_channel {
 	u_int		chan_num;
@@ -89,6 +88,7 @@ static int	ecadc_detach(device_t, int);
 static void	ecadc_refresh(struct sysmon_envsys *, envsys_data_t *);
 static void	ecadc_get_limits(struct sysmon_envsys *, envsys_data_t *,
 			sysmon_envsys_lim_t *, u_int32_t *);
+static int	ecadc_set_fan_speed(struct ecadc_softc *, u_int8_t, u_int8_t);
 static void	ecadc_timeout(void *);
 static void	ecadc_fan_adjust(void *);
 
@@ -205,6 +205,21 @@ ecadc_attach(device_t parent, device_t s
 		sc->sc_nchan++;
 	}
 
+	sc->sc_tag = ia->ia_tag;
+	sc->sc_addr = ia->ia_addr;
+
+	iic_acquire_bus(sc->sc_tag, 0);
+
+	/* Try a read now, so we can fail if this component isn't present */
+	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
+	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
+		aprint_normal(": read failed\n");
+		iic_release_bus(sc->sc_tag, 0);
+		return;
+	}
+
+	iic_release_bus(sc->sc_tag, 0);
+
 	/*
 	 * Fan speed changing information is missing from OFW
 	 * The E250 CPU fan is connected to the sensor at addr 0x4a, channel 1
@@ -214,7 +229,6 @@ ecadc_attach(device_t parent, device_t s
 	XLATE_MAX) > 0) {
 		sc->sc_channels[sc->sc_nchan].chan_num = 1;
 		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_CPU_FAN_CTRL;
-		sc->sc_channels[sc->sc_nchan].chan_speed = 0;
 		sensor = >sc_channels[sc->sc_nchan].chan_sensor;
 		sensor->units = ENVSYS_INTEGER;
 		sensor->flags = ENVSYS_FMONNOTSUPP;
@@ -225,26 +239,17 @@ ecadc_attach(device_t parent, device_t s
 		"added CPUFAN sensor (chan %d) with cpu-fan xlate\n",
 		device_xname(sc->sc_dev),
 		sc->sc_channels[sc->sc_nchan].chan_num);
-		sc->sc_nchan++;
 
-		sc->sc_hastimer = 1;
-	}
+		/* Set the fan to medium speed */
+		sc->sc_channels[sc->sc_nchan].chan_speed =
+		(sc->sc_cpu_fan_spd[0]+sc->sc_cpu_fan_spd[XLATE_MAX])/2;
+		ecadc_set_fan_speed(sc, sc->sc_channels[sc->sc_nchan].chan_num,
+		sc->sc_channels[sc->sc_nchan].chan_speed);
 
-	sc->sc_tag = ia->ia_tag;
-	sc->sc_addr = ia->ia_addr;
-
-	iic_acquire_bus(sc->sc_tag, 0);
-
-	/* Try a read now, so we can fail if this component isn't present */
-	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
-	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
-		aprint_normal(": read failed\n");
-		iic_release_bus(sc->sc_tag, 0);
-		return;
+		sc->sc_nchan++;
+		sc->sc_hastimer = 1;
 	}
 
-	iic_release_bus(sc->sc_tag, 0);
-
 	/* Hook us into the sysmon_envsys subsystem */
 	sc->sc_sme = sysmon_envsys_create();
 	sc->sc_sme->sme_name = device_xname(self);
@@ -280,6 +285,8 @@ static int
 ecadc_detach(device_t self, int flags)
 {
 	struct ecadc_softc *sc = device_private(self);
+	int c, i;
+
 	if (sc->sc_hastimer) {
 		callout_halt(>sc_timer, NULL);
 		callout_destroy(>sc_timer);
@@ -288,6 +295,23 @@ ecadc_detach(device_t self, int flags)
 	if (sc->sc_sme != NULL)
 		sysmon_envsys_unregister(sc->sc_sme);
 
+	for (i = 0; i < sc->sc_nchan; i++) {
+		struct ecadc_channel *chp = >sc_channels[i];
+
+		if (chp->chan_type == PCF8591_CPU_FAN_CTRL) {
+			/* Loop in case the bus is busy */
+			for (c = 0; c < 5; c++) {
+chp->chan_speed = sc->sc_cpu_fan_spd[0];
+if (!ecadc_set_fan_speed(sc, chp->chan_num,
+chp->chan_speed))
+	return 0;
+delay(1);
+			}
+			aprint_error_dev(sc->sc_dev,
+			"cannot set fan speed (chan %d)\n", 

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

2020-12-07 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon Dec  7 13:24:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Add some debugging output to check sensor addition and refresh.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.14
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13	Sun Dec  6 10:06:15 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Mon Dec  7 13:24:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.14 2020/12/07 13:24:15 jdc Exp $");
 
 #include 
 #include 
@@ -34,6 +34,12 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 #include 
 #include 
 
+#ifdef ECADC_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
 /* Translation tables contain 254 entries */
 #define XLATE_SIZE		256
 #define XLATE_MAX		(XLATE_SIZE - 2)
@@ -126,6 +132,7 @@ ecadc_attach(device_t parent, device_t s
 	sc->sc_nchan = 0;
 	sc->sc_hastimer = 0;
 
+	DPRINTF("\n");
 	if ((len = OF_getprop(node, "thermisters", term,
 	sizeof(term))) < 0) {
 		aprint_error(": couldn't find \"thermisters\" property\n");
@@ -170,15 +177,25 @@ ecadc_attach(device_t parent, device_t s
 		sensor->state = ENVSYS_SINVALID;
 		strlcpy(sensor->desc, desc, sizeof(sensor->desc));
 
-		if (strncmp(desc, "CPU", 3) == 0)
+		if (strncmp(desc, "CPU", 3) == 0) {
 			sc->sc_channels[sc->sc_nchan].chan_xlate =
 			sc->sc_cpu_xlate;
-		else if (strncmp(desc, "PS", 2) == 0)
+			DPRINTF("%s: "
+			"added %s sensor (chan %d) with cpu_xlate\n",
+			device_xname(sc->sc_dev), desc, chan);
+		} else if (strncmp(desc, "PS", 2) == 0) {
 			sc->sc_channels[sc->sc_nchan].chan_xlate =
 			sc->sc_ps_xlate;
-		else
+			DPRINTF("%s: "
+			"added %s sensor (chan %d) with ps_xlate\n",
+			device_xname(sc->sc_dev), desc, chan);
+		} else {
 			sc->sc_channels[sc->sc_nchan].chan_factor =
 			(100 * num) / den;
+			DPRINTF("%s: "
+			"added %s sensor (chan %d) without xlate\n",
+			device_xname(sc->sc_dev), desc, chan);
+		}
 		sc->sc_channels[sc->sc_nchan].chan_min =
 		27315 + 100 * minv;
 		sc->sc_channels[sc->sc_nchan].chan_warn =
@@ -204,6 +221,10 @@ ecadc_attach(device_t parent, device_t s
 		sensor->state = ENVSYS_SINVALID;
 		strlcpy(sensor->desc, "CPUFAN", sizeof(sensor->desc));
 		sc->sc_channels[sc->sc_nchan].chan_xlate = sc->sc_cpu_fan_spd;
+		DPRINTF("%s: "
+		"added CPUFAN sensor (chan %d) with cpu-fan xlate\n",
+		device_xname(sc->sc_dev),
+		sc->sc_channels[sc->sc_nchan].chan_num);
 		sc->sc_nchan++;
 
 		sc->sc_hastimer = 1;
@@ -312,9 +333,21 @@ ecadc_refresh(struct sysmon_envsys *sme,
 temp &= ~0xff;
 temp += data[1 + chp->chan_num];
 chp->chan_sensor.value_cur = temp;
-			} else
+DPRINTF("%s: xlate %s sensor = %d"
+" (0x%x > 0x%x)\n",
+device_xname(sc->sc_dev),
+chp->chan_sensor.desc, temp,
+data[1 + chp->chan_num],
+chp->chan_xlate[data[1 + chp->chan_num]]);
+			} else {
 chp->chan_sensor.value_cur = 27315 +
 chp->chan_factor * data[1 + chp->chan_num];
+DPRINTF("%s: read %s sensor = %d (0x%x)\n",
+device_xname(sc->sc_dev),
+chp->chan_sensor.desc,
+chp->chan_sensor.value_cur,
+data[1 + chp->chan_num]);
+			}
 			chp->chan_sensor.flags |= ENVSYS_FMONLIMITS;
 		}
 		if (chp->chan_type == PCF8591_CPU_FAN_CTRL ||
@@ -382,8 +415,8 @@ ecadc_set_fan_speed(struct ecadc_softc *
 		aprint_error_dev(sc->sc_dev,
 		"error changing fan speed (ch %d)\n", chan);
 	else
-		aprint_debug_dev(sc->sc_dev,
-		"changed fan speed (ch %d) to 0x%x\n", chan, val);
+		DPRINTF("%s changed fan speed (ch %d) to 0x%x\n",
+		device_xname(sc->sc_dev), chan, val);
 	iic_release_bus(sc->sc_tag, 0);
 	return ret;
 }



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

2020-12-06 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Dec  6 10:06:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.
While here, handle errors attaching sysmon and acquiring the iic bus lock.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.13
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12	Sat Dec  5 15:08:21 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sun Dec  6 10:06:15 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.13 2020/12/06 10:06:15 jdc Exp $");
 
 #include 
 #include 
@@ -99,28 +99,10 @@ static int
 ecadc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
-	struct ecadc_softc sc;
 	int match_result;
-	u_int8_t junk;
 
-	if (!iic_use_direct_match(ia, cf, compat_data, _result))
-		return 0;
-
-	/* Try a read so that we don't match on optional components */
-	if (match_result) {
-		sc.sc_tag = ia->ia_tag;
-		sc.sc_addr = ia->ia_addr;
-
-		iic_acquire_bus(sc.sc_tag, 0);
-		if (iic_exec(sc.sc_tag, I2C_OP_READ_WITH_STOP, sc.sc_addr,
-		NULL, 0, , 1, 0)) {
-			iic_release_bus(sc.sc_tag, 0);
-			return 0;
-		} else {
-			iic_release_bus(sc.sc_tag, 0);
-			return match_result;
-		}
-	}
+	if (iic_use_direct_match(ia, cf, compat_data, _result))
+		return match_result;
 
 	/* This driver is direct-config only. */
 
@@ -232,10 +214,10 @@ ecadc_attach(device_t parent, device_t s
 
 	iic_acquire_bus(sc->sc_tag, 0);
 
-	/* Try a read now, so we can fail if it doesn't work */
+	/* Try a read now, so we can fail if this component isn't present */
 	if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
 	NULL, 0, junk, sc->sc_nchan + 1, 0)) {
-		aprint_error(": read failed\n");
+		aprint_normal(": read failed\n");
 		iic_release_bus(sc->sc_tag, 0);
 		return;
 	}
@@ -259,6 +241,7 @@ ecadc_attach(device_t parent, device_t s
 		aprint_error_dev(self, "error %d registering with sysmon\n",
 			error);
 		sysmon_envsys_destroy(sc->sc_sme);
+		sc->sc_sme = NULL;
 		return;
 	}
 	
@@ -296,7 +279,8 @@ ecadc_refresh(struct sysmon_envsys *sme,
 	u_int8_t ctrl = PCF8591_CTRL_CH0 | PCF8591_CTRL_AUTOINC |
 	PCF8591_CTRL_OSCILLATOR;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0))
+		return;
 	if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, NULL, 0, 0)) {
 		iic_release_bus(sc->sc_tag, 0);
@@ -386,7 +370,12 @@ ecadc_set_fan_speed(struct ecadc_softc *
 	int ret;
 
 	ctrl |= chan;
-	iic_acquire_bus(sc->sc_tag, 0);
+	ret = iic_acquire_bus(sc->sc_tag, 0);
+	if (ret) {
+		aprint_error_dev(sc->sc_dev,
+		"error acquiring i2c bus (ch %d)\n", chan);
+		return ret;
+	}
 	ret = iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_addr,
 	, 1, , 1, 0);
 	if (ret)



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

2020-12-05 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Dec  5 15:08:21 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
When matching, try a read in case this is an optional device and isn't
actually present.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.12
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11	Sat Oct 31 13:17:34 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Dec  5 15:08:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.12 2020/12/05 15:08:21 jdc Exp $");
 
 #include 
 #include 
@@ -99,10 +99,28 @@ static int
 ecadc_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct i2c_attach_args *ia = aux;
+	struct ecadc_softc sc;
 	int match_result;
+	u_int8_t junk;
 
-	if (iic_use_direct_match(ia, cf, compat_data, _result))
-		return match_result;
+	if (!iic_use_direct_match(ia, cf, compat_data, _result))
+		return 0;
+
+	/* Try a read so that we don't match on optional components */
+	if (match_result) {
+		sc.sc_tag = ia->ia_tag;
+		sc.sc_addr = ia->ia_addr;
+
+		iic_acquire_bus(sc.sc_tag, 0);
+		if (iic_exec(sc.sc_tag, I2C_OP_READ_WITH_STOP, sc.sc_addr,
+		NULL, 0, , 1, 0)) {
+			iic_release_bus(sc.sc_tag, 0);
+			return 0;
+		} else {
+			iic_release_bus(sc.sc_tag, 0);
+			return match_result;
+		}
+	}
 
 	/* This driver is direct-config only. */
 



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

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 13:17:34 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c tda.c

Log Message:
Call sysmon_envsys_unregister() not sysmon_envsys_destroy() when
detaching.  Pointed out by Michael van Elst.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/tda.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10	Sat Oct 24 15:16:39 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Oct 31 13:17:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $");
 
 #include 
 #include 
@@ -264,7 +264,7 @@ ecadc_detach(device_t self, int flags)
 	}
 
 	if (sc->sc_sme != NULL)
-		sysmon_envsys_destroy(sc->sc_sme);
+		sysmon_envsys_unregister(sc->sc_sme);
 
 	return 0;
 }

Index: src/sys/arch/sparc64/dev/tda.c
diff -u src/sys/arch/sparc64/dev/tda.c:1.13 src/sys/arch/sparc64/dev/tda.c:1.14
--- src/sys/arch/sparc64/dev/tda.c:1.13	Fri Mar  1 02:38:17 2019
+++ src/sys/arch/sparc64/dev/tda.c	Sat Oct 31 13:17:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $	*/
+/*	$NetBSD: tda.c,v 1.14 2020/10/31 13:17:34 jdc Exp $	*/
 /*	$OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.14 2020/10/31 13:17:34 jdc Exp $");
 
 #include 
 #include 
@@ -177,7 +177,7 @@ tda_detach(device_t self, int flags)
 	struct tda_softc *sc = device_private(self);
 
 	if (sc->sc_sme != NULL)
-		sysmon_envsys_destroy(sc->sc_sme);
+		sysmon_envsys_unregister(sc->sc_sme);
 
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);



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

2020-10-30 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 30 06:44:38 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add pcagpio and pcf8574io - hardware status monitors on V210/V240 and E250.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.232 src/sys/arch/sparc64/conf/GENERIC:1.233
--- src/sys/arch/sparc64/conf/GENERIC:1.232	Mon Oct 26 11:49:45 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Fri Oct 30 06:44:37 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.232 2020/10/26 11:49:45 martin Exp $
+# $NetBSD: GENERIC,v 1.233 2020/10/30 06:44:37 jdc Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.232 $"
+#ident		"GENERIC-$Revision: 1.233 $"
 
 maxusers	64
 
@@ -826,6 +826,8 @@ lmtemp* 	at iic? addr?
 tda*		at iic? addr?	# fan control on SB1000/2000
 dbcool* 	at iic? addr?	# SB25000
 seeprom*	at iic? addr?	# i2c-at24c64 fru's
+pcagpio* 	at iic? addr?	# V210/V240 GPIO's
+pcf8574io* 	at iic? addr?	# E250 GPIO's
 
 ### Other pseudo-devices
 



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-29 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Oct 29 06:47:39 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.c ofw_patch.h

Log Message:
Add information about GPIO pin assignments and drive bays in the E250 and
v240.  Consolidate common code for v210/v240 and E250.
Modify the GPIO pin names to include a type (currently LED or INDICATOR)
which we can then handle in the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.226 src/sys/arch/sparc64/sparc64/autoconf.c:1.227
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.226	Fri Oct 23 15:18:10 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Thu Oct 29 06:47:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.227 2020/10/29 06:47:38 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.227 2020/10/29 06:47:38 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1089,6 +1089,11 @@ device_register(device_t dev, void *aux)
 add_gpio_props_v210(dev, aux);
 			}
 		} 
+		if (device_is_a(dev, "pcf8574io")) {
+			if (!strcmp(machine_model, "SUNW,Ultra-250")) {
+add_gpio_props_e250(dev, aux);
+			}
+		} 
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;
@@ -1117,9 +1122,7 @@ device_register(device_t dev, void *aux)
 		0, periph->periph_lun);
 		if (device_is_a(busdev, "scsibus")) {
 			/* see if we're in a known SCA drivebay */
-			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
-add_drivebay_props_v210(dev, ofnode, aux);
-			}
+			add_drivebay_props(dev, ofnode, aux);
 		}
 		return;
 	} else if (device_is_a(dev, "wd")) {

Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.6
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5	Sun Oct 25 07:46:53 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Thu Oct 29 06:47:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.6 2020/10/29 06:47:38 jdc Exp $");
 
 #include 
 
@@ -42,11 +42,10 @@ __KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,
 #include 
 
 static void
-add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
+add_gpio_pin(prop_array_t pins, const char *name, int num, int act, int def)
 {
 	prop_dictionary_t pin = prop_dictionary_create();
 	prop_dictionary_set_string(pin, "name", name);
-	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
 	prop_dictionary_set_uint32(pin, "pin", num);
 	prop_dictionary_set_bool(pin, "active_high", act);
 	if (def != -1)
@@ -62,7 +61,7 @@ create_i2c_dict(device_t busdev)
 	prop_array_t cfg = NULL;
 
 	cfg = prop_dictionary_get(props, "i2c-child-devices");
- 	if (!cfg) {
+	if (!cfg) {
 		DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n"));
 		cfg = prop_array_create();
 		prop_dictionary_set(props, "i2c-child-devices", cfg);
@@ -100,18 +99,89 @@ add_gpio_props_v210(device_t dev, void *
 	switch (ia->ia_addr) {
 		case 0x38:	/* front panel LEDs */
 			pins = prop_array_create();
-			add_gpio_LED(pins, "indicator", 7, 0, -1);
-			add_gpio_LED(pins, "fault", 5, 0, 0);
-			add_gpio_LED(pins, "power", 4, 0, 1);
+			add_gpio_pin(pins, "LED indicator", 7, 0, -1);
+			add_gpio_pin(pins, "LED fault", 5, 0, 0);
+			add_gpio_pin(pins, "LED power", 4, 0, 1);
 			prop_dictionary_set(dict, "pins", pins);
 			prop_object_release(pins);
 			break;
-		case 0x23:	/* drive bay LEDs */
+		case 0x23:	/* drive bay O/1 LEDs */
 			pins = prop_array_create();
-			add_gpio_LED(pins, "bay0_fault", 10, 0, 0);
-			add_gpio_LED(pins, "bay1_fault", 11, 0, 0);
-			add_gpio_LED(pins, "bay0_remove", 12, 0, 0);
-			add_gpio_LED(pins, "bay1_remove", 13, 0, 0);
+			add_gpio_pin(pins, "LED bay0_fault", 10, 0, 0);
+			add_gpio_pin(pins, "LED bay1_fault", 11, 0, 0);
+			add_gpio_pin(pins, "LED bay0_remove", 12, 0, 0);
+			add_gpio_pin(pins, "LED bay1_remove", 13, 0, 0);
+			prop_dictionary_set(dict, "pins", pins);
+			

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

2020-10-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Oct 26 11:49:45 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Backout previous, PR 54810 has been fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.231 src/sys/arch/sparc64/conf/GENERIC:1.232
--- src/sys/arch/sparc64/conf/GENERIC:1.231	Sun Oct 25 18:53:11 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Mon Oct 26 11:49:45 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.231 2020/10/25 18:53:11 martin Exp $
+# $NetBSD: GENERIC,v 1.232 2020/10/26 11:49:45 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.231 $"
+#ident		"GENERIC-$Revision: 1.232 $"
 
 maxusers	64
 
@@ -861,6 +861,3 @@ options 	PAX_SEGVGUARD=0		# PaX Segmenta
 # options 	PAX_MPROTECT=0		# PaX mprotect(2) restrictions
 # options 	PAX_MPROTECT_DEBUG=1	# PaX mprotect debug
 options 	PAX_ASLR=1		# PaX Address Space Layout Randomization
-
-# Temporary workaround while analyzing memory corruption when booting from CD
-no file-system NTFS



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

2020-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 25 18:53:12 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Temporarily disable NTFS for an internal test.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.230 src/sys/arch/sparc64/conf/GENERIC:1.231
--- src/sys/arch/sparc64/conf/GENERIC:1.230	Sun Sep 27 13:48:54 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Sun Oct 25 18:53:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.230 2020/09/27 13:48:54 roy Exp $
+# $NetBSD: GENERIC,v 1.231 2020/10/25 18:53:11 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.230 $"
+#ident		"GENERIC-$Revision: 1.231 $"
 
 maxusers	64
 
@@ -861,3 +861,6 @@ options 	PAX_SEGVGUARD=0		# PaX Segmenta
 # options 	PAX_MPROTECT=0		# PaX mprotect(2) restrictions
 # options 	PAX_MPROTECT_DEBUG=1	# PaX mprotect debug
 options 	PAX_ASLR=1		# PaX Address Space Layout Randomization
+
+# Temporary workaround while analyzing memory corruption when booting from CD
+no file-system NTFS



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-25 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 25 07:46:54 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Don't release the last reference to the "i2c-child-devices" dictionary in
the v210/v240 patches.
Fixes missing i2c devices there (pointed out by macallan@).
While here, add debug to show when we create the dictionary.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/sparc64/ofw_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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.5
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4	Sat Oct 24 13:47:53 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sun Oct 25 07:46:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.5 2020/10/25 07:46:53 jdc Exp $");
 
 #include 
 
@@ -63,6 +63,7 @@ create_i2c_dict(device_t busdev)
 
 	cfg = prop_dictionary_get(props, "i2c-child-devices");
  	if (!cfg) {
+		DPRINTF(ACDB_PROBE, ("\nCreating new i2c-child-devices\n"));
 		cfg = prop_array_create();
 		prop_dictionary_set(props, "i2c-child-devices", cfg);
 		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
@@ -171,8 +172,6 @@ add_env_sensors_v210(device_t busdev)
 	add_i2c_device(cfg, "hardware-monitor", "i2c-adm1026", 0x2e, 0);
 	/* LM75 at 0x4e */
 	add_i2c_device(cfg, "temperature-sensor", "i2c-lm75", 0x4e, 0);
-
-	prop_object_release(cfg);
 }
 
 /* Sensors and GPIO's for E450 and E250 */



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

2020-10-24 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 24 15:16:39 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c

Log Message:
Add support for automatically changing the CPU fan speed on the E250 in a
similar way to the SB1000/SB2000.
The fan control information was determined by experiment, as it's only
partially available in OFW.
Hardcode the missing information for E250 fan control into the driver
(it should be possible to support the E450 in future too).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/sparc64/dev/pcf8591_envctrl.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/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.9 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.9	Tue Jun 26 06:03:57 2018
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Oct 24 15:16:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.9 2018/06/26 06:03:57 thorpej Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,17 +19,25 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.9 2018/06/26 06:03:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $");
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
+#include 
+
+#include 
 
 #include 
 #include 
 
+/* Translation tables contain 254 entries */
+#define XLATE_SIZE		256
+#define XLATE_MAX		(XLATE_SIZE - 2)
+
 #define PCF8591_CHANNELS	4
 
 #define PCF8591_CTRL_CH0	0x00
@@ -39,35 +47,48 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8591_envc
 #define PCF8591_CTRL_AUTOINC	0x04
 #define PCF8591_CTRL_OSCILLATOR	0x40
 
+#define PCF8591_TEMP_SENS	0x00
+#define PCF8591_CPU_FAN_CTRL	0x01
+#define PCF8591_PS_FAN_CTRL	0x02
+
 struct ecadc_channel {
 	u_int		chan_num;
+	u_int		chan_type;
 	envsys_data_t	chan_sensor;
 	u_char		*chan_xlate;
 	int64_t		chan_factor;
 	int64_t		chan_min;
 	int64_t		chan_warn;
 	int64_t		chan_crit;
+	u_int8_t	chan_speed;
 };
 
 struct ecadc_softc {
 	device_t		sc_dev;
 	i2c_tag_t		sc_tag;
 	i2c_addr_t		sc_addr;
-	u_char			sc_ps_xlate[256];
-	u_char			sc_cpu_xlate[256];
+	u_char			sc_ps_xlate[XLATE_SIZE];
+	u_char			sc_cpu_xlate[XLATE_SIZE];
+	u_char			sc_cpu_fan_spd[XLATE_SIZE];
 	u_int			sc_nchan;
 	struct ecadc_channel	sc_channels[PCF8591_CHANNELS];
 	struct sysmon_envsys	*sc_sme;
+	int			sc_hastimer;
+	callout_t		sc_timer;
 };
 
 static int	ecadc_match(device_t, cfdata_t, void *);
 static void	ecadc_attach(device_t, device_t, void *);
+static int	ecadc_detach(device_t, int);
 static void	ecadc_refresh(struct sysmon_envsys *, envsys_data_t *);
 static void	ecadc_get_limits(struct sysmon_envsys *, envsys_data_t *,
-			sysmon_envsys_lim_t *, uint32_t *);
-
-CFATTACH_DECL_NEW(ecadc, sizeof(struct ecadc_softc),
-	ecadc_match, ecadc_attach, NULL, NULL);
+			sysmon_envsys_lim_t *, u_int32_t *);
+static void	ecadc_timeout(void *);
+static void	ecadc_fan_adjust(void *);
+
+CFATTACH_DECL3_NEW(ecadc, sizeof(struct ecadc_softc),
+	ecadc_match, ecadc_attach, ecadc_detach, NULL, NULL, NULL,
+	DVF_DETACH_SHUTDOWN);
 
 static const struct device_compatible_entry compat_data[] = {
 	{ "ecadc",		0 },
@@ -102,6 +123,9 @@ ecadc_attach(device_t parent, device_t s
 	u_int i;
 
 	sc->sc_dev = self;
+	sc->sc_nchan = 0;
+	sc->sc_hastimer = 0;
+
 	if ((len = OF_getprop(node, "thermisters", term,
 	sizeof(term))) < 0) {
 		aprint_error(": couldn't find \"thermisters\" property\n");
@@ -109,15 +133,14 @@ ecadc_attach(device_t parent, device_t s
 	}
 
 	if (OF_getprop(node, "cpu-temp-factors", >sc_cpu_xlate[2],
-	sizeof(sc->sc_cpu_xlate) - 2) < 0) {
+	XLATE_MAX) < 0) {
 		aprint_error(": couldn't find \"cpu-temp-factors\" property\n");
 		return;
 	}
 	sc->sc_cpu_xlate[0] = sc->sc_cpu_xlate[1] = sc->sc_cpu_xlate[2];
 
 	/* Only the Sun Enterprise 450 has these. */
-	OF_getprop(node, "ps-temp-factors", >sc_ps_xlate[2],
-	sizeof(sc->sc_ps_xlate) - 2);
+	OF_getprop(node, "ps-temp-factors", >sc_ps_xlate[2], XLATE_MAX);
 	sc->sc_ps_xlate[0] = sc->sc_ps_xlate[1] = sc->sc_ps_xlate[2];
 
 	cp = term;
@@ -139,6 +162,7 @@ ecadc_attach(device_t parent, device_t s
 			num = den = 1;
 
 		sc->sc_channels[sc->sc_nchan].chan_num = chan;
+		sc->sc_channels[sc->sc_nchan].chan_type = PCF8591_TEMP_SENS;
 
 		sensor = >sc_channels[sc->sc_nchan].chan_sensor;
 		sensor->units = ENVSYS_STEMP;
@@ -164,6 +188,27 @@ ecadc_attach(device_t parent, device_t s
 		sc->sc_nchan++;
 	}
 
+	/*
+	 * Fan speed changing information is missing from OFW
+	 * The E250 CPU fan is connected to the sensor at addr 0x4a, channel 1
+	 */
+	if (ia->ia_addr == 0x4a && !strcmp(machine_model, "SUNW,Ultra-250") &&
+	OF_getprop(node, "cpu-fan-speeds", >sc_cpu_fan_spd,
+	

CVS commit: src/sys/arch/sparc64/sparc64

2020-10-24 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 24 13:47:53 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add E250 i2c devices missing from the OFW tree.
Normalise the spelling of "temperature".


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/sparc64/ofw_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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.4
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3	Fri Oct 23 17:53:07 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Sat Oct 24 13:47:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.4 2020/10/24 13:47:53 jdc Exp $");
 
 #include 
 
@@ -187,13 +187,13 @@ add_i2c_props_e450(device_t busdev, uint
 	/* Power supply 1 temperature. */
 	add_i2c_device(cfg, "PSU-1", "ecadc", 0x48, node);
 
-	/* Power supply 2 termperature. */
+	/* Power supply 2 temperature. */
 	add_i2c_device(cfg, "PSU-2", "ecadc", 0x49, node);
 
-	/* Power supply 3 tempterature. */
+	/* Power supply 3 temperature. */
 	add_i2c_device(cfg, "PSU-3", "ecadc", 0x4a, node);
 
-	/* Ambient tempterature. */
+	/* Ambient temperature. */
 	add_i2c_device(cfg, "ambient", "i2c-lm75", 0x4d, node);
 
 	/* CPU temperatures. */
@@ -206,15 +206,29 @@ void
 add_i2c_props_e250(device_t busdev, uint64_t node)
 {
 	prop_array_t cfg;
+	int i;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
 	cfg = create_i2c_dict(busdev);
 
 	/* PSU temperature / CPU fan */
 	add_i2c_device(cfg, "PSU", "ecadc", 0x4a, node);
+
 	/* CPU & system board temperature */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
 
+	/* GPIO's */
+	for (i = 0x38; i <= 0x39; i++)
+		add_i2c_device(cfg, "gpio", "i2c-pcf8574", i, node);
+	for (i = 0x3d; i <= 0x3f; i++)
+		add_i2c_device(cfg, "gpio", "i2c-pcf8574", i, node);
+
+	/* NVRAM */
+	add_i2c_device(cfg, "nvram", "i2c-at24c02", 0x52, node);
+
+	/* RSC clock */
+	add_i2c_device(cfg, "rscrtc", "i2c-ds1307", 0x68, node);
+
 	prop_object_release(cfg);
 }
 



CVS commit: src/sys/arch/sparc64/sparc64

2020-10-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 23 17:53:07 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c

Log Message:
Add missing prop_object_release() to the E250/E450 patches.
Use the recently added (in r1.2) functions for SPARCle i2c devices too.
Simplify adding "compatible" entries and handle cases where there is none.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/sparc64/ofw_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/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.2 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.3
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.2	Fri Oct 23 15:18:10 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c	Fri Oct 23 17:53:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.c,v 1.2 2020/10/23 15:18:10 jdc Exp $ */
+/*	$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.2 2020/10/23 15:18:10 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.3 2020/10/23 17:53:07 jdc Exp $");
 
 #include 
 
@@ -75,15 +75,14 @@ add_i2c_device(prop_array_t cfg, const c
 uint32_t addr, uint64_t node)
 {
 	prop_dictionary_t dev;
-	prop_data_t data;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding i2c device: %s (%s) @ 0x%x (%lx)\n",
-	name, compat, addr, node & 0x));
+	name, compat == NULL ? "NULL" : compat, addr, node & 0x));
 	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);
+	if (compat != NULL)
+		prop_dictionary_set_data(dev, "compatible", compat,
+		strlen(compat) + 1);
 	prop_dictionary_set_uint32(dev, "addr", addr);
 	prop_dictionary_set_uint64(dev, "cookie", node);
 	prop_array_add(cfg, dev);
@@ -146,20 +145,14 @@ add_drivebay_props_v210(device_t dev, in
 void
 add_spdmem_props_sparcle(device_t busdev)
 {
-	prop_dictionary_t props = device_properties(busdev);
-	prop_array_t cfg = prop_array_create();
+	prop_array_t cfg;
 	int i;
 
 	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
-	for (i = 0x50; i <= 0x51; i++) {
-		prop_dictionary_t spd = prop_dictionary_create();
-		prop_dictionary_set_string(spd, "name", "dimm-spd");
-		prop_dictionary_set_uint32(spd, "addr", i);
-		prop_dictionary_set_uint64(spd, "cookie", 0);
-		prop_array_add(cfg, spd);
-		prop_object_release(spd);
-	}
-	prop_dictionary_set(props, "i2c-child-devices", cfg);
+
+	cfg = create_i2c_dict(busdev);
+	for (i = 0x50; i <= 0x51; i++)
+		add_i2c_device(cfg, "dimm-spd", NULL, i, 0);
 	prop_object_release(cfg);
 }
 
@@ -205,6 +198,8 @@ add_i2c_props_e450(device_t busdev, uint
 
 	/* CPU temperatures. */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
+
+	prop_object_release(cfg);
 }
 
 void
@@ -219,6 +214,8 @@ add_i2c_props_e250(device_t busdev, uint
 	add_i2c_device(cfg, "PSU", "ecadc", 0x4a, node);
 	/* CPU & system board temperature */
 	add_i2c_device(cfg, "CPU", "ecadc", 0x4f, node);
+
+	prop_object_release(cfg);
 }
 
 /* Hardware specific device properties */



CVS commit: src/sys/arch/sparc64

2020-10-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 23 15:18:10 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcfiic_ebus.c
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.c ofw_patch.h

Log Message:
Move E250 and E450 i2c patches from dev/pcfiic_ebus.c to sparc64/ofw_patch.c.
They are now co-located with the other OFW patch routines.
New i2c devices are created for E250/E450 and v210/v240, so create new
functions to avoid duplicate code.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/sparc64/dev/pcfiic_ebus.c
cvs rdiff -u -r1.225 -r1.226 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/dev/pcfiic_ebus.c
diff -u src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.6 src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.7
--- src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.6	Fri Jun 12 03:41:57 2020
+++ src/sys/arch/sparc64/dev/pcfiic_ebus.c	Fri Oct 23 15:18:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcfiic_ebus.c,v 1.6 2020/06/12 03:41:57 thorpej Exp $	*/
+/*	$NetBSD: pcfiic_ebus.c,v 1.7 2020/10/23 15:18:10 jdc Exp $	*/
 /*	$OpenBSD: pcfiic_ebus.c,v 1.13 2008/06/08 03:07:40 deraadt Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.6 2020/06/12 03:41:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.7 2020/10/23 15:18:10 jdc Exp $");
 
 /*
  * Device specific driver for the EBus i2c devices found on some sun4u
@@ -57,11 +57,6 @@ struct pcfiic_ebus_softc {
 CFATTACH_DECL_NEW(pcfiic, sizeof(struct pcfiic_ebus_softc),
 	pcfiic_ebus_match, pcfiic_ebus_attach, NULL, NULL);
 
-static prop_array_t create_dict(device_t);
-static void add_prop(prop_array_t, const char *, const char *, u_int, int);
-static void envctrl_props(prop_array_t, int);
-static void envctrltwo_props(prop_array_t, int);
-
 int
 pcfiic_ebus_match(device_t parent, struct cfdata *match, void *aux)
 {
@@ -103,6 +98,11 @@ pcfiic_ebus_attach(device_t parent, devi
 		return;
 	}
 
+	/* E450 and E250 have a different clock */
+	if ((strcmp(ea->ea_name, "SUNW,envctrl") == 0) ||
+	(strcmp(ea->ea_name, "SUNW,envctrltwo") == 0))
+		clock = PCF8584_CLK_12 | PCF8584_SCL_45;
+
 	sc->sc_dev = self;
 	if (OF_getprop(ea->ea_node, "compatible", compat, sizeof(compat)) > 0 &&
 	strcmp(compat, "SUNW,bbc-i2c") == 0) {
@@ -160,65 +160,5 @@ pcfiic_ebus_attach(device_t parent, devi
 	if (esc->esc_ih == NULL)
 		sc->sc_poll = 1;
 
-	if (strcmp(ea->ea_name, "SUNW,envctrl") == 0) {
-		envctrl_props(create_dict(self), ea->ea_node);
-		pcfiic_attach(sc, 0x55, PCF8584_CLK_12 | PCF8584_SCL_45, 0);
-	} else if (strcmp(ea->ea_name, "SUNW,envctrltwo") == 0) {
-		envctrltwo_props(create_dict(self), ea->ea_node);
-		pcfiic_attach(sc, 0x55, PCF8584_CLK_12 | PCF8584_SCL_45, 0);
-	} else
-		pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), clock, swapregs);
-}
-
-static prop_array_t
-create_dict(device_t parent)
-{
-	prop_dictionary_t props = device_properties(parent);
-	prop_array_t cfg = prop_dictionary_get(props, "i2c-child-devices");
-	if (cfg) return cfg;
-	cfg = prop_array_create();
-	prop_dictionary_set(props, "i2c-child-devices", cfg);
-	prop_object_release(cfg);
-	return cfg;
-}
-
-static void
-add_prop(prop_array_t c, const char *name, const char *compat, u_int addr,
-	int node)
-{
-	prop_dictionary_t dev;
-
-	dev = prop_dictionary_create();
-	prop_dictionary_set_string(dev, "name", name);
-	prop_dictionary_set_data(dev, "compatible", compat, strlen(compat)+1);
-	prop_dictionary_set_uint32(dev, "addr", addr);
-	prop_dictionary_set_uint64(dev, "cookie", node);
-	prop_array_add(c, dev);
-	prop_object_release(dev);
-}
-
-static void
-envctrl_props(prop_array_t c, int node)
-{
-	/* Power supply 1 temperature. */
-	add_prop(c, "PSU-1", "ecadc", 0x48, node);
-
-	/* Power supply 2 termperature. */
-	add_prop(c, "PSU-2", "ecadc", 0x49, node);
-
-	/* Power supply 3 tempterature. */
-	add_prop(c, "PSU-3", "ecadc", 0x4a, node);
-
-	/* Ambient tempterature. */
-	add_prop(c, "ambient", "i2c-lm75", 0x4d, node);
-
-	/* CPU temperatures. */
-	add_prop(c, "CPU", "ecadc", 0x4f, node);
-}
-
-static void
-envctrltwo_props(prop_array_t c, int node)
-{
-	add_prop(c, "PSU", "ecadc", 0x4a, node);
-	add_prop(c, "CPU", "ecadc", 0x4f, node);
+	pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), clock, swapregs);
 }

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.225 src/sys/arch/sparc64/sparc64/autoconf.c:1.226
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.225	Sat Oct 17 08:10:31 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Fri Oct 23 15:18:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.226 2020/10/23 15:18:10 jdc Exp 

CVS commit: src/sys/arch/sparc64/sparc64

2020-10-17 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 17 08:10:31 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: autoconf.c ofw_patch.h

Log Message:
Avoid declaring autoconf_debug twice when building with DEBUG.
Pointed out by palle@ - thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.224 src/sys/arch/sparc64/sparc64/autoconf.c:1.225
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.224	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Oct 17 08:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.225 2020/10/17 08:10:31 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -116,6 +116,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 
 #include "ksyms.h"
 
+int autoconf_debug = 0x0;
+
 struct evcnt intr_evcnts[] = {
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "spur"),
 	EVCNT_INITIALIZER(EVCNT_TYPE_INTR, NULL, "intr", "lev1"),

Index: src/sys/arch/sparc64/sparc64/ofw_patch.h
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.h:1.1 src/sys/arch/sparc64/sparc64/ofw_patch.h:1.2
--- src/sys/arch/sparc64/sparc64/ofw_patch.h:1.1	Fri Oct 16 07:35:16 2020
+++ src/sys/arch/sparc64/sparc64/ofw_patch.h	Sat Oct 17 08:10:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_patch.h,v 1.1 2020/10/16 07:35:16 jdc Exp $ */
+/*	$NetBSD: ofw_patch.h,v 1.2 2020/10/17 08:10:31 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #define ACDB_BOOTDEV0x1
 #define ACDB_PROBE  0x2
 #define ACDB_BOOTARGS   0x4
-int autoconf_debug = 0x0;
+extern int autoconf_debug;
 #define DPRINTF(l, s)   do { if (autoconf_debug & l) printf s; } while (0)
 #else
 #define DPRINTF(l, s)



CVS commit: src/sys/arch/sparc64

2020-10-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Fri Oct 16 07:35:16 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
src/sys/arch/sparc64/sparc64: autoconf.c
Added Files:
src/sys/arch/sparc64/sparc64: ofw_patch.c ofw_patch.h

Log Message:
Move OFW patching routines into their own file.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r1.223 -r1.224 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/sparc64/ofw_patch.c \
src/sys/arch/sparc64/sparc64/ofw_patch.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/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.160 src/sys/arch/sparc64/conf/files.sparc64:1.161
--- src/sys/arch/sparc64/conf/files.sparc64:1.160	Sun Oct 11 19:39:22 2020
+++ src/sys/arch/sparc64/conf/files.sparc64	Fri Oct 16 07:35:16 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.160 2020/10/11 19:39:22 jdc Exp $
+#	$NetBSD: files.sparc64,v 1.161 2020/10/16 07:35:16 jdc Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -142,7 +142,7 @@ file	dev/ebus/cs4231_ebus.c			audiocs_eb
 
 include	"dev/sdmmc/files.sdmmc"
 attach	wb at ebus with wb_ebus
-file	arch/sparc64/dev/wb_ebus.c		wb_ebus
+file	arch/sparc64/dev/wb_ebus.c  wb_ebus
 
 # PCMCIA bus (references fdc)
 include "dev/pcmcia/files.pcmcia"
@@ -255,6 +255,7 @@ file	arch/sparc64/sparc64/kobj_machdep.c
 # sparc64/sparc64/locore.s is handled specially in the makefile,
 # because it must come first in the "ld" command line.
 file	arch/sparc64/sparc64/machdep.c
+file	arch/sparc64/sparc64/ofw_patch.c
 file	arch/sparc64/sparc64/process_machdep.c
 file	arch/sparc64/sparc64/procfs_machdep.c	procfs
 file	arch/sparc64/sparc64/static_edid.c

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.223 src/sys/arch/sparc64/sparc64/autoconf.c:1.224
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.223	Sun Oct 11 19:39:22 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Fri Oct 16 07:35:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.223 2020/10/11 19:39:22 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.223 2020/10/11 19:39:22 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.224 2020/10/16 07:35:16 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -92,7 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
@@ -180,16 +180,6 @@ struct intrmap intrmap[] = {
 	{ NULL,		0 }
 };
 
-#ifdef DEBUG
-#define ACDB_BOOTDEV	0x1
-#define	ACDB_PROBE	0x2
-#define ACDB_BOOTARGS	0x4
-int autoconf_debug = 0x0;
-#define DPRINTF(l, s)   do { if (autoconf_debug & l) printf s; } while (0)
-#else
-#define DPRINTF(l, s)
-#endif
-
 int console_node, console_instance;
 struct genfb_colormap_callback gfb_cb;
 static void of_set_palette(void *, int, int, int, int);
@@ -1047,180 +1037,6 @@ device_setofnode(device_t dev, int node)
 	device_xname(dev), node));
 }
 
-static void
-add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
-{
-	prop_dictionary_t pin = prop_dictionary_create();
-	prop_dictionary_set_string(pin, "name", name);
-	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
-	prop_dictionary_set_uint32(pin, "pin", num);
-	prop_dictionary_set_bool(pin, "active_high", act);
-	if (def != -1)
-		prop_dictionary_set_int32(pin, "default_state", def);
-	prop_array_add(pins, pin);
-	prop_object_release(pin);
-}
-	
-static void
-add_gpio_props_v210(device_t dev, void *aux)
-{
-	struct i2c_attach_args *ia = aux;
-	prop_dictionary_t dict = device_properties(dev);
-	prop_array_t pins;
-
-	switch (ia->ia_addr) {
-		case 0x38:	/* front panel LEDs */
-			pins = prop_array_create();
-			add_gpio_LED(pins, "indicator", 7, 0, -1);
-			add_gpio_LED(pins, "fault", 5, 0, 0);
-			add_gpio_LED(pins, "power", 4, 0, 1);
-			prop_dictionary_set(dict, "pins", pins);
-			prop_object_release(pins);
-			break;
-		case 0x23:	/* drive bay LEDs */
-			pins = prop_array_create();
-			add_gpio_LED(pins, "bay0_fault", 10, 0, 0);
-			add_gpio_LED(pins, "bay1_fault", 11, 0, 0);
-			add_gpio_LED(pins, "bay0_remove", 12, 0, 0);
-			add_gpio_LED(pins, "bay1_remove", 13, 0, 0);
-			prop_dictionary_set(dict, "pins", pins);
-			prop_object_release(pins);
-			break;
-	}
-}
-
-static void
-add_drivebay_props_v210(device_t dev, int ofnode, void *aux)
-{
-	struct scsipibus_attach_args *sa = aux;
-	int target = sa->sa_periph->periph_target;
-	char path[256]= "";
-
-	OF_package_to_path(ofnode, path, sizeof(path));
-
-	/* see if we're on the onboard controller's 1st channel */

CVS commit: src/sys/arch/sparc64

2020-10-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sun Oct 11 19:39:23 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
src/sys/arch/sparc64/sparc64: autoconf.c
Added Files:
src/sys/arch/sparc64/sparc64: static_edid.c static_edid.h

Log Message:
Add a static EDID entry for the Mesostation-999.
Use the same logic as macppc for adding the entry.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r1.222 -r1.223 src/sys/arch/sparc64/sparc64/autoconf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/sparc64/static_edid.c \
src/sys/arch/sparc64/sparc64/static_edid.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/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.159 src/sys/arch/sparc64/conf/files.sparc64:1.160
--- src/sys/arch/sparc64/conf/files.sparc64:1.159	Mon May 11 15:56:15 2020
+++ src/sys/arch/sparc64/conf/files.sparc64	Sun Oct 11 19:39:22 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.159 2020/05/11 15:56:15 jdc Exp $
+#	$NetBSD: files.sparc64,v 1.160 2020/10/11 19:39:22 jdc Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -257,6 +257,7 @@ file	arch/sparc64/sparc64/kobj_machdep.c
 file	arch/sparc64/sparc64/machdep.c
 file	arch/sparc64/sparc64/process_machdep.c
 file	arch/sparc64/sparc64/procfs_machdep.c	procfs
+file	arch/sparc64/sparc64/static_edid.c
 file	arch/sparc/sparc/openprom.c
 file	arch/sparc/sparc/openfirm.c
 file	arch/sparc64/sparc64/ofw_machdep.c

Index: src/sys/arch/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.222 src/sys/arch/sparc64/sparc64/autoconf.c:1.223
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.222	Thu Jul 23 16:08:02 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Oct 11 19:39:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $ */
+/*	$NetBSD: autoconf.c,v 1.223 2020/10/11 19:39:22 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.223 2020/10/11 19:39:22 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -92,6 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -1205,6 +1206,21 @@ set_hw_props(device_t dev)
 	}
 }
 
+/* Static EDID definitions */
+static void
+set_static_edid(prop_dictionary_t dict)
+{
+	if (!strcmp(machine_model, "NATE,Meso-999")) {
+		prop_data_t edid;
+
+		DPRINTF(ACDB_PROBE, ("\nAdding EDID for Meso-999 "));
+		edid = prop_data_create_copy(edid_meso999,
+		sizeof(edid_meso999));
+		prop_dictionary_set(dict, "EDID:1", edid);
+		prop_object_release(edid);
+	}
+}
+
 /*
  * Called back during autoconfiguration for each device found
  */
@@ -1508,7 +1524,10 @@ noether:
 			if (OF_getprop(node, "width", , sizeof(width))
 			!= 4) {
 instance = OF_open(name);
+			}
+		}
 #endif
+		set_static_edid(dict);
 	}
 
 	set_hw_props(dev);

Added files:

Index: src/sys/arch/sparc64/sparc64/static_edid.c
diff -u /dev/null src/sys/arch/sparc64/sparc64/static_edid.c:1.1
--- /dev/null	Sun Oct 11 19:39:23 2020
+++ src/sys/arch/sparc64/sparc64/static_edid.c	Sun Oct 11 19:39:22 2020
@@ -0,0 +1,58 @@
+/*	$NetBSD: static_edid.c,v 1.1 2020/10/11 19:39:22 jdc Exp $ */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * 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 

CVS commit: src/sys/arch/sparc64/sparc64

2020-07-23 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Thu Jul 23 16:08:03 UTC 2020

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

Log Message:
Move machine-specific fixes into separate functions to improve readability.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.221 src/sys/arch/sparc64/sparc64/autoconf.c:1.222
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.221	Sun Jul  5 09:56:06 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Thu Jul 23 16:08:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.222 2020/07/23 16:08:02 jdc Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -,6 +,101 @@ add_drivebay_props_v210(device_t dev, in
 }
 
 /*
+ * Add SPARCle spdmem devices (0x50 and 0x51) that are not in the OFW tree
+ */
+static void
+add_spdmem_props_sparcle(device_t busdev)
+{
+	prop_dictionary_t props = device_properties(busdev);
+	prop_array_t cfg = prop_array_create();
+	int i;
+
+	DPRINTF(ACDB_PROBE, ("\nAdding spdmem for SPARCle "));
+	for (i = 0x50; i <= 0x51; i++) {
+		prop_dictionary_t spd = prop_dictionary_create();
+		prop_dictionary_set_string(spd, "name", "dimm-spd");
+		prop_dictionary_set_uint32(spd, "addr", i);
+		prop_dictionary_set_uint64(spd, "cookie", 0);
+		prop_array_add(cfg, spd);
+		prop_object_release(spd);
+	}
+	prop_dictionary_set(props, "i2c-child-devices", cfg);
+	prop_object_release(cfg);
+}
+
+/*
+ * Add V210/V240 environmental sensors that are not in the OFW tree.
+ */
+static void
+add_env_sensors_v210(device_t busdev)
+{
+	prop_dictionary_t props = device_properties(busdev);
+	prop_array_t cfg = NULL;
+	prop_dictionary_t sens;
+	prop_data_t data;
+	const char name_lm[] = "i2c-lm75";
+	const char name_adm[] = "i2c-adm1026";
+
+	DPRINTF(ACDB_PROBE, ("\nAdding sensors for %s ", machine_model));
+	cfg = prop_dictionary_get(props, "i2c-child-devices");
+ 	if (!cfg) {
+		cfg = prop_array_create();
+		prop_dictionary_set(props, "i2c-child-devices", cfg);
+		prop_dictionary_set_bool(props, "i2c-indirect-config", false);
+	}
+
+	/* ADM1026 at 0x2e */
+	sens = prop_dictionary_create();
+	prop_dictionary_set_uint32(sens, "addr", 0x2e);
+	prop_dictionary_set_uint64(sens, "cookie", 0);
+	prop_dictionary_set_string(sens, "name", "hardware-monitor");
+	data = prop_data_create_copy(_adm[0], sizeof(name_adm));
+	prop_dictionary_set(sens, "compatible", data);
+	prop_object_release(data);
+	prop_array_add(cfg, sens);
+	prop_object_release(sens);
+
+	/* LM75 at 0x4e */
+	sens = prop_dictionary_create();
+	prop_dictionary_set_uint32(sens, "addr", 0x4e);
+	prop_dictionary_set_uint64(sens, "cookie", 0);
+	prop_dictionary_set_string(sens, "name", "temperature-sensor");
+	data = prop_data_create_copy(_lm[0], sizeof(name_lm));
+	prop_dictionary_set(sens, "compatible", data);
+	prop_object_release(data);
+	prop_array_add(cfg, sens);
+	prop_object_release(sens);
+}
+
+/* Hardware specific device properties */
+static void
+set_hw_props(device_t dev)
+{
+	device_t busdev = device_parent(dev);
+
+	if ((!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+	!strcmp(machine_model, "SUNW,Sun-Fire-V210"))) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_uint8(props, "fan_div2", 0x55);
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+
+	if (!strcmp(machine_model, "SUNW,Sun-Fire-V440")) {
+		device_t busparent = device_parent(busdev);
+		prop_dictionary_t props = device_properties(dev);
+		if (busparent != NULL && device_is_a(busparent, "pcfiic") &&
+		device_is_a(dev, "adm1026hm") && props != NULL) {
+			prop_dictionary_set_bool(props, "multi_read", true);
+		}
+	}
+}
+
+/*
  * Called back during autoconfiguration for each device found
  */
 void
@@ -1155,7 +1250,8 @@ device_register(device_t dev, void *aux)
 
 		ofnode = (int)ia->ia_cookie;
 		if (device_is_a(dev, "pcagpio")) {
-			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+			if (!strcmp(machine_model, "SUNW,Sun-Fire-V240") ||
+			!strcmp(machine_model, "SUNW,Sun-Fire-V210")) {
 add_gpio_props_v210(dev, aux);
 			}
 		} 
@@ -1344,82 +1440,13 @@ noether:
 			}
 		}
 
-		/*
-		 * Add SPARCle spdmem devices (0x50 and 0x51) that the
-		 * firmware does not know about.
-		 */
-		if (!strcmp(machine_model, 

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

2020-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jul  5 09:55:08 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: ffb.c

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sparc64/dev/ffb.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/sparc64/dev/ffb.c
diff -u src/sys/arch/sparc64/dev/ffb.c:1.64 src/sys/arch/sparc64/dev/ffb.c:1.65
--- src/sys/arch/sparc64/dev/ffb.c:1.64	Sun Dec 22 23:23:31 2019
+++ src/sys/arch/sparc64/dev/ffb.c	Sun Jul  5 09:55:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffb.c,v 1.64 2019/12/22 23:23:31 thorpej Exp $	*/
+/*	$NetBSD: ffb.c,v 1.65 2020/07/05 09:55:07 martin Exp $	*/
 /*	$OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.64 2019/12/22 23:23:31 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.65 2020/07/05 09:55:07 martin Exp $");
 
 #include 
 #include 
@@ -306,7 +306,7 @@ ffb_attach(device_t self)
 		if (ffb_debug)
 			edid_print(>sc_edid_info);
 
-		data = prop_data_create_data(sc->sc_edid_data, EDID_DATA_LEN);
+		data = prop_data_create_copy(sc->sc_edid_data, EDID_DATA_LEN);
 		prop_dictionary_set(device_properties(self), "EDID", data);
 		prop_object_release(data);
 



CVS commit: src/sys/arch/sparc64/sparc64

2020-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jul  5 09:56:06 UTC 2020

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

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.220 src/sys/arch/sparc64/sparc64/autoconf.c:1.221
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.220	Sun Jul  5 09:27:11 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Jul  5 09:56:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.221 2020/07/05 09:56:06 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1413,7 +1413,7 @@ noether:
 			prop_dictionary_set_uint64(sens, "cookie", 0);
 			prop_dictionary_set_string(sens, "name",
 			"temperature-sensor");
-			data = prop_data_create_data(_lm[0],
+			data = prop_data_create_copy(_lm[0],
 			sizeof(name_lm));
 			prop_dictionary_set(sens, "compatible", data);
 			prop_object_release(data);



CVS commit: src/sys/arch/sparc64/sparc64

2020-07-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jul  5 09:27:11 UTC 2020

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

Log Message:
Adapt to proplib api changes


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.219 src/sys/arch/sparc64/sparc64/autoconf.c:1.220
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.219	Fri Jun 12 03:32:30 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Jul  5 09:27:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $ */
+/*	$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.219 2020/06/12 03:32:30 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.220 2020/07/05 09:27:11 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1050,7 +1050,7 @@ static void
 add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
 {
 	prop_dictionary_t pin = prop_dictionary_create();
-	prop_dictionary_set_cstring(pin, "name", name);
+	prop_dictionary_set_string(pin, "name", name);
 	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
 	prop_dictionary_set_uint32(pin, "pin", num);
 	prop_dictionary_set_bool(pin, "active_high", act);
@@ -1106,7 +1106,7 @@ add_drivebay_props_v210(device_t dev, in
 		char name[16];
 
 		snprintf(name, sizeof(name), "bay%d", target);		
-		prop_dictionary_set_cstring(dict, "location", name);
+		prop_dictionary_set_string(dict, "location", name);
 	}
 }
 
@@ -1258,7 +1258,7 @@ device_register(device_t dev, void *aux)
 if (!prom_get_node_ether(ofnode, eaddr))
 	goto noether;
 			}
-			blob = prop_data_create_data(eaddr, ETHER_ADDR_LEN);
+			blob = prop_data_create_copy(eaddr, ETHER_ADDR_LEN);
 			prop_dictionary_set(dict, "mac-address", blob);
 			prop_object_release(blob);
 			of_to_dataprop(dict, ofnode, "shared-pins",
@@ -1357,7 +1357,7 @@ noether:
 			for (i = 0x50; i <= 0x51; i++) {
 prop_dictionary_t spd =
 prop_dictionary_create();
-prop_dictionary_set_cstring(spd, "name",
+prop_dictionary_set_string(spd, "name",
 "dimm-spd");
 prop_dictionary_set_uint32(spd, "addr", i);
 prop_dictionary_set_uint64(spd, "cookie", 0);
@@ -1398,9 +1398,9 @@ noether:
 			sens = prop_dictionary_create();
 			prop_dictionary_set_uint32(sens, "addr", 0x2e);
 			prop_dictionary_set_uint64(sens, "cookie", 0);
-			prop_dictionary_set_cstring(sens, "name",
+			prop_dictionary_set_string(sens, "name",
 			"hardware-monitor");
-			data = prop_data_create_data(_adm[0],
+			data = prop_data_create_copy(_adm[0],
 			sizeof(name_adm));
 			prop_dictionary_set(sens, "compatible", data);
 			prop_object_release(data);
@@ -1411,7 +1411,7 @@ noether:
 			sens = prop_dictionary_create();
 			prop_dictionary_set_uint32(sens, "addr", 0x4e);
 			prop_dictionary_set_uint64(sens, "cookie", 0);
-			prop_dictionary_set_cstring(sens, "name",
+			prop_dictionary_set_string(sens, "name",
 			"temperature-sensor");
 			data = prop_data_create_data(_lm[0],
 			sizeof(name_lm));
@@ -1669,7 +1669,7 @@ copyprops(device_t busdev, int node, pro
 	pos = strstr(output_device, ":r");
 	if (pos == NULL)
 		return;
-	prop_dictionary_set_cstring(dict, "videomode", pos + 2);
+	prop_dictionary_set_string(dict, "videomode", pos + 2);
 }
 
 static void



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

2020-06-11 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Jun 12 03:41:57 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: jbus-i2c.c pcfiic_ebus.c

Log Message:
Update for proplib(3) API changes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/jbus-i2c.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/sparc64/dev/pcfiic_ebus.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/sparc64/dev/jbus-i2c.c
diff -u src/sys/arch/sparc64/dev/jbus-i2c.c:1.4 src/sys/arch/sparc64/dev/jbus-i2c.c:1.5
--- src/sys/arch/sparc64/dev/jbus-i2c.c:1.4	Sun Dec 22 23:23:31 2019
+++ src/sys/arch/sparc64/dev/jbus-i2c.c	Fri Jun 12 03:41:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: jbus-i2c.c,v 1.4 2019/12/22 23:23:31 thorpej Exp $	*/
+/*	$NetBSD: jbus-i2c.c,v 1.5 2020/06/12 03:41:57 thorpej Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: jbus-i2c.c,v 1.4 2019/12/22 23:23:31 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: jbus-i2c.c,v 1.5 2020/06/12 03:41:57 thorpej Exp $");
 
 #include 
 #include 
@@ -136,7 +136,6 @@ jbusi2c_setup_i2c(struct jbusi2c_softc *
 	struct i2cbus_attach_args iba;
 	prop_array_t cfg;
 	prop_dictionary_t dev;
-	prop_data_t data;
 	prop_dictionary_t dict = device_properties(sc->sc_dev);
 	int devs, regs[2], addr;
 	char name[64], compat[256];
@@ -167,10 +166,9 @@ jbusi2c_setup_i2c(struct jbusi2c_softc *
 		addr = (regs[1] & 0xff) >> 1;
 		DPRINTF("-> %s@%d,%x\n", name, regs[0], addr);
 		dev = prop_dictionary_create();
-		prop_dictionary_set_cstring(dev, "name", name);
-		data = prop_data_create_data(compat, strlen(compat)+1);
-		prop_dictionary_set(dev, "compatible", data);
-		prop_object_release(data);
+		prop_dictionary_set_string(dev, "name", name);
+		prop_dictionary_set_data(dev, "compatible", compat,
+		strlen(compat)+1);
 		prop_dictionary_set_uint32(dev, "addr", addr);
 		prop_dictionary_set_uint64(dev, "cookie", devs);
 		prop_array_add(cfg, dev);

Index: src/sys/arch/sparc64/dev/pcfiic_ebus.c
diff -u src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.5 src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.6
--- src/sys/arch/sparc64/dev/pcfiic_ebus.c:1.5	Sun Jan  3 17:32:17 2016
+++ src/sys/arch/sparc64/dev/pcfiic_ebus.c	Fri Jun 12 03:41:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcfiic_ebus.c,v 1.5 2016/01/03 17:32:17 jdc Exp $	*/
+/*	$NetBSD: pcfiic_ebus.c,v 1.6 2020/06/12 03:41:57 thorpej Exp $	*/
 /*	$OpenBSD: pcfiic_ebus.c,v 1.13 2008/06/08 03:07:40 deraadt Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.5 2016/01/03 17:32:17 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcfiic_ebus.c,v 1.6 2020/06/12 03:41:57 thorpej Exp $");
 
 /*
  * Device specific driver for the EBus i2c devices found on some sun4u
@@ -187,13 +187,10 @@ add_prop(prop_array_t c, const char *nam
 	int node)
 {
 	prop_dictionary_t dev;
-	prop_data_t data;
 
 	dev = prop_dictionary_create();
-	prop_dictionary_set_cstring(dev, "name", name);
-	data = prop_data_create_data(compat, strlen(compat)+1);
-	prop_dictionary_set(dev, "compatible", data);
-	prop_object_release(data);
+	prop_dictionary_set_string(dev, "name", name);
+	prop_dictionary_set_data(dev, "compatible", compat, strlen(compat)+1);
 	prop_dictionary_set_uint32(dev, "addr", addr);
 	prop_dictionary_set_uint64(dev, "cookie", node);
 	prop_array_add(c, dev);



CVS commit: src/sys/arch/sparc64/sparc64

2020-06-09 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun  9 21:57:00 UTC 2020

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

Log Message:
proplib API catchup
NFCI, tested on v210


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.217 src/sys/arch/sparc64/sparc64/autoconf.c:1.218
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.217	Sun Feb 23 05:14:29 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Tue Jun  9 21:57:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $ */
+/*	$NetBSD: autoconf.c,v 1.218 2020/06/09 21:57:00 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.218 2020/06/09 21:57:00 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1019,7 +1019,7 @@ device_ofnode(device_t dev)
 	if (obj == NULL)
 		return 0;
 
-	return prop_number_integer_value(obj);
+	return prop_number_signed_value(obj);
 }
 
 /*
@@ -1037,7 +1037,7 @@ device_setofnode(device_t dev, int node)
 	props = device_properties(dev);
 	if (props == NULL)
 		return;
-	obj = prop_number_create_integer(node);
+	obj = prop_number_create_signed(node);
 	if (obj == NULL)
 		return;
 	prop_dictionary_set(props, OFNODEKEY, obj);
@@ -1274,7 +1274,7 @@ noether:
 			if (OF_getprop(ofnode, "port-wwn", , sizeof(pwwn))
 			== sizeof(pwwn)) {
 pwwnd = 
-prop_number_create_unsigned_integer(pwwn);
+prop_number_create_unsigned(pwwn);
 prop_dictionary_set(dict, "port-wwn", pwwnd);
 prop_object_release(pwwnd);
 			}
@@ -1282,7 +1282,7 @@ noether:
 			if (OF_getprop(ofnode, "node-wwn", , sizeof(nwwn))
 			== sizeof(nwwn)) {
 nwwnd = 
-prop_number_create_unsigned_integer(nwwn);
+prop_number_create_unsigned(nwwn);
 prop_dictionary_set(dict, "node-wwn", nwwnd);
 prop_object_release(nwwnd);
 			}
@@ -1299,7 +1299,7 @@ noether:
 sizeof(id)) <= 0)
 	continue;
 
-idd = prop_number_create_unsigned_integer(id);
+idd = prop_number_create_unsigned(id);
 prop_dictionary_set(dict,
 		"scsi-initiator-id", idd);
 prop_object_release(idd);



CVS commit: src/sys/arch/sparc64/sparc64

2020-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 31 11:28:52 UTC 2020

Modified Files:
src/sys/arch/sparc64/sparc64: db_trace.c

Log Message:
Avoid using excessive kernel stack.
XXX maybe we should unite all "static proc_t" and "static lwp_t" in ddb
into one global each?


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/arch/sparc64/sparc64/db_trace.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/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.54 src/sys/arch/sparc64/sparc64/db_trace.c:1.55
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.54	Tue Mar 10 15:54:52 2020
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Sun May 31 11:28:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.54 2020/03/10 15:54:52 christos Exp $ */
+/*	$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.54 2020/03/10 15:54:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.55 2020/05/31 11:28:52 martin Exp $");
 
 #include 
 #include 
@@ -102,9 +102,10 @@ db_stack_trace_print(db_expr_t addr, boo
 #endif
 	} else {
 		if (trace_thread) {
-			proc_t p;
-			lwp_t l;
+			static proc_t p;
+			static lwp_t l;
 			struct pcb *pcb;
+
 			if (lwpaddr) {
 db_read_bytes(addr, sizeof(l), (char *));
 db_read_bytes((db_addr_t)l.l_proc,



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

2020-05-16 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat May 16 07:16:14 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: tadpmu.c tadpmureg.h tadpmuvar.h

Log Message:
Extend the monitoring to battery state, with capacity based on voltage.
Add more PMU definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/sparc64/dev/tadpmu.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/dev/tadpmureg.h \
src/sys/arch/sparc64/dev/tadpmuvar.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/sparc64/dev/tadpmu.c
diff -u src/sys/arch/sparc64/dev/tadpmu.c:1.4 src/sys/arch/sparc64/dev/tadpmu.c:1.5
--- src/sys/arch/sparc64/dev/tadpmu.c:1.4	Sun Oct 14 05:08:39 2018
+++ src/sys/arch/sparc64/dev/tadpmu.c	Sat May 16 07:16:14 2020
@@ -1,4 +1,4 @@
-/*/* $NetBSD: tadpmu.c,v 1.4 2018/10/14 05:08:39 macallan Exp $ */
+/*/* $NetBSD: tadpmu.c,v 1.5 2020/05/16 07:16:14 jdc Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz 
@@ -26,7 +26,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* a driver for the PMU found in Tadpole Wiper and possibly SPARCle laptops */
+/* a driver for the PMU found in Tadpole Viper and SPARCle laptops */
 
 #include "opt_tadpmu.h"
 #ifdef HAVE_TADPMU
@@ -56,13 +56,16 @@
 static bus_space_tag_t tadpmu_iot;
 static bus_space_handle_t tadpmu_hcmd;
 static bus_space_handle_t tadpmu_hdata;
-static struct sysmon_envsys *tadpmu_sme;
-static envsys_data_t tadpmu_sensors[5];
+static struct sysmon_envsys *tadpmu_sens_sme;
+static struct sysmon_envsys *tadpmu_acad_sme;
+static struct sysmon_envsys *tadpmu_batt_sme;
+static envsys_data_t tadpmu_sensors[8];
 static uint8_t idata = 0xff;
 static uint8_t ivalid = 0;
+static uint8_t ev_data = 0;
 static wchan_t tadpmu, tadpmuev;
-static struct sysmon_pswitch tadpmu_pbutton, tadpmu_lidswitch;
-static kmutex_t tadpmu_lock;
+static struct sysmon_pswitch tadpmu_pbutton, tadpmu_lidswitch, tadpmu_dcpower;
+static kmutex_t tadpmu_lock, data_lock;
 static lwp_t *tadpmu_thread;
 static int tadpmu_dying = 0;
 
@@ -202,10 +205,52 @@ tadpmu_send(uint8_t v)
 	}
 }
 
+static uint32_t
+tadpmu_battery_capacity(uint8_t gstat)
+{
+	uint8_t res;
+
+	if (gstat == GENSTAT_STATE_BATTERY_FULL) {
+		return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	}
+
+	mutex_enter(_lock);
+	tadpmu_flush();
+	tadpmu_send_cmd(CMD_READ_VBATT);
+	res = tadpmu_recv();
+	mutex_exit(_lock);
+
+	if (gstat & GENSTAT_STATE_BATTERY_DISCHARGE) {
+		if (res < TADPMU_BATT_DIS_CAP_CRIT)
+			return ENVSYS_BATTERY_CAPACITY_CRITICAL;
+		if (res < TADPMU_BATT_DIS_CAP_WARN)
+			return ENVSYS_BATTERY_CAPACITY_WARNING;
+		if (res < TADPMU_BATT_DIS_CAP_LOW)
+			return ENVSYS_BATTERY_CAPACITY_LOW;
+		else
+			return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	} else if (gstat == GENSTAT_STATE_BATTERY_CHARGE) {
+		if (res < TADPMU_BATT_CHG_CAP_CRIT)
+			return ENVSYS_BATTERY_CAPACITY_CRITICAL;
+		else if (res < TADPMU_BATT_CHG_CAP_WARN)
+			return ENVSYS_BATTERY_CAPACITY_WARNING;
+		else if (res < TADPMU_BATT_CHG_CAP_LOW)
+			return ENVSYS_BATTERY_CAPACITY_LOW;
+		else
+			return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	} else {
+		DPRINTF("%s unknown battery state %02x\n",
+		__func__, gstat);
+		return ENVSYS_BATTERY_CAPACITY_NORMAL;
+	}
+}
+
+/* The data to read is calculated from the command and the units */
 static void
 tadpmu_sensors_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
 {
 	int res;
+
 	if (edata->private > 0) {
 		mutex_enter(_lock);
 		tadpmu_flush();
@@ -214,8 +259,27 @@ tadpmu_sensors_refresh(struct sysmon_env
 		mutex_exit(_lock);
 		if (edata->units == ENVSYS_STEMP) {
 			edata->value_cur = res * 100 + 27315;
+		} else if (edata->units == ENVSYS_SVOLTS_DC) {
+			edata->value_cur = res * 10;
+		} else if (edata->units == ENVSYS_BATTERY_CHARGE) {
+			if (res & GENSTAT_BATTERY_CHARGING)
+edata->value_cur = ENVSYS_INDICATOR_TRUE;
+			else
+edata->value_cur = ENVSYS_INDICATOR_FALSE;
+		} else if (edata->units == ENVSYS_BATTERY_CAPACITY) {
+			edata->value_cur = tadpmu_battery_capacity(res);
 		} else {
-			edata->value_cur = res;
+			if (edata->units == ENVSYS_INDICATOR &&
+			edata->private == CMD_READ_GENSTAT) {
+if (res & GENSTAT_DC_PRESENT)
+	edata->value_cur =
+	ENVSYS_INDICATOR_TRUE;
+else
+	edata->value_cur =
+	ENVSYS_INDICATOR_FALSE;
+			} else {
+edata->value_cur = res;
+			}
 		}
 		edata->state = ENVSYS_SVALID;
 	} else {
@@ -226,27 +290,73 @@ tadpmu_sensors_refresh(struct sysmon_env
 static void
 tadpmu_events(void *cookie)
 {
-	uint8_t res, ores = 0;
+	uint8_t events, gs, vb;
+
 	while (!tadpmu_dying) {
 		mutex_enter(_lock);
 		tadpmu_flush();
 		tadpmu_send_cmd(CMD_READ_GENSTAT);
-		res = tadpmu_recv();
+		gs = tadpmu_recv();
+		tadpmu_send_cmd(CMD_READ_VBATT);
+		vb = tadpmu_recv();
 		mutex_exit(_lock);
-		res &= GENSTAT_LID_CLOSED;
-		if (res != ores) {
-			ores = res;
+
+		mutex_enter(_lock);
+		events = 

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

2020-05-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May 13 10:33:16 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Remove local USB device declarations, include the central list instead


To generate a diff of this commit:
cvs rdiff -u -r1.227 -r1.228 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.227 src/sys/arch/sparc64/conf/GENERIC:1.228
--- src/sys/arch/sparc64/conf/GENERIC:1.227	Mon May 11 18:29:59 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Wed May 13 10:33:16 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.227 2020/05/11 18:29:59 jdc Exp $
+# $NetBSD: GENERIC,v 1.228 2020/05/13 10:33:16 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.227 $"
+#ident		"GENERIC-$Revision: 1.228 $"
 
 maxusers	64
 
@@ -558,120 +558,8 @@ usb*	at ohci?
 usb*	at uhci?
 #usb*	at slhci?
 
-# USB Hubs
-uhub*	at usb?
-uhub*	at uhub? port ?
-
-# USB HID device
-uhidev* at uhub? port ? configuration ? interface ?
-
-# USB Mice
-ums*	at uhidev? reportid ?
-wsmouse* at ums? mux 0
-
-# USB eGalax touch-panel
-uep*	at uhub? port ?
-wsmouse* at uep? mux 0
-
-# USB Keyboards
-ukbd*	at uhidev? reportid ?
-wskbd*	at ukbd? console ? mux 1
-
-# USB TEMPer and TEMPerHUM
-uthum*	at uhidev? reportid ?
-
-# USB serial adapter
-ucycom* at uhidev? reportid ?
-
-# USB Generic HID devices
-uhid*	at uhidev? reportid ?
-
-# USB Printer
-ulpt*	at uhub? port ? configuration ? interface ?
-
-# USB Modem
-umodem* at uhub? port ? configuration ?
-ucom*	at umodem?
-
-# Option N.V. Wireless WAN modems
-uhso*	at uhub? port ? configuration ?
-
-# USB Mass Storage
-umass*	at uhub? port ? configuration ? interface ?
-
-# USB audio
-uaudio* at uhub? port ? configuration ?
-
-# USB MIDI
-umidi* at uhub? port ? configuration ?
-
-# USB IrDA
-# USB-IrDA bridge spec
-uirda* at uhub? port ? configuration ? interface ?
-irframe* at uirda?
-
-# SigmaTel STIr4200 USB/IrDA Bridge
-ustir* at uhub? port ?
-irframe* at ustir?
-
-# USB Ethernet adapters
-aue*	at uhub? port ?		# ADMtek AN986 Pegasus based adapters
-axe*	at uhub? port ?		# ASIX AX88172 based adapters
-cdce*	at uhub? port ?		# CDC, Ethernet Networking Control Model
-cue*	at uhub? port ?		# CATC USB-EL1201A based adapters
-kue*	at uhub? port ?		# Kawasaki LSI KL5KUSB101B based adapters
-mue*	at uhub? port ?		# Microchip LAN75xx/LAN78xx based adapters
-udav*	at uhub? port ?		# Davicom DM9601 based adapters
-ure*	at uhub? port ?		# Realtek RTL8152/RTL8153 based adapters
-url*	at uhub? port ?		# Realtek RTL8150L based adapters
-
-# USB 802.11 adapters
-atu*	at uhub? port ?		# Atmel AT76C50XX based adapters
-ural*	at uhub? port ?		# Ralink Technology RT2500USB 802.11a/b/g
-#zyd*	at uhub? port ?		# Zydas ZD1211
-
-# Prolific PL2301/PL2302 host-to-host adapter
-upl*	at uhub? port ?
-
-# Serial adapters
-ubsa*	at uhub? port ?		# Belkin serial adapter
-ucom*	at ubsa? portno ?
-
-uftdi*	at uhub? port ?		# FTDI FT8U100AX serial adapter
-ucom*	at uftdi? portno ?
-
-umct*	at uhub? port ?		# MCT USB-RS232 serial adapter
-ucom*	at umct? portno ?
-
-uplcom* at uhub? port ? 	# I/O DATA USB-RSAQ2 serial adapter
-ucom*	at uplcom? portno ?
-
-uvscom* at uhub? port ? 	# SUNTAC Slipper U VS-10U serial adapter
-ucom*	at uvscom? portno ?
-
-# USB Handspring Visor
-uvisor* at uhub? port ?
-ucom*	at uvisor?
-
-# Kyocera AIR-EDGE PHONE
-ukyopon* at uhub? port ?
-ucom*	at ukyopon? portno ?
-
-# USB scanners
-#uscanner* at uhub? port ?
-
-# USB scanners that use SCSI emulation, e.g., HP5300
-usscanner* at uhub? port ?
-
-# Y@P firmware loader
-uyap* at uhub? port ?
-
-# D-Link DSB-R100 USB radio
-udsbr*	at uhub? port ?
-radio*	at udsbr?
-
-# USB Generic driver
-ugen*	at uhub? port ?
+# USB device drivers
+include "dev/usb/usbdevices.config"
 
 # Firewire support
 fwohci* at pci? dev ? function ?	# IEEE1394 Open Host Controller



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

2020-05-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 11 18:29:59 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: GENERIC

Log Message:
Add "wb at ebus" and sdmmc, ld for the SD card reader on SPARCle.


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/arch/sparc64/conf/GENERIC

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/sparc64/conf/GENERIC
diff -u src/sys/arch/sparc64/conf/GENERIC:1.226 src/sys/arch/sparc64/conf/GENERIC:1.227
--- src/sys/arch/sparc64/conf/GENERIC:1.226	Sat Mar 28 08:35:36 2020
+++ src/sys/arch/sparc64/conf/GENERIC	Mon May 11 18:29:59 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.226 2020/03/28 08:35:36 isaki Exp $
+# $NetBSD: GENERIC,v 1.227 2020/05/11 18:29:59 jdc Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/sparc64/conf/std.sparc64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.226 $"
+#ident		"GENERIC-$Revision: 1.227 $"
 
 maxusers	64
 
@@ -281,6 +281,11 @@ options 	PMS_SYNAPTICS_TOUCHPAD	# Enable
 wskbd*		at pckbd? console ?
 wsmouse*	at pms? mux 0
 
+## Tadpole SPARCle SD card
+wb* 		at ebus?		# Winbond W83L518D SD/MMC reader
+sdmmc* 		at wb?
+ld* 		at sdmmc?
+
 ## Magma Serial/Parallel driver (not tested)
 #magma*	at sbus? slot ? offset ?
 #mtty*	at magma?



CVS commit: src/sys/arch/sparc64

2020-05-11 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Mon May 11 15:56:15 UTC 2020

Modified Files:
src/sys/arch/sparc64/conf: files.sparc64
Added Files:
src/sys/arch/sparc64/dev: wb_ebus.c

Log Message:
Add an ebus frontend for the Winbond W83l518D SD card reader as found on
Tadpole SPARCLE latops.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sys/arch/sparc64/conf/files.sparc64
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/dev/wb_ebus.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/sparc64/conf/files.sparc64
diff -u src/sys/arch/sparc64/conf/files.sparc64:1.158 src/sys/arch/sparc64/conf/files.sparc64:1.159
--- src/sys/arch/sparc64/conf/files.sparc64:1.158	Sun Jan 27 02:08:38 2019
+++ src/sys/arch/sparc64/conf/files.sparc64	Mon May 11 15:56:15 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sparc64,v 1.158 2019/01/27 02:08:38 pgoyette Exp $
+#	$NetBSD: files.sparc64,v 1.159 2020/05/11 15:56:15 jdc Exp $
 
 # @(#)files.sparc64	8.1 (Berkeley) 7/19/93
 # sparc64-specific configuration info
@@ -140,6 +140,10 @@ file	arch/sparc64/dev/fdc.c			fdc | fd n
 attach	audiocs at ebus with audiocs_ebus
 file	dev/ebus/cs4231_ebus.c			audiocs_ebus
 
+include	"dev/sdmmc/files.sdmmc"
+attach	wb at ebus with wb_ebus
+file	arch/sparc64/dev/wb_ebus.c		wb_ebus
+
 # PCMCIA bus (references fdc)
 include "dev/pcmcia/files.pcmcia"
 

Added files:

Index: src/sys/arch/sparc64/dev/wb_ebus.c
diff -u /dev/null src/sys/arch/sparc64/dev/wb_ebus.c:1.1
--- /dev/null	Mon May 11 15:56:15 2020
+++ src/sys/arch/sparc64/dev/wb_ebus.c	Mon May 11 15:56:15 2020
@@ -0,0 +1,86 @@
+/*	$NetBSD: wb_ebus.c,v 1.1 2020/05/11 15:56:15 jdc Exp $	*/
+
+/*
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * 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 
+__RCSID("$NetBSD: wb_ebus.c,v 1.1 2020/05/11 15:56:15 jdc Exp $");
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+static int	wb_ebus_match(device_t, cfdata_t , void *);
+static void	wb_ebus_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(wb_ebus, sizeof(struct wb_softc),
+	wb_ebus_match, wb_ebus_attach, NULL, NULL);
+
+static int
+wb_ebus_match(device_t parent, cfdata_t match, void *aux) 
+{
+	struct ebus_attach_args *ea = aux;
+
+	return (strcmp(ea->ea_name, "TAD,wb-sdcard") == 0);
+}
+
+static void
+wb_ebus_attach(device_t parent, device_t self, void *aux)
+{
+	struct wb_softc *sc = device_private(self);
+	struct ebus_attach_args *ea = aux;
+
+	sc->wb_dev = self;
+
+	if (bus_space_map(ea->ea_bustag, EBUS_ADDR_FROM_REG(>ea_reg[0]),
+	ea->ea_reg[0].size, 0, >wb_ioh) == 0)
+		sc->wb_iot = ea->ea_bustag;
+	else {
+		aprint_error(": can't map register space\n");
+return;
+	}
+
+	bus_intr_establish(sc->wb_iot, ea->ea_intr[0], IPL_BIO, wb_intr, sc);
+
+	aprint_normal("\n");
+
+	sc->wb_type = WB_DEVNO_SD;
+	sc->wb_quirks = WB_QUIRK_1BIT;	/* 4bit bus width always fails */
+	wb_attach(sc);
+}



CVS commit: src/sys/arch/sparc64

2020-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 10 15:54:52 UTC 2020

Modified Files:
src/sys/arch/sparc64/include: db_machdep.h
src/sys/arch/sparc64/sparc64: db_machdep.c db_trace.c

Log Message:
Don't provide things that don't make sense in userland. We don't provide
access to registers crash(8)...


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/sparc64/include/db_machdep.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc64/sparc64/db_machdep.c
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/sparc64/sparc64/db_trace.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/sparc64/include/db_machdep.h
diff -u src/sys/arch/sparc64/include/db_machdep.h:1.35 src/sys/arch/sparc64/include/db_machdep.h:1.36
--- src/sys/arch/sparc64/include/db_machdep.h:1.35	Sun Nov  5 22:47:48 2017
+++ src/sys/arch/sparc64/include/db_machdep.h	Tue Mar 10 11:54:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.h,v 1.35 2017/11/06 03:47:48 christos Exp $ */
+/*	$NetBSD: db_machdep.h,v 1.36 2020/03/10 15:54:52 christos Exp $ */
 
 /*
  * Mach Operating System
@@ -69,9 +69,11 @@ typedef struct {
 } db_regs_t;
 
 /* Current CPU register state */
+#ifdef _KERNEL
 #define	DDB_REGS	((db_regs_t*)__UNVOLATILE(curcpu()->ci_ddb_regs))
 #define	DDB_TF		(_REGS->db_tf)
 #define	DDB_FP		(_REGS->db_fpstate)
+#endif
 
 /* DDB commands not in db_interface.c */
 void	db_dump_ts(db_expr_t, bool, db_expr_t, const char *);

Index: src/sys/arch/sparc64/sparc64/db_machdep.c
diff -u src/sys/arch/sparc64/sparc64/db_machdep.c:1.1 src/sys/arch/sparc64/sparc64/db_machdep.c:1.2
--- src/sys/arch/sparc64/sparc64/db_machdep.c:1.1	Sat Feb 18 10:56:31 2012
+++ src/sys/arch/sparc64/sparc64/db_machdep.c	Tue Mar 10 11:54:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.1 2012/02/18 15:56:31 christos Exp $ */
+/*	$NetBSD: db_machdep.c,v 1.2 2020/03/10 15:54:52 christos Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.1 2012/02/18 15:56:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.2 2020/03/10 15:54:52 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_machdep.c
 #include 
 #include 
 
+#ifdef _KERNEL
 static int
 db_sparc_charop(const struct db_variable *vp, db_expr_t *val, int opcode)
 {
@@ -220,6 +221,7 @@ const struct db_variable db_regs[] = {
 	{ "gsr",	dbregfp(gsr),		db_sparc_intop, 0 },
 };
 const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+#endif
 
 #ifndef	DDB
 const struct db_command db_machine_command_table[] = {

Index: src/sys/arch/sparc64/sparc64/db_trace.c
diff -u src/sys/arch/sparc64/sparc64/db_trace.c:1.53 src/sys/arch/sparc64/sparc64/db_trace.c:1.54
--- src/sys/arch/sparc64/sparc64/db_trace.c:1.53	Wed May 22 11:10:13 2019
+++ src/sys/arch/sparc64/sparc64/db_trace.c	Tue Mar 10 11:54:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_trace.c,v 1.53 2019/05/22 15:10:13 martin Exp $ */
+/*	$NetBSD: db_trace.c,v 1.54 2020/03/10 15:54:52 christos Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.53 2019/05/22 15:10:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.54 2020/03/10 15:54:52 christos Exp $");
 
 #include 
 #include 
@@ -202,6 +202,7 @@ db_stack_trace_print(db_expr_t addr, boo
 }
 
 
+#ifdef _KERNEL
 void
 db_dump_window(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
 {
@@ -222,6 +223,7 @@ db_dump_window(db_expr_t addr, bool have
 	db_printf("Window %lx ", (long)addr);
 	db_print_window(frame);
 }
+#endif
 
 void 
 db_print_window(uint64_t frame)
@@ -307,6 +309,7 @@ db_print_window(uint64_t frame)
 	}
 }
 
+#ifdef _KERNEL
 void
 db_dump_stack(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
 {
@@ -549,3 +552,4 @@ db_dump_ts(db_expr_t addr, bool have_add
 	}
 
 }
+#endif



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

2020-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 10 03:49:56 UTC 2020

Modified Files:
src/sys/arch/sparc64/include: cpu.h

Log Message:
kill extra curproc/curlwp definitions that have no chance of working.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/arch/sparc64/include/cpu.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/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.129 src/sys/arch/sparc64/include/cpu.h:1.130
--- src/sys/arch/sparc64/include/cpu.h:1.129	Sun Dec 29 16:09:27 2019
+++ src/sys/arch/sparc64/include/cpu.h	Mon Mar  9 23:49:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.129 2019/12/29 21:09:27 martin Exp $ */
+/*	$NetBSD: cpu.h,v 1.130 2020/03/10 03:49:56 christos Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -457,15 +457,5 @@ void kgdb_panic(void);
 int	fixalign(struct lwp *, struct trapframe64 *);
 int	emulinstr(vaddr_t, struct trapframe64 *);
 
-#else /* _KERNEL */
-
-/*
- * XXX: provide some definitions for crash(8), probably can share
- */
-#if defined(_KMEMUSER)
-#define	curcpu()	(((struct cpu_info *)CPUINFO_VA)->ci_self)
-#define curlwp		curcpu()->ci_curlwp
-#endif
-
 #endif /* _KERNEL */
 #endif /* _CPU_H_ */



CVS commit: src/sys/arch/sparc64/sparc64

2020-02-22 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Feb 23 05:14:29 UTC 2020

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

Log Message:
add location info to sd instances if we know which drive bay they live in
Sun Fire v210 only for now, others should be easy to add


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.216 src/sys/arch/sparc64/sparc64/autoconf.c:1.217
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.216	Sun Feb  2 06:38:23 2020
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Feb 23 05:14:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $ */
+/*	$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.217 2020/02/23 05:14:29 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1088,6 +1088,28 @@ add_gpio_props_v210(device_t dev, void *
 	}
 }
 
+static void
+add_drivebay_props_v210(device_t dev, int ofnode, void *aux)
+{
+	struct scsipibus_attach_args *sa = aux;
+	int target = sa->sa_periph->periph_target;
+	char path[256]= "";
+
+	OF_package_to_path(ofnode, path, sizeof(path));
+
+	/* see if we're on the onboard controller's 1st channel */
+	if (strcmp(path, "/pci@1c,60/scsi@2") != 0)
+		return;
+	/* yes, yes we are */
+	if ( target < 2) {
+		prop_dictionary_t dict = device_properties(dev);
+		char name[16];
+
+		snprintf(name, sizeof(name), "bay%d", target);		
+		prop_dictionary_set_cstring(dict, "location", name);
+	}
+}
+
 /*
  * Called back during autoconfiguration for each device found
  */
@@ -1163,6 +1185,12 @@ device_register(device_t dev, void *aux)
 		ofnode = device_ofnode(device_parent(busdev));
 		dev_bi_unit_drive_match(dev, ofnode, periph->periph_target + off,
 		0, periph->periph_lun);
+		if (device_is_a(busdev, "scsibus")) {
+			/* see if we're in a known SCA drivebay */
+			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+add_drivebay_props_v210(dev, ofnode, aux);
+			}
+		}
 		return;
 	} else if (device_is_a(dev, "wd")) {
 		struct ata_device *adev = aux;



CVS commit: src/sys/arch/sparc64/sparc64

2020-02-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sun Feb  2 06:38:24 UTC 2020

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

Log Message:
pass pin info to pcagpio instances, so far for front panel LEDs on
Sun Fire v210 only


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.216 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.215 src/sys/arch/sparc64/sparc64/autoconf.c:1.216
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.215	Sat Jan  5 15:46:02 2019
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sun Feb  2 06:38:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.216 2020/02/02 06:38:23 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -1046,6 +1046,48 @@ device_setofnode(device_t dev, int node)
 	device_xname(dev), node));
 }
 
+static void
+add_gpio_LED(prop_array_t pins, const char *name, int num, int act, int def)
+{
+	prop_dictionary_t pin = prop_dictionary_create();
+	prop_dictionary_set_cstring(pin, "name", name);
+	prop_dictionary_set_uint32(pin, "type", 0);	/* 0 for LED, for now */
+	prop_dictionary_set_uint32(pin, "pin", num);
+	prop_dictionary_set_bool(pin, "active_high", act);
+	if (def != -1)
+		prop_dictionary_set_int32(pin, "default_state", def);
+	prop_array_add(pins, pin);
+	prop_object_release(pin);
+}
+	
+static void
+add_gpio_props_v210(device_t dev, void *aux)
+{
+	struct i2c_attach_args *ia = aux;
+	prop_dictionary_t dict = device_properties(dev);
+	prop_array_t pins;
+
+	switch (ia->ia_addr) {
+		case 0x38:	/* front panel LEDs */
+			pins = prop_array_create();
+			add_gpio_LED(pins, "indicator", 7, 0, -1);
+			add_gpio_LED(pins, "fault", 5, 0, 0);
+			add_gpio_LED(pins, "power", 4, 0, 1);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
+		case 0x23:	/* drive bay LEDs */
+			pins = prop_array_create();
+			add_gpio_LED(pins, "bay0_fault", 10, 0, 0);
+			add_gpio_LED(pins, "bay1_fault", 11, 0, 0);
+			add_gpio_LED(pins, "bay0_remove", 12, 0, 0);
+			add_gpio_LED(pins, "bay1_remove", 13, 0, 0);
+			prop_dictionary_set(dict, "pins", pins);
+			prop_object_release(pins);
+			break;
+	}
+}
+
 /*
  * Called back during autoconfiguration for each device found
  */
@@ -1090,6 +1132,11 @@ device_register(device_t dev, void *aux)
 			return;
 
 		ofnode = (int)ia->ia_cookie;
+		if (device_is_a(dev, "pcagpio")) {
+			if (strcmp(machine_model, "SUNW,Sun-Fire-V210") == 0) {
+add_gpio_props_v210(dev, aux);
+			}
+		} 
 	} else if (device_is_a(dev, "sd") || device_is_a(dev, "cd")) {
 		struct scsipibus_attach_args *sa = aux;
 		struct scsipi_periph *periph = sa->sa_periph;



CVS commit: src/sys/arch/sparc64/doc

2020-01-30 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Fri Jan 31 06:05:00 UTC 2020

Added Files:
src/sys/arch/sparc64/doc: SunFire_v210.txt

Log Message:
document what I found out about the v210's i2c GPIOs.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc64/doc/SunFire_v210.txt

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/sparc64/doc/SunFire_v210.txt
diff -u /dev/null src/sys/arch/sparc64/doc/SunFire_v210.txt:1.1
--- /dev/null	Fri Jan 31 06:05:00 2020
+++ src/sys/arch/sparc64/doc/SunFire_v210.txt	Fri Jan 31 06:05:00 2020
@@ -0,0 +1,47 @@
+This is about the i2c GPIO chips found in the Sun Fire v210, starting at
+/pci/isa@7/i2c@0,320/gpio@0,44
+Input/Output assignments and levels are what the firmware leaves us with -
+all LEDs off except the power one.
+
+All known pin functions were determined by experiment. No idea what the
+undocumented pins do, if anything.
+
+[ 1.00] pcagpio0 at iic0 addr 0x22: PCA9555
+[ 1.00] dir: I-II
+[ 1.00] lvl: X   XXX 
+[ 1.00] dir: -O--
+[ 1.00] lvl:  X  
+  ^
+0x0400 clears when the case is open
+
+[ 1.00] pcagpio1 at iic0 addr 0x23: PCA9555
+[ 1.00] dir: --II
+[ 1.00] lvl:     
+[ 1.00] dir: OO--
+[ 1.00] lvl: XX  
+Bit 0x0002 gets set when bay 1 is empty, I would assume 0x0001 is for bay 0.
+The output bits seem to control the drive bay LEDs
+0x2000 - bay 1, blue LED
+0x1000 - bay 0, blue LED
+0x0800 - bay 1, both LEDs orange
+0x0400 - bay 0, both LEDs orange
+all low active, the remaining outputs don't seem to do anything.
+
+[ 1.00] pcagpio2 at iic0 addr 0x34: PCA9555
+[ 1.00] dir: --II
+[ 1.00] lvl:   X 
+[ 1.00] dir: OO--
+[ 1.00] lvl: XX  
+clearing 0x0300 reset the machine
+probably controls redundant / hot-swappable power supplies on v240.
+
+[ 1.00] pcagpio3 at iic0 addr 0x38: PCA9556
+[ 1.00] dir: 
+[ 1.00] lvl: 
+[ 1.00] dir: 
+[ 1.00] lvl: XXX 
+This controls the front panel LEDs
+0x80 - indicator LED
+0x20 - fault LED
+0x10 - power LED
+all low active, the remaining outputs don't seem to do anything.



CVS commit: src/sys/arch/sparc64/sparc64

2019-12-29 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Dec 30 06:54:31 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: cpu.c

Log Message:
add highly experimental NUMA support for US-IIIi machines


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/arch/sparc64/sparc64/cpu.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/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.136 src/sys/arch/sparc64/sparc64/cpu.c:1.137
--- src/sys/arch/sparc64/sparc64/cpu.c:1.136	Tue Oct  1 18:00:08 2019
+++ src/sys/arch/sparc64/sparc64/cpu.c	Mon Dec 30 06:54:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.136 2019/10/01 18:00:08 chs Exp $ */
+/*	$NetBSD: cpu.c,v 1.137 2019/12/30 06:54:31 macallan Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.136 2019/10/01 18:00:08 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.137 2019/12/30 06:54:31 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -556,7 +556,15 @@ cpu_attach(device_t parent, device_t dev
 		(u_int)GETVER_CPU_IMPL(),
 		(u_int)GETVER_CPU_MASK());
 	}
-
+#ifdef NUMA
+	if (CPU_IS_USIIIi()) {
+		uint64_t start = ci->ci_cpuid;
+		start <<= 36;
+		ci->ci_numa_id = ci->ci_cpuid;
+		printf("NUMA bucket %d %016lx\n", ci->ci_cpuid, start);
+		uvm_page_numa_load(start, 0x10, ci->ci_cpuid);
+	}
+#endif
 	if (ci->ci_system_clockrate[0] != 0) {
 		aprint_normal_dev(dev, "system tick frequency %s MHz\n",
 		clockfreq(ci->ci_system_clockrate[0]));



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

2019-12-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec 29 21:09:27 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: cpu.h

Log Message:
Simplify some macros: if we only ever use them on the local cpu,
there is no need to do another pointer derefernence to go via the global
address of our cpu info.
Pointed out by ad.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/arch/sparc64/include/cpu.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/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.128 src/sys/arch/sparc64/include/cpu.h:1.129
--- src/sys/arch/sparc64/include/cpu.h:1.128	Sun Dec  1 15:34:45 2019
+++ src/sys/arch/sparc64/include/cpu.h	Sun Dec 29 21:09:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.128 2019/12/01 15:34:45 ad Exp $ */
+/*	$NetBSD: cpu.h,v 1.129 2019/12/29 21:09:27 martin Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -256,18 +256,21 @@ extern int sparc_ncpus;
 extern struct cpu_info *cpus;
 extern struct pool_cache *fpstate_cache;
 
-#define	curcpu()	(((struct cpu_info *)CPUINFO_VA)->ci_self)
+/* CURCPU_INT() a local (per CPU) view of our cpu_info */
+#define	CURCPU_INT()	((struct cpu_info *)CPUINFO_VA)
+/* in general we prefer the globaly visible pointer */
+#define	curcpu()	(CURCPU_INT()->ci_self)
 #define	cpu_number()	(curcpu()->ci_index)
 #define	CPU_IS_PRIMARY(ci)	((ci)->ci_flags & CPUF_PRIMARY)
 
 #define CPU_INFO_ITERATOR		int __unused
 #define CPU_INFO_FOREACH(cii, ci)	ci = cpus; ci != NULL; ci = ci->ci_next
 
-#define curlwp		curcpu()->ci_curlwp
-#define fplwp		curcpu()->ci_fplwp
-#define curpcb		curcpu()->ci_cpcb
-
-#define want_ast	curcpu()->ci_want_ast
+/* these are only valid on the local cpu */
+#define curlwp		CURCPU_INT()->ci_curlwp
+#define fplwp		CURCPU_INT()->ci_fplwp
+#define curpcb		CURCPU_INT()->ci_cpcb
+#define want_ast	CURCPU_INT()->ci_want_ast
 
 /*
  * definitions of cpu-dependent requirements



CVS commit: src/sys/arch/sparc64/sparc64

2019-04-07 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Apr  7 19:31:38 UTC 2019

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

Log Message:
make trap 0x70 a TRAP() not UTRAP().  we should be able to handle
fast ECC error as a normal trap, and i saw this once a few years
ago but it never repeated so i haven't been able to test this.


To generate a diff of this commit:
cvs rdiff -u -r1.419 -r1.420 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.419 src/sys/arch/sparc64/sparc64/locore.s:1.420
--- src/sys/arch/sparc64/sparc64/locore.s:1.419	Fri Feb  8 20:34:23 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Sun Apr  7 19:31:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.419 2019/02/08 20:34:23 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.420 2019/04/07 19:31:38 mrg Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -763,7 +763,8 @@ ufast_DMMU_protection:			! 06c = fast da
 #endif
 	nop
 	TA32
-	UTRAP(0x070)			! Implementation dependent traps
+	TRAP(0x070)			! 0x070 fast_ECC_error
+	! Implementation dependent traps
 	UTRAP(0x071); UTRAP(0x072); UTRAP(0x073); UTRAP(0x074); UTRAP(0x075); UTRAP(0x076)
 	UTRAP(0x077); UTRAP(0x078); UTRAP(0x079); UTRAP(0x07a); UTRAP(0x07b); UTRAP(0x07c)
 	UTRAP(0x07d); UTRAP(0x07e); UTRAP(0x07f)
@@ -973,7 +974,8 @@ kfast_DMMU_protection:			! 06c = fast da
 #endif
 	nop
 	TA32
-	UTRAP(0x070)			! Implementation dependent traps
+	TRAP(0x070)			! 0x070 fast_ECC_error
+	! Implementation dependent traps
 	UTRAP(0x071); UTRAP(0x072); UTRAP(0x073); UTRAP(0x074); UTRAP(0x075); UTRAP(0x076)
 	UTRAP(0x077); UTRAP(0x078); UTRAP(0x079); UTRAP(0x07a); UTRAP(0x07b); UTRAP(0x07c)
 	UTRAP(0x07d); UTRAP(0x07e); UTRAP(0x07f)



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

2019-04-06 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Sat Apr  6 21:40:15 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: psl.h

Log Message:
The real cause for removing asm inline code on clang is that the
"r" constraint cannot handle 64-bit and is treated as 32-bit.

So code that refers to the upper 32-bit (manuf or impl) of the %ver
register is removed by optimization.

Use 32-bit kernel code as a workaround when referring to the %ver
register.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/sparc64/include/psl.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/sparc64/include/psl.h
diff -u src/sys/arch/sparc64/include/psl.h:1.59 src/sys/arch/sparc64/include/psl.h:1.60
--- src/sys/arch/sparc64/include/psl.h:1.59	Fri Apr  5 12:15:41 2019
+++ src/sys/arch/sparc64/include/psl.h	Sat Apr  6 21:40:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: psl.h,v 1.59 2019/04/05 12:15:41 nakayama Exp $ */
+/*	$NetBSD: psl.h,v 1.60 2019/04/06 21:40:15 nakayama Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -292,9 +292,8 @@
  * Put "memory" to asm inline on sun4v to avoid issuing rdpr %ver
  * before checking cputyp as a result of code moving by compiler
  * optimization.
- * For clang, to prevent it from being removed by optimization.
  */
-#if defined(SUN4V) || defined(__clang__)
+#ifdef SUN4V
 #define constasm_clobbers "memory"
 #else
 #define constasm_clobbers
@@ -323,11 +322,13 @@ static __inline void set##name(type _val
 	__asm volatile(#wr " %0,0,%" #reg : : "r" (_val) : "memory");	\
 }
 
-#ifdef __arch64__
+/*
+ * XXX: clang's "r" constraint cannot handle 64-bit,
+ * so use 32-bit kernel code as a workaround.
+ */
+#if defined(__arch64__) && !defined(__clang__)
 #define SPARC64_RDCONST64_DEF(rd, name, reg) \
 	SPARC64_RDCONST_DEF(rd, name, reg, uint64_t)
-#define SPARC64_RD64_DEF(rd, name, reg) SPARC64_RD_DEF(rd, name, reg, uint64_t)
-#define SPARC64_WR64_DEF(wr, name, reg) SPARC64_WR_DEF(wr, name, reg, uint64_t)
 #else
 #define SPARC64_RDCONST64_DEF(rd, name, reg)\
 static __inline __constfunc uint64_t get##name(void)			\
@@ -337,6 +338,12 @@ static __inline __constfunc uint64_t get
 		: "=r" (_hi), "=r" (_lo) : : constasm_clobbers);	\
 	return ((uint64_t)_hi << 32) | _lo;\
 }
+#endif
+
+#ifdef __arch64__
+#define SPARC64_RD64_DEF(rd, name, reg) SPARC64_RD_DEF(rd, name, reg, uint64_t)
+#define SPARC64_WR64_DEF(wr, name, reg) SPARC64_WR_DEF(wr, name, reg, uint64_t)
+#else
 #define SPARC64_RD64_DEF(rd, name, reg)	\
 static __inline uint64_t get##name(void)\
 {	\



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

2019-04-05 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Apr  5 23:09:18 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: ctlreg.h

Log Message:
Redo previous.
In the case of store variant, put dummy constraint in output
instead of input.

Suggested by joerg@ in source-changes-d@


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/sparc64/include/ctlreg.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/sparc64/include/ctlreg.h
diff -u src/sys/arch/sparc64/include/ctlreg.h:1.65 src/sys/arch/sparc64/include/ctlreg.h:1.66
--- src/sys/arch/sparc64/include/ctlreg.h:1.65	Fri Apr  5 12:16:13 2019
+++ src/sys/arch/sparc64/include/ctlreg.h	Fri Apr  5 23:09:18 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctlreg.h,v 1.65 2019/04/05 12:16:13 nakayama Exp $ */
+/*	$NetBSD: ctlreg.h,v 1.66 2019/04/05 23:09:18 nakayama Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath
@@ -681,10 +681,10 @@ SPARC64_LD_DEF64(ldxa, uint64_t)
 /* 64-bit kernel, non-constant */
 #define SPARC64_ST_NONCONST(st, type)	\
 	__asm volatile(			\
-		"wr %2,%%g0,%%asi;	"\
-		#st " %0,[%1]%%asi	"\
-		: : "r" (value), "r" ((__uintptr_t)(loc)),		\
-		"r" (asi), "m" (*(type *)(__uintptr_t)(loc)))
+		"wr %3,%%g0,%%asi;	"\
+		#st " %1,[%2]%%asi	"\
+		: "=m" (*(type *)(__uintptr_t)(loc))			\
+		: "r" (value), "r" ((__uintptr_t)(loc)), "r" (asi))
 
 #if defined(__GNUC__) && defined(__OPTIMIZE__)
 #define SPARC64_ST_DEF(st, type)	\
@@ -692,9 +692,10 @@ static __inline void st(paddr_t loc, int
 {	\
 	if (__builtin_constant_p(asi))	\
 		__asm volatile(		\
-			#st " %0,[%1]%2		"			\
-			: : "r" (value), "r" ((__uintptr_t)(loc)),	\
-			"n" (asi), "m" (*(type *)(__uintptr_t)(loc))); \
+			#st " %1,[%2]%3		"			\
+			: "=m" (*(type *)(__uintptr_t)(loc))		\
+			: "r" (value), "r" ((__uintptr_t)(loc)),	\
+			  "n" (asi));	\
 	else\
 		SPARC64_ST_NONCONST(st, type);\
 }



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

2019-04-05 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Apr  5 12:16:13 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: ctlreg.h

Log Message:
Add dummy constraints to avoid excessive optimization in clang.
GENERIC kernel compiled with clang now boot at least on my Fire V100.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/arch/sparc64/include/ctlreg.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/sparc64/include/ctlreg.h
diff -u src/sys/arch/sparc64/include/ctlreg.h:1.64 src/sys/arch/sparc64/include/ctlreg.h:1.65
--- src/sys/arch/sparc64/include/ctlreg.h:1.64	Wed Dec 28 19:16:25 2016
+++ src/sys/arch/sparc64/include/ctlreg.h	Fri Apr  5 12:16:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ctlreg.h,v 1.64 2016/12/28 19:16:25 martin Exp $ */
+/*	$NetBSD: ctlreg.h,v 1.65 2019/04/05 12:16:13 nakayama Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath
@@ -485,12 +485,13 @@
 #ifdef __arch64__
 
 /* 64-bit kernel, non-constant */
-#define SPARC64_LD_NONCONST(ld)	\
+#define SPARC64_LD_NONCONST(ld, type)	\
 	__asm volatile(			\
 		"wr %2,%%g0,%%asi;	"\
 		#ld " [%1]%%asi,%0	"\
 		: "=r" (_v)		\
-		: "r" ((__uintptr_t)(loc)), "r" (asi))
+		: "r" ((__uintptr_t)(loc)), "r" (asi),			\
+		  "m" (*(type *)(__uintptr_t)(loc)))
 
 #if defined(__GNUC__) && defined(__OPTIMIZE__)
 #define SPARC64_LD_DEF(ld, type, vtype)	\
@@ -501,9 +502,10 @@ static __inline type ld(paddr_t loc, int
 		__asm volatile(		\
 			#ld " [%1]%2,%0		"			\
 			: "=r" (_v)	\
-			: "r" ((__uintptr_t)(loc)), "n" (asi));		\
+			: "r" ((__uintptr_t)(loc)), "n" (asi),		\
+			  "m" (*(type *)(__uintptr_t)(loc)));		\
 	else\
-		SPARC64_LD_NONCONST(ld);\
+		SPARC64_LD_NONCONST(ld, type);\
 	return _v;			\
 }
 #else
@@ -511,7 +513,7 @@ static __inline type ld(paddr_t loc, int
 static __inline type ld(paddr_t loc, int asi)\
 {	\
 	vtype _v;			\
-	SPARC64_LD_NONCONST(ld);	\
+	SPARC64_LD_NONCONST(ld, type);	\
 	return _v;			\
 }
 #endif
@@ -677,12 +679,12 @@ SPARC64_LD_DEF64(ldxa, uint64_t)
 #ifdef __arch64__
 
 /* 64-bit kernel, non-constant */
-#define SPARC64_ST_NONCONST(st)	\
+#define SPARC64_ST_NONCONST(st, type)	\
 	__asm volatile(			\
 		"wr %2,%%g0,%%asi;	"\
 		#st " %0,[%1]%%asi	"\
 		: : "r" (value), "r" ((__uintptr_t)(loc)),		\
-		"r" (asi))
+		"r" (asi), "m" (*(type *)(__uintptr_t)(loc)))
 
 #if defined(__GNUC__) && defined(__OPTIMIZE__)
 #define SPARC64_ST_DEF(st, type)	\
@@ -692,15 +694,15 @@ static __inline void st(paddr_t loc, int
 		__asm volatile(		\
 			#st " %0,[%1]%2		"			\
 			: : "r" (value), "r" ((__uintptr_t)(loc)),	\
-			"n" (asi));	\
+			"n" (asi), "m" (*(type *)(__uintptr_t)(loc))); \
 	else\
-		SPARC64_ST_NONCONST(st);\
+		SPARC64_ST_NONCONST(st, type);\
 }
 #else
 #define SPARC64_ST_DEF(st, type)	\
 static __inline void st(paddr_t loc, int asi, type value)		\
 {	\
-	SPARC64_ST_NONCONST(st);	\
+	SPARC64_ST_NONCONST(st, type);	\
 }
 #endif
 #define SPARC64_ST_DEF64(st, type)	SPARC64_ST_DEF(st, type)



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

2019-04-05 Thread Takeshi Nakayama
Module Name:src
Committed By:   nakayama
Date:   Fri Apr  5 12:15:41 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: psl.h

Log Message:
Put "memory" to asm inline reading privilege registers for clang to
prevent it from being removed by excessive optimization.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/sparc64/include/psl.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/sparc64/include/psl.h
diff -u src/sys/arch/sparc64/include/psl.h:1.58 src/sys/arch/sparc64/include/psl.h:1.59
--- src/sys/arch/sparc64/include/psl.h:1.58	Fri Feb  8 20:09:24 2019
+++ src/sys/arch/sparc64/include/psl.h	Fri Apr  5 12:15:41 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: psl.h,v 1.58 2019/02/08 20:09:24 palle Exp $ */
+/*	$NetBSD: psl.h,v 1.59 2019/04/05 12:15:41 nakayama Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -292,8 +292,9 @@
  * Put "memory" to asm inline on sun4v to avoid issuing rdpr %ver
  * before checking cputyp as a result of code moving by compiler
  * optimization.
+ * For clang, to prevent it from being removed by optimization.
  */
-#ifdef SUN4V
+#if defined(SUN4V) || defined(__clang__)
 #define constasm_clobbers "memory"
 #else
 #define constasm_clobbers



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

2019-02-28 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Mar  1 02:38:17 UTC 2019

Modified Files:
src/sys/arch/sparc64/dev: tda.c

Log Message:
make the conversion from degC to uK a macro instead of open
coding it 4 places.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sparc64/dev/tda.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/sparc64/dev/tda.c
diff -u src/sys/arch/sparc64/dev/tda.c:1.12 src/sys/arch/sparc64/dev/tda.c:1.13
--- src/sys/arch/sparc64/dev/tda.c:1.12	Sat Jun 16 21:22:13 2018
+++ src/sys/arch/sparc64/dev/tda.c	Fri Mar  1 02:38:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tda.c,v 1.12 2018/06/16 21:22:13 thorpej Exp $	*/
+/*	$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $	*/
 /*	$OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.12 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $");
 
 #include 
 #include 
@@ -52,10 +52,12 @@ __KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.12
 #define SENSOR_FAN_CPU		0
 #define SENSOR_FAN_SYS		1
 
-#define CPU_TEMP_MAX		(67 * 100 + 27315)
-#define CPU_TEMP_MIN		(57 * 100 + 27315)
-#define SYS_TEMP_MAX		(30 * 100 + 27315)
-#define SYS_TEMP_MIN		(20 * 100 + 27315)
+#define DEGC_TO_mK(c)		(((c) * 100) + 27315)
+
+#define CPU_TEMP_MAX		DEGC_TO_mK(67)
+#define CPU_TEMP_MIN		DEGC_TO_mK(57)
+#define SYS_TEMP_MAX		DEGC_TO_mK(30)
+#define SYS_TEMP_MIN		DEGC_TO_mK(20)
 
 struct tda_softc {
 	device_t		sc_dev;



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Feb 15 16:36:33 UTC 2019

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

Log Message:
Add /* FALLTHROUGH */ for DEBUG kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.190 src/sys/arch/sparc64/sparc64/trap.c:1.191
--- src/sys/arch/sparc64/sparc64/trap.c:1.190	Thu Feb 14 20:09:40 2019
+++ src/sys/arch/sparc64/sparc64/trap.c	Fri Feb 15 16:36:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $ */
+/*	$NetBSD: trap.c,v 1.191 2019/02/15 16:36:33 hannken Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.191 2019/02/15 16:36:33 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -625,6 +625,7 @@ dopanic:
 		   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm,
 		   pc, type, type < N_TRAP_TYPES ? trap_type[type] : T);
 #endif
+		/* FALLTHROUGH */
 	case T_ILLINST:
 #if defined(DDB) && defined(DEBUG)
 		if (trapdebug & TDB_STOPSIG)



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-14 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Thu Feb 14 20:09:40 UTC 2019

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

Log Message:
sun4v: add debug printout for ALIGN trap


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/trap.c
diff -u src/sys/arch/sparc64/sparc64/trap.c:1.189 src/sys/arch/sparc64/sparc64/trap.c:1.190
--- src/sys/arch/sparc64/sparc64/trap.c:1.189	Wed Dec 19 13:57:50 2018
+++ src/sys/arch/sparc64/sparc64/trap.c	Thu Feb 14 20:09:40 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.189 2018/12/19 13:57:50 maxv Exp $ */
+/*	$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.189 2018/12/19 13:57:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.190 2019/02/14 20:09:40 palle Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -717,6 +717,10 @@ dopanic:
 #ifdef DEBUG
 		if (!CPU_ISSUN4V) {
 			isfsr = ldxa(SFSR, ASI_IMMU);
+		} else {
+		  paddr_t mmu_fsa_ifa = cpus->ci_mmufsa
+		+ offsetof(struct mmufsa, ifa);
+			isfsr = ldxa(mmu_fsa_ifa, ASI_PHYS_CACHED);
 		}
 #endif
 		/* 
@@ -731,10 +735,34 @@ dopanic:
 		
 #ifdef DEBUG
 #define fmt64(x)	(u_int)((x)>>32), (u_int)((x))
-		printf("Alignment error: pid=%d.%d comm=%s dsfsr=%08x:%08x "
-		   "dsfar=%x:%x isfsr=%08x:%08x pc=%lx\n",
-		   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, fmt64(dsfsr), fmt64(dsfar),
-		   fmt64(isfsr), pc);
+		if (!CPU_ISSUN4V) {
+			printf("Alignment error: pid=%d.%d comm=%s dsfsr=%08x:%08x "
+			   "dsfar=%x:%x isfsr=%08x:%08x pc=%lx\n",
+			   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, fmt64(dsfsr), fmt64(dsfar),
+			   fmt64(isfsr), pc);
+		} else {
+		  
+			printf("Alignment error: pid=%d.%d comm=%s pc=%lx\n",
+			   l->l_proc->p_pid, l->l_lid, l->l_proc->p_comm, pc);
+			paddr_t mmufsa_ift_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ift);
+			paddr_t mmufsa_ifa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifa);
+			paddr_t mmufsa_ifc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, ifc);
+			paddr_t mmufsa_dft_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dft);
+			paddr_t mmufsa_dfa_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfa);
+			paddr_t mmufsa_dfc_addr = cpus->ci_mmufsa + offsetof(struct mmufsa, dfc);
+			int64_t ift = ldxa(mmufsa_ift_addr, ASI_PHYS_CACHED);
+			printf("ift = %016lx\n", ift);
+			int64_t ifa = ldxa(mmufsa_ifa_addr, ASI_PHYS_CACHED);
+			printf("ifa = %016lx\n", ifa);
+			int64_t ifc = ldxa(mmufsa_ifc_addr, ASI_PHYS_CACHED);
+			printf("ifc = %016lx\n", ifc);
+			int64_t dft = ldxa(mmufsa_dft_addr, ASI_PHYS_CACHED);
+			printf("dft = %016lx\n", dft);
+			int64_t dfa = ldxa(mmufsa_dfa_addr, ASI_PHYS_CACHED);
+			printf("dfa = %016lx\n", dfa);
+			int64_t dfc = ldxa(mmufsa_dfc_addr, ASI_PHYS_CACHED);
+			printf("dfc = %016lx\n", dfc);
+		}
 #endif
 		
 #if defined(DDB) && defined(DEBUG)



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-10 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Feb 11 07:51:46 UTC 2019

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

Log Message:
retry timed out IPIs, complain and dump timing info into dmesg
ok martin@


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/vm_machdep.c
diff -u src/sys/arch/sparc64/sparc64/vm_machdep.c:1.101 src/sys/arch/sparc64/sparc64/vm_machdep.c:1.102
--- src/sys/arch/sparc64/sparc64/vm_machdep.c:1.101	Fri Nov  6 15:30:59 2015
+++ src/sys/arch/sparc64/sparc64/vm_machdep.c	Mon Feb 11 07:51:46 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm_machdep.c,v 1.101 2015/11/06 15:30:59 martin Exp $ */
+/*	$NetBSD: vm_machdep.c,v 1.102 2019/02/11 07:51:46 macallan Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.101 2015/11/06 15:30:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.102 2019/02/11 07:51:46 macallan Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -305,12 +305,13 @@ fpusave_lwp(struct lwp *l, bool save)
 	}
 
 	for (ci = cpus; ci != NULL; ci = ci->ci_next) {
-		int spincount;
+		int spincount, retrycount=0;
 
 		if (ci == curcpu() || !CPUSET_HAS(cpus_active, ci->ci_index))
 			continue;
 		if (ci->ci_fplwp != l)
 			continue;
+again:
 		sparc64_send_ipi(ci->ci_cpuid, save ?
  sparc64_ipi_save_fpstate :
  sparc64_ipi_drop_fpstate, (uintptr_t)l, 0);
@@ -319,9 +320,13 @@ fpusave_lwp(struct lwp *l, bool save)
 		while (ci->ci_fplwp == l) {
 			membar_Sync();
 			spincount++;
-			if (spincount > 1000)
-panic("fpusave_lwp ipi didn't");
+			if (spincount > 1000) {
+printf("fpusave_lwp ipi didn't (%d)\n", retrycount);
+retrycount++;
+goto again;
+			}
 		}
+		if (retrycount > 0) printf("spincount %d\n", spincount);
 		break;
 	}
 #else



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

2019-02-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Feb  9 11:27:06 UTC 2019

Modified Files:
src/sys/arch/sparc64/dev: iommu.c iommuvar.h schizo.c

Log Message:
on tomatillo unload the map before flushing the iommu, instead of
the reverse.  from opensolaris.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/arch/sparc64/dev/iommu.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/sparc64/dev/iommuvar.h
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/sparc64/dev/schizo.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/sparc64/dev/iommu.c
diff -u src/sys/arch/sparc64/dev/iommu.c:1.114 src/sys/arch/sparc64/dev/iommu.c:1.115
--- src/sys/arch/sparc64/dev/iommu.c:1.114	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sparc64/dev/iommu.c	Sat Feb  9 11:27:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommu.c,v 1.114 2018/09/03 16:29:27 riastradh Exp $	*/
+/*	$NetBSD: iommu.c,v 1.115 2019/02/09 11:27:05 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.114 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.115 2019/02/09 11:27:05 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -748,10 +748,21 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bu
 	/* Flush the iommu */
 	if (!map->_dm_dvmastart)
 		panic("%s: error dvmastart is zero!\n", __func__);
-	iommu_remove(is, map->_dm_dvmastart, map->_dm_dvmasize);
 
-	/* Flush the caches */
-	bus_dmamap_unload(t->_parent, map);
+	if (is->is_flags & IOMMU_SYNC_BEFORE_UNMAP) {
+
+		/* Flush the caches */
+		bus_dmamap_unload(t->_parent, map);
+
+		iommu_remove(is, map->_dm_dvmastart, map->_dm_dvmasize);
+
+	} else {
+
+		iommu_remove(is, map->_dm_dvmastart, map->_dm_dvmasize);
+
+		/* Flush the caches */
+		bus_dmamap_unload(t->_parent, map);
+	}
 
 	mutex_enter(>is_lock);
 	error = extent_free(is->is_dvmamap, map->_dm_dvmastart,

Index: src/sys/arch/sparc64/dev/iommuvar.h
diff -u src/sys/arch/sparc64/dev/iommuvar.h:1.22 src/sys/arch/sparc64/dev/iommuvar.h:1.23
--- src/sys/arch/sparc64/dev/iommuvar.h:1.22	Thu Sep  3 19:43:35 2015
+++ src/sys/arch/sparc64/dev/iommuvar.h	Sat Feb  9 11:27:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: iommuvar.h,v 1.22 2015/09/03 19:43:35 palle Exp $	*/
+/*	$NetBSD: iommuvar.h,v 1.23 2019/02/09 11:27:05 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -59,6 +59,7 @@ struct iommu_state {
 	int			is_flags;
 #define IOMMU_FLUSH_CACHE	0x0001
 #define IOMMU_TSBSIZE_IN_PTSB	0x0002	/* PCIe */
+#define IOMMU_SYNC_BEFORE_UNMAP	0x0004
 
 	struct strbuf_ctl	*is_sb[2];	/* Streaming buffers if any */
 

Index: src/sys/arch/sparc64/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.40 src/sys/arch/sparc64/dev/schizo.c:1.41
--- src/sys/arch/sparc64/dev/schizo.c:1.40	Tue Feb  5 06:10:53 2019
+++ src/sys/arch/sparc64/dev/schizo.c	Sat Feb  9 11:27:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.40 2019/02/05 06:10:53 mrg Exp $	*/
+/*	$NetBSD: schizo.c,v 1.41 2019/02/09 11:27:05 mrg Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.40 2019/02/05 06:10:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.41 2019/02/09 11:27:05 mrg Exp $");
 
 #include 
 #include 
@@ -263,6 +263,8 @@ schizo_attach(device_t parent, device_t 
 	}
 
 	aprint_normal_dev(sc->sc_dev, " ");
+	if (sc->sc_tomatillo)
+		is->is_flags |= IOMMU_SYNC_BEFORE_UNMAP;
 	schizo_init_iommu(sc, pbm);
 
 	pbm->sp_memt = schizo_alloc_mem_tag(pbm);



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 20:34:23 UTC 2019

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

Log Message:
sun4v: Improve comment for next_stick_init() - no functional changes


To generate a diff of this commit:
cvs rdiff -u -r1.418 -r1.419 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.418 src/sys/arch/sparc64/sparc64/locore.s:1.419
--- src/sys/arch/sparc64/sparc64/locore.s:1.418	Fri Feb  8 20:14:51 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 20:34:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.418 2019/02/08 20:14:51 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.419 2019/02/08 20:34:23 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7513,6 +7513,9 @@ Lstick_ovflw:
  * Sets the %stick_cmpr register to the value retrieved from %stick so
  * next_stick() does not spend too much time in the function when called
  * for the first time.
+ * This has been observed on (at least) a SPARC-T5 (sun4v) system where
+ * the %stick_cmpr ends up being less than the %stick value and then
+ * the stickitr() interrupt is never triggered.
  */
 ENTRY(next_stick_init)
 	rd	STICK, %o0



CVS commit: src/sys/arch/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 20:14:51 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: cpu.h
src/sys/arch/sparc64/sparc64: clock.c locore.s

Log Message:
sun4v: initialize %stickcmpr properly when establishing interrupt - fixes issue 
seen on newer sun4v/SPARC-T5 system where the interrupt never fires.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/arch/sparc64/include/cpu.h
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/sparc64/sparc64/clock.c
cvs rdiff -u -r1.417 -r1.418 src/sys/arch/sparc64/sparc64/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/sparc64/include/cpu.h
diff -u src/sys/arch/sparc64/include/cpu.h:1.125 src/sys/arch/sparc64/include/cpu.h:1.126
--- src/sys/arch/sparc64/include/cpu.h:1.125	Wed Aug 22 01:05:23 2018
+++ src/sys/arch/sparc64/include/cpu.h	Fri Feb  8 20:14:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.h,v 1.125 2018/08/22 01:05:23 msaitoh Exp $ */
+/*	$NetBSD: cpu.h,v 1.126 2019/02/08 20:14:50 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -434,6 +434,7 @@ void	switchtoctx_us(int);
 void	switchtoctx_usiii(int);
 void	next_tick(long);
 void	next_stick(long);
+void	next_stick_init(void);
 /* trap.c */
 void	cpu_vmspace_exec(struct lwp *, vaddr_t, vaddr_t);
 int	rwindow_save(struct lwp *);

Index: src/sys/arch/sparc64/sparc64/clock.c
diff -u src/sys/arch/sparc64/sparc64/clock.c:1.120 src/sys/arch/sparc64/sparc64/clock.c:1.121
--- src/sys/arch/sparc64/sparc64/clock.c:1.120	Thu Jul  7 06:55:38 2016
+++ src/sys/arch/sparc64/sparc64/clock.c	Fri Feb  8 20:14:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: clock.c,v 1.120 2016/07/07 06:55:38 msaitoh Exp $ */
+/*	$NetBSD: clock.c,v 1.121 2019/02/08 20:14:51 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.120 2016/07/07 06:55:38 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.121 2019/02/08 20:14:51 palle Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -406,6 +406,7 @@ stickintr_establish(int pil, int (*fun)(
 	ci->ci_tick_increment = ci->ci_system_clockrate[0] / hz;
 
 	s = intr_disable();
+	next_stick_init();
 	next_stick(ci->ci_tick_increment);
 	intr_restore(s);
 }

Index: src/sys/arch/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.417 src/sys/arch/sparc64/sparc64/locore.s:1.418
--- src/sys/arch/sparc64/sparc64/locore.s:1.417	Fri Feb  8 19:45:24 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 20:14:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.417 2019/02/08 19:45:24 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.418 2019/02/08 20:14:51 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -7507,6 +7507,21 @@ Lstick_ovflw:
 	retl
 	 wr	%o2, STICK_CMPR
 
+/*
+ * next_stick_init()
+ *
+ * Sets the %stick_cmpr register to the value retrieved from %stick so
+ * next_stick() does not spend too much time in the function when called
+ * for the first time.
+ */
+ENTRY(next_stick_init)
+	rd	STICK, %o0
+	mov	1, %o1		! Mask off high bits of the register
+	sllx	%o1, 63, %o1
+	andn	%o0, %o1, %o0
+	retl
+	 wr	%o0, STICK_CMPR
+
 ENTRY(setjmp)
 	save	%sp, -CC64FSZ, %sp	! Need a frame to return to.
 	flushw



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

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 20:09:24 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: psl.h

Log Message:
Introduce getstickcmpr() function


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/sparc64/include/psl.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/sparc64/include/psl.h
diff -u src/sys/arch/sparc64/include/psl.h:1.57 src/sys/arch/sparc64/include/psl.h:1.58
--- src/sys/arch/sparc64/include/psl.h:1.57	Wed May 18 07:59:30 2016
+++ src/sys/arch/sparc64/include/psl.h	Fri Feb  8 20:09:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: psl.h,v 1.57 2016/05/18 07:59:30 nakayama Exp $ */
+/*	$NetBSD: psl.h,v 1.58 2019/02/08 20:09:24 palle Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -383,6 +383,9 @@ SPARC64_RDCONST64_DEF(rdpr, ver, %ver)		
 SPARC64_RDASR64_DEF(stick, STICK)		/* getstick() */
 SPARC64_WRASR64_DEF(stick, STICK)		/* setstick() */
 
+/* System Tick Compare Register (ASR 25) */
+SPARC64_RDASR64_DEF(stickcmpr, STICK_CMPR)	/* getstickcmpr() */
+
 /* Some simple macros to check the cpu type. */
 #define GETVER_CPU_MASK()	((getver() & VER_MASK) >> VER_MASK_SHIFT)
 #define GETVER_CPU_IMPL()	((getver() & VER_IMPL) >> VER_IMPL_SHIFT)



CVS commit: src/sys/arch/sparc64/doc

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 19:55:40 UTC 2019

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update the TODO file noting (at least) some progess with sun4v


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.28 src/sys/arch/sparc64/doc/TODO:1.29
--- src/sys/arch/sparc64/doc/TODO:1.28	Mon Dec 17 20:13:46 2018
+++ src/sys/arch/sparc64/doc/TODO	Fri Feb  8 19:55:40 2019
@@ -1,4 +1,4 @@
- /* $NetBSD: TODO,v 1.28 2018/12/17 20:13:46 palle Exp $ */
+ /* $NetBSD: TODO,v 1.29 2019/02/08 19:55:40 palle Exp $ */
 
 Things to be done:
 
@@ -11,14 +11,9 @@ sun4u:
 - GENERIC.UP kernel hangs on v445 (missing interrupt?)
 
 sun4v:
- - current status: The kernel boots and starts the init process (pid 1) 
-   which spawns /sbin/sh (pid 2). This is forked as a new /sbin/sh (pid 3)
-   which crashes, probably due to MMU DPROT issues.
-   Looks like the user process tries to write to the stack as part of a save
-   instruction since cansave is zero. This causes a DMMU PROT trap (0x6c) which
-   calls sun4v_tl0_dtsb_prot which calls sun4v_datatrap which calls TRAP_SETUP().
-   This macro has code that does a save instruction, again to the user stack,
-   which again causes a MMU DPROT trap...
+ - current status: The kernel boots and starts the init process. 
+   The following processes seem to crash on and on so more debugging to be done...
+
 - 64-bit kernel support
 - 32-bit kernel support
 - libkvm



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 19:45:24 UTC 2019

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

Log Message:
sun4v: introduce macros for handling spill traps from userlevevel @ traplevel 1 
(from OpenBSD) - spill traps at level 1 from userspace now works better


To generate a diff of this commit:
cvs rdiff -u -r1.416 -r1.417 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.416 src/sys/arch/sparc64/sparc64/locore.s:1.417
--- src/sys/arch/sparc64/sparc64/locore.s:1.416	Fri Feb  8 19:26:25 2019
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 19:45:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.416 2019/02/08 19:26:25 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.417 2019/02/08 19:45:24 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -227,6 +227,18 @@
 	LDPTR	[\reg + %lo(CPUINFO_VA + CI_TSB_DMMU)], \reg
 	.endm
 
+	.macro sun4v_tl1_uspill_normal
+	ba,a,pt	%xcc, pcbspill_normals
+	 nop
+	.align 128
+	.endm
+
+	.macro sun4v_tl1_uspill_other
+	ba,a,pt	%xcc, pcbspill_others
+	 nop
+	.align 128
+	.endm
+	
 #endif
 		
 #if 1
@@ -1155,17 +1167,17 @@ _C_LABEL(trapbase_sun4v):
 	sun4v_trap_entry 56	! 0x034-0x06b
 	VTRAP(T_FDMMU_PROT, sun4v_tl1_dtsb_prot)		! 0x06c
 	sun4v_trap_entry 19	! 0x06d-0x07f
-	SPILL64(uspill8_sun4vt1,ASI_AIUS)			! 0x080 spill_0_normal -- save user windows
-	SPILL32(uspill4_sun4vt1,ASI_AIUS)			! 0x084 spill_1_normal
-	SPILLBOTH(uspill8_sun4vt1,uspill4_sun4vt1,ASI_AIUS)	! 0x088 spill_2_normal
+	sun4v_tl1_uspill_normal	! 0x080 spill_0_normal -- save user windows
+	sun4v_tl1_uspill_normal	! 0x084 spill_1_normal
+	sun4v_tl1_uspill_normal	! 0x088 spill_2_normal
 	sun4v_trap_entry_spill_fill_fail 1			! 0x08c spill_3_normal
 	SPILL64(kspill8_sun4vt1,ASI_N)! 0x090 spill_4_normal -- save supervisor windows
 	SPILL32(kspill4_sun4vt1,ASI_N)! 0x094 spill_5_normal
 	SPILLBOTH(kspill8_sun4vt1,kspill4_sun4vt1,ASI_N)	! 0x098 spill_6_normal
 	sun4v_trap_entry_spill_fill_fail 1			! 0x09c spill_7_normal
-	SPILL64(uspillk8_sun4vt1,ASI_AIUS)			! 0x0a0 spill_0_other -- save user windows in nucleus mode
-	SPILL32(uspillk4_sun4vt1,ASI_AIUS)			! 0x0a4 spill_1_other
-	SPILLBOTH(uspillk8_sun4vt1,uspillk4_sun4vt1,ASI_AIUS)	! 0x0a8 spill_2_other
+	sun4v_tl1_uspill_other	! 0x0a0 spill_0_other -- save user windows in nucleus mode
+	sun4v_tl1_uspill_other	! 0x0a4 spill_1_other
+	sun4v_tl1_uspill_other	! 0x0a8 spill_2_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0ac spill_3_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0b0 spill_4_other
 	sun4v_trap_entry_spill_fill_fail 1			! 0x0b4 spill_5_other



CVS commit: src/sys/arch/sparc64/sparc64

2019-02-08 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Fri Feb  8 19:26:25 UTC 2019

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

Log Message:
sun4v: add comment documenting the contents of the %g2 register - no functional 
changes


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/locore.s
diff -u src/sys/arch/sparc64/sparc64/locore.s:1.415 src/sys/arch/sparc64/sparc64/locore.s:1.416
--- src/sys/arch/sparc64/sparc64/locore.s:1.415	Sun Nov  4 20:02:07 2018
+++ src/sys/arch/sparc64/sparc64/locore.s	Fri Feb  8 19:26:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.415 2018/11/04 20:02:07 palle Exp $	*/
+/*	$NetBSD: locore.s,v 1.416 2019/02/08 19:26:25 palle Exp $	*/
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -3034,7 +3034,7 @@ sun4v_tl0_dtsb_prot:
 
 #	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
 	mov	1, %g2
-	sllx	%g2, 61, %g2
+	sllx	%g2, 61, %g2			! %g2 is now SUN4V_TLB_REAL_W
 	or	%g2, SUN4V_TLB_W, %g2
 	btst	%g2, %g4
 	bz,pn	%xcc, sun4v_datatrap			! No -- really fault
@@ -3263,7 +3263,7 @@ sun4v_tl1_dtsb_prot:
 
 #	btst	SUN4V_TLB_REAL_W|SUN4V_TLB_W, %g4	! Is it a ref fault?
 	mov	1, %g2
-	sllx	%g2, 61, %g2
+	sllx	%g2, 61, %g2			! %g2 is now SUN4V_TLB_REAL_W
 	or	%g2, SUN4V_TLB_W, %g2
 	btst	%g2, %g4
 	bz,pn	%xcc, sun4v_tl1_ptbl_miss		! No -- really fault



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

2019-02-04 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Feb  5 06:10:53 UTC 2019

Modified Files:
src/sys/arch/sparc64/dev: fdc.c psycho.c schizo.c

Log Message:
add or avoid fallthru comments.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/sparc64/dev/fdc.c
cvs rdiff -u -r1.126 -r1.127 src/sys/arch/sparc64/dev/psycho.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/sparc64/dev/schizo.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/sparc64/dev/fdc.c
diff -u src/sys/arch/sparc64/dev/fdc.c:1.45 src/sys/arch/sparc64/dev/fdc.c:1.46
--- src/sys/arch/sparc64/dev/fdc.c:1.45	Mon Sep  3 16:29:27 2018
+++ src/sys/arch/sparc64/dev/fdc.c	Tue Feb  5 06:10:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fdc.c,v 1.45 2018/09/03 16:29:27 riastradh Exp $	*/
+/*	$NetBSD: fdc.c,v 1.46 2019/02/05 06:10:53 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.45 2018/09/03 16:29:27 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.46 2019/02/05 06:10:53 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -2010,12 +2010,13 @@ loop:
 	case RECALWAIT:
 		callout_stop(>sc_timo_ch);
 		fdc->sc_state = RECALCOMPLETE;
-		if (fdc->sc_flags & FDC_NEEDHEADSETTLE) {
+		if ((fdc->sc_flags & FDC_NEEDHEADSETTLE) != 0) {
 			/* allow 1/30 second for heads to settle */
 			callout_reset(>sc_intr_ch, hz / 30,
 			fdcpseudointr, fdc);
 			return 1;		/* will return later */
 		}
+		/* FALLTHROUGH */
 
 	case RECALCOMPLETE:
 		if (fdc->sc_nstat != 2 || (st0 & 0xf8) != 0x20 || cyl != 0) {

Index: src/sys/arch/sparc64/dev/psycho.c
diff -u src/sys/arch/sparc64/dev/psycho.c:1.126 src/sys/arch/sparc64/dev/psycho.c:1.127
--- src/sys/arch/sparc64/dev/psycho.c:1.126	Sun Mar 26 12:51:42 2017
+++ src/sys/arch/sparc64/dev/psycho.c	Tue Feb  5 06:10:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: psycho.c,v 1.126 2017/03/26 12:51:42 martin Exp $	*/
+/*	$NetBSD: psycho.c,v 1.127 2019/02/05 06:10:53 mrg Exp $	*/
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.126 2017/03/26 12:51:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.127 2019/02/05 06:10:53 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -1068,11 +1068,16 @@ psycho_iommu_init(struct psycho_softc *s
 		iobase = vdma[0];
 #define	TSBCASE(x)	case 1<<((x)+23): tsbsize = (x); break
 		switch (vdma[1]) {
-			TSBCASE(1); TSBCASE(2); TSBCASE(3);
-			TSBCASE(4); TSBCASE(5); TSBCASE(6);
+			TSBCASE(1);
+			TSBCASE(2);
+			TSBCASE(3);
+			TSBCASE(4);
+			TSBCASE(5);
+			TSBCASE(6);
+			TSBCASE(7);
 		default:
 			printf("bogus tsb size %x, using 7\n", vdma[1]);
-			TSBCASE(7);
+			tsbsize = 7;
 		}
 #undef TSBCASE
 	}

Index: src/sys/arch/sparc64/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.39 src/sys/arch/sparc64/dev/schizo.c:1.40
--- src/sys/arch/sparc64/dev/schizo.c:1.39	Sat Jun  3 21:32:43 2017
+++ src/sys/arch/sparc64/dev/schizo.c	Tue Feb  5 06:10:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: schizo.c,v 1.39 2017/06/03 21:32:43 mrg Exp $	*/
+/*	$NetBSD: schizo.c,v 1.40 2019/02/05 06:10:53 mrg Exp $	*/
 /*	$OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $	*/
 
 /*
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.39 2017/06/03 21:32:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.40 2019/02/05 06:10:53 mrg Exp $");
 
 #include 
 #include 
@@ -490,11 +490,16 @@ schizo_init_iommu(struct schizo_softc *s
 		iobase = vdma[0];
 #define	TSBCASE(x)	case 1 << ((x) + 23): tsbsize = (x); break
 		switch (vdma[1]) { 
-			TSBCASE(1); TSBCASE(2); TSBCASE(3);
-			TSBCASE(4); TSBCASE(5); TSBCASE(6);
+			TSBCASE(1);
+			TSBCASE(2);
+			TSBCASE(3);
+			TSBCASE(4);
+			TSBCASE(5);
+			TSBCASE(6);
+			TSBCASE(7);
 		default: 
 			printf("bogus tsb size %x, using 7\n", vdma[1]);
-			TSBCASE(7);
+			tsbsize = 7;
 		}
 #undef TSBCASE
 		DPRINTF(SDB_BUSMAP, ("schizo_init_iommu: iobase=0x%x\n", iobase));



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Jan 30 10:11:11 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: netbsd32_machdep_13.c

Log Message:
Make this compile with "options DEBUG".


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.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/sparc64/sparc64/netbsd32_machdep_13.c
diff -u src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c:1.2 src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c:1.3
--- src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c:1.2	Sun Jan 27 02:08:38 2019
+++ src/sys/arch/sparc64/sparc64/netbsd32_machdep_13.c	Wed Jan 30 10:11:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_machdep_13.c,v 1.2 2019/01/27 02:08:38 pgoyette Exp $	*/
+/*	$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/01/30 10:11:11 hannken Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.2 2019/01/27 02:08:38 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep_13.c,v 1.3 2019/01/30 10:11:11 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -83,6 +83,10 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac
 #include 
 #include 
 
+#ifdef DEBUG
+#include 
+#endif
+
 int
 compat_13_netbsd32_sigreturn(struct lwp *l, const struct compat_13_netbsd32_sigreturn_args *uap, register_t *retval)
 {
@@ -108,7 +112,7 @@ compat_13_netbsd32_sigreturn(struct lwp 
 	}
 #ifdef DEBUG
 	if (sigdebug & SDB_FOLLOW) {
-		printf("%s: %s[%d], sigcntxp %p\n", __func__,
+		printf("%s: %s[%d], sigcntxp %u\n", __func__,
 		p->p_comm, p->p_pid, SCARG(uap, sigcntxp));
 		if (sigdebug & SDB_DDB) Debugger();
 	}
@@ -133,7 +137,7 @@ compat_13_netbsd32_sigreturn(struct lwp 
 	if (((sc.sc_pc | sc.sc_npc) & 3) != 0)
 #ifdef DEBUG
 	{
-		printf("%s: pc %p or npc %p invalid\n",
+		printf("%s: pc %d or npc %d invalid\n",
 		   __func__, sc.sc_pc, sc.sc_npc);
 		Debugger();
 		return (EINVAL);
@@ -150,7 +154,7 @@ compat_13_netbsd32_sigreturn(struct lwp 
 	tf->tf_out[6] = (int64_t)sc.sc_sp;
 #ifdef DEBUG
 	if (sigdebug & SDB_FOLLOW) {
-		printf("%s: return trapframe pc=%p sp=%p tstate=%x\n", __func__,
+		printf("%s: return trapframe pc=%d sp=%d tstate=%x\n", __func__,
 		   (int)tf->tf_pc, (int)tf->tf_out[6], (int)tf->tf_tstate);
 		if (sigdebug & SDB_DDB) Debugger();
 	}



CVS commit: src/sys/arch/sparc64

2019-01-10 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Jan 10 10:33:50 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: pmap.h
src/sys/arch/sparc64/sparc64: db_interface.c pmap.c

Log Message:
- move pmap_ctx() macro into pmap.h instead of duplicating it.
- fix description of some mach ddb commands.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/sparc64/include/pmap.h
cvs rdiff -u -r1.133 -r1.134 src/sys/arch/sparc64/sparc64/db_interface.c
cvs rdiff -u -r1.309 -r1.310 src/sys/arch/sparc64/sparc64/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/sparc64/include/pmap.h
diff -u src/sys/arch/sparc64/include/pmap.h:1.61 src/sys/arch/sparc64/include/pmap.h:1.62
--- src/sys/arch/sparc64/include/pmap.h:1.61	Fri Nov  4 05:41:01 2016
+++ src/sys/arch/sparc64/include/pmap.h	Thu Jan 10 10:33:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.h,v 1.61 2016/11/04 05:41:01 macallan Exp $	*/
+/*	$NetBSD: pmap.h,v 1.62 2019/01/10 10:33:49 mrg Exp $	*/
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -269,6 +269,13 @@ do {	\
 	(pg)->mdpage.mdpg_pvh.pv_va = 0;\
 } while (/*CONSTCOND*/0)
 
+#ifdef MULTIPROCESSOR
+#define pmap_ctx_cpu(PM, C)	((PM)->pm_ctx[(C)])
+#define pmap_ctx(PM)		pmap_ctx_cpu((PM), cpu_number())
+#else
+#define pmap_ctx(PM)		((PM)->pm_ctx[0])
+#endif
+
 #endif	/* _KERNEL */
 
 #endif	/* _LOCORE */

Index: src/sys/arch/sparc64/sparc64/db_interface.c
diff -u src/sys/arch/sparc64/sparc64/db_interface.c:1.133 src/sys/arch/sparc64/sparc64/db_interface.c:1.134
--- src/sys/arch/sparc64/sparc64/db_interface.c:1.133	Sun May  1 20:12:54 2016
+++ src/sys/arch/sparc64/sparc64/db_interface.c	Thu Jan 10 10:33:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.133 2016/05/01 20:12:54 palle Exp $ */
+/*	$NetBSD: db_interface.c,v 1.134 2019/01/10 10:33:49 mrg Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath.  All rights reserved.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.133 2016/05/01 20:12:54 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.134 2019/01/10 10:33:49 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -90,15 +90,6 @@ extern struct traptrace {
 	u_int tfault;		/* MMU tag access */
 } trap_trace[], trap_trace_end[];
 
-/*
- * Helpers for ddb variables.
- */
-#ifdef MULTIPROCESSOR
-#define pmap_ctx(PM)	((PM)->pm_ctx[cpu_number()])
-#else
-#define pmap_ctx(PM)	((PM)->pm_ctx[0])
-#endif
-
 void fill_ddb_regs_from_tf(struct trapframe64 *tf);
 void ddb_restore_state(void);
 bool ddb_running_on_this_cpu(void);
@@ -428,7 +419,7 @@ db_prom_cmd(db_expr_t addr, bool have_ad
 void
 db_dump_dtlb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
 {
-	extern void print_dtlb(size_t, int);
+	extern void print_dtlb(size_t /*tlbsize*/, int /*tlbmask*/);
 
 	if (CPU_IS_USIII_UP()) {
 		print_dtlb(TLB_SIZE_CHEETAH_D16, TLB_CHEETAH_D16);
@@ -443,7 +434,7 @@ db_dump_dtlb(db_expr_t addr, bool have_a
 void
 db_dump_itlb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
 {
-	extern void print_itlb(size_t, int);
+	extern void print_itlb(size_t /*tlbsize*/, int /*tlbmask*/);
 
 	if (CPU_IS_USIII_UP()) {
 		print_itlb(TLB_SIZE_CHEETAH_I16, TLB_CHEETAH_I16);
@@ -1056,10 +1047,10 @@ const struct db_command db_machine_comma
 	  "switch to another cpu", "cpu-no", NULL) },
 #endif
 	{ DDB_ADD_CMD("dtlb",	db_dump_dtlb,	0,
-	  "Print data translation look-aside buffer context information.",
+	  "Display data translation look-aside buffer context information.",
 	  NULL,NULL) },
 	{ DDB_ADD_CMD("itlb",	db_dump_itlb,	0,
-	  "Display instruction translation storage buffer information.",
+	  "Display instruction translation look-aside buffer information.",
 	  NULL,NULL) },
 	{ DDB_ADD_CMD("dtsb",	db_dump_dtsb,	0,
 	  "Display data translation storage buffer information.", NULL,NULL) },

Index: src/sys/arch/sparc64/sparc64/pmap.c
diff -u src/sys/arch/sparc64/sparc64/pmap.c:1.309 src/sys/arch/sparc64/sparc64/pmap.c:1.310
--- src/sys/arch/sparc64/sparc64/pmap.c:1.309	Thu Nov 29 20:58:36 2018
+++ src/sys/arch/sparc64/sparc64/pmap.c	Thu Jan 10 10:33:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.309 2018/11/29 20:58:36 palle Exp $	*/
+/*	$NetBSD: pmap.c,v 1.310 2019/01/10 10:33:49 mrg Exp $	*/
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.309 2018/11/29 20:58:36 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.310 2019/01/10 10:33:49 mrg Exp $");
 
 #undef	NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define	HWREF
@@ -194,12 +194,6 @@ pmap_has_ctx(struct pmap *p)
 	return false;
 }
 
-#ifdef MULTIPROCESSOR
-#define pmap_ctx(PM)	((PM)->pm_ctx[cpu_number()])
-#else
-#define pmap_ctx(PM)	((PM)->pm_ctx[0])
-#endif
-
 /*
  * Check if this pmap has a live mapping on 

CVS commit: src/sys/arch/sparc64/sparc64

2019-01-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Jan  9 10:42:27 UTC 2019

Modified Files:
src/sys/arch/sparc64/sparc64: cache.h

Log Message:
avoid function param names in prototypes.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/sparc64/sparc64/cache.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/sparc64/sparc64/cache.h
diff -u src/sys/arch/sparc64/sparc64/cache.h:1.28 src/sys/arch/sparc64/sparc64/cache.h:1.29
--- src/sys/arch/sparc64/sparc64/cache.h:1.28	Mon Jan  5 11:40:56 2015
+++ src/sys/arch/sparc64/sparc64/cache.h	Wed Jan  9 10:42:27 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cache.h,v 1.28 2015/01/05 11:40:56 palle Exp $ */
+/*	$NetBSD: cache.h,v 1.29 2019/01/09 10:42:27 mrg Exp $ */
 
 /*
  * Copyright (c) 2011 Matthew R. Green
@@ -124,8 +124,8 @@ void cache_setup_funcs(void);
 extern	void	(*sp_dcache_flush_page)(paddr_t);
 
 void smp_tlb_flush_pte(vaddr_t, struct pmap *);
-void smp_dcache_flush_page_cpuset(paddr_t pa, sparc64_cpuset_t);
-void smp_dcache_flush_page_allcpu(paddr_t pa);
+void smp_dcache_flush_page_cpuset(paddr_t, sparc64_cpuset_t);
+void smp_dcache_flush_page_allcpu(paddr_t);
 void smp_blast_dcache(void);
 #define	tlb_flush_pte(va,pm)		smp_tlb_flush_pte(va, pm)
 #define	dcache_flush_page_all(pa)	smp_dcache_flush_page_cpuset(pa, cpus_active)



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

2019-01-08 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue Jan  8 19:53:40 UTC 2019

Modified Files:
src/sys/arch/sparc64/include: bootinfo.h

Log Message:
remove explicit  include, code including this already includes



To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/sparc64/include/bootinfo.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/sparc64/include/bootinfo.h
diff -u src/sys/arch/sparc64/include/bootinfo.h:1.8 src/sys/arch/sparc64/include/bootinfo.h:1.9
--- src/sys/arch/sparc64/include/bootinfo.h:1.8	Fri Sep 15 13:25:34 2017
+++ src/sys/arch/sparc64/include/bootinfo.h	Tue Jan  8 19:53:40 2019
@@ -1,4 +1,4 @@
-/*   $NetBSD: bootinfo.h,v 1.8 2017/09/15 13:25:34 martin Exp $*/
+/*   $NetBSD: bootinfo.h,v 1.9 2019/01/08 19:53:40 jdolecek Exp $*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -29,7 +29,6 @@
 #ifndef _BOOTINFO_H_
 #define _BOOTINFO_H_
 
-#include 
 #include 
 
 /*



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan  7 13:10:44 UTC 2019

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

Log Message:
When writing a kernel core dump, display the countdown w/o timestamps.


To generate a diff of this commit:
cvs rdiff -u -r1.290 -r1.291 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/machdep.c
diff -u src/sys/arch/sparc64/sparc64/machdep.c:1.290 src/sys/arch/sparc64/sparc64/machdep.c:1.291
--- src/sys/arch/sparc64/sparc64/machdep.c:1.290	Wed Dec 19 13:57:50 2018
+++ src/sys/arch/sparc64/sparc64/machdep.c	Mon Jan  7 13:10:44 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.290 2018/12/19 13:57:50 maxv Exp $ */
+/*	$NetBSD: machdep.c,v 1.291 2019/01/07 13:10:44 martin Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.290 2018/12/19 13:57:50 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.291 2019/01/07 13:10:44 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -122,6 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 
 #define _SPARC_BUS_DMA_PRIVATE
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -755,7 +756,8 @@ dumpsys(void)
 
 			/* print out how many MBs we still have to dump */
 			if ((todo % (1024*1024)) == 0)
-printf_nolog("\r%6" PRIu64 " M ",
+printf_flags(TOCONS|NOTSTAMP, 
+"\r%6" PRIu64 " M ",
 todo / (1024*1024));
 			for (off = 0; off < n; off += PAGE_SIZE)
 pmap_kenter_pa(dumpspace+off, maddr+off,
@@ -790,7 +792,8 @@ dumpsys(void)
 		break;
 
 	case 0:
-		printf("\rdump succeeded\n");
+		printf_flags(TOCONS|NOTSTAMP, "\r   ");
+		printf("\ndump succeeded\n");
 		break;
 
 	default:



CVS commit: src/sys/arch/sparc64/sparc64

2019-01-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan  5 15:46:02 UTC 2019

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

Log Message:
Remove debugging leftover, pointed out by mrg


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/autoconf.c
diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.214 src/sys/arch/sparc64/sparc64/autoconf.c:1.215
--- src/sys/arch/sparc64/sparc64/autoconf.c:1.214	Fri Jan  4 16:25:06 2019
+++ src/sys/arch/sparc64/sparc64/autoconf.c	Sat Jan  5 15:46:02 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.214 2019/01/04 16:25:06 martin Exp $ */
+/*	$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.214 2019/01/04 16:25:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.215 2019/01/05 15:46:02 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -905,7 +905,6 @@ openbios_secondary_ata_heuristic(int par
 		   " secondary ATA bus, applying workaround target+2\n"));
 		return true;
 	} else if (strcmp(tmp, "ide") == 0) {
-		regs[0] = 42;
 		if (OF_getprop(parent, "reg", , sizeof(regs))
 		>= sizeof(regs[0])) {
 			DPRINTF(ACDB_BOOTDEV, ("parent seems to be an OpenBIOS"



  1   2   3   4   5   6   7   8   >