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

2020-03-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Mar 25 06:17:23 UTC 2020

Modified Files:
src/sys/arch/arm/arm32: db_machdep.c

Log Message:
Simplify #ifdefs


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/arm32/db_machdep.c

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

Modified files:

Index: src/sys/arch/arm/arm32/db_machdep.c
diff -u src/sys/arch/arm/arm32/db_machdep.c:1.26 src/sys/arch/arm/arm32/db_machdep.c:1.27
--- src/sys/arch/arm/arm32/db_machdep.c:1.26	Wed Mar 25 06:02:09 2020
+++ src/sys/arch/arm/arm32/db_machdep.c	Wed Mar 25 06:17:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.26 2020/03/25 06:02:09 skrll Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.27 2020/03/25 06:17:23 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Mark Brinicombe
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.26 2020/03/25 06:02:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.27 2020/03/25 06:17:23 skrll Exp $");
 
 #include 
 #include 
@@ -117,17 +117,17 @@ const struct db_command db_machine_comma
 	{ DDB_ADD_CMD("fault",	db_show_fault_cmd,	0,
 			"Displays the fault registers",
 		 	NULL,NULL) },
-#endif
-#if defined(_KERNEL) && (defined(CPU_CORTEXA5) || defined(CPU_CORTEXA7))
+#if defined(CPU_CORTEXA5) || defined(CPU_CORTEXA7)
 	{ DDB_ADD_CMD("tlb",	db_show_tlb_cmd,	0,
 			"Displays the TLB",
 		 	NULL,NULL) },
 #endif
-#if defined(_KERNEL) && defined(MULTIPROCESSOR)
+#if defined(MULTIPROCESSOR)
 	{ DDB_ADD_CMD("cpu",	db_switch_cpu_cmd,	0,
 			"switch to a different cpu",
 		 	NULL,NULL) },
 #endif
+#endif /* _KERNEL */
 
 #ifdef ARM32_DB_COMMANDS
 	ARM32_DB_COMMANDS,
@@ -135,6 +135,31 @@ const struct db_command db_machine_comma
 	{ DDB_ADD_CMD(NULL, NULL,   0,NULL,NULL,NULL) }
 };
 
+void
+db_show_frame_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
+{
+	struct trapframe *frame;
+
+	if (!have_addr) {
+		db_printf("frame address must be specified\n");
+		return;
+	}
+
+	frame = (struct trapframe *)addr;
+
+	db_printf("frame address = %08x  ", (u_int)frame);
+	db_printf("spsr=%08x\n", frame->tf_spsr);
+	db_printf("r0 =%08x r1 =%08x r2 =%08x r3 =%08x\n",
+	frame->tf_r0, frame->tf_r1, frame->tf_r2, frame->tf_r3);
+	db_printf("r4 =%08x r5 =%08x r6 =%08x r7 =%08x\n",
+	frame->tf_r4, frame->tf_r5, frame->tf_r6, frame->tf_r7);
+	db_printf("r8 =%08x r9 =%08x r10=%08x r11=%08x\n",
+	frame->tf_r8, frame->tf_r9, frame->tf_r10, frame->tf_r11);
+	db_printf("r12=%08x r13=%08x r14=%08x r15=%08x\n",
+	frame->tf_r12, frame->tf_usr_sp, frame->tf_usr_lr, frame->tf_pc);
+	db_printf("slr=%08x ssp=%08x\n", frame->tf_svc_lr, frame->tf_svc_sp);
+}
+
 #ifdef _KERNEL
 int
 db_access_und_sp(const struct db_variable *vp, db_expr_t *valp, int rw)
@@ -423,35 +448,8 @@ db_show_tlb_cmd(db_expr_t addr, bool hav
 	db_printf("%zu TLB valid entries found\n", n);
 }
 #endif /* CPU_CORTEXA5 || CPU_CORTEXA7 */
-#endif /* _KERNEL */
-
-
-void
-db_show_frame_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
-{
-	struct trapframe *frame;
-
-	if (!have_addr) {
-		db_printf("frame address must be specified\n");
-		return;
-	}
-
-	frame = (struct trapframe *)addr;
 
-	db_printf("frame address = %08x  ", (u_int)frame);
-	db_printf("spsr=%08x\n", frame->tf_spsr);
-	db_printf("r0 =%08x r1 =%08x r2 =%08x r3 =%08x\n",
-	frame->tf_r0, frame->tf_r1, frame->tf_r2, frame->tf_r3);
-	db_printf("r4 =%08x r5 =%08x r6 =%08x r7 =%08x\n",
-	frame->tf_r4, frame->tf_r5, frame->tf_r6, frame->tf_r7);
-	db_printf("r8 =%08x r9 =%08x r10=%08x r11=%08x\n",
-	frame->tf_r8, frame->tf_r9, frame->tf_r10, frame->tf_r11);
-	db_printf("r12=%08x r13=%08x r14=%08x r15=%08x\n",
-	frame->tf_r12, frame->tf_usr_sp, frame->tf_usr_lr, frame->tf_pc);
-	db_printf("slr=%08x ssp=%08x\n", frame->tf_svc_lr, frame->tf_svc_sp);
-}
-
-#if defined(_KERNEL) && defined(MULTIPROCESSOR)
+#if defined(MULTIPROCESSOR)
 void
 db_switch_cpu_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
 {
@@ -473,3 +471,4 @@ db_switch_cpu_cmd(db_expr_t addr, bool h
 	db_continue_cmd(0, false, 0, "");
 }
 #endif
+#endif /* _KERNEL */



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

2020-03-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Mar 25 06:02:09 UTC 2020

Modified Files:
src/sys/arch/arm/arm32: db_machdep.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/arm/arm32/db_machdep.c

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

Modified files:

Index: src/sys/arch/arm/arm32/db_machdep.c
diff -u src/sys/arch/arm/arm32/db_machdep.c:1.25 src/sys/arch/arm/arm32/db_machdep.c:1.26
--- src/sys/arch/arm/arm32/db_machdep.c:1.25	Wed Aug 15 06:00:02 2018
+++ src/sys/arch/arm/arm32/db_machdep.c	Wed Mar 25 06:02:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_machdep.c,v 1.25 2018/08/15 06:00:02 skrll Exp $	*/
+/*	$NetBSD: db_machdep.c,v 1.26 2020/03/25 06:02:09 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Mark Brinicombe
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.25 2018/08/15 06:00:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.26 2020/03/25 06:02:09 skrll Exp $");
 
 #include 
 #include 
@@ -208,7 +208,7 @@ struct db_tlbinfo {
 	vaddr_t (*dti_decode_vpn)(size_t, uint32_t, uint32_t);
 	void (*dti_print_header)(void);
 	void (*dti_print_entry)(size_t, size_t, uint32_t, uint32_t);
-	u_int dti_index; 
+	u_int dti_index;
 };
 
 #if defined(CPU_CORTEXA5)



CVS commit: src/sys/dev/ic

2020-03-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar 25 04:53:11 UTC 2020

Modified Files:
src/sys/dev/ic: bwfm.c bwfmvar.h

Log Message:
Add a file type entry for CLM files.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/bwfmvar.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/dev/ic/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.21 src/sys/dev/ic/bwfm.c:1.22
--- src/sys/dev/ic/bwfm.c:1.21	Wed Mar 25 03:44:44 2020
+++ src/sys/dev/ic/bwfm.c	Wed Mar 25 04:53:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.21 2020/03/25 03:44:44 thorpej Exp $ */
+/* $NetBSD: bwfm.c,v 1.22 2020/03/25 04:53:11 thorpej Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -144,6 +144,10 @@ static const struct {
 		.suffix = "txt",
 		.description = "NVRAM",
 	},
+	[BWFM_FILETYPE_CLM] = {
+		.suffix = "clm_blob",
+		.description = "CLM",
+	},
 };
 
 static void

Index: src/sys/dev/ic/bwfmvar.h
diff -u src/sys/dev/ic/bwfmvar.h:1.7 src/sys/dev/ic/bwfmvar.h:1.8
--- src/sys/dev/ic/bwfmvar.h:1.7	Wed Mar 25 03:44:44 2020
+++ src/sys/dev/ic/bwfmvar.h	Wed Mar 25 04:53:11 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfmvar.h,v 1.7 2020/03/25 03:44:44 thorpej Exp $ */
+/* $NetBSD: bwfmvar.h,v 1.8 2020/03/25 04:53:11 thorpej Exp $ */
 /* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -85,7 +85,8 @@ struct bwfm_firmware_selector {
 
 #define	BWFM_FILETYPE_UCODE	0
 #define	BWFM_FILETYPE_NVRAM	1
-#define	BWFM_NFILETYPES		2
+#define	BWFM_FILETYPE_CLM	2
+#define	BWFM_NFILETYPES		3
 
 struct bwfm_firmware_context {
 	/* inputs */



CVS commit: src/sys/dev

2020-03-24 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar 25 03:44:45 UTC 2020

Modified Files:
src/sys/dev/ic: bwfm.c bwfmvar.h
src/sys/dev/pci: if_bwfm_pci.c
src/sys/dev/sdmmc: if_bwfm_sdio.c
src/sys/dev/usb: if_bwfm_usb.c

Log Message:
- Refactor the firmware loading code into a set of common routines in the
  core driver that understand how to find model-specific files before the
  generic files.  This greatly simplifies the firmware loading procedure
  in each of the bus front ends.  Adding additional firmware file types
  (such as CLM files) much simpler.
- Make firmware image selection table-driven rather than a set of switch()
  and if() statements.
- Add several additional firmware image entries.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/bwfm.c
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/bwfmvar.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/if_bwfm_pci.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/sdmmc/if_bwfm_sdio.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/usb/if_bwfm_usb.c

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

Modified files:

Index: src/sys/dev/ic/bwfm.c
diff -u src/sys/dev/ic/bwfm.c:1.20 src/sys/dev/ic/bwfm.c:1.21
--- src/sys/dev/ic/bwfm.c:1.20	Wed Jan 29 14:14:55 2020
+++ src/sys/dev/ic/bwfm.c	Wed Mar 25 03:44:44 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.20 2020/01/29 14:14:55 thorpej Exp $ */
+/* $NetBSD: bwfm.c,v 1.21 2020/03/25 03:44:44 thorpej Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -132,6 +132,180 @@ struct bwfm_proto_ops bwfm_proto_bcdc_op
 	.proto_set_dcmd = bwfm_proto_bcdc_set_dcmd,
 };
 
+static const struct {
+	const char *suffix;
+	const char *description;
+} bwfm_firmware_filetypes[] = {
+	[BWFM_FILETYPE_UCODE] = {
+		.suffix = "bin",
+		.description = "Firmware",
+	},
+	[BWFM_FILETYPE_NVRAM] = {
+		.suffix = "txt",
+		.description = "NVRAM",
+	},
+};
+
+static void
+bwfm_firmware_read_file(struct bwfm_softc * const sc,
+const struct bwfm_firmware_selector * const fwp,
+struct bwfm_firmware_context * const ctx,
+unsigned int const which)
+{
+	firmware_handle_t fwh;
+	char *names[2];
+	int i, error;
+
+	names[1] = kmem_asprintf("%s.%s", fwp->fwsel_basename,
+	bwfm_firmware_filetypes[which].suffix);
+	if (ctx->ctx_model)
+	names[0] = ctx->ctx_model ? kmem_asprintf("%s.%s.%s",
+	fwp->fwsel_basename, ctx->ctx_model,
+	bwfm_firmware_filetypes[which].suffix) : NULL;
+
+	aprint_verbose_dev(sc->sc_dev, "%s file default:%s\n",
+	bwfm_firmware_filetypes[which].description, names[1]);
+	if (names[0]) {
+		aprint_verbose_dev(sc->sc_dev, "%s file model-spec: %s\n",
+		bwfm_firmware_filetypes[which].description, names[0]);
+	}
+
+	for (i = 0; i < 2; i++) {
+		if (names[i] == NULL)
+			continue;
+		error = firmware_open("if_bwfm", names[i], &fwh);
+		if (error == 0)
+			break;
+	}
+	if (i == 2)
+		goto out;
+
+	aprint_verbose_dev(sc->sc_dev, "Found %s file: %s\n",
+	bwfm_firmware_filetypes[which].description, names[i]);
+
+	size_t size = firmware_get_size(fwh);
+	void *data = firmware_malloc(size);
+	if (data == NULL) {
+		aprint_error_dev(sc->sc_dev,
+		"unable to allocate %zu bytes for %s image\n", size,
+		bwfm_firmware_filetypes[which].description);
+		firmware_close(fwh);
+		goto out;
+	}
+	error = firmware_read(fwh, 0, data, size);
+	firmware_close(fwh);
+	if (error) {
+		aprint_error_dev(sc->sc_dev,
+		"failed to read %s file, error %d\n",
+		bwfm_firmware_filetypes[which].description,
+		error);
+		firmware_free(data, size);
+		goto out;
+	}
+
+	ctx->ctx_file[which].ctx_f_data = data;
+	ctx->ctx_file[which].ctx_f_size = size;
+ out:
+	for (i = 0; i < 2; i++) {
+		if (names[i])
+			kmem_free(names[i], strlen(names[i])+1);
+	}
+}
+
+void
+bwfm_firmware_context_init(struct bwfm_firmware_context * const ctx,
+uint32_t const chip, uint32_t const chiprev, const char * const model,
+uint32_t req)
+{
+	memset(ctx, 0, sizeof(*ctx));
+	ctx->ctx_chip = chip;
+	ctx->ctx_chiprev = chiprev;
+	ctx->ctx_model = model;
+
+	/* all devices require ucode */
+	ctx->ctx_req = req | BWFM_FWREQ(BWFM_FILETYPE_UCODE);
+}
+
+bool
+bwfm_firmware_open(struct bwfm_softc * const sc,
+const struct bwfm_firmware_selector * const fwtab,
+struct bwfm_firmware_context * const ctx)
+{
+	const struct bwfm_firmware_selector *fwp;
+	unsigned int i;
+
+	KASSERT(fwtab != NULL);
+	KASSERT(ctx != NULL);
+
+	/* First locate the appropriate entry for this chip / rev. */
+	for (fwp = fwtab; fwp->fwsel_basename != NULL; fwp++) {
+		if (fwp->fwsel_chip == ctx->ctx_chip &&
+		fwp->fwsel_revmask & __BIT(ctx->ctx_chiprev))
+			break;
+	}
+	if (fwp->fwsel_basename == NULL) {
+		aprint_error_dev(sc->sc_dev,
+		"No firmware entry for chip 0x%x/%u rev %u model %s\n",
+		ctx->ctx_chip, ctx->ctx_chip, ctx->ctx_chiprev,
+		   

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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Wed Mar 25 01:39:50 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
make sure to use mac_write() for GMACxxx registers. try to decode xMII link 
status report


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sociox/if_scx.c

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

Modified files:

Index: src/sys/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.12 src/sys/arch/arm/sociox/if_scx.c:1.13
--- src/sys/arch/arm/sociox/if_scx.c:1.12	Tue Mar 24 13:44:21 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Wed Mar 25 01:39:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.13 2020/03/25 01:39:49 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.13 2020/03/25 01:39:49 nisimura Exp $");
 
 #include 
 #include 
@@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #include 
 #include 
 
+/* SC2A11 register block */
 #define SWRESET		0x104
 #define COMINIT		0x120
 #define INTRST		0x200
@@ -124,6 +125,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define DESCENG_INIT	0x11fc
 #define DESCENG_SRST	0x1204
 
+/* GMAC register block. use mac_write()/mac_read() to handle */
 #define GMACMCR		0x		/* MAC configuration */
 #define  MCR_IBN	(1U<<30)	/* */
 #define  MCR_CST	(1U<<25)	/* strip CRC */
@@ -169,13 +171,21 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define GMACMAL0	0x0044		/* MAC address 0 31:0 */
 #define GMACMAH(i) 	((i)*8+0x40)	/* supplimental MAC addr 1 - 15 */
 #define GMACMAL(i) 	((i)*8+0x44)
-#define GMACMDSR	0x00d8		/* GMII/RGMII/MII command/status */
+#define GMACMIISR	0x00d8		/* resolved xMII link status */
+	/*  3   link up detected
+	 *  2:1 resovled speed
+	 *  0 2.5Mhz (10Mbps) 
+	 *	1 25Mhz  (100bps)
+	 *	2 125Mhz (1000Mbps)
+	 *  1   full duplex detected */
+
 #define GMACMHT0	0x0500		/* multicast hash table 0 - 7 */
 #define GMACMHT(i)	((i)*4+0x500)
 #define GMACVHT		0x0588		/* VLAN tag hash */
 #define GMACAMAH(i)	((i)*8+0x800)	/* supplimental MAC addr 16-127 */
 #define GMACAMAL(i)	((i)*8+0x804)
 #define GMACEVCNT(i)	((i)*4+0x114)	/* event counter 0x114~284 */
+#define GMACEVCTL	0x0100		/* clear event counter registers */
 
 #define GMACBMR		0x1000		/* DMA bus mode control
 	 * 244PBL
@@ -202,8 +212,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define  OMR_TXE	(1U<<13)	/* start Tx DMA engine, 0 to stop */
 #define  OMR_RXE	(1U<<1)		/* start Rx DMA engine, 0 to stop */
 
-static int get_mdioclk(uint32_t);
-
 /* descriptor format definition */
 struct tdes {
 	uint32_t t0, t1, t2, t3;
@@ -390,6 +398,8 @@ static int scx_intr(void *);
 static void txreap(struct scx_softc *);
 static void rxintr(struct scx_softc *);
 static int add_rxbuf(struct scx_softc *, int);
+
+static int get_mdioclk(uint32_t);
 static int spin_waitfor(struct scx_softc *, int, int);
 static int mac_read(struct scx_softc *, int);
 static void mac_write(struct scx_softc *, int, int);
@@ -585,7 +595,7 @@ scx_attach_i(struct scx_softc *sc)
 	csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 4);
 	enaddr[4] = csr >> 24;
 	enaddr[5] = csr >> 16;
-	csr = CSR_READ(sc, GMACIMPL);
+	csr = mac_read(sc, GMACIMPL);
 
 	aprint_normal_dev(sc->sc_dev, "NetSec GbE (%d.%d) impl (%x.%x)\n",
 	hwver >> 16, hwver & 0x, csr >> 16, csr & 0x);
@@ -747,6 +757,7 @@ scx_reset(struct scx_softc *sc)
 	mac_write(sc, GMACRDLAR, _RDLAR);
 	mac_write(sc, GMACTDLAR, _TDLAR);
 	mac_write(sc, GMACAFR, _AFR);
+	mac_write(sc, GMACEVCTL, 1);
 }
 
 static int
@@ -763,28 +774,43 @@ scx_init(struct ifnet *ifp)
 	/* Reset the chip to a known state. */
 	scx_reset(sc);
 
-	/* build sane Tx and load Rx descriptors with mbuf */
-	for (i = 0; i < MD_NTXDESC; i++)
-		sc->sc_txdescs[i].t0 = T0_OWN;
-	sc->sc_txdescs[MD_NTXDESC - 1].t0 |= T0_EOD; /* tie off the ring */
-	for (i = 0; i < MD_NRXDESC; i++)
-		(void)add_rxbuf(sc, i);
-
 	/* set my address in perfect match slot 0 */
 	csr = (ea[3] << 24) | (ea[2] << 16) | (ea[1] << 8) |  ea[0];
-	CSR_WRITE(sc, GMACMAL0, csr);
+	mac_write(sc, GMACMAL0, csr);
 	csr = (ea[5] << 8) | ea[4];
-	CSR_WRITE(sc, GMACMAH0, csr | 1U<<31); /* always valid? */
+	mac_write(sc, GMACMAH0, csr | 1U<<31); /* always valid? */
 
 	/* accept multicast frame or run promisc mode */
 	scx_set_rcvfilt(sc);
 
 	(void)scx_ifmedia_upd(ifp);
 
+	/* build sane Tx */
+	memset(sc->sc_txdescs, 0, sizeof(struct tdes) * MD_NTXDESC);
+	sc->sc_txdescs[MD_NTXDESC - 1].t0 |= T0_EOD; /* tie off the ring */
+	SCX_CDTXSYNC(sc, 0, MD_NTXDESC,
+		BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	sc->sc_txfree = MD_NTXDESC;
+	sc->sc_txnext = 0;
+	for (i = 0; i < MD_TXQUEUELE

CVS commit: src/sys

2020-03-24 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Tue Mar 24 22:09:50 UTC 2020

Modified Files:
src/sys/arch/arm/sunxi: files.sunxi
src/sys/dev/fdt: files.fdt

Log Message:
ohci@fdt, ehci@fdt are machine independent; move from sunxi to sys/dev/fdt


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/arm/sunxi/files.sunxi
cvs rdiff -u -r1.51 -r1.52 src/sys/dev/fdt/files.fdt

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

Modified files:

Index: src/sys/arch/arm/sunxi/files.sunxi
diff -u src/sys/arch/arm/sunxi/files.sunxi:1.67 src/sys/arch/arm/sunxi/files.sunxi:1.68
--- src/sys/arch/arm/sunxi/files.sunxi:1.67	Mon Dec  9 04:51:03 2019
+++ src/sys/arch/arm/sunxi/files.sunxi	Tue Mar 24 22:09:50 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.sunxi,v 1.67 2019/12/09 04:51:03 riastradh Exp $
+#	$NetBSD: files.sunxi,v 1.68 2020/03/24 22:09:50 tnn Exp $
 #
 # Configuration info for Allwinner sunxi family SoCs
 #
@@ -159,14 +159,6 @@ device	sun9iusbphy
 attach	sun9iusbphy at fdt with sunxi_a80_usbphy
 file	arch/arm/sunxi/sun9i_a80_usbphy.c	sunxi_a80_usbphy
 
-# EHCI
-attach	ehci at fdt with ehci_fdt
-file	dev/fdt/ehci_fdt.c			ehci_fdt	
-
-# OHCI
-attach	ohci at fdt with ohci_fdt
-file	dev/fdt/ohci_fdt.c			ohci_fdt
-
 # TWI
 device	sunxitwi: i2cbus, i2cexec, mvi2c
 attach	sunxitwi at fdt with sunxi_twi

Index: src/sys/dev/fdt/files.fdt
diff -u src/sys/dev/fdt/files.fdt:1.51 src/sys/dev/fdt/files.fdt:1.52
--- src/sys/dev/fdt/files.fdt:1.51	Sat Feb 22 00:28:35 2020
+++ src/sys/dev/fdt/files.fdt	Tue Mar 24 22:09:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.51 2020/02/22 00:28:35 jmcneill Exp $
+# $NetBSD: files.fdt,v 1.52 2020/03/24 22:09:50 tnn Exp $
 
 include	"external/bsd/libfdt/conf/files.libfdt"
 
@@ -116,6 +116,14 @@ file	dev/fdt/simplefb.c			simplefb
 attach	com at fdt with dw_apb_uart
 file	dev/fdt/dw_apb_uart.c			dw_apb_uart
 
+# EHCI
+attach	ehci at fdt with ehci_fdt
+file	dev/fdt/ehci_fdt.c			ehci_fdt
+
+# OHCI
+attach	ohci at fdt with ohci_fdt
+file	dev/fdt/ohci_fdt.c			ohci_fdt
+
 # Designware USB2 OTG
 attach	dwctwo at fdt with dwc2_fdt
 file	dev/fdt/dwc2_fdt.c			dwc2_fdt



CVS commit: src/sys/kern

2020-03-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Tue Mar 24 21:05:06 UTC 2020

Modified Files:
src/sys/kern: kern_sleepq.c

Log Message:
Update a comment.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/kern_sleepq.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/kern/kern_sleepq.c
diff -u src/sys/kern/kern_sleepq.c:1.61 src/sys/kern/kern_sleepq.c:1.62
--- src/sys/kern/kern_sleepq.c:1.61	Sat Feb 15 18:12:15 2020
+++ src/sys/kern/kern_sleepq.c	Tue Mar 24 21:05:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sleepq.c,v 1.61 2020/02/15 18:12:15 ad Exp $	*/
+/*	$NetBSD: kern_sleepq.c,v 1.62 2020/03/24 21:05:06 ad Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.61 2020/02/15 18:12:15 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.62 2020/03/24 21:05:06 ad Exp $");
 
 #include 
 #include 
@@ -303,7 +303,7 @@ sleepq_block(int timo, bool catch_p)
 			 * Acquiring p_lock may cause us to recurse
 			 * through the sleep path and back into this
 			 * routine, but is safe because LWPs sleeping
-			 * on locks are non-interruptable.  We will
+			 * on locks are non-interruptable and we will
 			 * not recurse again.
 			 */
 			mutex_enter(p->p_lock);



CVS commit: src/sys/dev/pci

2020-03-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Tue Mar 24 18:09:07 UTC 2020

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

Log Message:
add entry for NetMos NM9900 Quad UART.

The NM9900 seems to have variations such as 4UART and 2UART+1Printer,
but I tested on 4UART board.


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/sys/dev/pci/pucdata.c

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

Modified files:

Index: src/sys/dev/pci/pucdata.c
diff -u src/sys/dev/pci/pucdata.c:1.105 src/sys/dev/pci/pucdata.c:1.106
--- src/sys/dev/pci/pucdata.c:1.105	Thu Nov 14 08:49:48 2019
+++ src/sys/dev/pci/pucdata.c	Tue Mar 24 18:09:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pucdata.c,v 1.105 2019/11/14 08:49:48 hauke Exp $	*/
+/*	$NetBSD: pucdata.c,v 1.106 2020/03/24 18:09:07 ryo Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.105 2019/11/14 08:49:48 hauke Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.106 2020/03/24 18:09:07 ryo Exp $");
 
 #include 
 #include 
@@ -983,6 +983,15 @@ const struct puc_device_description puc_
 	},
 	},
 
+	/* NetMos PCIe NM9900 : 4S */
+	{   "NetMos NM9900 UART",
+	{	PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9900, 0xa000, 0x1000 },
+	{	0x,	0x,  0x, 0x },
+	{
+		{ PUC_PORT_TYPE_COM, PCI_BAR0, 0x00, COM_FREQ },
+	},
+	},
+
 	/* NetMos PCIe Peripheral Controller :UART part */
 	{   "NetMos NM9901 UART",
 	{   PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9901, 0xa000, 0x1000 },



CVS commit: src/sys/arch

2020-03-24 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Tue Mar 24 17:38:33 UTC 2020

Modified Files:
src/sys/arch/evbarm/conf: MMNET_GENERIC
src/sys/arch/hpcarm/conf: NETBOOKPRO WZERO3

Log Message:
g/c UGEN_BULK_RA_WB which is not a supported option


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/evbarm/conf/MMNET_GENERIC
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/hpcarm/conf/NETBOOKPRO
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/hpcarm/conf/WZERO3

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

Modified files:

Index: src/sys/arch/evbarm/conf/MMNET_GENERIC
diff -u src/sys/arch/evbarm/conf/MMNET_GENERIC:1.48 src/sys/arch/evbarm/conf/MMNET_GENERIC:1.49
--- src/sys/arch/evbarm/conf/MMNET_GENERIC:1.48	Wed Jan 29 18:39:01 2020
+++ src/sys/arch/evbarm/conf/MMNET_GENERIC	Tue Mar 24 17:38:33 2020
@@ -1,4 +1,4 @@
-# $NetBSD: MMNET_GENERIC,v 1.48 2020/01/29 18:39:01 maya Exp $
+# $NetBSD: MMNET_GENERIC,v 1.49 2020/03/24 17:38:33 sevan Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include		"arch/evbarm/conf/std.mmnet"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.48 $"
+#ident 		"GENERIC-$Revision: 1.49 $"
 
 maxusers	32		# estimated number of users
 
@@ -472,8 +472,6 @@ ucom*	at uvscom? portno ?
 
 # USB Generic driver
 #ugen*	at uhub? port ?
-# On ugen bulk endpoints, perform read-ahead and write-behind.
-#options UGEN_BULK_RA_WB
 
 
 # IrDA and Consumer Ir devices

Index: src/sys/arch/hpcarm/conf/NETBOOKPRO
diff -u src/sys/arch/hpcarm/conf/NETBOOKPRO:1.30 src/sys/arch/hpcarm/conf/NETBOOKPRO:1.31
--- src/sys/arch/hpcarm/conf/NETBOOKPRO:1.30	Sun Jan 19 01:25:05 2020
+++ src/sys/arch/hpcarm/conf/NETBOOKPRO	Tue Mar 24 17:38:33 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: NETBOOKPRO,v 1.30 2020/01/19 01:25:05 thorpej Exp $
+#	$NetBSD: NETBOOKPRO,v 1.31 2020/03/24 17:38:33 sevan Exp $
 #
 #	NETBOOKPRO -- Psion Teklogix NETBOOK PRO
 #
@@ -8,7 +8,7 @@ include	"arch/hpcarm/conf/files.netbookp
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.30 $"
+#ident 		"GENERIC-$Revision: 1.31 $"
 
 # estimated number of users
 maxusers	32
@@ -268,8 +268,6 @@ ubt*	at uhub? port ?
 
 # USB Generic driver
 ugen*	at uhub? port ?
-# On ugen bulk endpoints, perform read-ahead and write-behind.
-options 	UGEN_BULK_RA_WB
 
 # Bluetooth Device Hub
 bthub* at bcsp?

Index: src/sys/arch/hpcarm/conf/WZERO3
diff -u src/sys/arch/hpcarm/conf/WZERO3:1.51 src/sys/arch/hpcarm/conf/WZERO3:1.52
--- src/sys/arch/hpcarm/conf/WZERO3:1.51	Sun Jan 19 01:25:05 2020
+++ src/sys/arch/hpcarm/conf/WZERO3	Tue Mar 24 17:38:33 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: WZERO3,v 1.51 2020/01/19 01:25:05 thorpej Exp $
+#	$NetBSD: WZERO3,v 1.52 2020/03/24 17:38:33 sevan Exp $
 #
 #	WZERO3 -- Sharp Windows Mobile 5 based PDA
 #
@@ -8,7 +8,7 @@ include	"arch/hpcarm/conf/files.wzero3"
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.51 $"
+#ident 		"GENERIC-$Revision: 1.52 $"
 
 # estimated number of users
 maxusers	32
@@ -271,8 +271,6 @@ uk*	at scsibus? target ? lun ?	# SCSI un
 
 # USB Generic driver
 ugen*	at uhub? port ?
-# On ugen bulk endpoints, perform read-ahead and write-behind.
-#options 	UGEN_BULK_RA_WB
 
 
 # Pseudo-devices



CVS commit: src/sys/dev/usb

2020-03-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Mar 24 17:20:55 UTC 2020

Modified Files:
src/sys/dev/usb: vhci.c

Log Message:
Remove the argument from USB_{ATTACH,DETACH}, for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/usb/vhci.c

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

Modified files:

Index: src/sys/dev/usb/vhci.c
diff -u src/sys/dev/usb/vhci.c:1.11 src/sys/dev/usb/vhci.c:1.12
--- src/sys/dev/usb/vhci.c:1.11	Tue Mar 24 07:11:07 2020
+++ src/sys/dev/usb/vhci.c	Tue Mar 24 17:20:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vhci.c,v 1.11 2020/03/24 07:11:07 maxv Exp $ */
+/*	$NetBSD: vhci.c,v 1.12 2020/03/24 17:20:55 maxv Exp $ */
 
 /*
  * Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.11 2020/03/24 07:11:07 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.12 2020/03/24 17:20:55 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -804,22 +804,14 @@ struct vhci_ioc_set_addr {
 	uint8_t addr;
 };
 
-struct vhci_ioc_usb_attach {
-	u_int port;
-};
-
-struct vhci_ioc_usb_detach {
-	u_int port;
-};
-
 #define VHCI_IOC_GET_INFO	_IOR('V', 0, struct vhci_ioc_get_info)
 #define VHCI_IOC_SET_PORT	_IOW('V', 1, struct vhci_ioc_set_port)
 #define VHCI_IOC_SET_ADDR	_IOW('V', 2, struct vhci_ioc_set_addr)
-#define VHCI_IOC_USB_ATTACH	_IOW('V', 10, struct vhci_ioc_usb_attach)
-#define VHCI_IOC_USB_DETACH	_IOW('V', 11, struct vhci_ioc_usb_detach)
+#define VHCI_IOC_USB_ATTACH	_IO ('V', 10)
+#define VHCI_IOC_USB_DETACH	_IO ('V', 11)
 
 static int
-vhci_usb_attach(vhci_fd_t *vfd, struct vhci_ioc_usb_attach *args)
+vhci_usb_attach(vhci_fd_t *vfd)
 {
 	vhci_softc_t *sc = vfd->softc;
 	vhci_port_t *port;
@@ -827,9 +819,7 @@ vhci_usb_attach(vhci_fd_t *vfd, struct v
 	u_char *p;
 	int ret = 0;
 
-	if (args->port == 0 || args->port >= sc->sc_nports)
-		return EINVAL;
-	port = &sc->sc_port[args->port];
+	port = &sc->sc_port[vfd->port];
 
 	mutex_enter(&sc->sc_lock);
 
@@ -849,7 +839,7 @@ vhci_usb_attach(vhci_fd_t *vfd, struct v
 
 	p = xfer->ux_buf;
 	memset(p, 0, xfer->ux_length);
-	p[0] = __BIT(args->port);
+	p[0] = __BIT(vfd->port);
 	xfer->ux_actlen = xfer->ux_length;
 	xfer->ux_status = USBD_NORMAL_COMPLETION;
 
@@ -909,16 +899,14 @@ vhci_port_flush(vhci_softc_t *sc, vhci_p
 }
 
 static int
-vhci_usb_detach(vhci_fd_t *vfd, struct vhci_ioc_usb_detach *args)
+vhci_usb_detach(vhci_fd_t *vfd)
 {
 	vhci_softc_t *sc = vfd->softc;
 	vhci_port_t *port;
 	struct usbd_xfer *xfer;
 	u_char *p;
 
-	if (args->port == 0 || args->port >= sc->sc_nports)
-		return EINVAL;
-	port = &sc->sc_port[args->port];
+	port = &sc->sc_port[vfd->port];
 
 	mutex_enter(&sc->sc_lock);
 
@@ -936,7 +924,7 @@ vhci_usb_detach(vhci_fd_t *vfd, struct v
 
 	p = xfer->ux_buf;
 	memset(p, 0, xfer->ux_length);
-	p[0] = __BIT(args->port);
+	p[0] = __BIT(vfd->port);
 	xfer->ux_actlen = xfer->ux_length;
 	xfer->ux_status = USBD_NORMAL_COMPLETION;
 
@@ -1051,14 +1039,11 @@ vhci_fd_open(dev_t dev, int flags, int t
 static int
 vhci_fd_close(file_t *fp)
 {
-	struct vhci_ioc_usb_detach args;
 	vhci_fd_t *vfd = fp->f_data;
 	int ret __diagused;
 
 	KASSERT(vfd != NULL);
-
-	args.port = vfd->port;
-	ret = vhci_usb_detach(vfd, &args);
+	ret = vhci_usb_detach(vfd);
 	KASSERT(ret == 0);
 
 	kmem_free(vfd, sizeof(*vfd));
@@ -1228,9 +1213,9 @@ vhci_fd_ioctl(file_t *fp, u_long cmd, vo
 	case VHCI_IOC_SET_ADDR:
 		return vhci_set_addr(vfd, data);
 	case VHCI_IOC_USB_ATTACH:
-		return vhci_usb_attach(vfd, data);
+		return vhci_usb_attach(vfd);
 	case VHCI_IOC_USB_DETACH:
-		return vhci_usb_detach(vfd, data);
+		return vhci_usb_detach(vfd);
 	default:
 		return EINVAL;
 	}



CVS commit: src/lib/librumpuser

2020-03-24 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Tue Mar 24 14:56:32 UTC 2020

Modified Files:
src/lib/librumpuser: rumpuser_sp.c

Log Message:
If we're going to loop, pausing and then retrying malloc() after it
has failed, in the hope that some other thread has free'd some memory,
but we want to bound the number of attempts, it helps if we actually
count them - otherwise we never get nearer to the limit.

In practice, malloc() for a reasonable application on a modern system
almost never fails, so the code containing this bug has probably never
been, and never will be, executed, but just in case, someday.

For this, it isn't clear if the intent was to have 10 retries (ie: 11
attempts) or 10 tries, but as the code said "retries > 10", I am
assuming the former (not that it matters, if the malloc() has failed
10 times in a row, with 10 second pauses between, the chances of an
11th succeeding aren't great).


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/lib/librumpuser/rumpuser_sp.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.74 src/lib/librumpuser/rumpuser_sp.c:1.75
--- src/lib/librumpuser/rumpuser_sp.c:1.74	Tue Mar 24 14:47:02 2020
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Mar 24 14:56:31 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.75 2020/03/24 14:56:31 kre Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.75 2020/03/24 14:56:31 kre Exp $");
 #endif /* !lint */
 
 #include 
@@ -912,7 +912,7 @@ schedulework(struct spclient *spc, enum 
 
 	reqno = spc->spc_hdr.rsp_reqno;
 	while ((sba = malloc(sizeof(*sba))) == NULL) {
-		if (nworker == 0 || retries > 10) {
+		if (nworker == 0 || retries++ > 10) {
 			send_error_resp(spc, reqno, RUMPSP_ERR_TRYAGAIN);
 			spcfreebuf(spc);
 			return;



CVS commit: src/lib/librumpuser

2020-03-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Mar 24 14:47:02 UTC 2020

Modified Files:
src/lib/librumpuser: rumpuser_sp.c

Log Message:
Revert previous

It will be addressed in a better way.

Requested by 


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/lib/librumpuser/rumpuser_sp.c

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

Modified files:

Index: src/lib/librumpuser/rumpuser_sp.c
diff -u src/lib/librumpuser/rumpuser_sp.c:1.73 src/lib/librumpuser/rumpuser_sp.c:1.74
--- src/lib/librumpuser/rumpuser_sp.c:1.73	Tue Mar 24 01:56:56 2020
+++ src/lib/librumpuser/rumpuser_sp.c	Tue Mar 24 14:47:02 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: rumpuser_sp.c,v 1.73 2020/03/24 01:56:56 kamil Exp $	*/
+/*  $NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $	*/
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -37,7 +37,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_sp.c,v 1.73 2020/03/24 01:56:56 kamil Exp $");
+__RCSID("$NetBSD: rumpuser_sp.c,v 1.74 2020/03/24 14:47:02 kamil Exp $");
 #endif /* !lint */
 
 #include 
@@ -717,7 +717,7 @@ serv_handleexec(struct spclient *spc, st
 
 	/* ensure comm is 0-terminated */
 	/* TODO: make sure it contains sensible chars? */
-	comm[commlen - 1] = '\0';
+	comm[commlen] = '\0';
 
 	lwproc_switch(spc->spc_mainlwp);
 	lwproc_execnotify(comm);
@@ -981,7 +981,7 @@ handlereq(struct spclient *spc)
 
 			/* ensure it's 0-terminated */
 			/* XXX make sure it contains sensible chars? */
-			comm[commlen - 1] = '\0';
+			comm[commlen] = '\0';
 
 			/* make sure we fork off of proc1 */
 			_DIAGASSERT(lwproc_curlwp() == NULL);



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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Mar 24 13:44:21 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
add more register description


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sociox/if_scx.c

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

Modified files:

Index: src/sys/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.11 src/sys/arch/arm/sociox/if_scx.c:1.12
--- src/sys/arch/arm/sociox/if_scx.c:1.11	Tue Mar 24 13:07:46 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Tue Mar 24 13:44:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $");
 
 #include 
 #include 
@@ -169,11 +169,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define GMACMAL0	0x0044		/* MAC address 0 31:0 */
 #define GMACMAH(i) 	((i)*8+0x40)	/* supplimental MAC addr 1 - 15 */
 #define GMACMAL(i) 	((i)*8+0x44)
+#define GMACMDSR	0x00d8		/* GMII/RGMII/MII command/status */
 #define GMACMHT0	0x0500		/* multicast hash table 0 - 7 */
 #define GMACMHT(i)	((i)*4+0x500)
 #define GMACVHT		0x0588		/* VLAN tag hash */
 #define GMACAMAH(i)	((i)*8+0x800)	/* supplimental MAC addr 16-127 */
 #define GMACAMAL(i)	((i)*8+0x804)
+#define GMACEVCNT(i)	((i)*4+0x114)	/* event counter 0x114~284 */
 
 #define GMACBMR		0x1000		/* DMA bus mode control
 	 * 244PBL
@@ -185,15 +187,17 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 	 *  1rxtx ratio 21
 	 *  0rxtx ratio 11
 	 * 13:8  PBL possible DMA burst len
-	 * 0 reset op. self clear
+	 *  0reset op. self clear
 	 */
 #define  _BMR		0x00412080	/* XXX TBD */
 #define  _BMR0		0x00020181	/* XXX TBD */
 #define  BMR_RST	(1U<<0)		/* reset op. self clear when done */
-#define GMACRDLAR	0x100c		/* */
-#define  _RDLAR		0x18000		/* XXX TBD */
-#define GMACTDLAR	0x1010		/* */
-#define  _TDLAR		0x1c000		/* XXX TBD */
+#define GMACTDS		0x1004		/* write any to resume tdes */
+#define GMACRDS		0x1008		/* write any to resume rdes */
+#define GMACRDLAR	0x100c		/* rdes base address 32bit paddr */
+#define  _RDLAR		0x18000		/* XXX TBD system SRAM with CC ? */
+#define GMACTDLAR	0x1010		/* tdes base address 32bit paddr */
+#define  _TDLAR		0x1c000		/* XXX TBD system SRAM with CC ? */
 #define GMACOMR		0x1018		/* DMA operation */
 #define  OMR_TXE	(1U<<13)	/* start Tx DMA engine, 0 to stop */
 #define  OMR_RXE	(1U<<1)		/* start Rx DMA engine, 0 to stop */
@@ -1203,7 +1207,7 @@ scx_start(struct ifnet *ifp)
 		BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 		/* Tell DMA start transmit */
-		/* CSR_WRITE(sc, MDTSC, 1); */
+		/* CSR_WRITE(sc, GMACTDS, 1); */
 
 		txs->txs_mbuf = m0;
 		txs->txs_firstdesc = sc->sc_txnext;



CVS commit: src/sys/net

2020-03-24 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Tue Mar 24 13:30:54 UTC 2020

Modified Files:
src/sys/net: if_bridge.c

Log Message:
reset the csum_flags in bridge_brodcast() also for bmcast path

for destination interfaces with real hardware offloading this fixes
multicast packet corruption; for xvif(4) this fix stops treating them
as having no csum

may fix PR kern/42386


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/sys/net/if_bridge.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/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.168 src/sys/net/if_bridge.c:1.169
--- src/sys/net/if_bridge.c:1.168	Mon Feb 24 00:47:38 2020
+++ src/sys/net/if_bridge.c	Tue Mar 24 13:30:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.168 2020/02/24 00:47:38 rin Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.169 2020/03/24 13:30:54 jdolecek Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.168 2020/02/24 00:47:38 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.169 2020/03/24 13:30:54 jdolecek Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -2101,6 +2101,12 @@ bridge_broadcast(struct bridge_softc *sc
 if_statinc(&sc->sc_if, if_oerrors);
 goto next;
 			}
+			/*
+			 * Before enqueueing this packet to the destination
+			 * interface, clear any in-bound checksum flags to
+			 * prevent them from being misused as out-bound flags.
+			 */
+			mc->m_pkthdr.csum_flags = 0;
 
 			m_set_rcvif(mc, dst_if);
 			mc->m_flags &= ~M_PROMISC;



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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Mar 24 13:07:46 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
add more registers supposed to exist


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sociox/if_scx.c

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

Modified files:

Index: src/sys/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.10 src/sys/arch/arm/sociox/if_scx.c:1.11
--- src/sys/arch/arm/sociox/if_scx.c:1.10	Tue Mar 24 11:26:21 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Tue Mar 24 13:07:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $");
 
 #include 
 #include 
@@ -170,17 +170,20 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define GMACMAH(i) 	((i)*8+0x40)	/* supplimental MAC addr 1 - 15 */
 #define GMACMAL(i) 	((i)*8+0x44)
 #define GMACMHT0	0x0500		/* multicast hash table 0 - 7 */
-#define GMACMHT(i)	((i)*4+0500)
+#define GMACMHT(i)	((i)*4+0x500)
+#define GMACVHT		0x0588		/* VLAN tag hash */
+#define GMACAMAH(i)	((i)*8+0x800)	/* supplimental MAC addr 16-127 */
+#define GMACAMAL(i)	((i)*8+0x804)
 
 #define GMACBMR		0x1000		/* DMA bus mode control
 	 * 244PBL
 	 * 22:17 RPBL
 	 * 16fix burst
 	 * 15:14 priority between Rx and Tx
-	 *  3rxtx41
-	 *  2rxtx31
-	 *  1rxtx21
-	 *  0rxtx11
+	 *  3rxtx ratio 41
+	 *  2rxtx ratio 31
+	 *  1rxtx ratio 21
+	 *  0rxtx ratio 11
 	 * 13:8  PBL possible DMA burst len
 	 * 0 reset op. self clear
 	 */



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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Mar 24 11:40:08 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: sni_gpio.c

Log Message:
try to show 32 GPIO line usage


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/sni_gpio.c

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

Modified files:

Index: src/sys/arch/arm/sociox/sni_gpio.c
diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.2 src/sys/arch/arm/sociox/sni_gpio.c:1.3
--- src/sys/arch/arm/sociox/sni_gpio.c:1.2	Thu Mar 19 20:53:53 2020
+++ src/sys/arch/arm/sociox/sni_gpio.c	Tue Mar 24 11:40:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sni_gpio.c,v 1.2 2020/03/19 20:53:53 nisimura Exp $	*/
+/*	$NetBSD: sni_gpio.c,v 1.3 2020/03/24 11:40:08 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.2 2020/03/19 20:53:53 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.3 2020/03/24 11:40:08 nisimura Exp $");
 
 #include 
 #include 
@@ -64,6 +64,7 @@ struct snigpio_softc {
 	bus_space_handle_t	sc_ioh;
 	bus_addr_t		sc_iob;
 	bus_size_t		sc_ios;
+	void			*sc_ih;
 	kmutex_t		sc_lock;
 	struct gpio_chipset_tag	sc_gpio_gc;
 	gpio_pin_t		sc_gpio_pins[32];
@@ -77,7 +78,19 @@ CFATTACH_DECL_NEW(snigpio_fdt, sizeof(st
 CFATTACH_DECL_NEW(snigpio_acpi, sizeof(struct snigpio_softc),
 snigpio_acpi_match, snigpio_acpi_attach, NULL, NULL);
 
+/*
+ * "DevelopmentBox" implementation
+ *DSW3-PIN1,  DSW3-PIN2,  DSW3-PIN3,DSW3-PIN4,
+ *DSW3-PIN5,  DSW3-PIN6,  DSW3-PIN7,DSW3-PIN8,
+ *PEC-PD8,PEC-PD9,PEC-PD10, PEC-PD11,
+ *NC, NC, PCIE1EXTINT,  PCIE0EXTINT,
+ *PHY_P2_2,   PHY_P1_2,   NC,   NC,
+ *NC, NC, NC,   NC,
+ *NC, NC, PEC-PD26, PEC-PD27,
+ *PEC-PD28,   PEC-PD29,   PEC-PD30, PEC-PD31;
+ */
 static void snigpio_attach_i(struct snigpio_softc *);
+static int snigpio_intr(void *);
 
 static int
 snigpio_fdt_match(device_t parent, struct cfdata *match, void *aux)
@@ -102,8 +115,8 @@ snigpio_fdt_attach(device_t parent, devi
 	bus_space_handle_t ioh;
 	bus_addr_t addr;
 	bus_size_t size;
+	char intrstr[128];
 	_Bool disable;
-	int error;
 
 	prop_dictionary_get_bool(dict, "disable", &disable);
 	if (disable) {
@@ -111,16 +124,25 @@ snigpio_fdt_attach(device_t parent, devi
 		aprint_normal(": disabled\n");
 		return;
 	}
-	error = fdtbus_get_reg(phandle, 0, &addr, &size);
-	if (error) {
-		aprint_error(": couldn't get registers\n");
-		return;
-	}
-	error = bus_space_map(faa->faa_bst, addr, size, 0, &ioh);
-	if (error) {
+	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0
+	|| bus_space_map(faa->faa_bst, addr, size, 0, &ioh) != 0) {
 		aprint_error(": unable to map device\n");
 		return;
 	}
+	if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
+		aprint_error(": failed to decode interrupt\n");
+		goto fail;
+	}
+	sc->sc_ih = fdtbus_intr_establish(phandle,
+			0, IPL_VM, 0, snigpio_intr, sc);
+	if (sc->sc_ih == NULL) {
+		aprint_error_dev(self, "couldn't establish interrupt\n");
+		goto fail;
+	}
+
+	aprint_naive("\n");
+	aprint_normal(": GPIO controller\n");
+	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 
 	sc->sc_dev = self;
 	sc->sc_phandle = phandle;
@@ -131,7 +153,13 @@ snigpio_fdt_attach(device_t parent, devi
 
 	snigpio_attach_i(sc);
 
+/* dig FDT description to show 32 of GPIO line usage */
+/* DIPSW3 1-8 usage remain unclear */
+
 	return;
+ fail:
+	bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
+	return;	
 }
 
 static int
@@ -163,22 +191,24 @@ snigpio_acpi_attach(device_t parent, dev
 	&res, &acpi_resource_parse_ops_default);
 	if (ACPI_FAILURE(rv))
 		return;
-
 	mem = acpi_res_mem(&res, 0);
 	irq = acpi_res_irq(&res, 0);
-	if (mem == NULL || irq == NULL) {
+	if (mem == NULL || irq == NULL || mem->ar_length == 0) {
 		aprint_error(": incomplete resources\n");
 		return;
 	}
-	if (mem->ar_length == 0) {
-		aprint_error(": zero length memory resource\n");
-		return;
-	}
 	if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0,
 	&ioh)) {
 		aprint_error(": couldn't map registers\n");
 		return;
 	}
+	sc->sc_ih = acpi_intr_establish(self,
+	(uint64_t)(uintptr_t)aa->aa_node->ad_handle,
+	IPL_VM, false, snigpio_intr, sc, device_xname(self));
+	if (sc->sc_ih == NULL) {
+		aprint_error_dev(self, "couldn't establish interrupt\n");
+		goto fail;
+	}
 
 	sc->sc_dev = self;
 	sc->sc_iot = aa->aa_memt;
@@ -186,31 +216,46 @@ snigpio_acpi_attach(device_t parent, dev
 	sc->sc_ios = mem->ar_length;
 
 	snigpio_attach_i(sc);
+
+/* dig _DSD property to show 32 of GPIO line usage */
+/* DIPSW3 1-8 usage remain unclear */
+
+	acpi_resource_cleanup(&res);
+	return;
+ fail:
+	acpi_resource_cleanup(&res);
+	bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
+	return;	
 }
 
 static void

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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Mar 24 11:26:21 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
fix FDT 2nd addr to map EEPROM store. mention ACPI _DSD contains FDT equiv 
parameters.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sociox/if_scx.c

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

Modified files:

Index: src/sys/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.9 src/sys/arch/arm/sociox/if_scx.c:1.10
--- src/sys/arch/arm/sociox/if_scx.c:1.9	Tue Mar 24 10:47:03 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Tue Mar 24 11:26:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $");
 
 #include 
 #include 
@@ -438,7 +438,7 @@ scx_fdt_attach(device_t parent, device_t
 		goto fail;
 	}
 	if (fdtbus_get_reg(phandle, 1, addr+1, size+1) != 0
-	|| bus_space_map(faa->faa_bst, addr[0], size[1], 0, &eebsh) != 0) {
+	|| bus_space_map(faa->faa_bst, addr[1], size[1], 0, &eebsh) != 0) {
 		aprint_error(": unable to map device eeprom\n");
 		goto fail;
 	}
@@ -504,6 +504,7 @@ scx_acpi_attach(device_t parent, device_
 	&res, &acpi_resource_parse_ops_default);
 	if (ACPI_FAILURE(rv))
 		return;
+acpi_resource_print(self, &res);
 	mem = acpi_res_mem(&res, 0);
 	irq = acpi_res_irq(&res, 0);
 	if (mem == NULL || irq == NULL || mem->ar_length == 0) {
@@ -541,6 +542,8 @@ scx_acpi_attach(device_t parent, device_
 	sc->sc_eesh = eebsh;
 	sc->sc_dmat = aa->aa_dmat64;
 
+/* dig _DSD to see parameters. safe to assume RGMII/spd1000 though */
+
 	scx_attach_i(sc);
 
 	acpi_resource_cleanup(&res);



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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Mar 24 10:47:03 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
try to be consistent for the number of address match filter. tentative util the 
reality.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sociox/if_scx.c

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

Modified files:

Index: src/sys/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.8 src/sys/arch/arm/sociox/if_scx.c:1.9
--- src/sys/arch/arm/sociox/if_scx.c:1.8	Tue Mar 24 10:31:52 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Tue Mar 24 10:47:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -40,12 +40,13 @@
  *   to designify ring number from which to arrive or to which go.
  * - memory mapped EEPROM to hold MAC address. The rest of the area is
  *   occupied by a set of ucode for two DMA engines and one packet engine.
- * - The size of frame address filter is unknown. Might be 32
+ * - The size of frame address filter is unknown. Might be 16 or even 128.
  * - The first slot is my own station address. Always enabled to perform
  *   to identify oneself.
- * - 1~31 are for supplimental MAC addresses. Independently enabled
- *   for use. Good to catch multicast. Byte-wise selective match available.
- *   Use to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }.
+ * - 1~16 are for supplimental MAC addresses. Independently enabled for
+ *   use. Good to catch multicast. Byte-wise selective match available.
+ *   Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }.
+ * - 16~128 might be exact match without byte-mask.
  * - The size of multicast hash filter store is unknown. Might be 256 bit.
  * - Socionext/Linaro "NetSec" code makes many cut shorts. Some constants
  *   are left unexplained. The values should be handled via external
@@ -55,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $");
 
 #include 
 #include 
@@ -924,7 +925,7 @@ scx_set_rcvfilt(struct scx_softc *sc)
 		}
 printf("[%d] %s\n", i, ether_sprintf(enm->enm_addrlo));
 		if (i < 16) {
-			/* use 31 entry perfect match filter */
+			/* use 15 entry perfect match filter */
 			uint32_t addr;
 			uint8_t *ep = enm->enm_addrlo;
 			addr = (ep[3] << 24) | (ep[2] << 16)



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

2020-03-24 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Tue Mar 24 10:31:52 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
small knit about multicast hash table handling. use sc_100mii as bool


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sociox/if_scx.c

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

Modified files:

Index: src/sys/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.7 src/sys/arch/arm/sociox/if_scx.c:1.8
--- src/sys/arch/arm/sociox/if_scx.c:1.7	Tue Mar 24 02:31:59 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Tue Mar 24 10:31:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.7 2020/03/24 02:31:59 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.7 2020/03/24 02:31:59 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $");
 
 #include 
 #include 
@@ -162,13 +162,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define GMACFCR		0x0018		/* 802.3x flowcontrol */
 #define  FCR_RFE	(1U<<2)		/* accept PAUSE to throttle Tx */
 #define  FCR_TFE	(1U<<1)		/* generate PAUSE to moderate Rx lvl */
-#define GMACIMPL	0x0020		/* implementation number . */
 #define GMACVTAG	0x001c		/* VLAN tag control */
+#define GMACIMPL	0x0020		/* implementation number . */
 #define GMACMAH0	0x0040		/* MAC address 0 47:32 */
 #define GMACMAL0	0x0044		/* MAC address 0 31:0 */
 #define GMACMAH(i) 	((i)*8+0x40)	/* supplimental MAC addr 1 - 15 */
 #define GMACMAL(i) 	((i)*8+0x44)
-#define GMACMHT0	0x0500		/* multicast hash table 0 - 8*/
+#define GMACMHT0	0x0500		/* multicast hash table 0 - 7 */
+#define GMACMHT(i)	((i)*4+0500)
 
 #define GMACBMR		0x1000		/* DMA bus mode control
 	 * 244PBL
@@ -300,7 +301,7 @@ struct scx_softc {
 	uint32_t sc_mdclk;		/* GAR 5:2 clock selection */
 	uint32_t sc_t0coso;		/* T0_CSUM | T0_SGOL to run */
 	int sc_ucodeloaded;		/* ucode for H2M/M2H/PKT */
-	int sc_100mii;			/* 1<<15 RMII/MII, 0 for RGMII */
+	int sc_100mii;			/* 1 for RMII/MII, 0 for RGMII */
 	int sc_phandle;			/* fdt phandle */
 
 	bus_dmamap_t sc_cddmamap;	/* control data DMA map */
@@ -459,7 +460,7 @@ scx_fdt_attach(device_t parent, device_t
 	sc->sc_eesz = size[1];
 	sc->sc_dmat = faa->faa_dmat;
 	sc->sc_phandle = phandle;
-	sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0) ? MCR_USEMII : 0;
+	sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0);
 
 	scx_attach_i(sc);
 	return;
@@ -945,13 +946,13 @@ printf("[%d] %s\n", i, ether_sprintf(enm
 
 	if (crc)
 		csr |= AFR_MHTE;
-	for (i = 0; i < 8; i++)
-		CSR_WRITE(sc, GMACMHT0 + i * 4, mchash[i]);
+	for (i = 0; i < __arraycount(mchash); i++)
+		CSR_WRITE(sc, GMACMHT(i), mchash[i]);
 	CSR_WRITE(sc, GMACAFR, csr);
 	return;
 
  update:
-	/* With PM or AM, MHTE/MHTL/MHTH are never consulted. really? */
+	/* With PM or AM, MHTE/MHT0-7 are never consulted. really? */
 	if (ifp->if_flags & IFF_PROMISC)
 		csr |= AFR_PM;	/* run promisc. mode */
 	else



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

2020-03-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Mar 24 09:27:46 UTC 2020

Modified Files:
src/sys/arch/x86/pci: if_vmx.c

Log Message:
fix vmx(4) cannot link up at boot time.  reviewed by msaitoh@n.o, thanks.

vmx(4) could call if_link_state_change(ifp, LINK_STATE_UP) from vmxnet3_init()
before ifp->if_link_cansched was set, because dp->dom_if_up() (in6_if_up() for
INET6) could call ifp->if_init().  And then, workqueue_enqueue() was not called
at that time.
As the result, the last LQ_ITEM was stuck LINK_STATE_UP, so
if_link_state_change_work_schedule() was never called until
if_link_state_change(ifp, LINK_STATE_DOWN) was called.

To fix this issue, vmx(4) avoid calling if_link_state_change() before
ifp->if_link_cansched is set.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/x86/pci/if_vmx.c

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

Modified files:

Index: src/sys/arch/x86/pci/if_vmx.c
diff -u src/sys/arch/x86/pci/if_vmx.c:1.58 src/sys/arch/x86/pci/if_vmx.c:1.59
--- src/sys/arch/x86/pci/if_vmx.c:1.58	Sun Mar 15 23:04:50 2020
+++ src/sys/arch/x86/pci/if_vmx.c	Tue Mar 24 09:27:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.58 2020/03/15 23:04:50 thorpej Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.59 2020/03/24 09:27:46 knakahara Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.58 2020/03/15 23:04:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.59 2020/03/24 09:27:46 knakahara Exp $");
 
 #include 
 #include 
@@ -445,9 +445,10 @@ static int vmxnet3_ifflags_cb(struct eth
 static int vmxnet3_watchdog(struct vmxnet3_txqueue *);
 static void vmxnet3_refresh_host_stats(struct vmxnet3_softc *);
 static void vmxnet3_tick(void *);
-static void vmxnet3_link_status(struct vmxnet3_softc *);
-static void vmxnet3_media_status(struct ifnet *, struct ifmediareq *);
-static int vmxnet3_media_change(struct ifnet *);
+static void vmxnet3_if_link_status(struct vmxnet3_softc *);
+static bool vmxnet3_cmd_link_status(struct ifnet *);
+static void vmxnet3_ifmedia_status(struct ifnet *, struct ifmediareq *);
+static int vmxnet3_ifmedia_change(struct ifnet *);
 static void vmxnet3_set_lladdr(struct vmxnet3_softc *);
 static void vmxnet3_get_lladdr(struct vmxnet3_softc *);
 
@@ -1857,8 +1858,8 @@ vmxnet3_setup_interface(struct vmxnet3_s
 
 	/* Initialize ifmedia structures. */
 	sc->vmx_ethercom.ec_ifmedia = &sc->vmx_media;
-	ifmedia_init_with_lock(&sc->vmx_media, IFM_IMASK, vmxnet3_media_change,
-	vmxnet3_media_status, sc->vmx_mtx);
+	ifmedia_init_with_lock(&sc->vmx_media, IFM_IMASK, vmxnet3_ifmedia_change,
+	vmxnet3_ifmedia_status, sc->vmx_mtx);
 	ifmedia_add(&sc->vmx_media, IFM_ETHER | IFM_AUTO, 0, NULL);
 	ifmedia_add(&sc->vmx_media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL);
 	ifmedia_add(&sc->vmx_media, IFM_ETHER | IFM_10G_T, 0, NULL);
@@ -1870,7 +1871,7 @@ vmxnet3_setup_interface(struct vmxnet3_s
 	if_deferred_start_init(ifp, NULL);
 	ether_ifattach(ifp, sc->vmx_lladdr);
 	ether_set_ifflags_cb(&sc->vmx_ethercom, vmxnet3_ifflags_cb);
-	vmxnet3_link_status(sc);
+	vmxnet3_cmd_link_status(ifp);
 
 	/* should set before setting interrupts */
 	sc->vmx_rx_intr_process_limit = VMXNET3_RX_INTR_PROCESS_LIMIT;
@@ -2069,7 +2070,7 @@ vmxnet3_evintr(struct vmxnet3_softc *sc)
 
 	if (event & VMXNET3_EVENT_LINK) {
 		sc->vmx_event_link.ev_count++;
-		vmxnet3_link_status(sc);
+		vmxnet3_if_link_status(sc);
 		if (sc->vmx_link_active != 0)
 			if_schedule_deferred_start(&sc->vmx_ethercom.ec_if);
 	}
@@ -2909,7 +2910,7 @@ vmxnet3_init_locked(struct vmxnet3_softc
 	}
 
 	ifp->if_flags |= IFF_RUNNING;
-	vmxnet3_link_status(sc);
+	vmxnet3_cmd_link_status(ifp);
 
 	vmxnet3_enable_all_intrs(sc);
 	callout_reset(&sc->vmx_tick, hz, vmxnet3_tick, sc);
@@ -3425,6 +3426,8 @@ vmxnet3_ifflags_cb(struct ethercom *ec)
 	vmxnet3_set_rxfilter(sc);
 	VMXNET3_CORE_UNLOCK(sc);
 
+	vmxnet3_if_link_status(sc);
+
 	return 0;
 }
 
@@ -3481,17 +3484,20 @@ vmxnet3_tick(void *xsc)
 	VMXNET3_CORE_UNLOCK(sc);
 }
 
+/*
+ * update link state of ifnet and softc
+ */
 static void
-vmxnet3_link_status(struct vmxnet3_softc *sc)
+vmxnet3_if_link_status(struct vmxnet3_softc *sc)
 {
 	struct ifnet *ifp = &sc->vmx_ethercom.ec_if;
-	u_int x, link, speed;
+	u_int x, link;
+
+	vmxnet3_cmd_link_status(ifp);
 
 	x = vmxnet3_read_cmd(sc, VMXNET3_CMD_GET_LINK);
-	speed = x >> 16;
 	if (x & 1) {
 		sc->vmx_link_active = 1;
-		ifp->if_baudrate = IF_Mbps(speed);
 		link = LINK_STATE_UP;
 	} else {
 		sc->vmx_link_active = 0;
@@ -3501,17 +3507,37 @@ vmxnet3_link_status(struct vmxnet3_softc
 	if_link_state_change(ifp, link);
 }
 
-static void
-vmxnet3_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+/*
+ * check vmx(4) state by VMXNET3_CMD and update ifp->if_baudrate
+ *   returns
+ *   - true:  link up
+ *   - flase: link down
+ */

CVS commit: src/share/man/man9

2020-03-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Mar 24 08:48:32 UTC 2020

Modified Files:
src/share/man/man9: cprng.9

Log Message:
Fix cprng_fast64 return type to match code


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/share/man/man9/cprng.9

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

Modified files:

Index: src/share/man/man9/cprng.9
diff -u src/share/man/man9/cprng.9:1.10 src/share/man/man9/cprng.9:1.11
--- src/share/man/man9/cprng.9:1.10	Thu Feb 19 15:38:30 2015
+++ src/share/man/man9/cprng.9	Tue Mar 24 08:48:31 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: cprng.9,v 1.10 2015/02/19 15:38:30 riastradh Exp $
+.\"	$NetBSD: cprng.9,v 1.11 2020/03/24 08:48:31 skrll Exp $
 .\"
 .\" Copyright (c) 2011-2015 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 19, 2015
+.Dd March 24, 2020
 .Dt CPRNG 9
 .Os
 .Sh NAME
@@ -57,7 +57,7 @@
 .Fn cprng_fast "void *buf" "size_t len"
 .Ft uint32_t
 .Fn cprng_fast32 "void"
-.Ft uint32_t
+.Ft uint64_t
 .Fn cprng_fast64 "void"
 .Bd -literal
 #define CPRNG_MAX_LEN   524288



CVS commit: src/share/mk

2020-03-24 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Mar 24 07:56:26 UTC 2020

Modified Files:
src/share/mk: bsd.README

Log Message:
note that MKLLVMRT affects more than amdgpu.


To generate a diff of this commit:
cvs rdiff -u -r1.398 -r1.399 src/share/mk/bsd.README

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

Modified files:

Index: src/share/mk/bsd.README
diff -u src/share/mk/bsd.README:1.398 src/share/mk/bsd.README:1.399
--- src/share/mk/bsd.README:1.398	Tue Mar  3 02:25:03 2020
+++ src/share/mk/bsd.README	Tue Mar 24 07:56:26 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.README,v 1.398 2020/03/03 02:25:03 christos Exp $
+#	$NetBSD: bsd.README,v 1.399 2020/03/24 07:56:26 mrg Exp $
 #	@(#)bsd.README	8.2 (Berkeley) 4/2/94
 
 This is the README file for the make "include" files for the NetBSD
@@ -333,8 +333,9 @@ MKLLVM		If "yes", build and install clan
 		Default: no
 
 MKLLVMRT	If "yes", build the LLVM PIC libraries necessary for the
-		AMDGPU backend and the native JIT of the target architecture,
-		if supported.
+		various Mesa backend and the native JIT of the target
+		architecture, if supported.  (Radeon R300 and newer,
+		LLVMPIPE for most.)
 		Default: no, enabled automatically with HAVE_MESA_VER=18.
 
 MKLVM		If "no", don't build or install the logical volume manager



CVS commit: src/sys/dev/usb

2020-03-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Mar 24 07:12:16 UTC 2020

Modified Files:
src/sys/dev/usb: if_umb.c

Log Message:
Fix type confusion. Found by kASan when doing a normal attach+detach over
vHCI.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/if_umb.c

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

Modified files:

Index: src/sys/dev/usb/if_umb.c
diff -u src/sys/dev/usb/if_umb.c:1.18 src/sys/dev/usb/if_umb.c:1.19
--- src/sys/dev/usb/if_umb.c:1.18	Sat Mar 21 06:55:13 2020
+++ src/sys/dev/usb/if_umb.c	Tue Mar 24 07:12:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_umb.c,v 1.18 2020/03/21 06:55:13 skrll Exp $ */
+/*	$NetBSD: if_umb.c,v 1.19 2020/03/24 07:12:16 maxv Exp $ */
 /*	$OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
 
 /*
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.18 2020/03/21 06:55:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.19 2020/03/24 07:12:16 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -569,7 +569,7 @@ fail:
 Static int
 umb_detach(device_t self, int flags)
 {
-	struct umb_softc *sc = (struct umb_softc *)self;
+	struct umb_softc *sc = device_private(self);
 	struct ifnet *ifp = GET_IFP(sc);
 	int	 s;
 



CVS commit: src/sys/dev/usb

2020-03-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue Mar 24 07:11:07 UTC 2020

Modified Files:
src/sys/dev/usb: vhci.c

Log Message:
Use a vhci_request_t, will be required for future changes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/usb/vhci.c

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

Modified files:

Index: src/sys/dev/usb/vhci.c
diff -u src/sys/dev/usb/vhci.c:1.10 src/sys/dev/usb/vhci.c:1.11
--- src/sys/dev/usb/vhci.c:1.10	Sun Mar 22 17:15:15 2020
+++ src/sys/dev/usb/vhci.c	Tue Mar 24 07:11:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vhci.c,v 1.10 2020/03/22 17:15:15 maxv Exp $ */
+/*	$NetBSD: vhci.c,v 1.11 2020/03/24 07:11:07 maxv Exp $ */
 
 /*
  * Copyright (c) 2019-2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.10 2020/03/22 17:15:15 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vhci.c,v 1.11 2020/03/24 07:11:07 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -175,12 +175,27 @@ static const struct usbd_pipe_methods vh
 
 struct vhci_xfer;
 
+typedef struct {
+	int type;
+#define VHCI_REQ_CTRL	0
+
+	union {
+		usb_device_request_t ctrl;
+	} u;
+} vhci_request_t;
+
 typedef struct vhci_packet {
+	/* General. */
 	TAILQ_ENTRY(vhci_packet) portlist;
 	TAILQ_ENTRY(vhci_packet) xferlist;
 	struct vhci_xfer *vxfer;
 	bool utoh;
 	uint8_t addr;
+
+	/* For a request packet, the storage goes there. */
+	vhci_request_t reqbuf;
+
+	/* Exposed for FD operations. */
 	uint8_t *buf;
 	size_t size;
 	size_t cursor;
@@ -257,7 +272,7 @@ extern struct cfdriver vhci_cd;
 /* -- */
 
 static void
-vhci_pkt_create(vhci_port_t *port, struct usbd_xfer *xfer, bool utoh,
+vhci_pkt_ctrl_create(vhci_port_t *port, struct usbd_xfer *xfer, bool utoh,
 uint8_t addr)
 {
 	vhci_xfer_t *vxfer = (vhci_xfer_t *)xfer;
@@ -271,11 +286,17 @@ vhci_pkt_create(vhci_port_t *port, struc
 	req->vxfer = vxfer;
 	req->utoh = false;
 	req->addr = addr;
-	req->buf = (uint8_t *)&xfer->ux_request;
-	req->size = sizeof(xfer->ux_request);
+	req->buf = (uint8_t *)&req->reqbuf;
+	req->size = sizeof(req->reqbuf);
 	req->cursor = 0;
 	npkts++;
 
+	/* Init the request buffer. */
+	memset(&req->reqbuf, 0, sizeof(req->reqbuf));
+	req->reqbuf.type = VHCI_REQ_CTRL;
+	memcpy(&req->reqbuf.u.ctrl, &xfer->ux_request,
+	sizeof(xfer->ux_request));
+
 	/* Data packet. */
 	if (xfer->ux_length > 0) {
 		if (utoh) {
@@ -595,7 +616,7 @@ vhci_device_ctrl_start(struct usbd_xfer 
 	mutex_enter(&port->lock);
 	if (port->status & UPS_PORT_ENABLED) {
 		xfer->ux_status = USBD_IN_PROGRESS;
-		vhci_pkt_create(port, xfer, isread, addr);
+		vhci_pkt_ctrl_create(port, xfer, isread, addr);
 		ret = USBD_IN_PROGRESS;
 	} else {
 		ret = USBD_IOERROR;
@@ -622,9 +643,8 @@ vhci_device_ctrl_abort(struct usbd_xfer 
 
 	callout_halt(&xfer->ux_callout, &sc->sc_lock);
 
-	KASSERT(xfer->ux_status != USBD_CANCELLED);
-
 	/* If anyone else beat us, we're done.  */
+	KASSERT(xfer->ux_status != USBD_CANCELLED);
 	if (xfer->ux_status != USBD_IN_PROGRESS)
 		return;