CVS commit: [netbsd-9] src/sys/dev

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 20:35:52 UTC 2019

Modified Files:
src/sys/dev [netbsd-9]: fss.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #356):

sys/dev/fss.c: revision 1.108

Check fc_type before fc_cluster, because the latter may not be initialized.

This is harmless because fc_type is always initialized properly, so the
next branch wouldn't have been taken.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.107.4.1 src/sys/dev/fss.c

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



CVS commit: [netbsd-9] src/sys/dev

2019-10-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Oct 23 20:35:52 UTC 2019

Modified Files:
src/sys/dev [netbsd-9]: fss.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #356):

sys/dev/fss.c: revision 1.108

Check fc_type before fc_cluster, because the latter may not be initialized.

This is harmless because fc_type is always initialized properly, so the
next branch wouldn't have been taken.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.107.4.1 src/sys/dev/fss.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/fss.c
diff -u src/sys/dev/fss.c:1.107 src/sys/dev/fss.c:1.107.4.1
--- src/sys/dev/fss.c:1.107	Wed Feb 20 10:03:25 2019
+++ src/sys/dev/fss.c	Wed Oct 23 20:35:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fss.c,v 1.107 2019/02/20 10:03:25 hannken Exp $	*/
+/*	$NetBSD: fss.c,v 1.107.4.1 2019/10/23 20:35:52 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.107 2019/02/20 10:03:25 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.107.4.1 2019/10/23 20:35:52 martin Exp $");
 
 #include 
 #include 
@@ -992,16 +992,19 @@ restart:
 		return 0;
 	}
 
-	for (scp = sc->sc_cache; scp < scl; scp++)
-		if (scp->fc_cluster == cl) {
-			if (scp->fc_type == FSS_CACHE_VALID) {
+	for (scp = sc->sc_cache; scp < scl; scp++) {
+		if (scp->fc_type == FSS_CACHE_VALID) {
+			if (scp->fc_cluster == cl) {
 mutex_exit(&sc->sc_slock);
 return 0;
-			} else if (scp->fc_type == FSS_CACHE_BUSY) {
+			}
+		} else if (scp->fc_type == FSS_CACHE_BUSY) {
+			if (scp->fc_cluster == cl) {
 cv_wait(&scp->fc_state_cv, &sc->sc_slock);
 goto restart;
 			}
 		}
+	}
 
 	for (scp = sc->sc_cache; scp < scl; scp++)
 		if (scp->fc_type == FSS_CACHE_FREE) {



CVS commit: [netbsd-9] src/sys/dev

2019-11-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 18 19:46:33 UTC 2019

Modified Files:
src/sys/dev/hyperv [netbsd-9]: if_hvn.c
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #441):

sys/dev/hyperv/if_hvn.c: revision 1.7
sys/dev/pci/if_mcx.c: revision 1.6

Fixed incorrect m_defrag return value check.


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/hyperv/if_hvn.c
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/dev/pci/if_mcx.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/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.4.2.1 src/sys/dev/hyperv/if_hvn.c:1.4.2.2
--- src/sys/dev/hyperv/if_hvn.c:1.4.2.1	Sat Nov 16 16:51:45 2019
+++ src/sys/dev/hyperv/if_hvn.c	Mon Nov 18 19:46:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.4.2.1 2019/11/16 16:51:45 martin Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.4.2.2 2019/11/18 19:46:33 martin Exp $	*/
 /*	$OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.4.2.1 2019/11/16 16:51:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.4.2.2 2019/11/18 19:46:33 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -565,7 +565,7 @@ hvn_encap(struct hvn_softc *sc, struct m
 	case 0:
 		break;
 	case EFBIG:
-		if (m_defrag(m, M_NOWAIT) == 0 &&
+		if (m_defrag(m, M_NOWAIT) != NULL &&
 		bus_dmamap_load_mbuf(sc->sc_dmat, txd->txd_dmap, m,
 		  BUS_DMA_READ | BUS_DMA_NOWAIT) == 0)
 			break;

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.1.2.4 src/sys/dev/pci/if_mcx.c:1.1.2.5
--- src/sys/dev/pci/if_mcx.c:1.1.2.4	Sun Sep 29 07:26:23 2019
+++ src/sys/dev/pci/if_mcx.c	Mon Nov 18 19:46:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.1.2.4 2019/09/29 07:26:23 martin Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.1.2.5 2019/11/18 19:46:33 martin Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -6347,7 +6347,7 @@ mcx_load_mbuf(struct mcx_softc *sc, stru
 		break;
 
 	case EFBIG:
-		if (m_defrag(m, M_DONTWAIT) == 0 &&
+		if (m_defrag(m, M_DONTWAIT) != NULL &&
 		bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
 		BUS_DMA_STREAMING | BUS_DMA_NOWAIT) == 0)
 			break;



CVS commit: [netbsd-9] src/sys/dev

2019-11-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 18 19:46:33 UTC 2019

Modified Files:
src/sys/dev/hyperv [netbsd-9]: if_hvn.c
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #441):

sys/dev/hyperv/if_hvn.c: revision 1.7
sys/dev/pci/if_mcx.c: revision 1.6

Fixed incorrect m_defrag return value check.


To generate a diff of this commit:
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/hyperv/if_hvn.c
cvs rdiff -u -r1.1.2.4 -r1.1.2.5 src/sys/dev/pci/if_mcx.c

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



CVS commit: [netbsd-9] src/sys/dev

2019-11-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 27 14:03:14 UTC 2019

Modified Files:
src/sys/dev/ieee1394 [netbsd-9]: fwohci.c
src/sys/dev/pci [netbsd-9]: eso.c sv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #492):

sys/dev/pci/sv.c: revision 1.57
sys/dev/pci/eso.c: revision 1.72
sys/dev/ieee1394/fwohci.c: revision 1.144

Fix operand priority of bit op vs ternary operator.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/dev/ieee1394/fwohci.c
cvs rdiff -u -r1.71 -r1.71.2.1 src/sys/dev/pci/eso.c
cvs rdiff -u -r1.56 -r1.56.2.1 src/sys/dev/pci/sv.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/ieee1394/fwohci.c
diff -u src/sys/dev/ieee1394/fwohci.c:1.142 src/sys/dev/ieee1394/fwohci.c:1.142.2.1
--- src/sys/dev/ieee1394/fwohci.c:1.142	Tue May 28 08:59:34 2019
+++ src/sys/dev/ieee1394/fwohci.c	Wed Nov 27 14:03:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: fwohci.c,v 1.142 2019/05/28 08:59:34 msaitoh Exp $	*/
+/*	$NetBSD: fwohci.c,v 1.142.2.1 2019/11/27 14:03:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  *
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.142 2019/05/28 08:59:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.142.2.1 2019/11/27 14:03:14 martin Exp $");
 
 #include 
 #include 
@@ -1746,8 +1746,8 @@ fwohci_db_init(struct fwohci_softc *sc, 
 	dbch->ndb, BUS_DMA_WAITOK);
 #else	/* Ooops, debugging now... */
 	dbch->ndb, BUS_DMA_WAITOK |
-		(dbch->off == OHCI_ARQOFF || dbch->off == OHCI_ARSOFF) ?
-			BUS_DMA_COHERENT : 0);
+		((dbch->off == OHCI_ARQOFF || dbch->off == OHCI_ARSOFF) ?
+			BUS_DMA_COHERENT : 0));
 #endif
 	if (dbch->am == NULL) {
 		aprint_error_dev(fc->dev, "fwdma_malloc_multiseg failed\n");

Index: src/sys/dev/pci/eso.c
diff -u src/sys/dev/pci/eso.c:1.71 src/sys/dev/pci/eso.c:1.71.2.1
--- src/sys/dev/pci/eso.c:1.71	Sat Jun  8 08:02:38 2019
+++ src/sys/dev/pci/eso.c	Wed Nov 27 14:03:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: eso.c,v 1.71 2019/06/08 08:02:38 isaki Exp $	*/
+/*	$NetBSD: eso.c,v 1.71.2.1 2019/11/27 14:03:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.71 2019/06/08 08:02:38 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: eso.c,v 1.71.2.1 2019/11/27 14:03:14 martin Exp $");
 
 #include "mpu.h"
 
@@ -1489,7 +1489,7 @@ eso_allocmem(struct eso_softc *sc, size_
 
 	error = bus_dmamap_load(ed->ed_dmat, ed->ed_map, ed->ed_kva,
 	ed->ed_size, NULL, BUS_DMA_WAITOK |
-	(direction == AUMODE_RECORD) ? BUS_DMA_READ : BUS_DMA_WRITE);
+	((direction == AUMODE_RECORD) ? BUS_DMA_READ : BUS_DMA_WRITE));
 	if (error)
 		goto destroy;
 

Index: src/sys/dev/pci/sv.c
diff -u src/sys/dev/pci/sv.c:1.56 src/sys/dev/pci/sv.c:1.56.2.1
--- src/sys/dev/pci/sv.c:1.56	Sat Jun  8 08:02:38 2019
+++ src/sys/dev/pci/sv.c	Wed Nov 27 14:03:14 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: sv.c,v 1.56 2019/06/08 08:02:38 isaki Exp $ */
+/*  $NetBSD: sv.c,v 1.56.2.1 2019/11/27 14:03:14 martin Exp $ */
 /*  $OpenBSD: sv.c,v 1.2 1998/07/13 01:50:15 csapuntz Exp $ */
 
 /*
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.56 2019/06/08 08:02:38 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sv.c,v 1.56.2.1 2019/11/27 14:03:14 martin Exp $");
 
 #include 
 #include 
@@ -530,7 +530,7 @@ sv_allocmem(struct sv_softc *sc, size_t 
 		goto unmap;
 
 	error = bus_dmamap_load(sc->sc_dmatag, p->map, p->addr, p->size, NULL,
-	BUS_DMA_WAITOK | (direction == AUMODE_RECORD) ? BUS_DMA_READ : BUS_DMA_WRITE);
+	BUS_DMA_WAITOK | ((direction == AUMODE_RECORD) ? BUS_DMA_READ : BUS_DMA_WRITE));
 	if (error)
 		goto destroy;
 	DPRINTF(("sv_allocmem: pa=%lx va=%lx pba=%lx\n",



CVS commit: [netbsd-9] src/sys/dev

2019-11-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 27 14:03:14 UTC 2019

Modified Files:
src/sys/dev/ieee1394 [netbsd-9]: fwohci.c
src/sys/dev/pci [netbsd-9]: eso.c sv.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #492):

sys/dev/pci/sv.c: revision 1.57
sys/dev/pci/eso.c: revision 1.72
sys/dev/ieee1394/fwohci.c: revision 1.144

Fix operand priority of bit op vs ternary operator.


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.142.2.1 src/sys/dev/ieee1394/fwohci.c
cvs rdiff -u -r1.71 -r1.71.2.1 src/sys/dev/pci/eso.c
cvs rdiff -u -r1.56 -r1.56.2.1 src/sys/dev/pci/sv.c

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



CVS commit: [netbsd-9] src/sys/dev

2022-12-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec 30 14:39:10 UTC 2022

Modified Files:
src/sys/dev/ata [netbsd-9]: ata.c ata_recovery.c ata_wdc.c atavar.h
satapmp_subr.c wd.c
src/sys/dev/ic [netbsd-9]: ahcisata_core.c mvsata.c siisata.c wdc.c
wdcvar.h
src/sys/dev/scsipi [netbsd-9]: atapi_wdc.c
src/sys/dev/usb [netbsd-9]: umass_isdata.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1557):

sys/dev/ic/ahcisata_core.c: revision 1.83
sys/dev/ic/ahcisata_core.c: revision 1.102
sys/dev/ata/ata.c: revision 1.164
sys/dev/ata/ata_wdc.c: revision 1.115
sys/dev/ata/ata_recovery.c: revision 1.4
sys/dev/ic/siisata.c: revision 1.42
sys/dev/ic/wdc.c: revision 1.308
sys/dev/ic/mvsata.c: revision 1.56
sys/dev/scsipi/atapi_wdc.c: revision 1.138
sys/dev/ic/siisata.c: revision 1.49
sys/dev/ata/atavar.h: revision 1.105
sys/dev/ata/wd.c: revision 1.460
sys/dev/ata/ata.c: revision 1.155
sys/dev/ata/wd.c: revision 1.462
sys/dev/ata/atavar.h: revision 1.109
sys/dev/ata/satapmp_subr.c: revision 1.16
sys/dev/ic/wdc.c: revision 1.299
sys/dev/ic/ahcisata_core.c: revision 1.93
sys/dev/ata/ata_wdc.c: revision 1.120
sys/dev/ic/wdcvar.h: revision 1.100
sys/dev/scsipi/atapi_wdc.c: revision 1.141
sys/dev/ic/mvsata.c: revision 1.61
sys/dev/usb/umass_isdata.c  (apply patch)

drop wd lock in wdstart1() before calling the ata_bio hook; when called
from ata thread context, that can still need to sleep for wdc attachments
in wdcwait()

fix use-after-free for ata xfer on bio submission found by KASAN
driver ata_bio hooks read parts of the xfer after ata_exec_xfer()
call in order to determine return value, change so that the hook
doesn't return any value - callers do not care already,
as all I/O requests are asynchronous

this problem was uncovered by recent change for wd(4) to not hold
wd mutex during ata_bio call, the interrupt for the xfer might
thus actually fire immediately

adjust also ata_exec_command driver hooks similarily - remove all
completion and waiting logic from drivers, upper layer ata code
using AT_WAIT/AT_POLL changed to call ata_wait_cmd() itself
PR kern/55169 by Nick Hudson

Function declaration formating whitespace consistency.  NFCI.

PR kern/56403
Fix kernel freeze for wdc(4) variants with ATAC_CAP_NOIRQ:

(1) Change ata_xfer_ops:c_poll from void to int function. When it returns
ATAPOLL_AGAIN, let ata_xfer_start() iterate itself again.
(2) Let wdc_ata_bio_poll() return ATAPOLL_AGAIN until ATA_ITSDONE is
achieved.

A similar change has been made for mvsata(4) (see mvsata_bio_poll()),
and no functional changes for other devices.

This is how the drivers worked before jdolecek-ncq branch was merged.
Note that this changes are less likely to cause infinite recursion:

(1) wdc_ata_bio_intr() called from wdc_ata_bio_poll() asserts ATA_ITSDONE
in its error handling paths via wdc_ata_bio_done().
(2) Return value from c_start (= wdc_ata_bio_start()) is checked in
ata_xfer_start().

Therefore, errors encountered in ata_xfer_ops:c_poll and c_start routines
terminate the recursion for wdc(4). The situation is similar for mvsata(4).

Still, there is a possibility where ata_xfer_start() takes long time to
finish a normal operation. This can result in a delayed response for lower
priority interrupts. But, I've never observed such a situation, even when
heavy thrashing takes place for swap partition in wd(4).
"Go ahead" by jdolecek@.


To generate a diff of this commit:
cvs rdiff -u -r1.149.2.2 -r1.149.2.3 src/sys/dev/ata/ata.c
cvs rdiff -u -r1.2.8.1 -r1.2.8.2 src/sys/dev/ata/ata_recovery.c
cvs rdiff -u -r1.113 -r1.113.4.1 src/sys/dev/ata/ata_wdc.c
cvs rdiff -u -r1.103 -r1.103.4.1 src/sys/dev/ata/atavar.h
cvs rdiff -u -r1.15 -r1.15.4.1 src/sys/dev/ata/satapmp_subr.c
cvs rdiff -u -r1.452.2.2 -r1.452.2.3 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.75.4.4 -r1.75.4.5 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.48 -r1.48.2.1 src/sys/dev/ic/mvsata.c
cvs rdiff -u -r1.39 -r1.39.4.1 src/sys/dev/ic/siisata.c
cvs rdiff -u -r1.291.4.1 -r1.291.4.2 src/sys/dev/ic/wdc.c
cvs rdiff -u -r1.98.10.1 -r1.98.10.2 src/sys/dev/ic/wdcvar.h
cvs rdiff -u -r1.133 -r1.133.4.1 src/sys/dev/scsipi/atapi_wdc.c
cvs rdiff -u -r1.42 -r1.42.4.1 src/sys/dev/usb/umass_isdata.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/ata/ata.c
diff -u src/sys/dev/ata/ata.c:1.149.2.2 src/sys/dev/ata/ata.c:1.149.2.3
--- src/sys/dev/ata/ata.c:1.149.2.2	Tue Aug 30 18:28:42 2022
+++ src/sys/dev/ata/ata.c	Fri Dec 30 14:39:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata.c,v 1.149.2.2 2022/08/30 18:28:42 martin Exp $	*/
+/*	$NetBSD: ata.c,v 1.149.2.3 2022/12/30 14:39:10 martin Exp $	*/
 
 /*
  * Copyrig

CVS commit: [netbsd-9] src/sys/dev

2022-12-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec 30 14:39:10 UTC 2022

Modified Files:
src/sys/dev/ata [netbsd-9]: ata.c ata_recovery.c ata_wdc.c atavar.h
satapmp_subr.c wd.c
src/sys/dev/ic [netbsd-9]: ahcisata_core.c mvsata.c siisata.c wdc.c
wdcvar.h
src/sys/dev/scsipi [netbsd-9]: atapi_wdc.c
src/sys/dev/usb [netbsd-9]: umass_isdata.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1557):

sys/dev/ic/ahcisata_core.c: revision 1.83
sys/dev/ic/ahcisata_core.c: revision 1.102
sys/dev/ata/ata.c: revision 1.164
sys/dev/ata/ata_wdc.c: revision 1.115
sys/dev/ata/ata_recovery.c: revision 1.4
sys/dev/ic/siisata.c: revision 1.42
sys/dev/ic/wdc.c: revision 1.308
sys/dev/ic/mvsata.c: revision 1.56
sys/dev/scsipi/atapi_wdc.c: revision 1.138
sys/dev/ic/siisata.c: revision 1.49
sys/dev/ata/atavar.h: revision 1.105
sys/dev/ata/wd.c: revision 1.460
sys/dev/ata/ata.c: revision 1.155
sys/dev/ata/wd.c: revision 1.462
sys/dev/ata/atavar.h: revision 1.109
sys/dev/ata/satapmp_subr.c: revision 1.16
sys/dev/ic/wdc.c: revision 1.299
sys/dev/ic/ahcisata_core.c: revision 1.93
sys/dev/ata/ata_wdc.c: revision 1.120
sys/dev/ic/wdcvar.h: revision 1.100
sys/dev/scsipi/atapi_wdc.c: revision 1.141
sys/dev/ic/mvsata.c: revision 1.61
sys/dev/usb/umass_isdata.c  (apply patch)

drop wd lock in wdstart1() before calling the ata_bio hook; when called
from ata thread context, that can still need to sleep for wdc attachments
in wdcwait()

fix use-after-free for ata xfer on bio submission found by KASAN
driver ata_bio hooks read parts of the xfer after ata_exec_xfer()
call in order to determine return value, change so that the hook
doesn't return any value - callers do not care already,
as all I/O requests are asynchronous

this problem was uncovered by recent change for wd(4) to not hold
wd mutex during ata_bio call, the interrupt for the xfer might
thus actually fire immediately

adjust also ata_exec_command driver hooks similarily - remove all
completion and waiting logic from drivers, upper layer ata code
using AT_WAIT/AT_POLL changed to call ata_wait_cmd() itself
PR kern/55169 by Nick Hudson

Function declaration formating whitespace consistency.  NFCI.

PR kern/56403
Fix kernel freeze for wdc(4) variants with ATAC_CAP_NOIRQ:

(1) Change ata_xfer_ops:c_poll from void to int function. When it returns
ATAPOLL_AGAIN, let ata_xfer_start() iterate itself again.
(2) Let wdc_ata_bio_poll() return ATAPOLL_AGAIN until ATA_ITSDONE is
achieved.

A similar change has been made for mvsata(4) (see mvsata_bio_poll()),
and no functional changes for other devices.

This is how the drivers worked before jdolecek-ncq branch was merged.
Note that this changes are less likely to cause infinite recursion:

(1) wdc_ata_bio_intr() called from wdc_ata_bio_poll() asserts ATA_ITSDONE
in its error handling paths via wdc_ata_bio_done().
(2) Return value from c_start (= wdc_ata_bio_start()) is checked in
ata_xfer_start().

Therefore, errors encountered in ata_xfer_ops:c_poll and c_start routines
terminate the recursion for wdc(4). The situation is similar for mvsata(4).

Still, there is a possibility where ata_xfer_start() takes long time to
finish a normal operation. This can result in a delayed response for lower
priority interrupts. But, I've never observed such a situation, even when
heavy thrashing takes place for swap partition in wd(4).
"Go ahead" by jdolecek@.


To generate a diff of this commit:
cvs rdiff -u -r1.149.2.2 -r1.149.2.3 src/sys/dev/ata/ata.c
cvs rdiff -u -r1.2.8.1 -r1.2.8.2 src/sys/dev/ata/ata_recovery.c
cvs rdiff -u -r1.113 -r1.113.4.1 src/sys/dev/ata/ata_wdc.c
cvs rdiff -u -r1.103 -r1.103.4.1 src/sys/dev/ata/atavar.h
cvs rdiff -u -r1.15 -r1.15.4.1 src/sys/dev/ata/satapmp_subr.c
cvs rdiff -u -r1.452.2.2 -r1.452.2.3 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.75.4.4 -r1.75.4.5 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.48 -r1.48.2.1 src/sys/dev/ic/mvsata.c
cvs rdiff -u -r1.39 -r1.39.4.1 src/sys/dev/ic/siisata.c
cvs rdiff -u -r1.291.4.1 -r1.291.4.2 src/sys/dev/ic/wdc.c
cvs rdiff -u -r1.98.10.1 -r1.98.10.2 src/sys/dev/ic/wdcvar.h
cvs rdiff -u -r1.133 -r1.133.4.1 src/sys/dev/scsipi/atapi_wdc.c
cvs rdiff -u -r1.42 -r1.42.4.1 src/sys/dev/usb/umass_isdata.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 23 12:05:36 UTC 2023

Modified Files:
src/sys/dev/pci [netbsd-9]: xhci_pci.c
src/sys/dev/usb [netbsd-9]: xhci.c xhcivar.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1570:

sys/dev/pci/xhci_pci.c  1.31 via patch
sys/dev/usb/xhci.c  1.173-1.175
sys/dev/usb/xhcivar.h   1.22

Support xHCI device which has USB 2 port only.


To generate a diff of this commit:
cvs rdiff -u -r1.21.4.1 -r1.21.4.2 src/sys/dev/pci/xhci_pci.c
cvs rdiff -u -r1.107.2.10 -r1.107.2.11 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.11.4.2 -r1.11.4.3 src/sys/dev/usb/xhcivar.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/pci/xhci_pci.c
diff -u src/sys/dev/pci/xhci_pci.c:1.21.4.1 src/sys/dev/pci/xhci_pci.c:1.21.4.2
--- src/sys/dev/pci/xhci_pci.c:1.21.4.1	Mon May 17 15:50:35 2021
+++ src/sys/dev/pci/xhci_pci.c	Mon Jan 23 12:05:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci_pci.c,v 1.21.4.1 2021/05/17 15:50:35 martin Exp $	*/
+/*	$NetBSD: xhci_pci.c,v 1.21.4.2 2023/01/23 12:05:36 martin Exp $	*/
 /*	OpenBSD: xhci_pci.c,v 1.4 2014/07/12 17:38:51 yuo Exp	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.21.4.1 2021/05/17 15:50:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci_pci.c,v 1.21.4.2 2023/01/23 12:05:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_xhci_pci.h"
@@ -267,9 +267,11 @@ xhci_pci_attach(device_t parent, device_
 		aprint_error_dev(self, "couldn't establish power handler\n");
 
 	/* Attach usb buses. */
-	sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
+	if (sc->sc_usb3nports != 0)
+		sc->sc_child = config_found(self, &sc->sc_bus, usbctlprint);
 
- 	sc->sc_child2 = config_found(self, &sc->sc_bus2, usbctlprint);
+	if (sc->sc_usb2nports != 0)
+		sc->sc_child2 = config_found(self, &sc->sc_bus2, usbctlprint);
 
 	return;
 

Index: src/sys/dev/usb/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107.2.10 src/sys/dev/usb/xhci.c:1.107.2.11
--- src/sys/dev/usb/xhci.c:1.107.2.10	Fri Sep 16 18:32:49 2022
+++ src/sys/dev/usb/xhci.c	Mon Jan 23 12:05:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107.2.10 2022/09/16 18:32:49 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.11 2023/01/23 12:05:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.10 2022/09/16 18:32:49 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.11 2023/01/23 12:05:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1177,7 +1177,11 @@ xhci_id_protocols(struct xhci_softc *sc,
 	case 0x0310:
 	case 0x0320:
 		aprint_debug_dev(sc->sc_dev, " %s ports %d - %d\n",
-		major == 3 ? "ss" : "hs", cpo, cpo + cpc -1);
+		major == 3 ? "ss" : "hs", cpo, cpo + cpc - 1);
+		if (major == 3)
+			sc->sc_usb3nports += cpo + cpc - 1;
+		else
+			sc->sc_usb2nports += cpo + cpc - 1;
 		break;
 	default:
 		aprint_error_dev(sc->sc_dev, " unknown major/minor (%d/%d)\n",
@@ -1399,11 +1403,13 @@ xhci_init(struct xhci_softc *sc)
 	/* default all ports to bus 0, i.e. usb 3 */
 	sc->sc_ctlrportbus = kmem_zalloc(
 	howmany(sc->sc_maxports * sizeof(uint8_t), NBBY), KM_SLEEP);
-	sc->sc_ctlrportmap = kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
+	sc->sc_ctlrportmap =
+	kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
 
 	/* controller port to bus roothub port map */
 	for (size_t j = 0; j < __arraycount(sc->sc_rhportmap); j++) {
-		sc->sc_rhportmap[j] = kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
+		sc->sc_rhportmap[j] =
+		kmem_zalloc(sc->sc_maxports * sizeof(int), KM_SLEEP);
 	}
 
 	/*

Index: src/sys/dev/usb/xhcivar.h
diff -u src/sys/dev/usb/xhcivar.h:1.11.4.2 src/sys/dev/usb/xhcivar.h:1.11.4.3
--- src/sys/dev/usb/xhcivar.h:1.11.4.2	Tue Jun 22 05:10:50 2021
+++ src/sys/dev/usb/xhcivar.h	Mon Jan 23 12:05:36 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhcivar.h,v 1.11.4.2 2021/06/22 05:10:50 martin Exp $	*/
+/*	$NetBSD: xhcivar.h,v 1.11.4.3 2023/01/23 12:05:36 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -103,6 +103,8 @@ struct xhci_softc {
 	 * Port routing and root hub - xHCI 4.19.7
 	 */
 	int sc_maxports;		/* number of controller ports */
+	int sc_usb3nports;
+	int sc_usb2nports;
 
 	uint8_t *sc_ctlrportbus;	/* a bus bit per port */
 



CVS commit: [netbsd-9] src/sys/dev

2023-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jan 23 12:05:36 UTC 2023

Modified Files:
src/sys/dev/pci [netbsd-9]: xhci_pci.c
src/sys/dev/usb [netbsd-9]: xhci.c xhcivar.h

Log Message:
Pull up the following revisions, requested by msaitoh in ticket #1570:

sys/dev/pci/xhci_pci.c  1.31 via patch
sys/dev/usb/xhci.c  1.173-1.175
sys/dev/usb/xhcivar.h   1.22

Support xHCI device which has USB 2 port only.


To generate a diff of this commit:
cvs rdiff -u -r1.21.4.1 -r1.21.4.2 src/sys/dev/pci/xhci_pci.c
cvs rdiff -u -r1.107.2.10 -r1.107.2.11 src/sys/dev/usb/xhci.c
cvs rdiff -u -r1.11.4.2 -r1.11.4.3 src/sys/dev/usb/xhcivar.h

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



CVS commit: [netbsd-9] src/sys/dev

2023-03-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 15 18:43:28 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: vnd.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1614):

sys/dev/vnd.c: revision 1.288

Do not limit the number of pending requests for the worker thread.

With wedge on vnd it prevents a deadlock when requests get queued with
biodone() -> dkstart() -> vndstrategy().

Fixes PR kern/57263 "vnd locks up when using vn_rdwr"


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.272.4.1 src/sys/dev/vnd.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-03-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Mar 15 18:43:28 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: vnd.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1614):

sys/dev/vnd.c: revision 1.288

Do not limit the number of pending requests for the worker thread.

With wedge on vnd it prevents a deadlock when requests get queued with
biodone() -> dkstart() -> vndstrategy().

Fixes PR kern/57263 "vnd locks up when using vn_rdwr"


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.272.4.1 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.272 src/sys/dev/vnd.c:1.272.4.1
--- src/sys/dev/vnd.c:1.272	Fri Mar  1 11:06:56 2019
+++ src/sys/dev/vnd.c	Wed Mar 15 18:43:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.272 2019/03/01 11:06:56 pgoyette Exp $	*/
+/*	$NetBSD: vnd.c,v 1.272.4.1 2023/03/15 18:43:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.272 2019/03/01 11:06:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.272.4.1 2023/03/15 18:43:28 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -552,11 +552,18 @@ vndstrategy(struct buf *bp)
 		printf("vndstrategy(%p): unit %d\n", bp, unit);
 #endif
 	if ((vnd->sc_flags & VNF_USE_VN_RDWR)) {
-		KASSERT(vnd->sc_pending >= 0 &&
-		vnd->sc_pending <= VND_MAXPENDING(vnd));
-		while (vnd->sc_pending == VND_MAXPENDING(vnd))
-			tsleep(&vnd->sc_pending, PRIBIO, "vndpc", 0);
+		/*
+		 * Limit the number of pending requests to not exhaust
+		 * resources needed for I/O but always allow the worker
+		 * thread to add requests, as a wedge on vnd queues
+		 * requests with biodone() -> dkstart() -> vndstrategy().
+		 */
+		if (curlwp != vnd->sc_kthread) {
+			while (vnd->sc_pending >= VND_MAXPENDING(vnd))
+tsleep(&vnd->sc_pending, PRIBIO, "vndpc", 0);
+		}
 		vnd->sc_pending++;
+		KASSERT(vnd->sc_pending > 0);
 	}
 	bufq_put(vnd->sc_tab, bp);
 	wakeup(&vnd->sc_tab);
@@ -673,8 +680,7 @@ vndthread(void *arg)
 			continue;
 		};
 		if ((vnd->sc_flags & VNF_USE_VN_RDWR)) {
-			KASSERT(vnd->sc_pending > 0 &&
-			vnd->sc_pending <= VND_MAXPENDING(vnd));
+			KASSERT(vnd->sc_pending > 0);
 			if (vnd->sc_pending-- == VND_MAXPENDING(vnd))
 wakeup(&vnd->sc_pending);
 		}



CVS commit: [netbsd-9] src/sys/dev

2021-12-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 30 12:38:22 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: cgd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1398):

sys/dev/cgd.c: revision 1.142

cgd(4): Fix criterion for detach when wedgies are held.

The somewhat confusingly named DK_BUSY(dksc, pmask) answers the
following question:

Suppose I hold either the character or the block device (but
not both) of all of the partitions in pmask.  Is anyone else
using the disk, rendering it unsafe to detach?

This is useful for ioctls like CGDIOCCLR and VNDIOCCLR, which must be
issued on open file descriptors for the disk, so the question cannot
simply be answered by testing whether dk_openmask != 0.
Instead, DK_BUSY breaks the question into the following criteria:

1. Are there any _other_ partitions than those in pmask open
   at all?  If so, it must be someone else, since I only hold
   partitions in pmask -- hence the disk is busy.
2. Are any of the partitions in pmask open _both_ as a block
   device _and_ as a character device?  If so, it must be
   someone else, since I only hold _either_ the character
   _or_ the block device open but not both -- hence the disk
   is busy.

When config_detach_all runs at shutdown time, it tries to detach
cgd(4), which has DVF_DETACH_SHUTDOWN; this is important so we submit
queued writes to the underlying disk and wait for them to complete
with dk_drain.

If cgd(4) has any dk wedges with file systems mounted still
configured on it, it isn't ready to detach yet.  But asking
DK_BUSY(dksc, 1 << RAW_PART) returns false, because the dk wedges
only hold RAW_PART open as a block device -- so if nobody has
RAW_PART open as a character device, or any other partitions open,
cgd_detach blithely goes on its way to forcibly detach the wedges.

Instead, ask DK_BUSY(dksc, 0), because the caller -- cgd_detach
issued by config_detach_all -- does not, in fact, hold any partitions
open, so it doesn't need to work around them like ioctl(CGDIOCCLR)
does.  Fixes hang in zfs on dk on cgd during shutdown (and probably
also zfs on cgd without any intervening dk but I haven't tested).

(This change might have the side effect that `drvctl -d cgdN' doesn't
work, but I don't care.)

XXX pullup-9
XXX pullup-8 (...-7, -6, -5...)


To generate a diff of this commit:
cvs rdiff -u -r1.116.10.4 -r1.116.10.5 src/sys/dev/cgd.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/cgd.c
diff -u src/sys/dev/cgd.c:1.116.10.4 src/sys/dev/cgd.c:1.116.10.5
--- src/sys/dev/cgd.c:1.116.10.4	Tue Dec 14 19:05:11 2021
+++ src/sys/dev/cgd.c	Thu Dec 30 12:38:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.116.10.4 2021/12/14 19:05:11 martin Exp $ */
+/* $NetBSD: cgd.c,v 1.116.10.5 2021/12/30 12:38:22 martin Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.116.10.4 2021/12/14 19:05:11 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.116.10.5 2021/12/30 12:38:22 martin Exp $");
 
 #include 
 #include 
@@ -354,11 +354,10 @@ static int
 cgd_detach(device_t self, int flags)
 {
 	int ret;
-	const int pmask = 1 << RAW_PART;
 	struct cgd_softc *sc = device_private(self);
 	struct dk_softc *dksc = &sc->sc_dksc;
 
-	if (DK_BUSY(dksc, pmask))
+	if (DK_BUSY(dksc, 0))
 		return EBUSY;
 
 	if (DK_ATTACHED(dksc) &&



CVS commit: [netbsd-9] src/sys/dev

2021-12-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 30 12:38:22 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: cgd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1398):

sys/dev/cgd.c: revision 1.142

cgd(4): Fix criterion for detach when wedgies are held.

The somewhat confusingly named DK_BUSY(dksc, pmask) answers the
following question:

Suppose I hold either the character or the block device (but
not both) of all of the partitions in pmask.  Is anyone else
using the disk, rendering it unsafe to detach?

This is useful for ioctls like CGDIOCCLR and VNDIOCCLR, which must be
issued on open file descriptors for the disk, so the question cannot
simply be answered by testing whether dk_openmask != 0.
Instead, DK_BUSY breaks the question into the following criteria:

1. Are there any _other_ partitions than those in pmask open
   at all?  If so, it must be someone else, since I only hold
   partitions in pmask -- hence the disk is busy.
2. Are any of the partitions in pmask open _both_ as a block
   device _and_ as a character device?  If so, it must be
   someone else, since I only hold _either_ the character
   _or_ the block device open but not both -- hence the disk
   is busy.

When config_detach_all runs at shutdown time, it tries to detach
cgd(4), which has DVF_DETACH_SHUTDOWN; this is important so we submit
queued writes to the underlying disk and wait for them to complete
with dk_drain.

If cgd(4) has any dk wedges with file systems mounted still
configured on it, it isn't ready to detach yet.  But asking
DK_BUSY(dksc, 1 << RAW_PART) returns false, because the dk wedges
only hold RAW_PART open as a block device -- so if nobody has
RAW_PART open as a character device, or any other partitions open,
cgd_detach blithely goes on its way to forcibly detach the wedges.

Instead, ask DK_BUSY(dksc, 0), because the caller -- cgd_detach
issued by config_detach_all -- does not, in fact, hold any partitions
open, so it doesn't need to work around them like ioctl(CGDIOCCLR)
does.  Fixes hang in zfs on dk on cgd during shutdown (and probably
also zfs on cgd without any intervening dk but I haven't tested).

(This change might have the side effect that `drvctl -d cgdN' doesn't
work, but I don't care.)

XXX pullup-9
XXX pullup-8 (...-7, -6, -5...)


To generate a diff of this commit:
cvs rdiff -u -r1.116.10.4 -r1.116.10.5 src/sys/dev/cgd.c

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



CVS commit: [netbsd-9] src/sys/dev

2021-11-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 20 14:59:04 UTC 2021

Modified Files:
src/sys/dev/mii [netbsd-9]: ihphy.c
src/sys/dev/pci [netbsd-9]: if_wm.c if_wmreg.h

Log Message:
Pull up the following, requested by msaitoh in ticket #1373:

sys/dev/pci/if_wm.c 1.716-1.718 via patch
sys/dev/pci/if_wmreg.h  1.121
sys/dev/mii/ihphy.c 1.20

- Fix a bug that device timeout still happens when the link is down
  on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.1 -r1.14.4.2 src/sys/dev/mii/ihphy.c
cvs rdiff -u -r1.645.2.11 -r1.645.2.12 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.115.2.3 -r1.115.2.4 src/sys/dev/pci/if_wmreg.h

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



CVS commit: [netbsd-9] src/sys/dev

2021-11-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Nov 20 14:59:04 UTC 2021

Modified Files:
src/sys/dev/mii [netbsd-9]: ihphy.c
src/sys/dev/pci [netbsd-9]: if_wm.c if_wmreg.h

Log Message:
Pull up the following, requested by msaitoh in ticket #1373:

sys/dev/pci/if_wm.c 1.716-1.718 via patch
sys/dev/pci/if_wmreg.h  1.121
sys/dev/mii/ihphy.c 1.20

- Fix a bug that device timeout still happens when the link is down
  on ICH/PCH. Fixes PR kern/56478.
- Add some sysctl info for debugging.
- ihphy(4): Don't power down the PHY when the interface goes down.
- Use macro. Fix comment.


To generate a diff of this commit:
cvs rdiff -u -r1.14.4.1 -r1.14.4.2 src/sys/dev/mii/ihphy.c
cvs rdiff -u -r1.645.2.11 -r1.645.2.12 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.115.2.3 -r1.115.2.4 src/sys/dev/pci/if_wmreg.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/mii/ihphy.c
diff -u src/sys/dev/mii/ihphy.c:1.14.4.1 src/sys/dev/mii/ihphy.c:1.14.4.2
--- src/sys/dev/mii/ihphy.c:1.14.4.1	Sun Jan 26 11:11:13 2020
+++ src/sys/dev/mii/ihphy.c	Sat Nov 20 14:59:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ihphy.c,v 1.14.4.1 2020/01/26 11:11:13 martin Exp $	*/
+/*	$NetBSD: ihphy.c,v 1.14.4.2 2021/11/20 14:59:04 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.14.4.1 2020/01/26 11:11:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.14.4.2 2021/11/20 14:59:04 martin Exp $");
 
 #include 
 #include 
@@ -210,7 +210,6 @@ ihphy_service(struct mii_softc *sc, stru
 
 	case MII_DOWN:
 		mii_phy_down(sc);
-		PHY_WRITE(sc, MII_BMCR, BMCR_PDOWN);
 		return 0;
 	}
 

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.645.2.11 src/sys/dev/pci/if_wm.c:1.645.2.12
--- src/sys/dev/pci/if_wm.c:1.645.2.11	Thu Oct 21 14:30:10 2021
+++ src/sys/dev/pci/if_wm.c	Sat Nov 20 14:59:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.645.2.11 2021/10/21 14:30:10 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.645.2.12 2021/11/20 14:59:04 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645.2.11 2021/10/21 14:30:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645.2.12 2021/11/20 14:59:04 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1067,6 +1067,8 @@ static bool	wm_phy_need_linkdown_discard
 static void	wm_set_linkdown_discard(struct wm_softc *);
 static void	wm_clear_linkdown_discard(struct wm_softc *);
 
+static int	wm_sysctl_tdh_handler(SYSCTLFN_PROTO);
+static int	wm_sysctl_tdt_handler(SYSCTLFN_PROTO);
 #ifdef WM_DEBUG
 static int	wm_sysctl_debug(SYSCTLFN_PROTO);
 #endif
@@ -3153,8 +3155,12 @@ alloc_retry:
 
 	sc->sc_txrx_use_workqueue = false;
 
-	if (wm_phy_need_linkdown_discard(sc))
+	if (wm_phy_need_linkdown_discard(sc)) {
+		DPRINTF(sc, WM_DEBUG_LINK,
+		("%s: %s: Set linkdown discard flag\n",
+			device_xname(sc->sc_dev), __func__));
 		wm_set_linkdown_discard(sc);
+	}
 
 	wm_init_sysctls(sc);
 
@@ -3625,10 +3631,12 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 		splx(s);
 #endif
 		if (error == 0 && wm_phy_need_linkdown_discard(sc)) {
-			if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE)
+			if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE) {
+DPRINTF(sc, WM_DEBUG_LINK,
+("%s: %s: Set linkdown discard flag\n",
+	device_xname(sc->sc_dev), __func__));
 wm_set_linkdown_discard(sc);
-			else
-wm_clear_linkdown_discard(sc);
+			}
 		}
 		break;
 	case SIOCINITIFADDR:
@@ -3644,14 +3652,14 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 			break;
 		}
 		WM_CORE_UNLOCK(sc);
-		if (((ifp->if_flags & IFF_UP) == 0) && wm_phy_need_linkdown_discard(sc))
-			wm_clear_linkdown_discard(sc);
 		/*FALLTHROUGH*/
 	default:
 		if (cmd == SIOCSIFFLAGS && wm_phy_need_linkdown_discard(sc)) {
-			if (((ifp->if_flags & IFF_UP) == 0) && ((ifr->ifr_flags & IFF_UP) != 0)) {
-wm_clear_linkdown_discard(sc);
-			} else if (((ifp->if_flags & IFF_UP) != 0) && ((ifr->ifr_flags & IFF_UP) == 0)) {
+			if (((ifp->if_flags & IFF_UP) != 0) &&
+			((ifr->ifr_flags & IFF_UP) == 0)) {
+DPRINTF(sc, WM_DEBUG_LINK,
+("%s: %s: Set linkdown discard flag\n",
+	device_xname(sc->sc_dev), __func__));
 wm_set_linkdown_discard(sc);
 			}
 		}
@@ -5993,6 +6001,7 @@ wm_init_sysctls(struct wm_softc *sc)
 		sc->sc_queue[i].sysctlname, SYSCTL_DESCR("Queue Name"),
 		NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0)
 			break;
+
 		if (sysctl_createv(log, 0, &qnode, &cnode,
 		CTLFLAG_READONLY, CTLTYPE_INT,
 		"txq_free", SYSCTL_DESCR("TX queue free"),
@@ -6001,10 +6010,58 @@ wm_init_sysctls(struct wm_softc *sc)
 			break;
 		if (sysctl_createv(log, 0, &qnode, &cnode

CVS commit: [netbsd-9] src/sys/dev

2021-12-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec  3 18:20:41 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: sdhc_pci.c
src/sys/dev/sdmmc [netbsd-9]: sdhc.c sdmmc_mem.c

Log Message:
Pull up the followin revisions (all via patch), requested by msaitoh
in ticket #1383:

sys/dev/sdmmc/sdhc.c1.110, 1.112
sys/dev/sdmmc/sdmmc_mem.c   1.74
sys/dev/pci/sdhc_pci.c  1.18

- Support 64bit BAR.
- Use unsigned to avoid undefined behavior in hwrite[12]() and
  sdmmc_mem_sd_switch().
- Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.16.1 src/sys/dev/pci/sdhc_pci.c
cvs rdiff -u -r1.103.2.2 -r1.103.2.3 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.68.2.2 -r1.68.2.3 src/sys/dev/sdmmc/sdmmc_mem.c

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



CVS commit: [netbsd-9] src/sys/dev

2021-12-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec  3 18:20:41 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-9]: sdhc_pci.c
src/sys/dev/sdmmc [netbsd-9]: sdhc.c sdmmc_mem.c

Log Message:
Pull up the followin revisions (all via patch), requested by msaitoh
in ticket #1383:

sys/dev/sdmmc/sdhc.c1.110, 1.112
sys/dev/sdmmc/sdmmc_mem.c   1.74
sys/dev/pci/sdhc_pci.c  1.18

- Support 64bit BAR.
- Use unsigned to avoid undefined behavior in hwrite[12]() and
  sdmmc_mem_sd_switch().
- Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.16.1 src/sys/dev/pci/sdhc_pci.c
cvs rdiff -u -r1.103.2.2 -r1.103.2.3 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.68.2.2 -r1.68.2.3 src/sys/dev/sdmmc/sdmmc_mem.c

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

Modified files:

Index: src/sys/dev/pci/sdhc_pci.c
diff -u src/sys/dev/pci/sdhc_pci.c:1.14 src/sys/dev/pci/sdhc_pci.c:1.14.16.1
--- src/sys/dev/pci/sdhc_pci.c:1.14	Thu Apr 27 10:01:54 2017
+++ src/sys/dev/pci/sdhc_pci.c	Fri Dec  3 18:20:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc_pci.c,v 1.14 2017/04/27 10:01:54 msaitoh Exp $	*/
+/*	$NetBSD: sdhc_pci.c,v 1.14.16.1 2021/12/03 18:20:40 martin Exp $	*/
 /*	$OpenBSD: sdhc_pci.c,v 1.7 2007/10/30 18:13:45 chl Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.14 2017/04/27 10:01:54 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_pci.c,v 1.14.16.1 2021/12/03 18:20:40 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -250,6 +250,7 @@ sdhc_pci_attach(device_t parent, device_
 	bus_space_handle_t ioh;
 	bus_size_t size;
 	uint32_t flags;
+	int width;
 	char intrbuf[PCI_INTRSTR_LEN];
 
 	sc->sc.sc_dev = self;
@@ -313,13 +314,23 @@ sdhc_pci_attach(device_t parent, device_
 	if ((PCI_INTERFACE(pa->pa_class) == SDHC_PCI_INTERFACE_DMA))
 		SET(sc->sc.sc_flags, SDHC_FLAG_USE_DMA);
 
-	/* XXX: handle 64-bit BARs */
 	cnt = 0;
 	for (reg = SDHC_PCI_BAR_START + SDHC_PCI_FIRST_BAR(slotinfo) *
 		 sizeof(uint32_t);
 	 reg < SDHC_PCI_BAR_END && nslots > 0;
-	 reg += sizeof(uint32_t), nslots--) {
-		if (pci_mapreg_map(pa, reg, PCI_MAPREG_TYPE_MEM, 0,
+	 reg += width, nslots--) {
+		pcireg_t type;
+
+		type = pci_mapreg_type(pa->pa_pc, pa->pa_tag, reg);
+		if (type == PCI_MAPREG_TYPE_IO)
+			break;
+		else if (PCI_MAPREG_MEM_TYPE(type)
+		== PCI_MAPREG_MEM_TYPE_64BIT)
+			width = 8;
+		else
+			width = 4;
+
+		if (pci_mapreg_map(pa, reg, type, 0,
 		&iot, &ioh, NULL, &size)) {
 			continue;
 		}

Index: src/sys/dev/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.103.2.2 src/sys/dev/sdmmc/sdhc.c:1.103.2.3
--- src/sys/dev/sdmmc/sdhc.c:1.103.2.2	Mon Jul 20 18:15:43 2020
+++ src/sys/dev/sdmmc/sdhc.c	Fri Dec  3 18:20:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.103.2.2 2020/07/20 18:15:43 martin Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.103.2.3 2021/12/03 18:20:41 martin Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.103.2.2 2020/07/20 18:15:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.103.2.3 2021/12/03 18:20:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -138,7 +138,7 @@ hwrite1(struct sdhc_host *hp, bus_size_t
 		const size_t shift = 8 * (o & 3);
 		o &= -4;
 		uint32_t tmp = bus_space_read_4(hp->iot, hp->ioh, o);
-		tmp = (val << shift) | (tmp & ~(0xff << shift));
+		tmp = (val << shift) | (tmp & ~(0xffU << shift));
 		bus_space_write_4(hp->iot, hp->ioh, o, tmp);
 	}
 }
@@ -153,7 +153,7 @@ hwrite2(struct sdhc_host *hp, bus_size_t
 		const size_t shift = 8 * (o & 2);
 		o &= -4;
 		uint32_t tmp = bus_space_read_4(hp->iot, hp->ioh, o);
-		tmp = (val << shift) | (tmp & ~(0x << shift));
+		tmp = (val << shift) | (tmp & ~(0xU << shift));
 		bus_space_write_4(hp->iot, hp->ioh, o, tmp);
 	}
 }
@@ -403,7 +403,7 @@ sdhc_host_found(struct sdhc_softc *sc, b
 
 	/*
 	 * Use DMA if the host system and the controller support it.
-	 * Suports integrated or external DMA egine, with or without
+	 * Supports integrated or external DMA egine, with or without
 	 * SDHC_DMA_ENABLE in the command.
 	 */
 	if (ISSET(sc->sc_flags, SDHC_FLAG_FORCE_DMA) ||

Index: src/sys/dev/sdmmc/sdmmc_mem.c
diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.68.2.2 src/sys/dev/sdmmc/sdmmc_mem.c:1.68.2.3
--- src/sys/dev/sdmmc/sdmmc_mem.c:1.68.2.2	Sun Aug  9 14:03:07 2020
+++ src/sys/dev/sdmmc/sdmmc_mem.c	Fri Dec  3 18:20:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmc_mem.c,v 1.68.2.2 2020/08/09 14:03:07 martin Exp $	*/
+/*	$NetBSD: sdmmc_mem.c,v 1.68.2.3 2021/12/03 18:20:41 martin Exp $	*/
 /*	$OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -45,7 +45,7 @@
 /* Routines for SD/MMC memory cards. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdmmc

CVS commit: [netbsd-9] src/sys/dev

2021-12-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Dec  8 15:50:13 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: ipmi.c

Log Message:
Pull up following revision(s) (requested by hauke in ticket #1392):

sys/dev/ipmi.c: revision 1.6
sys/dev/ipmi.c: revision 1.7
sys/dev/ipmi.c: revision 1.8
sys/dev/ipmi.c: revision 1.9

Fail open when ipmi device was found.
Clear sc_envsys on failure to prevent double-free.

ipmi(4): Use config_pending_incr/decr.
Don't abuse autoconf's private (and incoherent) dv_flags.

ipmi(4): Notify config_pending_decr when ready, not when dying.
Should fix hang at boot.

ipmi(4): Tidy up ipmi_thread a little.
- Join on detach -- don't free anything until thread has exited; thread
  may still be using stuff.
- Nix dead error branch -- malloc(M_WAITOK) cannot fail.
- x = malloc(sizeof(x[0]) * n), not x = malloc(sizeof(type_t) * n)


To generate a diff of this commit:
cvs rdiff -u -r1.4.4.1 -r1.4.4.2 src/sys/dev/ipmi.c

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



CVS commit: [netbsd-9] src/sys/dev

2021-12-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Dec  8 15:50:13 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: ipmi.c

Log Message:
Pull up following revision(s) (requested by hauke in ticket #1392):

sys/dev/ipmi.c: revision 1.6
sys/dev/ipmi.c: revision 1.7
sys/dev/ipmi.c: revision 1.8
sys/dev/ipmi.c: revision 1.9

Fail open when ipmi device was found.
Clear sc_envsys on failure to prevent double-free.

ipmi(4): Use config_pending_incr/decr.
Don't abuse autoconf's private (and incoherent) dv_flags.

ipmi(4): Notify config_pending_decr when ready, not when dying.
Should fix hang at boot.

ipmi(4): Tidy up ipmi_thread a little.
- Join on detach -- don't free anything until thread has exited; thread
  may still be using stuff.
- Nix dead error branch -- malloc(M_WAITOK) cannot fail.
- x = malloc(sizeof(x[0]) * n), not x = malloc(sizeof(type_t) * n)


To generate a diff of this commit:
cvs rdiff -u -r1.4.4.1 -r1.4.4.2 src/sys/dev/ipmi.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/ipmi.c
diff -u src/sys/dev/ipmi.c:1.4.4.1 src/sys/dev/ipmi.c:1.4.4.2
--- src/sys/dev/ipmi.c:1.4.4.1	Tue Aug 18 09:36:36 2020
+++ src/sys/dev/ipmi.c	Wed Dec  8 15:50:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.4.4.1 2020/08/18 09:36:36 martin Exp $ */
+/*	$NetBSD: ipmi.c,v 1.4.4.2 2021/12/08 15:50:13 martin Exp $ */
 
 /*
  * Copyright (c) 2019 Michael van Elst
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.1 2020/08/18 09:36:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.2 2021/12/08 15:50:13 martin Exp $");
 
 #include 
 #include 
@@ -238,7 +238,6 @@ static	int bmc_io_wait(struct ipmi_softc
 static	int bmc_io_wait_spin(struct ipmi_softc *, int, uint8_t, uint8_t);
 static	int bmc_io_wait_sleep(struct ipmi_softc *, int, uint8_t, uint8_t);
 
-static	void *bt_buildmsg(struct ipmi_softc *, int, int, int, const void *, int *);
 static	void *cmn_buildmsg(struct ipmi_softc *, int, int, int, const void *, int *);
 
 static	int getbits(uint8_t *, int, int);
@@ -268,6 +267,7 @@ static	int kcs_reset(struct ipmi_softc *
 static	int kcs_sendmsg(struct ipmi_softc *, int, const uint8_t *);
 static	int kcs_recvmsg(struct ipmi_softc *, int, int *len, uint8_t *);
 
+static	void *bt_buildmsg(struct ipmi_softc *, int, int, int, const void *, int *);
 static	int bt_probe(struct ipmi_softc *);
 static	int bt_reset(struct ipmi_softc *);
 static	int bt_sendmsg(struct ipmi_softc *, int, const uint8_t *);
@@ -1984,13 +1984,8 @@ ipmi_thread(void *cookie)
 			break;
 
 	/* allocate and fill sensor arrays */
-	sc->sc_sensor =
-	malloc(sizeof(envsys_data_t) * sc->sc_nsensors,
-	M_DEVBUF, M_WAITOK | M_ZERO);
-	if (sc->sc_sensor == NULL) {
-		aprint_error_dev(self, "can't allocate envsys_data_t\n");
-		kthread_exit(0);
-	}
+	sc->sc_sensor = malloc(sizeof(sc->sc_sensor[0]) * sc->sc_nsensors,
+	M_DEVBUF, M_WAITOK | M_ZERO);
 
 	sc->sc_envsys = sysmon_envsys_create();
 	sc->sc_envsys->sme_cookie = sc;
@@ -2034,6 +2029,7 @@ ipmi_thread(void *cookie)
 	if (sysmon_envsys_register(sc->sc_envsys)) {
 		aprint_error_dev(self, "unable to register with sysmon\n");
 		sysmon_envsys_destroy(sc->sc_envsys);
+		sc->sc_envsys = NULL;
 	}
 
 	/* initialize sensor list for thread */
@@ -2089,6 +2085,8 @@ ipmi_thread(void *cookie)
 	if (!pmf_device_register(self, ipmi_suspend, NULL))
 aprint_error_dev(self, "couldn't establish a power handler\n");
 
+	config_pending_decr(self);
+
 	mutex_enter(&sc->sc_poll_mtx);
 	while (sc->sc_thread_running) {
 		while (sc->sc_mode == IPMI_MODE_COMMAND)
@@ -2107,7 +2105,6 @@ ipmi_thread(void *cookie)
 		SENSOR_REFRESH_RATE);
 	}
 	mutex_exit(&sc->sc_poll_mtx);
-	self->dv_flags &= ~DVF_ATTACH_INPROGRESS;
 	kthread_exit(0);
 }
 
@@ -2130,11 +2127,11 @@ ipmi_attach(device_t parent, device_t se
 	cv_init(&sc->sc_poll_cv, "ipmipoll");
 	cv_init(&sc->sc_mode_cv, "ipmimode");
 
-	if (kthread_create(PRI_NONE, 0, NULL, ipmi_thread, self,
+	if (kthread_create(PRI_NONE, KTHREAD_MUSTJOIN, NULL, ipmi_thread, self,
 	&sc->sc_kthread, "%s", device_xname(self)) != 0) {
 		aprint_error_dev(self, "unable to create thread, disabled\n");
 	} else
-		self->dv_flags |= DVF_ATTACH_INPROGRESS;
+		config_pending_incr(self);
 }
 
 static int
@@ -2148,6 +2145,8 @@ ipmi_detach(device_t self, int flags)
 	sc->sc_thread_running = false;
 	cv_signal(&sc->sc_poll_cv);
 	mutex_exit(&sc->sc_poll_mtx);
+	if (sc->sc_kthread)
+		(void)kthread_join(sc->sc_kthread);
 
 	if ((rc = sysmon_wdog_unregister(&sc->sc_wdog)) != 0) {
 		if (rc == ERESTART)
@@ -2314,6 +2313,13 @@ ipmi_suspend(device_t dev, const pmf_qua
 static int
 ipmi_open(dev_t dev, int flag, int fmt, lwp_t *l)
 {
+	struct ipmi_softc *sc;
+	int unit;
+
+	unit = IPMIUNIT(dev);
+	if ((sc = device_lookup_private(&ipmi_cd, unit)) == NULL)
+		return (ENXIO);
+
 	return 0;
 }
 



CVS commit: [netbsd-9] src/sys/dev

2021-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 14 19:05:11 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: cgd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1393):

sys/dev/cgd.c: revision 1.141

cgd(4): Wait for worker threads to complete before destroying mutex.

Fixes PR kern/56546 (probably!).


To generate a diff of this commit:
cvs rdiff -u -r1.116.10.3 -r1.116.10.4 src/sys/dev/cgd.c

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



CVS commit: [netbsd-9] src/sys/dev

2021-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 14 19:05:11 UTC 2021

Modified Files:
src/sys/dev [netbsd-9]: cgd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1393):

sys/dev/cgd.c: revision 1.141

cgd(4): Wait for worker threads to complete before destroying mutex.

Fixes PR kern/56546 (probably!).


To generate a diff of this commit:
cvs rdiff -u -r1.116.10.3 -r1.116.10.4 src/sys/dev/cgd.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/cgd.c
diff -u src/sys/dev/cgd.c:1.116.10.3 src/sys/dev/cgd.c:1.116.10.4
--- src/sys/dev/cgd.c:1.116.10.3	Mon Apr  6 14:57:42 2020
+++ src/sys/dev/cgd.c	Tue Dec 14 19:05:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.116.10.3 2020/04/06 14:57:42 martin Exp $ */
+/* $NetBSD: cgd.c,v 1.116.10.4 2021/12/14 19:05:11 martin Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.116.10.3 2020/04/06 14:57:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.116.10.4 2021/12/14 19:05:11 martin Exp $");
 
 #include 
 #include 
@@ -516,14 +516,20 @@ cgd_create_worker(void)
 static void
 cgd_destroy_worker(struct cgd_worker *cw)
 {
+
+	/*
+	 * Wait for all worker threads to complete before destroying
+	 * the rest of the cgd_worker.
+	 */
+	if (cw->cw_wq)
+		workqueue_destroy(cw->cw_wq);
+
 	mutex_destroy(&cw->cw_lock);
 
 	if (cw->cw_cpool) {
 		pool_destroy(cw->cw_cpool);
 		kmem_free(cw->cw_cpool, sizeof(struct pool));
 	}
-	if (cw->cw_wq)
-		workqueue_destroy(cw->cw_wq);
 
 	kmem_free(cw, sizeof(struct cgd_worker));
 }



CVS commit: [netbsd-9] src/sys/dev

2022-08-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  3 10:55:45 UTC 2022

Modified Files:
src/sys/dev/isa [netbsd-9]: mcd.c
src/sys/dev/pci [netbsd-9]: if_iwi.c
src/sys/dev/raidframe [netbsd-9]: rf_netbsdkintf.c
src/sys/dev/scsipi [netbsd-9]: ses.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1485):

sys/dev/pci/if_iwi.c: revision 1.117
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.401
sys/dev/scsipi/ses.c: revision 1.52
sys/dev/isa/mcd.c: revision 1.121

sys/dev: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure.  If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.

I think the iwi(4), mcd(4), and ses(4) changes actually plug leaks;
the raidframe(4) change probably doesn't (but doesn't hurt).


To generate a diff of this commit:
cvs rdiff -u -r1.118.4.1 -r1.118.4.2 src/sys/dev/isa/mcd.c
cvs rdiff -u -r1.111 -r1.111.4.1 src/sys/dev/pci/if_iwi.c
cvs rdiff -u -r1.376.4.1 -r1.376.4.2 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.51 -r1.51.4.1 src/sys/dev/scsipi/ses.c

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



CVS commit: [netbsd-9] src/sys/dev

2022-08-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  3 10:55:45 UTC 2022

Modified Files:
src/sys/dev/isa [netbsd-9]: mcd.c
src/sys/dev/pci [netbsd-9]: if_iwi.c
src/sys/dev/raidframe [netbsd-9]: rf_netbsdkintf.c
src/sys/dev/scsipi [netbsd-9]: ses.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1485):

sys/dev/pci/if_iwi.c: revision 1.117
sys/dev/raidframe/rf_netbsdkintf.c: revision 1.401
sys/dev/scsipi/ses.c: revision 1.52
sys/dev/isa/mcd.c: revision 1.121

sys/dev: Memset zero before copyout.

Just in case of uninitialized padding which would lead to kernel
stack disclosure.  If the compiler can prove the memset redundant
then it can optimize it away; otherwise better safe than sorry.

I think the iwi(4), mcd(4), and ses(4) changes actually plug leaks;
the raidframe(4) change probably doesn't (but doesn't hurt).


To generate a diff of this commit:
cvs rdiff -u -r1.118.4.1 -r1.118.4.2 src/sys/dev/isa/mcd.c
cvs rdiff -u -r1.111 -r1.111.4.1 src/sys/dev/pci/if_iwi.c
cvs rdiff -u -r1.376.4.1 -r1.376.4.2 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.51 -r1.51.4.1 src/sys/dev/scsipi/ses.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/isa/mcd.c
diff -u src/sys/dev/isa/mcd.c:1.118.4.1 src/sys/dev/isa/mcd.c:1.118.4.2
--- src/sys/dev/isa/mcd.c:1.118.4.1	Thu Nov 14 15:38:02 2019
+++ src/sys/dev/isa/mcd.c	Wed Aug  3 10:55:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcd.c,v 1.118.4.1 2019/11/14 15:38:02 martin Exp $	*/
+/*	$NetBSD: mcd.c,v 1.118.4.2 2022/08/03 10:55:45 martin Exp $	*/
 
 /*
  * Copyright (c) 1993, 1994, 1995 Charles M. Hannum.  All rights reserved.
@@ -56,7 +56,7 @@
 /*static char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";*/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mcd.c,v 1.118.4.1 2019/11/14 15:38:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mcd.c,v 1.118.4.2 2022/08/03 10:55:45 martin Exp $");
 
 #include 
 #include 
@@ -1601,6 +1601,7 @@ mcd_read_subchannel(struct mcd_softc *sc
 	if ((error = mcd_getqchan(sc, &q, ch->data_format)) != 0)
 		return error;
 
+	memset(info, 0, sizeof(*info));
 	info->header.audio_status = sc->audio_status;
 	info->what.media_catalog.data_format = ch->data_format;
 

Index: src/sys/dev/pci/if_iwi.c
diff -u src/sys/dev/pci/if_iwi.c:1.111 src/sys/dev/pci/if_iwi.c:1.111.4.1
--- src/sys/dev/pci/if_iwi.c:1.111	Sun Feb  3 03:19:27 2019
+++ src/sys/dev/pci/if_iwi.c	Wed Aug  3 10:55:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwi.c,v 1.111 2019/02/03 03:19:27 mrg Exp $  */
+/*	$NetBSD: if_iwi.c,v 1.111.4.1 2022/08/03 10:55:44 martin Exp $  */
 /*	$OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $	*/
 
 /*-
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.111 2019/02/03 03:19:27 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.111.4.1 2022/08/03 10:55:44 martin Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
@@ -1875,8 +1875,9 @@ iwi_get_table0(struct iwi_softc *sc, uin
 {
 	uint32_t size, buf[128];
 
+	memset(buf, 0, sizeof buf);
+
 	if (!(sc->flags & IWI_FLAG_FW_INITED)) {
-		memset(buf, 0, sizeof buf);
 		return copyout(buf, tbl, sizeof buf);
 	}
 

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.1 src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.2
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.376.4.1	Sat Mar 21 15:52:09 2020
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Wed Aug  3 10:55:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.1 2020/03/21 15:52:09 martin Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.376.4.2 2022/08/03 10:55:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376.4.1 2020/03/21 15:52:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.376.4.2 2022/08/03 10:55:45 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_raid_autoconfig.h"
@@ -3748,6 +3748,8 @@ void
 rf_check_recon_status_ext(RF_Raid_t *raidPtr, RF_ProgressInfo_t *info)
 {
 
+	memset(info, 0, sizeof(*info));
+
 	if (raidPtr->status != rf_rs_reconstructing) {
 		info->total = 100;
 		info->completed = 100;
@@ -3763,6 +3765,8 @@ void
 rf_check_parityrewrite_status_ext(RF_Raid_t *raidPtr, RF_ProgressInfo_t *info)
 {
 
+	memset(info, 0, sizeof(*info));
+
 	if (raidPtr->parity_rewrite_in_progress == 1) {
 		info->total = raidPtr->Layout.numStripe;
 		info->completed = raidPtr->parity_rewrite_stripes_done;
@@ -3778,6 +3782,8 @@ void
 rf_check_copyback_status_ext(RF_Raid_t *raidPtr, RF_ProgressInfo_t *info)
 {
 
+	memset(info, 0, sizeof(*info));
+
 	if (raidPtr->copyback_in_progress == 1) {
 		info->total = raidPtr->Layout.numStripe;
 		in

CVS commit: [netbsd-9] src/sys/dev

2022-08-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 29 15:48:31 UTC 2022

Modified Files:
src/sys/dev/ic [netbsd-9]: tpm.c
src/sys/dev/isa [netbsd-9]: tpm_isa.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1505):

sys/dev/isa/tpm_isa.c: revision 1.8
sys/dev/ic/tpm.c: revision 1.20

Add missing printing-of-newlines in the attach routine.

Remove extra newline from boot messages (isa and acpi front-ends
already provide the newline).


To generate a diff of this commit:
cvs rdiff -u -r1.13.2.2 -r1.13.2.3 src/sys/dev/ic/tpm.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/isa/tpm_isa.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/tpm.c
diff -u src/sys/dev/ic/tpm.c:1.13.2.2 src/sys/dev/ic/tpm.c:1.13.2.3
--- src/sys/dev/ic/tpm.c:1.13.2.2	Wed Aug  3 16:00:47 2022
+++ src/sys/dev/ic/tpm.c	Mon Aug 29 15:48:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tpm.c,v 1.13.2.2 2022/08/03 16:00:47 martin Exp $	*/
+/*	$NetBSD: tpm.c,v 1.13.2.3 2022/08/29 15:48:31 martin Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.13.2.2 2022/08/03 16:00:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.13.2.3 2022/08/29 15:48:31 martin Exp $");
 
 #include 
 #include 
@@ -821,9 +821,6 @@ tpm_tis12_init(struct tpm_softc *sc)
 {
 	int rv;
 
-	aprint_naive("\n");
-	aprint_normal("\n");
-
 	sc->sc_caps = bus_space_read_4(sc->sc_bt, sc->sc_bh,
 	TPM_INTF_CAPABILITY);
 	sc->sc_devid = bus_space_read_4(sc->sc_bt, sc->sc_bh, TPM_ID);

Index: src/sys/dev/isa/tpm_isa.c
diff -u src/sys/dev/isa/tpm_isa.c:1.4.2.1 src/sys/dev/isa/tpm_isa.c:1.4.2.2
--- src/sys/dev/isa/tpm_isa.c:1.4.2.1	Wed Oct 16 09:52:38 2019
+++ src/sys/dev/isa/tpm_isa.c	Mon Aug 29 15:48:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tpm_isa.c,v 1.4.2.1 2019/10/16 09:52:38 martin Exp $	*/
+/*	$NetBSD: tpm_isa.c,v 1.4.2.2 2022/08/29 15:48:30 martin Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tpm_isa.c,v 1.4.2.1 2019/10/16 09:52:38 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tpm_isa.c,v 1.4.2.2 2022/08/29 15:48:30 martin Exp $");
 
 #include 
 #include 
@@ -113,6 +113,9 @@ tpm_isa_attach(device_t parent, device_t
 	base = (unsigned int)ia->ia_iomem[0].ir_addr;
 	size = TPM_SPACE_SIZE;
 
+	aprint_normal("\n");
+	aprint_naive("\n");
+
 	sc->sc_dev = self;
 	sc->sc_ver = TPM_1_2;
 	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);



CVS commit: [netbsd-9] src/sys/dev

2022-08-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 29 15:48:31 UTC 2022

Modified Files:
src/sys/dev/ic [netbsd-9]: tpm.c
src/sys/dev/isa [netbsd-9]: tpm_isa.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1505):

sys/dev/isa/tpm_isa.c: revision 1.8
sys/dev/ic/tpm.c: revision 1.20

Add missing printing-of-newlines in the attach routine.

Remove extra newline from boot messages (isa and acpi front-ends
already provide the newline).


To generate a diff of this commit:
cvs rdiff -u -r1.13.2.2 -r1.13.2.3 src/sys/dev/ic/tpm.c
cvs rdiff -u -r1.4.2.1 -r1.4.2.2 src/sys/dev/isa/tpm_isa.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-06-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  3 15:17:31 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: ipmi.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1639):

sys/dev/ipmi.c: revision 1.10

Ignore non-recoverable and critical limits smaller than the warning limits.
These are usually invalid.

Name the limit flags to make code more readable.


To generate a diff of this commit:
cvs rdiff -u -r1.4.4.2 -r1.4.4.3 src/sys/dev/ipmi.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-06-03 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  3 15:17:31 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: ipmi.c

Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1639):

sys/dev/ipmi.c: revision 1.10

Ignore non-recoverable and critical limits smaller than the warning limits.
These are usually invalid.

Name the limit flags to make code more readable.


To generate a diff of this commit:
cvs rdiff -u -r1.4.4.2 -r1.4.4.3 src/sys/dev/ipmi.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/ipmi.c
diff -u src/sys/dev/ipmi.c:1.4.4.2 src/sys/dev/ipmi.c:1.4.4.3
--- src/sys/dev/ipmi.c:1.4.4.2	Wed Dec  8 15:50:13 2021
+++ src/sys/dev/ipmi.c	Sat Jun  3 15:17:31 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipmi.c,v 1.4.4.2 2021/12/08 15:50:13 martin Exp $ */
+/*	$NetBSD: ipmi.c,v 1.4.4.3 2023/06/03 15:17:31 martin Exp $ */
 
 /*
  * Copyright (c) 2019 Michael van Elst
@@ -76,7 +76,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.2 2021/12/08 15:50:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.4.4.3 2023/06/03 15:17:31 martin Exp $");
 
 #include 
 #include 
@@ -1533,6 +1533,14 @@ ipmi_get_limits(struct sysmon_envsys *sm
 	return;
 }
 
+/* valid bits for (upper,lower) x (non-recoverable, critical, warn) */
+#define UN	0x20
+#define UC	0x10
+#define UW	0x08
+#define LN	0x04
+#define LC	0x02
+#define LW	0x01
+
 static void
 ipmi_get_sensor_limits(struct ipmi_softc *sc, struct ipmi_sensor *psensor,
 		   sysmon_envsys_lim_t *limits, uint32_t *props)
@@ -1540,7 +1548,7 @@ ipmi_get_sensor_limits(struct ipmi_softc
 	struct sdrtype1	*s1 = (struct sdrtype1 *)psensor->i_sdr;
 	bool failure;
 	int	rxlen;
-	uint8_t	data[32];
+	uint8_t	data[32], valid;
 	uint32_t prop_critmax, prop_warnmax, prop_critmin, prop_warnmin;
 	int32_t *pcritmax, *pwarnmax, *pcritmin, *pwarnmin;
 
@@ -1582,27 +1590,43 @@ ipmi_get_sensor_limits(struct ipmi_softc
 		break;
 	}
 
-	if (data[0] & 0x20 && data[6] != 0xff) {
+	valid = data[0];
+
+	/* if upper non-recoverable < warning, ignore it */
+	if ((valid & (UN|UW)) == (UN|UW) && data[6] < data[4])
+		valid ^= UN;
+	/* if upper critical < warning, ignore it */
+	if ((valid & (UC|UW)) == (UC|UW) && data[5] < data[4])
+		valid ^= UC;
+
+	/* if lower non-recoverable > warning, ignore it */
+	if ((data[0] & (LN|LW)) == (LN|LW) && data[3] > data[1])
+		valid ^= LN;
+	/* if lower critical > warning, ignore it */
+	if ((data[0] & (LC|LW)) == (LC|LW) && data[2] > data[1])
+		valid ^= LC;
+
+	if (valid & UN && data[6] != 0xff) {
 		*pcritmax = ipmi_convert_sensor(&data[6], psensor);
 		*props |= prop_critmax;
 	}
-	if (data[0] & 0x10 && data[5] != 0xff) {
+	if (valid & UC && data[5] != 0xff) {
 		*pcritmax = ipmi_convert_sensor(&data[5], psensor);
 		*props |= prop_critmax;
 	}
-	if (data[0] & 0x08 && data[4] != 0xff) {
+	if (valid & UW && data[4] != 0xff) {
 		*pwarnmax = ipmi_convert_sensor(&data[4], psensor);
 		*props |= prop_warnmax;
 	}
-	if (data[0] & 0x04 && data[3] != 0x00) {
+	if (valid & LN && data[3] != 0x00) {
 		*pcritmin = ipmi_convert_sensor(&data[3], psensor);
 		*props |= prop_critmin;
 	}
-	if (data[0] & 0x02 && data[2] != 0x00) {
+	if (valid & LC && data[2] != 0x00) {
 		*pcritmin = ipmi_convert_sensor(&data[2], psensor);
 		*props |= prop_critmin;
 	}
-	if (data[0] & 0x01 && data[1] != 0x00) {
+	if (valid & LW && data[1] != 0x00) {
 		*pwarnmin = ipmi_convert_sensor(&data[1], psensor);
 		*props |= prop_warnmin;
 	}



CVS commit: [netbsd-9] src/sys/dev

2023-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  1 13:02:55 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: spkr.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1686):

sys/dev/spkr.c: revision 1.25 (patch)

spkr(4): Avoid some overflow issues.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.4.1 src/sys/dev/spkr.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/spkr.c
diff -u src/sys/dev/spkr.c:1.17 src/sys/dev/spkr.c:1.17.4.1
--- src/sys/dev/spkr.c:1.17	Thu Apr 18 13:01:38 2019
+++ src/sys/dev/spkr.c	Tue Aug  1 13:02:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: spkr.c,v 1.17 2019/04/18 13:01:38 isaki Exp $	*/
+/*	$NetBSD: spkr.c,v 1.17.4.1 2023/08/01 13:02:55 martin Exp $	*/
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (e...@snark.thyrsus.com)
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.17 2019/04/18 13:01:38 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.17.4.1 2023/08/01 13:02:55 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "wsmux.h"
@@ -173,6 +173,7 @@ playtone(struct spkr_softc *sc, int pitc
 		* snum / (val * sdenom));
 		return;
 	}
+	KASSERTMSG(pitch < __arraycount(pitchtab), "pitch=%d", pitch);
 
 	int fac = sc->sc_whole * (FILLTIME - sc->sc_fill);
 	int fval = FILLTIME * val;
@@ -198,6 +199,10 @@ playstring(struct spkr_softc *sc, const 
 
 #define GETNUM(cp, v)	\
 	for (v = 0; slen > 0 && isdigit((unsigned char)cp[1]); ) { \
+		if (v > INT_MAX/10 - (cp[1] - '0')) { \
+			v = INT_MAX; \
+			continue; \
+		} \
 		v = v * 10 + (*++cp - '0'); \
 		slen--; \
 	}
@@ -281,6 +286,8 @@ playstring(struct spkr_softc *sc, const 
 slen--;
 			} else {
 GETNUM(cp, sc->sc_octave);
+KASSERTMSG(sc->sc_octave >= 0, "%d",
+sc->sc_octave);
 if (sc->sc_octave >= NOCTAVES)
 	sc->sc_octave = DFLT_OCTAVE;
 sc->sc_octprefix = true;
@@ -301,6 +308,9 @@ playstring(struct spkr_softc *sc, const 
 
 		case 'N':
 			GETNUM(cp, pitch);
+			KASSERTMSG(pitch >= 0, "pitch=%d", pitch);
+			if (pitch >= __arraycount(pitchtab))
+break;
 			for (sustain = 0; slen > 0 && cp[1] == '.'; cp++) {
 slen--;
 sustain++;



CVS commit: [netbsd-9] src/sys/dev

2023-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  1 13:02:55 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: spkr.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1686):

sys/dev/spkr.c: revision 1.25 (patch)

spkr(4): Avoid some overflow issues.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.17.4.1 src/sys/dev/spkr.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  1 14:59:57 UTC 2023

Modified Files:
src/sys/dev/isapnp [netbsd-9]: sb_isapnp.c
src/sys/dev/ofisa [netbsd-9]: sb_ofisa.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1689):

sys/dev/isapnp/sb_isapnp.c: revision 1.54
sys/dev/ofisa/sb_ofisa.c: revision 1.24

sb(4): Fix missing mutex initialization at isapnp and ofisa.
PR kern/57363


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.53.2.1 src/sys/dev/isapnp/sb_isapnp.c
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/dev/ofisa/sb_ofisa.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-08-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug  1 14:59:57 UTC 2023

Modified Files:
src/sys/dev/isapnp [netbsd-9]: sb_isapnp.c
src/sys/dev/ofisa [netbsd-9]: sb_ofisa.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1689):

sys/dev/isapnp/sb_isapnp.c: revision 1.54
sys/dev/ofisa/sb_ofisa.c: revision 1.24

sb(4): Fix missing mutex initialization at isapnp and ofisa.
PR kern/57363


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.53.2.1 src/sys/dev/isapnp/sb_isapnp.c
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/dev/ofisa/sb_ofisa.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/isapnp/sb_isapnp.c
diff -u src/sys/dev/isapnp/sb_isapnp.c:1.53 src/sys/dev/isapnp/sb_isapnp.c:1.53.2.1
--- src/sys/dev/isapnp/sb_isapnp.c:1.53	Wed May  8 13:40:18 2019
+++ src/sys/dev/isapnp/sb_isapnp.c	Tue Aug  1 14:59:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sb_isapnp.c,v 1.53 2019/05/08 13:40:18 isaki Exp $	*/
+/*	$NetBSD: sb_isapnp.c,v 1.53.2.1 2023/08/01 14:59:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1991-1993 Regents of the University of California.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sb_isapnp.c,v 1.53 2019/05/08 13:40:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sb_isapnp.c,v 1.53.2.1 2023/08/01 14:59:57 martin Exp $");
 
 #include 
 #include 
@@ -158,6 +158,9 @@ sb_isapnp_attach(device_t parent, device
 		return;
 	}
 
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_AUDIO);
+
 	sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
 	ipa->ipa_irq[0].type, IPL_AUDIO, sbdsp_intr, sc);
 

Index: src/sys/dev/ofisa/sb_ofisa.c
diff -u src/sys/dev/ofisa/sb_ofisa.c:1.19 src/sys/dev/ofisa/sb_ofisa.c:1.19.2.1
--- src/sys/dev/ofisa/sb_ofisa.c:1.19	Wed May  8 13:40:18 2019
+++ src/sys/dev/ofisa/sb_ofisa.c	Tue Aug  1 14:59:57 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: sb_ofisa.c,v 1.19 2019/05/08 13:40:18 isaki Exp $	*/
+/*	$NetBSD: sb_ofisa.c,v 1.19.2.1 2023/08/01 14:59:57 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.19 2019/05/08 13:40:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.19.2.1 2023/08/01 14:59:57 martin Exp $");
 
 #include 
 #include 
@@ -174,6 +174,9 @@ sb_ofisa_attach(device_t parent, device_
 		return;
 	}
 
+	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_AUDIO);
+
 	sc->sc_ih = isa_intr_establish(aa->ic, intr.irq, IST_EDGE, IPL_AUDIO,
 	sbdsp_intr, sc);
 



CVS commit: [netbsd-9] src/sys/dev

2023-08-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 21 10:57:07 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: vnd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1716):

sys/dev/vnd.c: revision 1.289

Neither limit the number of requests for the page daemon.

Otherwise you may deadlock when the backend needs to allocate
memory and the page daemon needs to flush dirty vnd buffers.

See PR 57421 for details.


To generate a diff of this commit:
cvs rdiff -u -r1.272.4.1 -r1.272.4.2 src/sys/dev/vnd.c

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



CVS commit: [netbsd-9] src/sys/dev

2023-08-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 21 10:57:07 UTC 2023

Modified Files:
src/sys/dev [netbsd-9]: vnd.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1716):

sys/dev/vnd.c: revision 1.289

Neither limit the number of requests for the page daemon.

Otherwise you may deadlock when the backend needs to allocate
memory and the page daemon needs to flush dirty vnd buffers.

See PR 57421 for details.


To generate a diff of this commit:
cvs rdiff -u -r1.272.4.1 -r1.272.4.2 src/sys/dev/vnd.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/vnd.c
diff -u src/sys/dev/vnd.c:1.272.4.1 src/sys/dev/vnd.c:1.272.4.2
--- src/sys/dev/vnd.c:1.272.4.1	Wed Mar 15 18:43:28 2023
+++ src/sys/dev/vnd.c	Mon Aug 21 10:57:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.272.4.1 2023/03/15 18:43:28 martin Exp $	*/
+/*	$NetBSD: vnd.c,v 1.272.4.2 2023/08/21 10:57:07 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.272.4.1 2023/03/15 18:43:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.272.4.2 2023/08/21 10:57:07 martin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -122,6 +122,8 @@ __KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.27
 #include 
 #include 
 
+#include 
+
 #include 
 
 #include 
@@ -558,7 +560,7 @@ vndstrategy(struct buf *bp)
 		 * thread to add requests, as a wedge on vnd queues
 		 * requests with biodone() -> dkstart() -> vndstrategy().
 		 */
-		if (curlwp != vnd->sc_kthread) {
+		if (curlwp != vnd->sc_kthread && curlwp != uvm.pagedaemon_lwp) {
 			while (vnd->sc_pending >= VND_MAXPENDING(vnd))
 tsleep(&vnd->sc_pending, PRIBIO, "vndpc", 0);
 		}



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:03:13 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_et.c if_etreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #36):

sys/dev/pci/if_et.c: revision 1.25
sys/dev/pci/if_et.c: revision 1.26
sys/dev/pci/if_etreg.h: revision 1.2
sys/dev/pci/if_etreg.h: revision 1.3

Avoid undefined behavior when reset the chip. found by kUBSan.

 Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.

Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
  if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.2.1 src/sys/dev/pci/if_et.c
cvs rdiff -u -r1.1 -r1.1.68.1 src/sys/dev/pci/if_etreg.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/pci/if_et.c
diff -u src/sys/dev/pci/if_et.c:1.24 src/sys/dev/pci/if_et.c:1.24.2.1
--- src/sys/dev/pci/if_et.c:1.24	Tue May 28 07:41:49 2019
+++ src/sys/dev/pci/if_et.c	Fri Aug  9 16:03:13 2019
@@ -1,5 +1,5 @@
-/*	$NetBSD: if_et.c,v 1.24 2019/05/28 07:41:49 msaitoh Exp $	*/
-/*	$OpenBSD: if_et.c,v 1.11 2008/06/08 06:18:07 jsg Exp $	*/
+/*	$NetBSD: if_et.c,v 1.24.2.1 2019/08/09 16:03:13 martin Exp $	*/
+/*	$OpenBSD: if_et.c,v 1.12 2008/07/11 09:29:02 kevlo $	*/
 /*
  * Copyright (c) 2007 The DragonFly Project.  All rights reserved.
  *
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.24 2019/05/28 07:41:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.24.2.1 2019/08/09 16:03:13 martin Exp $");
 
 #include "opt_inet.h"
 #include "vlan.h"
@@ -83,17 +83,19 @@ __KERNEL_RCSID(0, "$NetBSD: if_et.c,v 1.
 
 int	et_match(device_t, cfdata_t, void *);
 void	et_attach(device_t, device_t, void *);
-int	et_detach(device_t, int flags);
+int	et_detach(device_t, int);
 int	et_shutdown(device_t);
 
 int	et_miibus_readreg(device_t, int, int, uint16_t *);
 int	et_miibus_writereg(device_t, int, int, uint16_t);
 void	et_miibus_statchg(struct ifnet *);
 
-int	et_init(struct ifnet *ifp);
+int	et_init(struct ifnet *);
 int	et_ioctl(struct ifnet *, u_long, void *);
 void	et_start(struct ifnet *);
 void	et_watchdog(struct ifnet *);
+static int	et_ifmedia_upd(struct ifnet *);
+static void	et_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 
 int	et_intr(void *);
 void	et_enable_intrs(struct et_softc *, uint32_t);
@@ -131,7 +133,6 @@ int	et_start_rxdma(struct et_softc *);
 int	et_start_txdma(struct et_softc *);
 int	et_stop_rxdma(struct et_softc *);
 int	et_stop_txdma(struct et_softc *);
-int	et_enable_txrx(struct et_softc *);
 void	et_reset(struct et_softc *);
 int	et_bus_config(struct et_softc *);
 void	et_get_eaddr(struct et_softc *, uint8_t[]);
@@ -190,6 +191,7 @@ et_attach(device_t parent, device_t self
 	const char *intrstr;
 	struct ifnet *ifp = &sc->sc_ethercom.ec_if;
 	struct mii_data * const mii = &sc->sc_miibus;
+	uint32_t pmcfg;
 	pcireg_t memtype;
 	int error;
 	char intrbuf[PCI_INTRSTR_LEN];
@@ -234,6 +236,9 @@ et_attach(device_t parent, device_t self
 	sc->sc_pct = pa->pa_pc;
 	sc->sc_pcitag = pa->pa_tag;
 
+	if (pa->pa_id == PCI_PRODUCT_LUCENT_ET1301)
+		sc->sc_flags |= ET_FLAG_FASTETHER;
+
 	error = et_bus_config(sc);
 	if (error)
 		goto fail;
@@ -243,8 +248,11 @@ et_attach(device_t parent, device_t self
 	aprint_normal_dev(self, "Ethernet address %s\n",
 	ether_sprintf(sc->sc_enaddr));
 
-	CSR_WRITE_4(sc, ET_PM,
-		ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE);
+	/* Take PHY out of COMA and enable clocks. */
+	pmcfg = ET_PM_SYSCLK_GATE | ET_PM_TXCLK_GATE | ET_PM_RXCLK_GATE;
+	if ((sc->sc_flags & ET_FLAG_FASTETHER) == 0)
+		pmcfg |= EM_PM_GIGEPHY_ENB;
+	CSR_WRITE_4(sc, ET_PM, pmcfg);
 
 	et_reset(sc);
 
@@ -273,8 +281,7 @@ et_attach(device_t parent, device_t self
 	mii->mii_statchg = et_miibus_statchg;
 
 	sc->sc_ethercom.ec_mii = mii;
-	ifmedia_init(&mii->mii_media, 0, ether_mediachange,
-	ether_mediastatus);
+	ifmedia_init(&mii->mii_media, 0, et_ifmedia_upd, et_ifmedia_sts);
 	mii_attach(self, mii, 0x, MII_PHY_ANY, MII_OFFSET_ANY, 0);
 	if (LIST_FIRST(&mii->mii_phys) == NULL) {
 		aprint_error_dev(self, "no PHY found!\n");
@@ -450,31 +457,117 @@ et_miibus_statchg(struct ifnet *ifp)
 {
 	struct et_softc *sc = ifp->if_softc;
 	struct mii_data *mii = &sc->sc_miibus;
-	uint32_t cfg2, ctrl;
+	uint32_t cfg1, cfg2, ctrl;
+	int i;
+
+	sc->sc_flags &= ~ET_FLAG_LINK;
+	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
+	(IFM_ACTIVE | IFM_AVALID)) {
+		switch (IFM_SUBTYPE(mii->mii_media_active)) {
+		case IFM_10_T:
+		case IFM_100_TX:
+			sc->sc_flags |= ET_FLAG_LINK;
+			break;
+		case IFM_1000_T:
+			if ((sc->sc_flags & ET_FLA

CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:03:13 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_et.c if_etreg.h

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #36):

sys/dev/pci/if_et.c: revision 1.25
sys/dev/pci/if_et.c: revision 1.26
sys/dev/pci/if_etreg.h: revision 1.2
sys/dev/pci/if_etreg.h: revision 1.3

Avoid undefined behavior when reset the chip. found by kUBSan.

 Add missing ifioctl_common() for SIOCSIFFLAGS to make if_flags controllable.

Make et(4) work:
- Enabling TX/RX in et_init() will always fail when cable is not plugged in,
  if this happens, we delay TX/RX enablement until link is up. From FreeBSD.
- Modify flow control stuff a little (from FrerBSD). It still doesn't work.
- KNF. Part of OpenBSD 1.12.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.24.2.1 src/sys/dev/pci/if_et.c
cvs rdiff -u -r1.1 -r1.1.68.1 src/sys/dev/pci/if_etreg.h

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



CVS commit: [netbsd-9] src/sys/dev/acpi

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:13:36 UTC 2019

Modified Files:
src/sys/dev/acpi [netbsd-9]: acpi_ec.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #38):

sys/dev/acpi/acpi_ec.c: revision 1.76
sys/dev/acpi/acpi_ec.c: revision 1.77

- Fix a bug that acpiec_space_handler() doesn't access more than 64bit
  correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
  address 0xa0. The error message was:
UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, 
shift exponent 64 is too large for 64-bit type 'long unsigned int'

- KNF.

- Make the case that width < 8 behave as the same as before. Pointed out by
  Joerg.

- Change "switch" to "if" for simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.20.1 src/sys/dev/acpi/acpi_ec.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/acpi/acpi_ec.c
diff -u src/sys/dev/acpi/acpi_ec.c:1.75 src/sys/dev/acpi/acpi_ec.c:1.75.20.1
--- src/sys/dev/acpi/acpi_ec.c:1.75	Sat Mar 11 08:26:23 2017
+++ src/sys/dev/acpi/acpi_ec.c	Fri Aug  9 16:13:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_ec.c,v 1.75 2017/03/11 08:26:23 tsutsui Exp $	*/
+/*	$NetBSD: acpi_ec.c,v 1.75.20.1 2019/08/09 16:13:35 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007 Joerg Sonnenberger .
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.75 2017/03/11 08:26:23 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_ec.c,v 1.75.20.1 2019/08/09 16:13:35 martin Exp $");
 
 #include 
 #include 
@@ -404,6 +404,7 @@ post_data_map:
 static bool
 acpiec_suspend(device_t dv, const pmf_qual_t *qual)
 {
+
 	acpiec_cold = true;
 
 	return true;
@@ -412,6 +413,7 @@ acpiec_suspend(device_t dv, const pmf_qu
 static bool
 acpiec_resume(device_t dv, const pmf_qual_t *qual)
 {
+
 	acpiec_cold = false;
 
 	return true;
@@ -454,9 +456,10 @@ acpiec_parse_gpe_package(device_t self, 
 		ACPI_FREE(p);
 		return false;
 	}
-	
+
 	if (p->Package.Count != 2) {
-		aprint_error_dev(self, "_GPE package does not contain 2 elements\n");
+		aprint_error_dev(self,
+		"_GPE package does not contain 2 elements\n");
 		ACPI_FREE(p);
 		return false;
 	}
@@ -511,6 +514,7 @@ static ACPI_STATUS
 acpiec_space_setup(ACPI_HANDLE region, uint32_t func, void *arg,
 void **region_arg)
 {
+
 	if (func == ACPI_REGION_DEACTIVATE)
 		*region_arg = NULL;
 	else
@@ -528,9 +532,11 @@ acpiec_lock(device_t dv)
 	mutex_enter(&sc->sc_access_mtx);
 
 	if (sc->sc_need_global_lock) {
-		rv = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT, &sc->sc_global_lock);
+		rv = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT,
+		&sc->sc_global_lock);
 		if (rv != AE_OK) {
-			aprint_error_dev(dv, "failed to acquire global lock: %s\n",
+			aprint_error_dev(dv,
+			"failed to acquire global lock: %s\n",
 			AcpiFormatException(rv));
 			return;
 		}
@@ -546,7 +552,8 @@ acpiec_unlock(device_t dv)
 	if (sc->sc_need_global_lock) {
 		rv = AcpiReleaseGlobalLock(sc->sc_global_lock);
 		if (rv != AE_OK) {
-			aprint_error_dev(dv, "failed to release global lock: %s\n",
+			aprint_error_dev(dv,
+			"failed to release global lock: %s\n",
 			AcpiFormatException(rv));
 		}
 	}
@@ -587,7 +594,8 @@ acpiec_read(device_t dv, uint8_t addr, u
 	} else if (cv_timedwait(&sc->sc_cv, &sc->sc_mtx, EC_CMD_TIMEOUT * hz)) {
 		mutex_exit(&sc->sc_mtx);
 		acpiec_unlock(dv);
-		aprint_error_dev(dv, "command takes over %d sec...\n", EC_CMD_TIMEOUT);
+		aprint_error_dev(dv,
+		"command takes over %d sec...\n", EC_CMD_TIMEOUT);
 		return AE_ERROR;
 	}
 
@@ -634,7 +642,8 @@ acpiec_write(device_t dv, uint8_t addr, 
 	} else if (cv_timedwait(&sc->sc_cv, &sc->sc_mtx, EC_CMD_TIMEOUT * hz)) {
 		mutex_exit(&sc->sc_mtx);
 		acpiec_unlock(dv);
-		aprint_error_dev(dv, "command takes over %d sec...\n", EC_CMD_TIMEOUT);
+		aprint_error_dev(dv,
+		"command takes over %d sec...\n", EC_CMD_TIMEOUT);
 		return AE_ERROR;
 	}
 
@@ -648,42 +657,36 @@ static ACPI_STATUS
 acpiec_space_handler(uint32_t func, ACPI_PHYSICAL_ADDRESS paddr,
 uint32_t width, ACPI_INTEGER *value, void *arg, void *region_arg)
 {
-	device_t dv;
+	device_t dv = arg;
 	ACPI_STATUS rv;
-	uint8_t addr, reg;
-	unsigned int i;
+	uint8_t addr;
+	uint8_t *reg;
 
+	if ((func != ACPI_READ) && (func != ACPI_WRITE)) {
+		aprint_error("%s: invalid Address Space function called: %x\n",
+		device_xname(dv), (unsigned int)func);
+		return AE_BAD_PARAMETER;
+	}
 	if (paddr > 0xff || width % 8 != 0 || value == NULL || arg == NULL ||
 	paddr + width / 8 > 0x100)
 		return AE_BAD_PARAMETER;
 
 	addr = paddr;
-	dv = arg;
+	reg = (uint8_t *)value;
 
 	rv = AE_OK;
 
-	switch (func) {
-	case ACPI_READ:
+	if (func == ACPI_READ)
 		*value = 0;
-		for (i = 0; i < width; i += 8, ++addr) {
-			rv = acpiec_read(dv, addr, ®);
-			if (rv != AE_OK)
-break;
-			*value |= (ACPI_INTEGER)re

CVS commit: [netbsd-9] src/sys/dev/acpi

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:13:36 UTC 2019

Modified Files:
src/sys/dev/acpi [netbsd-9]: acpi_ec.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #38):

sys/dev/acpi/acpi_ec.c: revision 1.76
sys/dev/acpi/acpi_ec.c: revision 1.77

- Fix a bug that acpiec_space_handler() doesn't access more than 64bit
  correctly. Found by kUBSan on Thinkpad X220. acpiec0 accessed 128bits from
  address 0xa0. The error message was:
UBSan: Undefined Behavior in ../../../../dev/acpi/acpi_ec.c:672:32, 
shift exponent 64 is too large for 64-bit type 'long unsigned int'

- KNF.

- Make the case that width < 8 behave as the same as before. Pointed out by
  Joerg.

- Change "switch" to "if" for simplify.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.20.1 src/sys/dev/acpi/acpi_ec.c

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:15:06 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: if_aue.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #39):

sys/dev/usb/if_aue.c: revision 1.156

Fix panic when setting multicast addresses. Write the hash table outside of
ETHER_LOC()/ETHER_UNLOCK().


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/usb/if_aue.c

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug  9 16:15:06 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: if_aue.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #39):

sys/dev/usb/if_aue.c: revision 1.156

Fix panic when setting multicast addresses. Write the hash table outside of
ETHER_LOC()/ETHER_UNLOCK().


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/usb/if_aue.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_aue.c
diff -u src/sys/dev/usb/if_aue.c:1.154 src/sys/dev/usb/if_aue.c:1.154.2.1
--- src/sys/dev/usb/if_aue.c:1.154	Tue May 28 07:41:50 2019
+++ src/sys/dev/usb/if_aue.c	Fri Aug  9 16:15:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aue.c,v 1.154 2019/05/28 07:41:50 msaitoh Exp $	*/
+/*	$NetBSD: if_aue.c,v 1.154.2.1 2019/08/09 16:15:06 martin Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.154 2019/05/28 07:41:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.154.2.1 2019/08/09 16:15:06 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -587,6 +587,7 @@ aue_setmulti(struct aue_softc *sc)
 	struct ether_multi	*enm;
 	struct ether_multistep	step;
 	uint32_t		h = 0, i;
+	uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 
 	DPRINTFN(5,("%s: %s: enter\n", device_xname(sc->aue_dev), __func__));
 
@@ -601,10 +602,6 @@ allmulti:
 
 	AUE_CLRBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI);
 
-	/* first, zot all the existing hash bits */
-	for (i = 0; i < 8; i++)
-		aue_csr_write_1(sc, AUE_MAR0 + i, 0);
-
 	/* now program new ones */
 	ETHER_LOCK(ec);
 	ETHER_FIRST_MULTI(step, ec, enm);
@@ -616,11 +613,15 @@ allmulti:
 		}
 
 		h = aue_crc(enm->enm_addrlo);
-		AUE_SETBIT(sc, AUE_MAR + (h >> 3), 1 << (h & 0x7));
+		hashtbl[h >> 3] |= 1 << (h & 0x7);
 		ETHER_NEXT_MULTI(step, enm);
 	}
 	ETHER_UNLOCK(ec);
 
+	/* write the hashtable */
+	for (i = 0; i < 8; i++)
+		aue_csr_write_1(sc, AUE_MAR0 + i, hashtbl[i]);
+
 	ifp->if_flags &= ~IFF_ALLMULTI;
 }
 



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 18 09:58:49 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: radeonfb.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #86):

sys/dev/pci/radeonfb.c: revision 1.105

Support bitmap fonts with stride 4 (i.e., width 17 to 32).


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.4.1 src/sys/dev/pci/radeonfb.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/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.104 src/sys/dev/pci/radeonfb.c:1.104.4.1
--- src/sys/dev/pci/radeonfb.c:1.104	Wed Mar 27 22:00:33 2019
+++ src/sys/dev/pci/radeonfb.c	Sun Aug 18 09:58:49 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.104 2019/03/27 22:00:33 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.104.4.1 2019/08/18 09:58:49 martin Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.104 2019/03/27 22:00:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.104.4.1 2019/08/18 09:58:49 martin Exp $");
 
 #include 
 #include 
@@ -2931,6 +2931,7 @@ radeonfb_putchar(void *cookie, int row, 
 	uint32_t		reg;
 	uint8_t			*data8;
 	uint16_t		*data16;
+	uint32_t		*data32;
 	void			*data;
 
 	if (dp->rd_wsmode != WSDISPLAYIO_MODE_EMUL)
@@ -3009,6 +3010,16 @@ radeonfb_putchar(void *cookie, int row, 
 			}
 			break;
 		}
+		case 4: {
+			data32 = data;
+			for (i = 0; i < h; i++) {
+reg = *data32;
+bus_space_write_stream_4(sc->sc_regt, 
+sc->sc_regh, RADEON_HOST_DATA0, reg);
+data32++;
+			}
+			break;
+		}
 	}
 	if (attr & 1)
 		radeonfb_rectfill(dp, xd, yd + h - 2, w, 1, fg);



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 18 09:58:49 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: radeonfb.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #86):

sys/dev/pci/radeonfb.c: revision 1.105

Support bitmap fonts with stride 4 (i.e., width 17 to 32).


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.104.4.1 src/sys/dev/pci/radeonfb.c

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 21 14:34:56 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: xhci.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #104):

sys/dev/usb/xhci.c: revision 1.108

typo in error message


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.107.2.1 src/sys/dev/usb/xhci.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107 src/sys/dev/usb/xhci.c:1.107.2.1
--- src/sys/dev/usb/xhci.c:1.107	Wed May  8 06:31:02 2019
+++ src/sys/dev/usb/xhci.c	Wed Aug 21 14:34:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107 2019/05/08 06:31:02 mrg Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.1 2019/08/21 14:34:56 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107 2019/05/08 06:31:02 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.1 2019/08/21 14:34:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -790,7 +790,7 @@ xhci_id_protocols(struct xhci_softc *sc,
 	/* Index arrays with 0..n-1 where ports are numbered 1..n */
 	for (size_t cp = cpo - 1; cp < cpo + cpc - 1; cp++) {
 		if (sc->sc_ctlrportmap[cp] != 0) {
-			aprint_error_dev(sc->sc_dev, "contoller port %zu "
+			aprint_error_dev(sc->sc_dev, "controller port %zu "
 			"already assigned", cp);
 			continue;
 		}



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug 21 14:34:56 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: xhci.c

Log Message:
Pull up following revision(s) (requested by skrll in ticket #104):

sys/dev/usb/xhci.c: revision 1.108

typo in error message


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.107.2.1 src/sys/dev/usb/xhci.c

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:54:42 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: usbdevs

Log Message:
Pull up following revision(s) (requested by mrg in ticket #111):

sys/dev/usb/usbdevs: revision 1.771
sys/dev/usb/usbdevs: revision 1.772
sys/dev/usb/usbdevs: revision 1.773

add 3 devices for upl(4) host-to-host networking:
- belkin F5U258
- national instruments USB host to host adapter
- prolific id 25a1

 -

add two kue(4) adapters:
ACTIONTEC KL5KUSB101 USB Ethernet adapter
ALLIEDTELESYN AT-USB10 USB Ethernet Adapter

 -

add MosChip MCS7730 and Sitecom Europe LN030 ethernet adapters.


To generate a diff of this commit:
cvs rdiff -u -r1.770 -r1.770.4.1 src/sys/dev/usb/usbdevs

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:54:42 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: usbdevs

Log Message:
Pull up following revision(s) (requested by mrg in ticket #111):

sys/dev/usb/usbdevs: revision 1.771
sys/dev/usb/usbdevs: revision 1.772
sys/dev/usb/usbdevs: revision 1.773

add 3 devices for upl(4) host-to-host networking:
- belkin F5U258
- national instruments USB host to host adapter
- prolific id 25a1

 -

add two kue(4) adapters:
ACTIONTEC KL5KUSB101 USB Ethernet adapter
ALLIEDTELESYN AT-USB10 USB Ethernet Adapter

 -

add MosChip MCS7730 and Sitecom Europe LN030 ethernet adapters.


To generate a diff of this commit:
cvs rdiff -u -r1.770 -r1.770.4.1 src/sys/dev/usb/usbdevs

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/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.770 src/sys/dev/usb/usbdevs:1.770.4.1
--- src/sys/dev/usb/usbdevs:1.770	Wed Jan 30 19:51:28 2019
+++ src/sys/dev/usb/usbdevs	Mon Aug 26 13:54:41 2019
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.770 2019/01/30 19:51:28 jakllsch Exp $
+$NetBSD: usbdevs,v 1.770.4.1 2019/08/26 13:54:41 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -724,6 +724,7 @@ product ACERW WARPLINK		0x0204	Warplink
 product ACTIONTEC PRISM_25	0x0408	Prism2.5 WLAN
 product ACTIONTEC PRISM_25A	0x0421	Prism2.5 WLAN A
 product ACTIONTEC AR9287	0x1200	AR9287+AR7010
+product ACTIONTEC KL5KUSB101	0x1200	KL5KUSB101 USB Ethernet adapter
 product ACTIONTEC FREELAN	0x6106	ROPEX FreeLan 802.11b
 product ACTIONTEC UAT1		0x7605	UAT1 Wireless Ethernet adapter
 
@@ -1066,6 +1067,7 @@ product BELKIN RTL8192CU_2	0x1004	RTL819
 product BELKIN RTL8188CU	0x1102	RTL8188CU
 product BELKIN RTL8188CUS	0x11f2	RTL8188CUS
 product BELKIN F5U120		0x1203	F5U120-PC Hub
+product BELKIN F5U258		0x258a	F5U258/F5U279 Host to host adapter
 product BELKIN RTL8192CU	0x2102	RTL8192CU
 product BELKIN F7D2102		0x2103	F7D2102
 product BELKIN RTL8192CU_1	0x21f2	RTL8192CU
@@ -2367,6 +2369,7 @@ product MOBILITY EASIDOCK	0x0304	EasiDoc
 /* MosChip Semiconductor */
 product MOSCHIP MCS7703		0x7703	MCS7703 USB Serial Adapter
 product MOSCHIP MCS7720		0x7720	MCS7720 USB Serial Adapter
+product MOSCHIP MCS7730		0x7730	MCS7730 Ethernet Adapter
 product MOSCHIP MCS7780		0x7780	MCS7780 Fast IrDA Adapter
 product MOSCHIP MCS7781		0x7781	MCS7781 Fast IrDA Adapter
 product MOSCHIP MCS7784		0x7784	MCS7784 Slow IrDA Adapter
@@ -2409,6 +2412,7 @@ product MUSTEK DV2000		0xc441	DV2000 dig
 
 /* National Instruments */
 product NI GPIB_USB_A		0xc920	GPIB-USB-A
+product NI HTOH_7825		0x7825	Host to Host Adapter
 
 /* National Semiconductor */
 product NATIONAL BEARPAW1200	0x1000	BearPaw 1200
@@ -2752,6 +2756,7 @@ product PROLIFIC PL2303		0x2303	PL2303 S
 product PROLIFIC PL2305		0x2305	Parallel printer adapter
 product PROLIFIC ATAPI4		0x2307	ATAPI-4 Bridge Controller
 product PROLIFIC PL2501		0x2501	PL2501 Host-Host interface
+product PROLIFIC PL25A1		0x25a1	PL25A1 Host-Host interface
 product PROLIFIC PL2303X	0xaaa0	PL2303 Serial adapter (Pharos GPS)
 product PROLIFIC RSAQ3		0xaaa2	PL2303 Serial adapter (IODATA USB-RSAQ3)
 product PROLIFIC2 PL2303	0x2303	PL2303 Serial adapter (SMART Technologies)
@@ -3064,6 +3069,9 @@ product SIGMATEL I_BEAD150	0x8009	i-Bead
 product SIGMATEL DNSSF7X	0x8020	Datum Networks SSF-7X Multi Players
 product SIGMATEL MUSICSTICK	0x8134	TrekStor Musicstick
 
+/* Allied Telesyn products */
+product ALLIEDTELESYN AT_USB10	0x07c9	AT-USB10 USB Ethernet Adapter
+
 /* SIIG products */
 product SIIG DIGIFILMREADER	0x0004	DigiFilm-Combo Reader
 product SIIG UISDMC2S		0x0200	MULTICARDREADER
@@ -3109,6 +3117,7 @@ product SITECOM CN104		0x2068	CN104 seri
 /* Sitecom Europe products */
 product SITECOMEU WL168V1	0x000d	WL-168 v1
 product SITECOMEU RT2870_1	0x0017	RT2870
+product SITECOMEU LN030		0x0021	LN-030
 product SITECOMEU WL168V4	0x0028	WL-168 v4
 product SITECOMEU RT2870_2	0x002b	RT2870
 product SITECOMEU RT2870_3	0x002c	RT2870



CVS commit: [netbsd-9] src/sys/dev/usb

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:55:36 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: usbdevs.h usbdevs_data.h

Log Message:
regen for ticket #111


To generate a diff of this commit:
cvs rdiff -u -r1.760 -r1.760.4.1 src/sys/dev/usb/usbdevs.h \
src/sys/dev/usb/usbdevs_data.h

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:58:19 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by mrg in ticket #112):

sys/dev/pci/pcidevs: revision 1.1384

add micron/crucial SM2263 nvme.
add some device found on asus x570-p with ryzen 3200G cpu.
spell it "PCIe' when using the name.


To generate a diff of this commit:
cvs rdiff -u -r1.1383 -r1.1383.2.1 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1383 src/sys/dev/pci/pcidevs:1.1383.2.1
--- src/sys/dev/pci/pcidevs:1.1383	Sun Jul 28 15:20:22 2019
+++ src/sys/dev/pci/pcidevs	Mon Aug 26 13:58:19 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1383 2019/07/28 15:20:22 mlelstv Exp $
+$NetBSD: pcidevs,v 1.1383.2.1 2019/08/26 13:58:19 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -686,6 +686,7 @@ vendor ADP2		0x9005	Adaptec (2nd PCI Ven
 vendor ATRONICS		0x907f	Atronics
 vendor NETMOS		0x9710	Netmos
 vendor PARALLELS	0x	Parallels	
+vendor MICRON		0xc0a9	Micron/Crucial Technology
 vendor CHRYSALIS	0xcafe	Chrysalis-ITS
 vendor MIDDLE_DIGITAL	0xdeaf	Middle Digital
 vendor ARC		0xedd8	ARC Logic
@@ -963,10 +964,10 @@ product AMAZON NVME	0x8061	NVMe SSD
 product AMAZON ENA	0xec20	Elastic Network Adapter
 
 /* AMD products */
-product AMD AMD64_HT	0x1100	K8 AMD64 HyperTransport Configuration
-product AMD AMD64_ADDR	0x1101	K8 AMD64 Address Map Configuration
-product AMD AMD64_DRAM	0x1102	K8 AMD64 DRAM Configuration
-product AMD AMD64_MISC	0x1103	K8 AMD64 Miscellaneous Configuration
+product AMD AMD64_HT		0x1100	K8 AMD64 HyperTransport Configuration
+product AMD AMD64_ADDR		0x1101	K8 AMD64 Address Map Configuration
+product AMD AMD64_DRAM		0x1102	K8 AMD64 DRAM Configuration
+product AMD AMD64_MISC		0x1103	K8 AMD64 Miscellaneous Configuration
 product AMD AMD64_F10_HT	0x1200	AMD64 Family10h HyperTransport Configuration
 product AMD AMD64_F10_ADDR	0x1201	AMD64 Family10h Address Map Configuration
 product AMD AMD64_F10_DRAM	0x1202	AMD64 Family10h DRAM Configuration
@@ -977,140 +978,145 @@ product AMD AMD64_F11_ADDR	0x1301	AMD64 
 product AMD AMD64_F11_DRAM	0x1302	AMD64 Family11h DRAM Configuration
 product AMD AMD64_F11_MISC	0x1303	AMD64 Family11h Miscellaneous Configuration
 product AMD AMD64_F11_LINK	0x1304	AMD64 Family11h Link Configuration
-product AMD F15_10_PF_0	0x1400	Family15h Processor Function 0
-product AMD F15_10_PF_1	0x1401	Family15h Processor Function 1
-product AMD F15_10_PF_2	0x1402	Family15h Processor Function 2
-product AMD F15_10_PF_3	0x1403	Family15h Processor Function 3
-product AMD F15_10_PF_4	0x1404	Family15h Processor Function 4
-product AMD F15_10_PF_5	0x1405	Family15h Processor Function 5
-product AMD F15_10_RC	0x1410	Family15h Root Complex
-product AMD F15_10_RP_2	0x1412	Family15h Root Port
-product AMD F15_10_RP_3	0x1413	Family15h Root Port
-product AMD F15_10_RP_4	0x1414	Family15h Root Port
-product AMD F15_10_RP_5	0x1415	Family15h Root Port
-product AMD F15_10_RP_6	0x1416	Family15h Root Port
-product AMD F15_10_RP_7	0x1417	Family15h Root Port
-product AMD F15_10_RP_8	0x1418	Family15h Root Port
+product AMD F15_10_PF_0		0x1400	Family15h Processor Function 0
+product AMD F15_10_PF_1		0x1401	Family15h Processor Function 1
+product AMD F15_10_PF_2		0x1402	Family15h Processor Function 2
+product AMD F15_10_PF_3		0x1403	Family15h Processor Function 3
+product AMD F15_10_PF_4		0x1404	Family15h Processor Function 4
+product AMD F15_10_PF_5		0x1405	Family15h Processor Function 5
+product AMD F15_10_RC		0x1410	Family15h Root Complex
+product AMD F15_10_RP_2		0x1412	Family15h Root Port
+product AMD F15_10_RP_3		0x1413	Family15h Root Port
+product AMD F15_10_RP_4		0x1414	Family15h Root Port
+product AMD F15_10_RP_5		0x1415	Family15h Root Port
+product AMD F15_10_RP_6		0x1416	Family15h Root Port
+product AMD F15_10_RP_7		0x1417	Family15h Root Port
+product AMD F15_10_RP_8		0x1418	Family15h Root Port
 product AMD F15_10_IOMMU	0x1419	Family15h IOMMU
-product AMD F15_30_PF_0	0x141a	Family15h Processor Function 0
-product AMD F15_30_PF_1	0x141b	Family15h Processor Function 1
-product AMD F15_30_PF_2	0x141c	Family15h Processor Function 2
-product AMD F15_30_PF_3	0x141d	Family15h Processor Function 3
-product AMD F15_30_PF_4	0x141e	Family15h Processor Function 4
-product AMD F15_30_PF_5	0x141f	Family15h Processor Function 5
-product AMD F15_30_RC	0x1422	Family15h Root Complex
+product AMD F15_30_PF_0		0x141a	Family15h Processor Function 0
+product AMD F15_30_PF_1		0x141b	Family15h Processor Function 1
+product AMD F15_30_PF_2		0x141c	Family15h Processor Function 2
+product AMD F15_30_PF_3		0x141d	Family15h Processor Function 3
+product AMD F15_30_PF_4		0x141e	Family15h Processor Function 4
+product AMD F15_30_PF_5		0x141f	Family15h Processor Functi

CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:58:19 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by mrg in ticket #112):

sys/dev/pci/pcidevs: revision 1.1384

add micron/crucial SM2263 nvme.
add some device found on asus x570-p with ryzen 3200G cpu.
spell it "PCIe' when using the name.


To generate a diff of this commit:
cvs rdiff -u -r1.1383 -r1.1383.2.1 src/sys/dev/pci/pcidevs

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:59:47 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #112


To generate a diff of this commit:
cvs rdiff -u -r1.1371 -r1.1371.2.1 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370 -r1.1370.2.1 src/sys/dev/pci/pcidevs_data.h

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

diffs are larger than 1MB and have been omitted


CVS commit: [netbsd-9] src/sys/dev/pci

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 13:59:47 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
Regen for ticket #112


To generate a diff of this commit:
cvs rdiff -u -r1.1371 -r1.1371.2.1 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370 -r1.1370.2.1 src/sys/dev/pci/pcidevs_data.h

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



CVS commit: [netbsd-9] src/sys/dev/sysmon

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 14:13:42 UTC 2019

Modified Files:
src/sys/dev/sysmon [netbsd-9]: sysmon.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #118):

sys/dev/sysmon/sysmon.c: revision 1.30

Module class of sysmon_envsys, sysmon_wdog and sysmon_power is
MODULE_CLASS_DRIVER, not MODULE_CLASS_MISC.

Fix that invoking envsys without sysmon_envsys kernel module failes with:
WARNING: module error: incompatible module class for `sysmon_envsys' (1 != 3)


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/dev/sysmon/sysmon.c

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



CVS commit: [netbsd-9] src/sys/dev/sysmon

2019-08-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Aug 26 14:13:42 UTC 2019

Modified Files:
src/sys/dev/sysmon [netbsd-9]: sysmon.c

Log Message:
Pull up following revision(s) (requested by nakayama in ticket #118):

sys/dev/sysmon/sysmon.c: revision 1.30

Module class of sysmon_envsys, sysmon_wdog and sysmon_power is
MODULE_CLASS_DRIVER, not MODULE_CLASS_MISC.

Fix that invoking envsys without sysmon_envsys kernel module failes with:
WARNING: module error: incompatible module class for `sysmon_envsys' (1 != 3)


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.29.2.1 src/sys/dev/sysmon/sysmon.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/sysmon/sysmon.c
diff -u src/sys/dev/sysmon/sysmon.c:1.29 src/sys/dev/sysmon/sysmon.c:1.29.2.1
--- src/sys/dev/sysmon/sysmon.c:1.29	Fri Apr 26 08:38:25 2019
+++ src/sys/dev/sysmon/sysmon.c	Mon Aug 26 14:13:42 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon.c,v 1.29 2019/04/26 08:38:25 pgoyette Exp $	*/
+/*	$NetBSD: sysmon.c,v 1.29.2.1 2019/08/26 14:13:42 martin Exp $	*/
 
 /*-
  * Copyright (c) 2000 Zembu Labs, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.29 2019/04/26 08:38:25 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.29.2.1 2019/08/26 14:13:42 martin Exp $");
 
 #include 
 #include 
@@ -151,7 +151,7 @@ sysmonopen(dev_t dev, int flag, int mode
 		if (sysmon_opvec_table[minor(dev)] == NULL) {
 			mutex_exit(&sysmon_minor_mtx);
 			error = module_autoload(sysmon_mod[minor(dev)],
-		MODULE_CLASS_MISC);
+			MODULE_CLASS_DRIVER);
 			if (error)
 return error;
 			mutex_enter(&sysmon_minor_mtx);



CVS commit: [netbsd-9] src/sys/dev/sysmon

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 10:57:53 UTC 2019

Modified Files:
src/sys/dev/sysmon [netbsd-9]: sysmon_power.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #128):

sys/dev/sysmon/sysmon_power.c: revision 1.61

Fix info leak, not all of 'pev' is initialized.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.4.1 src/sys/dev/sysmon/sysmon_power.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/sysmon/sysmon_power.c
diff -u src/sys/dev/sysmon/sysmon_power.c:1.60 src/sys/dev/sysmon/sysmon_power.c:1.60.4.1
--- src/sys/dev/sysmon/sysmon_power.c:1.60	Fri Mar  1 11:06:56 2019
+++ src/sys/dev/sysmon/sysmon_power.c	Sun Sep  1 10:57:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_power.c,v 1.60 2019/03/01 11:06:56 pgoyette Exp $	*/
+/*	$NetBSD: sysmon_power.c,v 1.60.4.1 2019/09/01 10:57:53 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.60 2019/03/01 11:06:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.60.4.1 2019/09/01 10:57:53 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -331,6 +331,8 @@ sysmon_power_daemon_task(struct power_ev
 	if (!ped || !ped->dict || !pev_data)
 		return EINVAL;
 
+	memset(&pev, 0, sizeof(pev));
+
 	mutex_enter(&sysmon_power_event_queue_mtx);
 	
 	switch (event) {



CVS commit: [netbsd-9] src/sys/dev/sysmon

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 10:57:53 UTC 2019

Modified Files:
src/sys/dev/sysmon [netbsd-9]: sysmon_power.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #128):

sys/dev/sysmon/sysmon_power.c: revision 1.61

Fix info leak, not all of 'pev' is initialized.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.4.1 src/sys/dev/sysmon/sysmon_power.c

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



CVS commit: [netbsd-9] src/sys/dev/mii

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 13:56:01 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-9]: etphy.c miidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #144):

sys/dev/mii/miidevs: revision 1.154
sys/dev/mii/etphy.c: revision 1.5
sys/dev/mii/etphy.c: revision 1.6

No functional change:
 - Use static.
 - KNF.

>From FreeBSD:
 - Rename ET1011 to ET1011C
 - Add ET1011

>From FreeBSD:
- Support ET1011.
- Use mii_phy_flowstatus() to reflect flow status from negotiated result.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/dev/mii/etphy.c
cvs rdiff -u -r1.153 -r1.153.2.1 src/sys/dev/mii/miidevs

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/mii/etphy.c
diff -u src/sys/dev/mii/etphy.c:1.4 src/sys/dev/mii/etphy.c:1.4.4.1
--- src/sys/dev/mii/etphy.c:1.4	Mon Mar 25 09:29:08 2019
+++ src/sys/dev/mii/etphy.c	Sun Sep  1 13:56:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: etphy.c,v 1.4 2019/03/25 09:29:08 msaitoh Exp $	*/
+/*	$NetBSD: etphy.c,v 1.4.4.1 2019/09/01 13:56:01 martin Exp $	*/
 /*	$OpenBSD: etphy.c,v 1.4 2008/04/02 20:12:58 brad Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.4 2019/03/25 09:29:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.4.4.1 2019/09/01 13:56:01 martin Exp $");
 
 #include 
 #include 
@@ -77,18 +77,19 @@ __KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.
 #define ETPHY_SR_FDX		0x0080
 
 
-int	etphy_service(struct mii_softc *, struct mii_data *, int);
-void	etphy_attach(device_t, device_t, void *);
-int	etphy_match(device_t, cfdata_t, void *);
-void	etphy_reset(struct mii_softc *);
-void	etphy_status(struct mii_softc *);
+static int	etphy_service(struct mii_softc *, struct mii_data *, int);
+static void	etphy_attach(device_t, device_t, void *);
+static int	etphy_match(device_t, cfdata_t, void *);
+static void	etphy_reset(struct mii_softc *);
+static void	etphy_status(struct mii_softc *);
 
-const struct mii_phy_funcs etphy_funcs = {
+static const struct mii_phy_funcs etphy_funcs = {
 	etphy_service, etphy_status, etphy_reset,
 };
 
 static const struct mii_phydesc etphys[] = {
 	MII_PHY_DESC(AGERE, ET1011),
+	MII_PHY_DESC(AGERE, ET1011C),
 	MII_PHY_END,
 };
 
@@ -133,7 +134,7 @@ static const struct etphy_dsp {
 	{ 0x8010,	46 }	/* IdlguardTime */
 };
 
-int
+static int
 etphy_match(device_t parent, cfdata_t match, void *aux)
 {
 	struct mii_attach_args *ma = aux;
@@ -144,7 +145,7 @@ etphy_match(device_t parent, cfdata_t ma
 	return 0;
 }
 
-void
+static void
 etphy_attach(device_t parent, device_t self, void *aux)
 {
 	struct mii_softc *sc = device_private(self);
@@ -185,7 +186,7 @@ etphy_attach(device_t parent, device_t s
 		aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
-int
+static int
 etphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
 {
 	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
@@ -229,7 +230,7 @@ etphy_service(struct mii_softc *sc, stru
 
 			if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) {
 PHY_WRITE(sc, MII_BMCR,
-	  bmcr | BMCR_AUTOEN | BMCR_STARTNEG);
+bmcr | BMCR_AUTOEN | BMCR_STARTNEG);
 			}
 		}
 		break;
@@ -252,19 +253,23 @@ etphy_service(struct mii_softc *sc, stru
 	return 0;
 }
 
-void
+static void
 etphy_reset(struct mii_softc *sc)
 {
 	uint16_t reg;
 	int i;
 
+	if (sc->mii_mpd_model == MII_MODEL_AGERE_ET1011) {
+		mii_phy_reset(sc);
+		return;
+	}
+
 	for (i = 0; i < 2; ++i) {
 		PHY_READ(sc, MII_PHYIDR1, ®);
 		PHY_READ(sc, MII_PHYIDR2, ®);
 
 		PHY_READ(sc, ETPHY_CTRL, ®);
-		PHY_WRITE(sc, ETPHY_CTRL,
-		ETPHY_CTRL_DIAG | ETPHY_CTRL_RSV1);
+		PHY_WRITE(sc, ETPHY_CTRL, ETPHY_CTRL_DIAG | ETPHY_CTRL_RSV1);
 
 		PHY_WRITE(sc, ETPHY_INDEX, ETPHY_INDEX_MAGIC);
 		PHY_READ(sc, ETPHY_DATA, ®);
@@ -294,13 +299,13 @@ etphy_reset(struct mii_softc *sc)
 
 	PHY_READ(sc, MII_BMCR, ®);
 	PHY_READ(sc, ETPHY_CTRL, ®);
-	PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN |  BMCR_S1000);
+	PHY_WRITE(sc, MII_BMCR, BMCR_AUTOEN | BMCR_S1000);
 	PHY_WRITE(sc, ETPHY_CTRL, ETPHY_CTRL_RSV1);
 
 	mii_phy_reset(sc);
 }
 
-void
+static void
 etphy_status(struct mii_softc *sc)
 {
 	struct mii_data *mii = sc->mii_pdata;
@@ -340,7 +345,7 @@ etphy_status(struct mii_softc *sc)
 	}
 
 	if (sr & ETPHY_SR_FDX)
-		mii->mii_media_active |= IFM_FDX;
+		mii->mii_media_active |= IFM_FDX | mii_phy_flowstatus(sc);
 	else
 		mii->mii_media_active |= IFM_HDX;
 }

Index: src/sys/dev/mii/miidevs
diff -u src/sys/dev/mii/miidevs:1.153 src/sys/dev/mii/miidevs:1.153.2.1
--- src/sys/dev/mii/miidevs:1.153	Thu Jun  6 16:04:13 2019
+++ src/sys/dev/mii/miidevs	Sun Sep  1 13:56:01 2019
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.153 2019/06/06 16:04:13 thorpej Exp $
+$NetBSD: miidevs,v 1.153.2.1 2019/09/01 13:56:01 martin Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -124,7 +124,

CVS commit: [netbsd-9] src/sys/dev/mii

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 13:56:01 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-9]: etphy.c miidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #144):

sys/dev/mii/miidevs: revision 1.154
sys/dev/mii/etphy.c: revision 1.5
sys/dev/mii/etphy.c: revision 1.6

No functional change:
 - Use static.
 - KNF.

>From FreeBSD:
 - Rename ET1011 to ET1011C
 - Add ET1011

>From FreeBSD:
- Support ET1011.
- Use mii_phy_flowstatus() to reflect flow status from negotiated result.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.4.1 src/sys/dev/mii/etphy.c
cvs rdiff -u -r1.153 -r1.153.2.1 src/sys/dev/mii/miidevs

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep  2 07:02:34 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: if_aue.c

Log Message:
Ticket #135: something went wrong in the pullup process for this file
(likely overlooked conflict with previously applied rev. 156).
So now actually sync this up to rev 1.161, as the last pullup claimed


To generate a diff of this commit:
cvs rdiff -u -r1.154.2.1 -r1.154.2.2 src/sys/dev/usb/if_aue.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_aue.c
diff -u src/sys/dev/usb/if_aue.c:1.154.2.1 src/sys/dev/usb/if_aue.c:1.154.2.2
--- src/sys/dev/usb/if_aue.c:1.154.2.1	Fri Aug  9 16:15:06 2019
+++ src/sys/dev/usb/if_aue.c	Mon Sep  2 07:02:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aue.c,v 1.154.2.1 2019/08/09 16:15:06 martin Exp $	*/
+/*	$NetBSD: if_aue.c,v 1.154.2.2 2019/09/02 07:02:34 martin Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -70,14 +70,13 @@
 /*
  * TODO:
  * better error messages from rxstat
- * split out if_auevar.h
  * more error checks
  * investigate short rx problem
  * proper cleanup on errors
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.154.2.1 2019/08/09 16:15:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.154.2.2 2019/09/02 07:02:34 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -85,51 +84,75 @@ __KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1
 #endif
 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
 
-#include 
+#include 
+#include 
+#include 
 
-#include 
 #ifdef INET
 #include 
 #include 
 #endif
 
+#ifdef USB_DEBUG
+#ifndef AUE_DEBUG
+#define auedebug 0
+#else
+static int auedebug = 10;
 
+SYSCTL_SETUP(sysctl_hw_aue_setup, "sysctl hw.aue setup")
+{
+	int err;
+	const struct sysctlnode *rnode;
+	const struct sysctlnode *cnode;
+
+	err = sysctl_createv(clog, 0, NULL, &rnode,
+	CTLFLAG_PERMANENT, CTLTYPE_NODE, "aue",
+	SYSCTL_DESCR("aue global controls"),
+	NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+	if (err)
+		goto fail;
+
+	/* control debugging printfs */
+	err = sysctl_createv(clog, 0, &rnode, &cnode,
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE, CTLTYPE_INT,
+	"debug", SYSCTL_DESCR("Enable debugging output"),
+	NULL, 0, &auedebug, sizeof(auedebug), CTL_CREATE, CTL_EOL);
+	if (err)
+		goto fail;
 
-#include 
-#include 
-
-#include 
-#include 
-#include 
-#include 
+	return;
+fail:
+	aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
 
-#include 
-#include 
+#endif /* AXE_DEBUG */
+#endif /* USB_DEBUG */
 
-#include 
+#define DPRINTF(FMT,A,B,C,D)	USBHIST_LOGN(auedebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D)	USBHIST_LOGN(auedebug,N,FMT,A,B,C,D)
+#define AUEHIST_FUNC()		USBHIST_FUNC()
+#define AUEHIST_CALLED(name)	USBHIST_CALLED(auedebug)
+#define AUEHIST_CALLARGS(FMT,A,B,C,D) \
+USBHIST_CALLARGS(auedebug,FMT,A,B,C,D)
+#define AUEHIST_CALLARGSN(N,FMT,A,B,C,D) \
+USBHIST_CALLARGSN(auedebug,N,FMT,A,B,C,D)
+
+#define AUE_TX_LIST_CNT		1
+#define AUE_RX_LIST_CNT		1
+
+struct aue_softc {
+	struct usbnet		aue_un;
+	struct usbnet_intr	aue_intr;
+	struct aue_intrpkt	aue_ibuf;
+};
 
-#ifdef AUE_DEBUG
-#define DPRINTF(x)	if (auedebug) printf x
-#define DPRINTFN(n, x)	if (auedebug >= (n)) printf x
-int	auedebug = 0;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n, x)
-#endif
+#define AUE_TIMEOUT		1000
+#define AUE_BUFSZ		1536
+#define AUE_MIN_FRAMELEN	60
+#define AUE_TX_TIMEOUT		1 /* ms */
+#define AUE_INTR_INTERVAL	100 /* ms */
 
 /*
  * Various supported device vendors/products.
@@ -142,7 +165,7 @@ struct aue_type {
 #define PII	0x0004		/* Pegasus II chip */
 };
 
-Static const struct aue_type aue_devs[] = {
+static const struct aue_type aue_devs[] = {
  {{ USB_VENDOR_3COM,		USB_PRODUCT_3COM_3C460B},	  PII },
  {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX1},	  PNA | PII },
  {{ USB_VENDOR_ABOCOM,		USB_PRODUCT_ABOCOM_XX2},	  PII },
@@ -210,49 +233,42 @@ Static const struct aue_type aue_devs[] 
 
 int aue_match(device_t, cfdata_t, void *);
 void aue_attach(device_t, device_t, void *);
-int aue_detach(device_t, int);
-int aue_activate(device_t, enum devact);
 
 CFATTACH_DECL_NEW(aue, sizeof(struct aue_softc), aue_match, aue_attach,
-aue_detach, aue_activate);
+usbnet_detach, usbnet_activate);
+
+static void aue_reset_pegasus_II(struct aue_softc *);
 
-Static void aue_multithread(void *);
+static void aue_stop_cb(struct ifnet *, int);
+static int aue_ioctl_cb(struct ifnet *, u_long, void *);
+static int aue_mii_read_reg(struct usbnet *, int, int, uint16_t *);
+static int aue_mii_write_reg(struct usbnet *, int, int, uint16_t);
+static void aue_mii_statchg(struct ifnet *);
+static unsigned aue_tx_prepare(struct usbnet *, struct mbuf *,
+			   struct usbnet_chain *);
+static void aue_rx_loop(struct usbnet *, s

CVS commit: [netbsd-9] src/sys/dev/usb

2019-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep  2 07:02:34 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: if_aue.c

Log Message:
Ticket #135: something went wrong in the pullup process for this file
(likely overlooked conflict with previously applied rev. 156).
So now actually sync this up to rev 1.161, as the last pullup claimed


To generate a diff of this commit:
cvs rdiff -u -r1.154.2.1 -r1.154.2.2 src/sys/dev/usb/if_aue.c

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



CVS commit: [netbsd-9] src/sys/dev/mii

2019-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep  2 07:06:11 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-9]: miidevs.h miidevs_data.h

Log Message:
regen (for ticket #144, also requested in ticket #171)


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.151.2.1 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.139 -r1.139.2.1 src/sys/dev/mii/miidevs_data.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/mii/miidevs.h
diff -u src/sys/dev/mii/miidevs.h:1.151 src/sys/dev/mii/miidevs.h:1.151.2.1
--- src/sys/dev/mii/miidevs.h:1.151	Thu Jun  6 16:05:45 2019
+++ src/sys/dev/mii/miidevs.h	Mon Sep  2 07:06:11 2019
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.151 2019/06/06 16:05:45 thorpej Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.151.2.1 2019/09/02 07:06:11 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.153 2019/06/06 16:04:13 thorpej Exp
+ *	NetBSD: miidevs,v 1.153.2.1 2019/09/01 13:56:01 martin Exp
  */
 
 /*-
@@ -131,8 +131,10 @@
 /*
  * Agere PHYs
  */
-#define	MII_MODEL_AGERE_ET1011	0x0004
-#define	MII_STR_AGERE_ET1011	"Agere ET1011 10/100/1000baseT PHY"
+#define	MII_MODEL_AGERE_ET1011	0x0001
+#define	MII_STR_AGERE_ET1011	"ET1011 10/100/1000baseT PHY"
+#define	MII_MODEL_AGERE_ET1011C	0x0004
+#define	MII_STR_AGERE_ET1011C	"ET1011C 10/100/1000baseT PHY"
 
 /* Asix semiconductor PHYs */
 #define	MII_MODEL_xxASIX_AX88X9X	0x0031

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.139 src/sys/dev/mii/miidevs_data.h:1.139.2.1
--- src/sys/dev/mii/miidevs_data.h:1.139	Thu Jun  6 16:05:45 2019
+++ src/sys/dev/mii/miidevs_data.h	Mon Sep  2 07:06:11 2019
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.139 2019/06/06 16:05:45 thorpej Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.139.2.1 2019/09/02 07:06:11 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.153 2019/06/06 16:04:13 thorpej Exp
+ *	NetBSD: miidevs,v 1.153.2.1 2019/09/01 13:56:01 martin Exp
  */
 
 /*-
@@ -43,6 +43,7 @@ struct mii_knowndev {
 };
 struct mii_knowndev mii_knowndevs[] = {
  { MII_OUI_AGERE, MII_MODEL_AGERE_ET1011, MII_STR_AGERE_ET1011 },
+ { MII_OUI_AGERE, MII_MODEL_AGERE_ET1011C, MII_STR_AGERE_ET1011C },
  { MII_OUI_xxASIX, MII_MODEL_xxASIX_AX88X9X, MII_STR_xxASIX_AX88X9X },
  { MII_OUI_yyASIX, MII_MODEL_yyASIX_AX88772, MII_STR_yyASIX_AX88772 },
  { MII_OUI_yyASIX, MII_MODEL_yyASIX_AX88772A, MII_STR_yyASIX_AX88772A },



CVS commit: [netbsd-9] src/sys/dev/mii

2019-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep  2 07:06:11 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-9]: miidevs.h miidevs_data.h

Log Message:
regen (for ticket #144, also requested in ticket #171)


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.151.2.1 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.139 -r1.139.2.1 src/sys/dev/mii/miidevs_data.h

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



CVS commit: [netbsd-9] src/sys/dev/ata

2019-09-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  5 09:02:48 UTC 2019

Modified Files:
src/sys/dev/ata [netbsd-9]: satafis_subr.c

Log Message:
Pull up following revision(s) (requested by gson in ticket #179):

sys/dev/ata/satafis_subr.c: revision 1.9

Set the ATAPI "BYTE COUNT LIMIT" field in the SATA case like we
already do in the ATA case, to make NetBSD work with the virtual
SATA CD-ROM of "qemu-system-i386 -machine q35".  Fixes PR kern/54389.

OK mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.10.1 src/sys/dev/ata/satafis_subr.c

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



CVS commit: [netbsd-9] src/sys/dev/ata

2019-09-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  5 09:02:48 UTC 2019

Modified Files:
src/sys/dev/ata [netbsd-9]: satafis_subr.c

Log Message:
Pull up following revision(s) (requested by gson in ticket #179):

sys/dev/ata/satafis_subr.c: revision 1.9

Set the ATAPI "BYTE COUNT LIMIT" field in the SATA case like we
already do in the ATA case, to make NetBSD work with the virtual
SATA CD-ROM of "qemu-system-i386 -machine q35".  Fixes PR kern/54389.

OK mlelstv.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.10.1 src/sys/dev/ata/satafis_subr.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/ata/satafis_subr.c
diff -u src/sys/dev/ata/satafis_subr.c:1.8 src/sys/dev/ata/satafis_subr.c:1.8.10.1
--- src/sys/dev/ata/satafis_subr.c:1.8	Sat Oct  7 16:05:32 2017
+++ src/sys/dev/ata/satafis_subr.c	Thu Sep  5 09:02:48 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: satafis_subr.c,v 1.8 2017/10/07 16:05:32 jdolecek Exp $ */
+/* $NetBSD: satafis_subr.c,v 1.8.10.1 2019/09/05 09:02:48 martin Exp $ */
 
 /*-
  * Copyright (c) 2009 Jonathan A. Kollasch.
@@ -51,7 +51,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.8 2017/10/07 16:05:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: satafis_subr.c,v 1.8.10.1 2019/09/05 09:02:48 martin Exp $");
 
 #include 
 #include 
@@ -149,12 +149,16 @@ satafis_rhd_construct_bio(struct ata_xfe
 void
 satafis_rhd_construct_atapi(struct ata_xfer *xfer, uint8_t *fis)
 {
+	int bcount16;
 
 	memset(fis, 0, RHD_FISLEN);
 
 	fis[fis_type] = RHD_FISTYPE;
 	fis[rhd_c] = RHD_C;
 	fis[rhd_command] = ATAPI_PKT_CMD;
+	bcount16 = xfer->c_bcount <= 0x ? xfer->c_bcount : 0x;
+	fis[rhd_lba1] = (bcount16 >> 0) & 0xff;
+	fis[rhd_lba2] = (bcount16 >> 8) & 0xff;
 	fis[rhd_features0] = (xfer->c_flags & C_DMA) ?
 	ATAPI_PKT_CMD_FTRE_DMA : 0;
 }



CVS commit: [netbsd-9] src/sys/dev/usb

2019-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 06:32:11 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: xhci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #196):

sys/dev/usb/xhci.c: revision 1.111
sys/dev/usb/xhci.c: revision 1.112
sys/dev/usb/xhci.c: revision 1.113
sys/dev/usb/xhci.c: revision 1.114

introduce and use XHCIHIST_CALLARGS().  reduces lots of double logs,
and includes useful info in all cases instead of just "called".
add a couple of more logs that i've wanted while debugging ryzen3
vs USB issues.

fix 32-bit debug build, and also vmstat -y.  reported by sc.dying.

fix ryzen usb issue: we set TD size to '1', where has xhci spec 4.11.2.4
says final TRB for a TD should have this set to '0'.  since we currently
only generate sinel TRB TDs, set this to 0.
from sc.dying

avoid non-debug kernel build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.107.2.2 -r1.107.2.3 src/sys/dev/usb/xhci.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/xhci.c
diff -u src/sys/dev/usb/xhci.c:1.107.2.2 src/sys/dev/usb/xhci.c:1.107.2.3
--- src/sys/dev/usb/xhci.c:1.107.2.2	Sun Sep  1 13:00:37 2019
+++ src/sys/dev/usb/xhci.c	Fri Sep 13 06:32:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: xhci.c,v 1.107.2.2 2019/09/01 13:00:37 martin Exp $	*/
+/*	$NetBSD: xhci.c,v 1.107.2.3 2019/09/13 06:32:11 martin Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.2 2019/09/01 13:00:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.107.2.3 2019/09/13 06:32:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -114,9 +114,12 @@ fail:
 #define HEXDUMP(a, b, c)
 #endif
 
-#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGN(xhcidebug,N,FMT,A,B,C,D)
-#define XHCIHIST_FUNC() USBHIST_FUNC()
-#define XHCIHIST_CALLED(name) USBHIST_CALLED(xhcidebug)
+#define DPRINTF(FMT,A,B,C,D)	USBHIST_LOG(xhcidebug,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D)	USBHIST_LOGN(xhcidebug,N,FMT,A,B,C,D)
+#define XHCIHIST_FUNC()		USBHIST_FUNC()
+#define XHCIHIST_CALLED(name)	USBHIST_CALLED(xhcidebug)
+#define XHCIHIST_CALLARGS(FMT,A,B,C,D) \
+USBHIST_CALLARGS(xhcidebug,FMT,A,B,C,D)
 
 #define XHCI_DCI_SLOT 0
 #define XHCI_DCI_EP_CONTROL 1
@@ -1297,10 +1300,10 @@ xhci_intr1(struct xhci_softc * const sc)
 	uint32_t usbsts;
 	uint32_t iman;
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
+	XHCIHIST_FUNC();
 
 	usbsts = xhci_op_read_4(sc, XHCI_USBSTS);
-	DPRINTFN(16, "USBSTS %08jx", usbsts, 0, 0, 0);
+	XHCIHIST_CALLARGS("USBSTS %08jx", usbsts, 0, 0, 0);
 	if ((usbsts & (XHCI_STS_HSE | XHCI_STS_EINT | XHCI_STS_PCD |
 	XHCI_STS_HCE)) == 0) {
 		DPRINTFN(16, "ignored intr not for %s",
@@ -1411,8 +1414,8 @@ xhci_configure_endpoint(struct usbd_pipe
 	struct xhci_soft_trb trb;
 	usbd_status err;
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(4, "slot %ju dci %ju epaddr 0x%02jx attr 0x%02jx",
+	XHCIHIST_FUNC();
+	XHCIHIST_CALLARGS("slot %ju dci %ju epaddr 0x%02jx attr 0x%02jx",
 	xs->xs_idx, dci, pipe->up_endpoint->ue_edesc->bEndpointAddress,
 	pipe->up_endpoint->ue_edesc->bmAttributes);
 
@@ -1450,8 +1453,8 @@ xhci_unconfigure_endpoint(struct usbd_pi
 	struct xhci_slot * const xs = pipe->up_dev->ud_hcpriv;
 #endif
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(4, "slot %ju", xs->xs_idx, 0, 0, 0);
+	XHCIHIST_FUNC();
+	XHCIHIST_CALLARGS("slot %ju", xs->xs_idx, 0, 0, 0);
 
 	return USBD_NORMAL_COMPLETION;
 }
@@ -1467,8 +1470,8 @@ xhci_reset_endpoint_locked(struct usbd_p
 	struct xhci_soft_trb trb;
 	usbd_status err;
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(4, "slot %ju dci %ju", xs->xs_idx, dci, 0, 0);
+	XHCIHIST_FUNC();
+	XHCIHIST_CALLARGS("slot %ju dci %ju", xs->xs_idx, dci, 0, 0);
 
 	KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -1509,8 +1512,8 @@ xhci_stop_endpoint(struct usbd_pipe *pip
 	usbd_status err;
 	const u_int dci = xhci_ep_get_dci(pipe->up_endpoint->ue_edesc);
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(4, "slot %ju dci %ju", xs->xs_idx, dci, 0, 0);
+	XHCIHIST_FUNC();
+	XHCIHIST_CALLARGS("slot %ju dci %ju", xs->xs_idx, dci, 0, 0);
 
 	KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -1543,8 +1546,8 @@ xhci_set_dequeue_locked(struct usbd_pipe
 	struct xhci_soft_trb trb;
 	usbd_status err;
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(4, "slot %ju dci %ju", xs->xs_idx, dci, 0, 0);
+	XHCIHIST_FUNC();
+	XHCIHIST_CALLARGS("slot %ju dci %ju", xs->xs_idx, dci, 0, 0);
 
 	KASSERT(mutex_owned(&sc->sc_lock));
 
@@ -1587,8 +1590,8 @@ xhci_open(struct usbd_pipe *pipe)
 	usb_endpoint_descriptor_t * const ed = pipe->up_endpoint->ue_edesc;
 	const uint8_t xfertype = UE_GET_XFERTYPE(ed->bmAttributes);
 
-	XHCIHIST_FUNC(); XHCIHIST_CALLED();
-	DPRINTFN(1, "addr %jd depth %jd port %jd speed %jd", dev->ud_addr,
+	XHCIHIST_FUNC();
+	XHCIHIST_CALLARGS("ad

CVS commit: [netbsd-9] src/sys/dev/usb

2019-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 06:32:11 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: xhci.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #196):

sys/dev/usb/xhci.c: revision 1.111
sys/dev/usb/xhci.c: revision 1.112
sys/dev/usb/xhci.c: revision 1.113
sys/dev/usb/xhci.c: revision 1.114

introduce and use XHCIHIST_CALLARGS().  reduces lots of double logs,
and includes useful info in all cases instead of just "called".
add a couple of more logs that i've wanted while debugging ryzen3
vs USB issues.

fix 32-bit debug build, and also vmstat -y.  reported by sc.dying.

fix ryzen usb issue: we set TD size to '1', where has xhci spec 4.11.2.4
says final TRB for a TD should have this set to '0'.  since we currently
only generate sinel TRB TDs, set this to 0.
from sc.dying

avoid non-debug kernel build issues.


To generate a diff of this commit:
cvs rdiff -u -r1.107.2.2 -r1.107.2.3 src/sys/dev/usb/xhci.c

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



CVS commit: [netbsd-9] src/sys/dev/usb

2019-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 06:51:59 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: if_upl.c if_url.c if_urndis.c usb_mem.c
usbnet.c usbnet.h

Log Message:
Pull up following revision(s) (requested by mrg in ticket #197):

sys/dev/usb/if_url.c: revision 1.71
sys/dev/usb/usbnet.h: revision 1.15
sys/dev/usb/usb_mem.c: revision 1.72
sys/dev/usb/if_urndis.c: revision 1.24
sys/dev/usb/if_upl.c: revision 1.67
sys/dev/usb/usbnet.c: revision 1.25
sys/dev/usb/usbnet.c: revision 1.26
sys/dev/usb/usbnet.c: revision 1.27
sys/dev/usb/usbnet.c: revision 1.28

Teach urndis to handle some REMOTE_NDIS_INDICATE_STATUS_MSG. If the status
is reasonable, don't tell userland we got an error. Stops spurious EIO.
>From openbsd.

Fix bug, remove {0,0} because we switched to usb_lookup().

s/no free/no freelist entry/ in a debug message.

fix a lock hang reported by sc.dying in PR#54495.

remove locking in usbnet_tick().  assume that all locking
needs are handled inside usbnet_tick_task(), which runs in
the usbtask thread.  ensure that usbnet private is valid
before using it.

also check NULL private pointer in usbnet_isdying().
all the other cases should never happen.

don't try to set dying when we haven't usbnet_attach()d yet.
reported by maxv.

- use CALLARGS vs CALLED for better usbhist
- turn off usbnetdebug default
- log for all entry/exit points of usbnet_pipe_intr()
- in usbnet_start_locked() track whether any packet has been
  transmitted for setting the timer.  avoids spurious
  "watchdog timeouts"
- in usbnet_stop() use callout_halt() vs callout_halt, and
  also stop the usb task.  fixes crash of usbtask after the
  phy has detached.
- add a little more defensive checking in the tick task, and
  add some high-log-level logs.
- in usbnet_detach() move the call to usbnet_stop_ifp() above
  the calls to callout/usbtask stopping.
- set ec_mii and unp_pri to NULL when freeing their data

normalise an error message.

document usbnet_private locking.  minor knf.


To generate a diff of this commit:
cvs rdiff -u -r1.64.2.1 -r1.64.2.2 src/sys/dev/usb/if_upl.c
cvs rdiff -u -r1.66.2.1 -r1.66.2.2 src/sys/dev/usb/if_url.c
cvs rdiff -u -r1.21.4.1 -r1.21.4.2 src/sys/dev/usb/if_urndis.c
cvs rdiff -u -r1.70.10.1 -r1.70.10.2 src/sys/dev/usb/usb_mem.c
cvs rdiff -u -r1.25.2.2 -r1.25.2.3 src/sys/dev/usb/usbnet.c
cvs rdiff -u -r1.14.2.2 -r1.14.2.3 src/sys/dev/usb/usbnet.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/usb/if_upl.c
diff -u src/sys/dev/usb/if_upl.c:1.64.2.1 src/sys/dev/usb/if_upl.c:1.64.2.2
--- src/sys/dev/usb/if_upl.c:1.64.2.1	Sun Sep  1 13:00:36 2019
+++ src/sys/dev/usb/if_upl.c	Fri Sep 13 06:51:58 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_upl.c,v 1.64.2.1 2019/09/01 13:00:36 martin Exp $	*/
+/*	$NetBSD: if_upl.c,v 1.64.2.2 2019/09/13 06:51:58 martin Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.64.2.1 2019/09/01 13:00:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.64.2.2 2019/09/13 06:51:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -95,8 +95,7 @@ static struct usb_devno sc_devs[] = {
 	{ USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL2302 },
 	{ USB_VENDOR_PROLIFIC, USB_PRODUCT_PROLIFIC_PL25A1 },
 	{ USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_F5U258 },
-	{ USB_VENDOR_NI, USB_PRODUCT_NI_HTOH_7825 },
-	{ 0, 0 }
+	{ USB_VENDOR_NI, USB_PRODUCT_NI_HTOH_7825 }
 };
 
 int	upl_match(device_t, cfdata_t, void *);

Index: src/sys/dev/usb/if_url.c
diff -u src/sys/dev/usb/if_url.c:1.66.2.1 src/sys/dev/usb/if_url.c:1.66.2.2
--- src/sys/dev/usb/if_url.c:1.66.2.1	Sun Sep  1 13:00:36 2019
+++ src/sys/dev/usb/if_url.c	Fri Sep 13 06:51:58 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_url.c,v 1.66.2.1 2019/09/01 13:00:36 martin Exp $	*/
+/*	$NetBSD: if_url.c,v 1.66.2.2 2019/09/13 06:51:58 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.66.2.1 2019/09/01 13:00:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.66.2.2 2019/09/13 06:51:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -190,7 +190,7 @@ url_attach(device_t parent, device_t sel
 	if (err) {
 		aprint_error_dev(self, "failed to set configuration"
 		", err=%s\n", usbd_errstr(err));
-		goto bad;
+		return;
 	}
 
 	/* get control interface */
@@ -198,7 +198,7 @@ url_attach(device_t parent, device_t sel
 	if (err) {
 		aprint_error_dev(self, "failed to get interface, err=%s\n",
 		   usbd_errstr(err));
-		goto bad;
+		return;
 	}
 
 	un->un_iface = iface;
@@ -221,7 +221,7 @@ url_attach(device_t parent, device_t sel
 		if (ed == NULL) {
 			aprint_error_dev(self,
 			"couldn't get endpoint %d\n", i);
-			goto bad;
+			retu

CVS commit: [netbsd-9] src/sys/dev/usb

2019-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Sep 13 06:51:59 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-9]: if_upl.c if_url.c if_urndis.c usb_mem.c
usbnet.c usbnet.h

Log Message:
Pull up following revision(s) (requested by mrg in ticket #197):

sys/dev/usb/if_url.c: revision 1.71
sys/dev/usb/usbnet.h: revision 1.15
sys/dev/usb/usb_mem.c: revision 1.72
sys/dev/usb/if_urndis.c: revision 1.24
sys/dev/usb/if_upl.c: revision 1.67
sys/dev/usb/usbnet.c: revision 1.25
sys/dev/usb/usbnet.c: revision 1.26
sys/dev/usb/usbnet.c: revision 1.27
sys/dev/usb/usbnet.c: revision 1.28

Teach urndis to handle some REMOTE_NDIS_INDICATE_STATUS_MSG. If the status
is reasonable, don't tell userland we got an error. Stops spurious EIO.
>From openbsd.

Fix bug, remove {0,0} because we switched to usb_lookup().

s/no free/no freelist entry/ in a debug message.

fix a lock hang reported by sc.dying in PR#54495.

remove locking in usbnet_tick().  assume that all locking
needs are handled inside usbnet_tick_task(), which runs in
the usbtask thread.  ensure that usbnet private is valid
before using it.

also check NULL private pointer in usbnet_isdying().
all the other cases should never happen.

don't try to set dying when we haven't usbnet_attach()d yet.
reported by maxv.

- use CALLARGS vs CALLED for better usbhist
- turn off usbnetdebug default
- log for all entry/exit points of usbnet_pipe_intr()
- in usbnet_start_locked() track whether any packet has been
  transmitted for setting the timer.  avoids spurious
  "watchdog timeouts"
- in usbnet_stop() use callout_halt() vs callout_halt, and
  also stop the usb task.  fixes crash of usbtask after the
  phy has detached.
- add a little more defensive checking in the tick task, and
  add some high-log-level logs.
- in usbnet_detach() move the call to usbnet_stop_ifp() above
  the calls to callout/usbtask stopping.
- set ec_mii and unp_pri to NULL when freeing their data

normalise an error message.

document usbnet_private locking.  minor knf.


To generate a diff of this commit:
cvs rdiff -u -r1.64.2.1 -r1.64.2.2 src/sys/dev/usb/if_upl.c
cvs rdiff -u -r1.66.2.1 -r1.66.2.2 src/sys/dev/usb/if_url.c
cvs rdiff -u -r1.21.4.1 -r1.21.4.2 src/sys/dev/usb/if_urndis.c
cvs rdiff -u -r1.70.10.1 -r1.70.10.2 src/sys/dev/usb/usb_mem.c
cvs rdiff -u -r1.25.2.2 -r1.25.2.3 src/sys/dev/usb/usbnet.c
cvs rdiff -u -r1.14.2.2 -r1.14.2.3 src/sys/dev/usb/usbnet.h

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:13:33 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: i82557.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #217):

sys/dev/ic/i82557.c: revision 1.155

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/ic/i82557.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/i82557.c
diff -u src/sys/dev/ic/i82557.c:1.154 src/sys/dev/ic/i82557.c:1.154.2.1
--- src/sys/dev/ic/i82557.c:1.154	Tue Jul  9 08:46:58 2019
+++ src/sys/dev/ic/i82557.c	Sun Sep 22 12:13:33 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: i82557.c,v 1.154 2019/07/09 08:46:58 msaitoh Exp $	*/
+/*	$NetBSD: i82557.c,v 1.154.2.1 2019/09/22 12:13:33 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.154 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.154.2.1 2019/09/22 12:13:33 martin Exp $");
 
 #include 
 #include 
@@ -1892,7 +1892,7 @@ fxp_init(struct ifnet *ifp)
 	CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->sc_cddma + FXP_CDIASOFF);
 	fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
 	/* ...and wait for it to complete. */
-	for (i = 1000; i > 0; i++) {
+	for (i = 1000; i > 0; i--) {
 		FXP_CDIASSYNC(sc,
 		BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 		status = le16toh(cb_ias->cb_status);



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:13:33 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: i82557.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #217):

sys/dev/ic/i82557.c: revision 1.155

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.154.2.1 src/sys/dev/ic/i82557.c

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:15:28 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #216):

sys/dev/pci/if_age.c: revision 1.61

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.2.1 src/sys/dev/pci/if_age.c

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:15:28 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_age.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #216):

sys/dev/pci/if_age.c: revision 1.61

Fix direction of the loop.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.60.2.1 src/sys/dev/pci/if_age.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/if_age.c
diff -u src/sys/dev/pci/if_age.c:1.60 src/sys/dev/pci/if_age.c:1.60.2.1
--- src/sys/dev/pci/if_age.c:1.60	Tue Jul  9 08:46:58 2019
+++ src/sys/dev/pci/if_age.c	Sun Sep 22 12:15:28 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.60 2019/07/09 08:46:58 msaitoh Exp $ */
+/*	$NetBSD: if_age.c,v 1.60.2.1 2019/09/22 12:15:28 martin Exp $ */
 /*	$OpenBSD: if_age.c,v 1.1 2009/01/16 05:00:34 kevlo Exp $	*/
 
 /*-
@@ -31,7 +31,7 @@
 /* Driver for Attansic Technology Corp. L1 Gigabit Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60 2019/07/09 08:46:58 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.60.2.1 2019/09/22 12:15:28 martin Exp $");
 
 #include "vlan.h"
 
@@ -575,7 +575,7 @@ age_get_macaddr(struct age_softc *sc, ui
 		 */
 		CSR_WRITE_4(sc, AGE_TWSI_CTRL, CSR_READ_4(sc, AGE_TWSI_CTRL) |
 		TWSI_CTRL_SW_LD_START);
-		for (i = 100; i > 0; i++) {
+		for (i = 100; i > 0; i--) {
 			DELAY(1000);
 			reg = CSR_READ_4(sc, AGE_TWSI_CTRL);
 			if ((reg & TWSI_CTRL_SW_LD_START) == 0)



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:18:56 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #218):

sys/dev/ic/nvme.c: revision 1.45

Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done().

A new completion queue entry check incorrectly determined that there was
a Completion Queue entry for a command that was not submitted.

Fix PR kern/54275, PR kern/54503, PR kern/54532.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44 src/sys/dev/ic/nvme.c:1.44.2.1
--- src/sys/dev/ic/nvme.c:1.44	Fri Jun 28 15:08:47 2019
+++ src/sys/dev/ic/nvme.c	Sun Sep 22 12:18:56 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44 2019/06/28 15:08:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $");
 
 #include 
 #include 
@@ -1302,8 +1302,8 @@ nvme_poll_done(struct nvme_queue *q, str
 {
 	struct nvme_poll_state *state = ccb->ccb_cookie;
 
-	SET(cqe->flags, htole16(NVME_CQE_PHASE));
 	state->c = *cqe;
+	SET(state->c.flags, htole16(NVME_CQE_PHASE));
 
 	ccb->ccb_cookie = state->cookie;
 	state->done(q, ccb, &state->c);



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 22 12:18:56 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #218):

sys/dev/ic/nvme.c: revision 1.45

Don't set Phase Tag bit of Completion Queue entry at nvme_poll_done().

A new completion queue entry check incorrectly determined that there was
a Completion Queue entry for a command that was not submitted.

Fix PR kern/54275, PR kern/54503, PR kern/54532.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/acpi

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 23 15:27:04 UTC 2019

Modified Files:
src/sys/dev/acpi [netbsd-9]: dwiic_acpi.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #233):

sys/dev/acpi/dwiic_acpi.c: revision 1.3

Match APMC0D0F compatible string.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.6.1 src/sys/dev/acpi/dwiic_acpi.c

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



CVS commit: [netbsd-9] src/sys/dev/acpi

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 23 15:27:04 UTC 2019

Modified Files:
src/sys/dev/acpi [netbsd-9]: dwiic_acpi.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #233):

sys/dev/acpi/dwiic_acpi.c: revision 1.3

Match APMC0D0F compatible string.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.6.1 src/sys/dev/acpi/dwiic_acpi.c

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

Modified files:

Index: src/sys/dev/acpi/dwiic_acpi.c
diff -u src/sys/dev/acpi/dwiic_acpi.c:1.2 src/sys/dev/acpi/dwiic_acpi.c:1.2.6.1
--- src/sys/dev/acpi/dwiic_acpi.c:1.2	Fri Nov 16 23:18:17 2018
+++ src/sys/dev/acpi/dwiic_acpi.c	Mon Sep 23 15:27:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_acpi.c,v 1.2 2018/11/16 23:18:17 jmcneill Exp $ */
+/* $NetBSD: dwiic_acpi.c,v 1.2.6.1 2019/09/23 15:27:04 martin Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.2 2018/11/16 23:18:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.2.6.1 2019/09/23 15:27:04 martin Exp $");
 
 #include 
 #include 
@@ -60,7 +60,8 @@ static void	dwiic_acpi_configure(struct 
 CFATTACH_DECL_NEW(dwiic_acpi, sizeof(struct dwiic_softc), dwiic_acpi_match, dwiic_acpi_attach, NULL, NULL);
 
 static const char * const compatible[] = {
-	"AMDI0510",
+	"AMDI0510",	/* AMD Seattle */
+	"APMC0D0F",	/* Ampere eMAG */
 	NULL
 };
 



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 24 02:59:35 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #237):

sys/dev/pci/pcidevs: revision 1.1385

Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.1 -r1.1383.2.2 src/sys/dev/pci/pcidevs

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 24 02:59:35 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #237):

sys/dev/pci/pcidevs: revision 1.1385

Add Mellanox ConnectX-4, ConnectX-4 Lx, ConnectX-5, and ConnectX-5 Ex


To generate a diff of this commit:
cvs rdiff -u -r1.1383.2.1 -r1.1383.2.2 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1383.2.1 src/sys/dev/pci/pcidevs:1.1383.2.2
--- src/sys/dev/pci/pcidevs:1.1383.2.1	Mon Aug 26 13:58:19 2019
+++ src/sys/dev/pci/pcidevs	Tue Sep 24 02:59:35 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1383.2.1 2019/08/26 13:58:19 martin Exp $
+$NetBSD: pcidevs,v 1.1383.2.2 2019/09/24 02:59:35 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -5869,6 +5869,10 @@ product MATROX G550_AGP		0x2527	MGA G550
 product MEDIAQ MQ200		0x0200	MQ200
 
 /* Mellanox Technologies */
+product MELLANOX MT27700	0x1013	ConnectX-4
+product MELLANOX MT27710	0x1015	ConnectX-4 Lx
+product MELLANOX MT27800	0x1017	ConnectX-5
+product MELLANOX MT28800	0x1019	ConnectX-5 Ex
 product MELLANOX MT23108	0x5a44	InfiniHost (Tavor)
 product MELLANOX MT23108_PCI	0x5a46	InfiniHost PCI Bridge (Tavor)
 product MELLANOX MT25204_OLD	0x5e8c	InfiniHost III Lx (old Sinai)



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 24 03:02:05 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pcidevs.h pcidevs_data.h

Log Message:
regen for ticket #237 (Mellanox device IDs added)


To generate a diff of this commit:
cvs rdiff -u -r1.1371.2.1 -r1.1371.2.2 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1370.2.1 -r1.1370.2.2 src/sys/dev/pci/pcidevs_data.h

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 18:52:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci_subr.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #243):

sys/dev/pci/pci_subr.c: revision 1.216
sys/dev/pci/pci_subr.c: revision 1.217

Whitespace fixes. No functional change.

 -

Print some DPC register values not with %04x but with %08x because those
are 32bit.


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.215.2.1 src/sys/dev/pci/pci_subr.c

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 18:52:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: pci_subr.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #243):

sys/dev/pci/pci_subr.c: revision 1.216
sys/dev/pci/pci_subr.c: revision 1.217

Whitespace fixes. No functional change.

 -

Print some DPC register values not with %04x but with %08x because those
are 32bit.


To generate a diff of this commit:
cvs rdiff -u -r1.215 -r1.215.2.1 src/sys/dev/pci/pci_subr.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/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.215 src/sys/dev/pci/pci_subr.c:1.215.2.1
--- src/sys/dev/pci/pci_subr.c:1.215	Thu Jul 18 07:49:26 2019
+++ src/sys/dev/pci/pci_subr.c	Thu Sep 26 18:52:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.215 2019/07/18 07:49:26 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.215.2.1 2019/09/26 18:52:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.215 2019/07/18 07:49:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.215.2.1 2019/09/26 18:52:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -209,7 +209,7 @@ static const struct pci_class pci_subcla
 
 /* PCI bridge programming interface */
 static const struct pci_class pci_interface_pcibridge[] = {
-	{ "",			PCI_INTERFACE_BRIDGE_PCI_PCI, NULL,	},
+	{ "",			PCI_INTERFACE_BRIDGE_PCI_PCI,	NULL,	},
 	{ "subtractive decode",	PCI_INTERFACE_BRIDGE_PCI_SUBDEC, NULL,	},
 	{ NULL,			0,NULL,	},
 };
@@ -223,8 +223,8 @@ static const struct pci_class pci_interf
 
 /* Advanced Switching programming interface */
 static const struct pci_class pci_interface_advsw[] = {
-	{ "custom interface",	PCI_INTERFACE_ADVSW_CUSTOM, NULL, },
-	{ "ASI-SIG",		PCI_INTERFACE_ADVSW_ASISIG, NULL, },
+	{ "custom interface",	PCI_INTERFACE_ADVSW_CUSTOM,	NULL, },
+	{ "ASI-SIG",		PCI_INTERFACE_ADVSW_ASISIG,	NULL, },
 	{ NULL,			0,NULL,	},
 };
 
@@ -304,7 +304,7 @@ static const struct pci_class pci_subcla
 /*
  * Class 0x08.
  * Base system peripheral.
- */ 
+ */
 
 /* PIC programming interface */
 static const struct pci_class pci_interface_pic[] = {
@@ -429,10 +429,10 @@ static const struct pci_class pci_interf
 
 /* IPMI programming interface */
 static const struct pci_class pci_interface_ipmi[] = {
-	{ "SMIC",		PCI_INTERFACE_IPMI_SMIC,		NULL,},
-	{ "keyboard",		PCI_INTERFACE_IPMI_KBD,			NULL,},
-	{ "block transfer",	PCI_INTERFACE_IPMI_BLOCKXFER,		NULL,},
-	{ NULL,			0,	NULL,},
+	{ "SMIC",		PCI_INTERFACE_IPMI_SMIC,	NULL,	},
+	{ "keyboard",		PCI_INTERFACE_IPMI_KBD,		NULL,	},
+	{ "block transfer",	PCI_INTERFACE_IPMI_BLOCKXFER,	NULL,	},
+	{ NULL,			0,NULL,	},
 };
 
 /* Subclasses */
@@ -478,8 +478,8 @@ static const struct pci_class pci_subcla
 
 /* Intelligent IO programming interface */
 static const struct pci_class pci_interface_i2o[] = {
-	{ "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40,		NULL,},
-	{ NULL,			0,	NULL,},
+	{ "FIFO at offset 0x40", PCI_INTERFACE_I2O_FIFOAT40,	NULL,	},
+	{ NULL,			0,NULL,	},
 };
 
 /* Subclasses */
@@ -494,9 +494,9 @@ static const struct pci_class pci_subcla
  * Satellite communication controller.
  */
 static const struct pci_class pci_subclass_satcom[] = {
-	{ "TV",			PCI_SUBCLASS_SATCOM_TV,	 	NULL,	},
-	{ "audio",		PCI_SUBCLASS_SATCOM_AUDIO, 	NULL,	},
-	{ "voice",		PCI_SUBCLASS_SATCOM_VOICE, 	NULL,	},
+	{ "TV",			PCI_SUBCLASS_SATCOM_TV,		NULL,	},
+	{ "audio",		PCI_SUBCLASS_SATCOM_AUDIO,	NULL,	},
+	{ "voice",		PCI_SUBCLASS_SATCOM_VOICE,	NULL,	},
 	{ "data",		PCI_SUBCLASS_SATCOM_DATA,	NULL,	},
 	{ "miscellaneous",	PCI_SUBCLASS_SATCOM_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
@@ -507,9 +507,9 @@ static const struct pci_class pci_subcla
  * Encryption/Decryption controller.
  */
 static const struct pci_class pci_subclass_crypto[] = {
-	{ "network/computing",	PCI_SUBCLASS_CRYPTO_NETCOMP, 	NULL,	},
+	{ "network/computing",	PCI_SUBCLASS_CRYPTO_NETCOMP,	NULL,	},
 	{ "entertainment",	PCI_SUBCLASS_CRYPTO_ENTERTAINMENT, NULL,},
-	{ "miscellaneous",	PCI_SUBCLASS_CRYPTO_MISC, 	NULL,	},
+	{ "miscellaneous",	PCI_SUBCLASS_CRYPTO_MISC,	NULL,	},
 	{ NULL,			0,NULL,	},
 };
 
@@ -585,7 +585,7 @@ DEV_VERBOSE_DEFINE(pci);
  * a positive value if the dest buffer would have overflowed.
  */
 
-static int __printflike(3,4)
+static int __printflike(3, 4)
 snappendf(char **dest, size_t *len, const char * restrict fmt, ...)
 {
 	va_list	ap;
@@ -609,7 +609,7 @@ snappendf(char **dest, size_t *len, cons
 	/* Update dest & len to point at trailing NUL */
 	*dest += count;
 	*len -= count;
-		
+
 	return 0;
 }
 
@@ -1285,7 +1285,7 @@ pci_conf_print_pcix_cap_2ndbusmode(int n
 		printf("PCI-X 266 (Mode 2)\n");
 	else
 		printf("PCI-X 533 (Mode 2)\n");
-	
+
 	printf("  Error

CVS commit: [netbsd-9] src/sys/dev/i2c

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 18:56:06 UTC 2019

Modified Files:
src/sys/dev/i2c [netbsd-9]: ihidev.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #244):

sys/dev/i2c/ihidev.c: revision 1.8

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/dev/i2c/ihidev.c

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



CVS commit: [netbsd-9] src/sys/dev/i2c

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 18:56:06 UTC 2019

Modified Files:
src/sys/dev/i2c [netbsd-9]: ihidev.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #244):

sys/dev/i2c/ihidev.c: revision 1.8

Abort attach if acpi_intr_establish() fails. From K. Schreiner on
current-users@.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/dev/i2c/ihidev.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/i2c/ihidev.c
diff -u src/sys/dev/i2c/ihidev.c:1.7 src/sys/dev/i2c/ihidev.c:1.7.4.1
--- src/sys/dev/i2c/ihidev.c:1.7	Fri Nov 16 23:05:50 2018
+++ src/sys/dev/i2c/ihidev.c	Thu Sep 26 18:56:05 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.c,v 1.7 2018/11/16 23:05:50 jmcneill Exp $ */
+/* $NetBSD: ihidev.c,v 1.7.4.1 2019/09/26 18:56:05 martin Exp $ */
 /* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
 
 /*-
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.7 2018/11/16 23:05:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.7.4.1 2019/09/26 18:56:05 martin Exp $");
 
 #include 
 #include 
@@ -210,8 +210,10 @@ ihidev_attach(device_t parent, device_t 
 
 		sc->sc_ih = acpi_intr_establish(self, sc->sc_phandle, IPL_TTY,
 		false, ihidev_intr, sc, device_xname(self));
-		if (sc->sc_ih == NULL)
+		if (sc->sc_ih == NULL) {
 			aprint_error_dev(self, "can't establish interrupt\n");
+			return;
+		}
 		aprint_normal_dev(self, "interrupting at %s\n",
 		acpi_intr_string(sc->sc_ih, buf, sizeof(buf)));
 	}



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:09:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #247):

sys/dev/pci/if_mcx.c: revision 1.2

Use IFM_50G_SR2.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/pci/if_mcx.c

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



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:09:58 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #247):

sys/dev/pci/if_mcx.c: revision 1.2

Use IFM_50G_SR2.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/dev/pci/if_mcx.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/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.1.2.2 src/sys/dev/pci/if_mcx.c:1.1.2.3
--- src/sys/dev/pci/if_mcx.c:1.1.2.2	Mon Sep 23 07:04:40 2019
+++ src/sys/dev/pci/if_mcx.c	Thu Sep 26 19:09:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.1.2.2 2019/09/23 07:04:40 martin Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.1.2.3 2019/09/26 19:09:57 martin Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -2159,7 +2159,7 @@ static const uint64_t mcx_eth_cap_map[] 
 	IFM_40G_SR4,
 	IFM_40G_LR4,
 	0,
-	0, /* IFM_50G_SR2 */
+	IFM_50G_SR2,
 	0,
 	IFM_100G_CR4,
 	IFM_100G_SR4,



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:13:14 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #248):

sys/dev/ic/nvme.c: revision 1.46

nvme(4): Don't attach the device, if namespace not found.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.1 -r1.44.2.2 src/sys/dev/ic/nvme.c

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



CVS commit: [netbsd-9] src/sys/dev/ic

2019-09-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep 26 19:13:14 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-9]: nvme.c

Log Message:
Pull up following revision(s) (requested by nonaka in ticket #248):

sys/dev/ic/nvme.c: revision 1.46

nvme(4): Don't attach the device, if namespace not found.


To generate a diff of this commit:
cvs rdiff -u -r1.44.2.1 -r1.44.2.2 src/sys/dev/ic/nvme.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/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.44.2.1 src/sys/dev/ic/nvme.c:1.44.2.2
--- src/sys/dev/ic/nvme.c:1.44.2.1	Sun Sep 22 12:18:56 2019
+++ src/sys/dev/ic/nvme.c	Thu Sep 26 19:13:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.1 2019/09/22 12:18:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $");
 
 #include 
 #include 
@@ -399,6 +399,10 @@ nvme_attach(struct nvme_softc *sc)
 		aprint_error_dev(sc->sc_dev, "unable to identify controller\n");
 		goto disable;
 	}
+	if (sc->sc_nn == 0) {
+		aprint_error_dev(sc->sc_dev, "namespace not found\n");
+		goto disable;
+	}
 
 	/* we know how big things are now */
 	sc->sc_max_sgl = sc->sc_mdts / sc->sc_mps;



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-09-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 28 07:22:16 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: fdt_pinctrl.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #256):

sys/dev/fdt/fdt_pinctrl.c: revision 1.9

Don't assume pinctrl-0 is the default configuration.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/dev/fdt/fdt_pinctrl.c

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



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-09-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 28 07:22:16 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: fdt_pinctrl.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #256):

sys/dev/fdt/fdt_pinctrl.c: revision 1.9

Don't assume pinctrl-0 is the default configuration.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.4.1 src/sys/dev/fdt/fdt_pinctrl.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/fdt/fdt_pinctrl.c
diff -u src/sys/dev/fdt/fdt_pinctrl.c:1.8 src/sys/dev/fdt/fdt_pinctrl.c:1.8.4.1
--- src/sys/dev/fdt/fdt_pinctrl.c:1.8	Wed Feb 27 16:56:00 2019
+++ src/sys/dev/fdt/fdt_pinctrl.c	Sat Sep 28 07:22:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_pinctrl.c,v 1.8 2019/02/27 16:56:00 jakllsch Exp $ */
+/* $NetBSD: fdt_pinctrl.c,v 1.8.4.1 2019/09/28 07:22:16 martin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fdt_pinctrl.c,v 1.8 2019/02/27 16:56:00 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_pinctrl.c,v 1.8.4.1 2019/09/28 07:22:16 martin Exp $");
 
 #include 
 #include 
@@ -142,16 +142,16 @@ fdtbus_pinctrl_configure_node(int phandl
 		fdtbus_pinctrl_configure_node(child);
 
 		/*
-		 * Set configuration 0 for this node. This may fail if the
+		 * Set default configuration for this node. This may fail if the
 		 * pinctrl provider is missing; that's OK, we will re-configure
 		 * when that provider attaches.
 		 */
 		fdtbus_get_path(child, buf, sizeof(buf));
-		error = fdtbus_pinctrl_set_config_index(child, 0);
+		error = fdtbus_pinctrl_set_config(child, "default");
 		if (error == 0)
-			aprint_debug("pinctrl: set config pinctrl-0 for %s\n", buf);
+			aprint_debug("pinctrl: set default config for %s\n", buf);
 		else if (error != ENOENT)
-			aprint_debug("pinctrl: failed to set config pinctrl-0 for %s: %d\n", buf, error);
+			aprint_debug("pinctrl: failed to set default config for %s: %d\n", buf, error);
 	}
 }
 



CVS commit: [netbsd-9] src/sys/dev/acpi

2019-09-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 28 12:39:23 UTC 2019

Modified Files:
src/sys/dev/acpi [netbsd-9]: acpi_i2c.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #265):

sys/dev/acpi/acpi_i2c.c: revision 1.5

joshua stein, PR kern/54493: acpi_i2c uses incorrect arguments for _DSM call

The last argument to the _DSM call has to be ACPI_TYPE_PACKAGE, as defined in in
clude/acpredef.h for _DSM.

Avoids an ACPI warning at boot.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/dev/acpi/acpi_i2c.c

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



CVS commit: [netbsd-9] src/sys/dev/acpi

2019-09-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 28 12:39:23 UTC 2019

Modified Files:
src/sys/dev/acpi [netbsd-9]: acpi_i2c.c

Log Message:
Pull up following revision(s) (requested by bouyer in ticket #265):

sys/dev/acpi/acpi_i2c.c: revision 1.5

joshua stein, PR kern/54493: acpi_i2c uses incorrect arguments for _DSM call

The last argument to the _DSM call has to be ACPI_TYPE_PACKAGE, as defined in in
clude/acpredef.h for _DSM.

Avoids an ACPI warning at boot.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.4.8.1 src/sys/dev/acpi/acpi_i2c.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/acpi/acpi_i2c.c
diff -u src/sys/dev/acpi/acpi_i2c.c:1.4 src/sys/dev/acpi/acpi_i2c.c:1.4.8.1
--- src/sys/dev/acpi/acpi_i2c.c:1.4	Sat May  5 17:16:23 2018
+++ src/sys/dev/acpi/acpi_i2c.c	Sat Sep 28 12:39:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.c,v 1.4 2018/05/05 17:16:23 christos Exp $ */
+/* $NetBSD: acpi_i2c.c,v 1.4.8.1 2019/09/28 12:39:23 martin Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.4 2018/05/05 17:16:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.4.8.1 2019/09/28 12:39:23 martin Exp $");
 
 #include 
 #include 
@@ -68,7 +68,7 @@ acpi_enter_i2c_hid(struct acpi_devnode *
 	obj[2].Type = ACPI_TYPE_INTEGER;
 	obj[2].Integer.Value = 1;
 
-	obj[3].Type = ACPI_TYPE_ANY;
+	obj[3].Type = ACPI_TYPE_PACKAGE;
 	obj[3].Buffer.Length = 0;
 
 	buf.Pointer = NULL;



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 29 07:26:23 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #266):

sys/dev/pci/if_mcx.c: revision 1.3
sys/dev/pci/if_mcx.c: revision 1.4

mcx(4): fix rx mbuf DMA overrun
pullup-9

 -

len -> m_len


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/dev/pci/if_mcx.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/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.1.2.3 src/sys/dev/pci/if_mcx.c:1.1.2.4
--- src/sys/dev/pci/if_mcx.c:1.1.2.3	Thu Sep 26 19:09:57 2019
+++ src/sys/dev/pci/if_mcx.c	Sun Sep 29 07:26:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.1.2.3 2019/09/26 19:09:57 martin Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.1.2.4 2019/09/29 07:26:23 martin Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.33 2019/09/12 04:23:59 jmatthew Exp $ */
 
 /*
@@ -5620,15 +5620,16 @@ mcx_rx_fill_slots(struct mcx_softc *sc, 
 #endif
 
 		m->m_data += ETHER_ALIGN;
-		m->m_len = m->m_pkthdr.len = bufsize;
+		m->m_len = m->m_pkthdr.len = m->m_ext.ext_size - ETHER_ALIGN;
 		if (bus_dmamap_load_mbuf(sc->sc_dmat, ms->ms_map, m,
 		BUS_DMA_NOWAIT) != 0) {
 			m_freem(m);
 			break;
 		}
+		bus_dmamap_sync(sc->sc_dmat, ms->ms_map, 0, ms->ms_map->dm_mapsize, BUS_DMASYNC_PREREAD);
 		ms->ms_m = m;
 
-		rqe[slot].rqe_byte_count = htobe32(bufsize);
+		rqe[slot].rqe_byte_count = htobe32(m->m_len);
 		rqe[slot].rqe_addr = htobe64(ms->ms_map->dm_segs[0].ds_addr);
 		rqe[slot].rqe_lkey = htobe32(sc->sc_lkey);
 



CVS commit: [netbsd-9] src/sys/dev/pci

2019-09-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 29 07:26:23 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-9]: if_mcx.c

Log Message:
Pull up following revision(s) (requested by tnn in ticket #266):

sys/dev/pci/if_mcx.c: revision 1.3
sys/dev/pci/if_mcx.c: revision 1.4

mcx(4): fix rx mbuf DMA overrun
pullup-9

 -

len -> m_len


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/dev/pci/if_mcx.c

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



CVS commit: [netbsd-9] src/sys/dev/audio

2019-10-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  6 10:58:15 UTC 2019

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #284):

sys/dev/audio/audio.c: revision 1.29

Add missing mutex, we were hitting a KASSERT.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28 src/sys/dev/audio/audio.c:1.28.2.1
--- src/sys/dev/audio/audio.c:1.28	Wed Jul 10 13:26:47 2019
+++ src/sys/dev/audio/audio.c	Sun Oct  6 10:58:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28 2019/07/10 13:26:47 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.1 2019/10/06 10:58:14 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28 2019/07/10 13:26:47 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.1 2019/10/06 10:58:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -7726,7 +7726,9 @@ mixer_ioctl(struct audio_softc *sc, u_lo
 		} else {
 			ma = NULL;
 		}
+		mutex_enter(sc->sc_lock);
 		mixer_remove(sc);	/* remove old entry */
+		mutex_exit(sc->sc_lock);
 		if (ma != NULL) {
 			ma->next = sc->sc_async_mixer;
 			ma->pid = curproc->p_pid;



CVS commit: [netbsd-9] src/sys/dev/audio

2019-10-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  6 10:58:15 UTC 2019

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #284):

sys/dev/audio/audio.c: revision 1.29

Add missing mutex, we were hitting a KASSERT.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.28.2.1 src/sys/dev/audio/audio.c

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



CVS commit: [netbsd-9] src/sys/dev/audio

2019-10-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  6 11:00:15 UTC 2019

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c audiovar.h

Log Message:
Pull up following revision(s) (requested by isaki in ticket #285):

sys/dev/audio/audiovar.h: revision 1.5
sys/dev/audio/audio.c: revision 1.30

Fix lock assertion on async I/O mode.
psignal() must be called without any spin locks.
Thanks maxv@!


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/dev/audio/audiovar.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.1 src/sys/dev/audio/audio.c:1.28.2.2
--- src/sys/dev/audio/audio.c:1.28.2.1	Sun Oct  6 10:58:14 2019
+++ src/sys/dev/audio/audio.c	Sun Oct  6 11:00:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.1 2019/10/06 10:58:14 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.2 2019/10/06 11:00:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.1 2019/10/06 10:58:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.2 2019/10/06 11:00:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -5730,6 +5730,36 @@ audio_track_drain(struct audio_softc *sc
 }
 
 /*
+ * Send signal to process.
+ * This is intended to be called only from audio_softintr_{rd,wr}.
+ * Must be called with sc_lock && sc_intr_lock held.
+ */
+static inline void
+audio_psignal(struct audio_softc *sc, pid_t pid, int signum)
+{
+	proc_t *p;
+
+	KASSERT(mutex_owned(sc->sc_lock));
+	KASSERT(mutex_owned(sc->sc_intr_lock));
+	KASSERT(pid != 0);
+
+	/*
+	 * psignal() must be called without spin lock held.
+	 * So leave intr_lock temporarily here.
+	 */
+	mutex_exit(sc->sc_intr_lock);
+
+	mutex_enter(proc_lock);
+	p = proc_find(pid);
+	if (p)
+		psignal(p, signum);
+	mutex_exit(proc_lock);
+
+	/* Enter intr_lock again */
+	mutex_enter(sc->sc_intr_lock);
+}
+
+/*
  * This is software interrupt handler for record.
  * It is called from recording hardware interrupt everytime.
  * It does:
@@ -5747,7 +5777,6 @@ audio_softintr_rd(void *cookie)
 {
 	struct audio_softc *sc = cookie;
 	audio_file_t *f;
-	proc_t *p;
 	pid_t pid;
 
 	mutex_enter(sc->sc_lock);
@@ -5767,10 +5796,7 @@ audio_softintr_rd(void *cookie)
 		pid = f->async_audio;
 		if (pid != 0) {
 			TRACEF(4, f, "sending SIGIO %d", pid);
-			mutex_enter(proc_lock);
-			if ((p = proc_find(pid)) != NULL)
-psignal(p, SIGIO);
-			mutex_exit(proc_lock);
+			audio_psignal(sc, pid, SIGIO);
 		}
 	}
 	mutex_exit(sc->sc_intr_lock);
@@ -5799,7 +5825,6 @@ audio_softintr_wr(void *cookie)
 	struct audio_softc *sc = cookie;
 	audio_file_t *f;
 	bool found;
-	proc_t *p;
 	pid_t pid;
 
 	TRACE(4, "called");
@@ -5826,14 +5851,13 @@ audio_softintr_wr(void *cookie)
 		 */
 		if (track->usrbuf.used <= track->usrbuf_usedlow &&
 		!track->is_pause) {
+			/* For selnotify */
 			found = true;
+			/* For SIGIO */
 			pid = f->async_audio;
 			if (pid != 0) {
 TRACEF(4, f, "sending SIGIO %d", pid);
-mutex_enter(proc_lock);
-if ((p = proc_find(pid)) != NULL)
-	psignal(p, SIGIO);
-mutex_exit(proc_lock);
+audio_psignal(sc, pid, SIGIO);
 			}
 		}
 	}

Index: src/sys/dev/audio/audiovar.h
diff -u src/sys/dev/audio/audiovar.h:1.4 src/sys/dev/audio/audiovar.h:1.4.2.1
--- src/sys/dev/audio/audiovar.h:1.4	Wed Jun 26 06:57:45 2019
+++ src/sys/dev/audio/audiovar.h	Sun Oct  6 11:00:15 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiovar.h,v 1.4 2019/06/26 06:57:45 isaki Exp $	*/
+/*	$NetBSD: audiovar.h,v 1.4.2.1 2019/10/06 11:00:15 martin Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -149,7 +149,8 @@ struct audio_softc {
 
 	/*
 	 * List of opened descriptors.
-	 * Must be protected by sc_intr_lock.
+	 * Must be protected by sc_lock || sc_intr_lock for traversal(FOREACH).
+	 * Must be protected by sc_lock && sc_intr_lock for insertion/removal.
 	 */
 	SLIST_HEAD(, audio_file) sc_files;
 



CVS commit: [netbsd-9] src/sys/dev/audio

2019-10-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  6 11:00:15 UTC 2019

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c audiovar.h

Log Message:
Pull up following revision(s) (requested by isaki in ticket #285):

sys/dev/audio/audiovar.h: revision 1.5
sys/dev/audio/audio.c: revision 1.30

Fix lock assertion on async I/O mode.
psignal() must be called without any spin locks.
Thanks maxv@!


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sys/dev/audio/audio.c
cvs rdiff -u -r1.4 -r1.4.2.1 src/sys/dev/audio/audiovar.h

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



CVS commit: [netbsd-9] src/sys/dev/audio

2019-10-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  6 11:02:32 UTC 2019

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #286):

sys/dev/audio/audio.c: revision 1.31

Tune some debug message level.
These messages are important for debugging hardware driver.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.28.2.2 src/sys/dev/audio/audio.c:1.28.2.3
--- src/sys/dev/audio/audio.c:1.28.2.2	Sun Oct  6 11:00:15 2019
+++ src/sys/dev/audio/audio.c	Sun Oct  6 11:02:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.28.2.2 2019/10/06 11:00:15 martin Exp $	*/
+/*	$NetBSD: audio.c,v 1.28.2.3 2019/10/06 11:02:32 martin Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -142,7 +142,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.2 2019/10/06 11:00:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.28.2.3 2019/10/06 11:02:32 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -4621,7 +4621,7 @@ audio_mixer_init(struct audio_softc *sc,
 		audio_params_t p = format2_to_params(&mixer->hwbuf.fmt);
 		rounded = sc->hw_if->round_blocksize(sc->hw_hdl, blksize,
 		mode, &p);
-		TRACE(2, "round_blocksize %d -> %d", blksize, rounded);
+		TRACE(1, "round_blocksize %d -> %d", blksize, rounded);
 		if (rounded != blksize) {
 			if ((rounded * NBBY) % (mixer->hwbuf.fmt.stride *
 			mixer->hwbuf.fmt.channels) != 0) {
@@ -4646,7 +4646,7 @@ audio_mixer_init(struct audio_softc *sc,
 		size_t rounded;
 		rounded = sc->hw_if->round_buffersize(sc->hw_hdl, mode,
 		bufsize);
-		TRACE(2, "round_buffersize %zd -> %zd", bufsize, rounded);
+		TRACE(1, "round_buffersize %zd -> %zd", bufsize, rounded);
 		if (rounded < bufsize) {
 			/* buffersize needs NBLKHW blocks at least. */
 			device_printf(sc->sc_dev,
@@ -4669,7 +4669,7 @@ audio_mixer_init(struct audio_softc *sc,
 			capacity = mixer->frames_per_block * hwblks;
 		}
 	}
-	TRACE(2, "buffersize for %s = %zu",
+	TRACE(1, "buffersize for %s = %zu",
 	(mode == AUMODE_PLAY) ? "playback" : "recording",
 	bufsize);
 	mixer->hwbuf.capacity = capacity;



CVS commit: [netbsd-9] src/sys/dev/audio

2019-10-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct  6 11:02:32 UTC 2019

Modified Files:
src/sys/dev/audio [netbsd-9]: audio.c

Log Message:
Pull up following revision(s) (requested by isaki in ticket #286):

sys/dev/audio/audio.c: revision 1.31

Tune some debug message level.
These messages are important for debugging hardware driver.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/dev/audio/audio.c

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



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 16:56:37 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: cpufreq_dt.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #291):

sys/dev/fdt/cpufreq_dt.c: revision 1.9
sys/dev/fdt/cpufreq_dt.c: revision 1.10

Change sysctl to be named after the first CPU in the DVFS domain.
  old: machdep.cpu.frequency.*, machdep.cpufreqdt4.frequency.*
  new: machdep.cpufreq.cpu0.*, machdep.cpufreq.cpu4.*


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/dev/fdt/cpufreq_dt.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/fdt/cpufreq_dt.c
diff -u src/sys/dev/fdt/cpufreq_dt.c:1.8 src/sys/dev/fdt/cpufreq_dt.c:1.8.2.1
--- src/sys/dev/fdt/cpufreq_dt.c:1.8	Tue May 21 22:15:26 2019
+++ src/sys/dev/fdt/cpufreq_dt.c	Tue Oct  8 16:56:37 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: cpufreq_dt.c,v 1.8 2019/05/21 22:15:26 jmcneill Exp $ */
+/* $NetBSD: cpufreq_dt.c,v 1.8.2.1 2019/10/08 16:56:37 martin Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.8 2019/05/21 22:15:26 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c,v 1.8.2.1 2019/10/08 16:56:37 martin Exp $");
 
 #include 
 #include 
@@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpufreq_dt.c
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -250,14 +251,36 @@ cpufreq_dt_sysctl_helper(SYSCTLFN_ARGS)
 	return error;
 }
 
+static struct cpu_info *
+cpufreq_dt_cpu_lookup(cpuid_t mpidr)
+{
+	CPU_INFO_ITERATOR cii;
+	struct cpu_info *ci;
+
+	for (CPU_INFO_FOREACH(cii, ci)) {
+		if (ci->ci_cpuid == mpidr)
+			return ci;
+	}
+
+	return NULL;
+}
+
 static void
 cpufreq_dt_init_sysctl(struct cpufreq_dt_softc *sc)
 {
-	const struct sysctlnode *node, *cpunode, *freqnode;
+	const struct sysctlnode *node, *cpunode;
 	struct sysctllog *cpufreq_log = NULL;
-	const char *cpunodename;
+	struct cpu_info *ci;
+	bus_addr_t mpidr;
 	int error, i;
 
+	if (fdtbus_get_reg(sc->sc_phandle, 0, &mpidr, 0) != 0)
+		return;
+
+	ci = cpufreq_dt_cpu_lookup(mpidr);
+	if (ci == NULL)
+		return;
+
 	sc->sc_freq_available = kmem_zalloc(strlen(" ") * sc->sc_nopp, KM_SLEEP);
 	for (i = 0; i < sc->sc_nopp; i++) {
 		char buf[6];
@@ -265,28 +288,23 @@ cpufreq_dt_init_sysctl(struct cpufreq_dt
 		strcat(sc->sc_freq_available, buf);
 	}
 
-	if (device_unit(sc->sc_dev) == 0)
-		cpunodename = "cpu";
-	else
-		cpunodename = device_xname(sc->sc_dev);
-
 	error = sysctl_createv(&cpufreq_log, 0, NULL, &node,
 	CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
 	NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
 	if (error)
 		goto sysctl_failed;
-	error = sysctl_createv(&cpufreq_log, 0, &node, &cpunode,
-	0, CTLTYPE_NODE, cpunodename, NULL,
+	error = sysctl_createv(&cpufreq_log, 0, &node, &node,
+	0, CTLTYPE_NODE, "cpufreq", NULL,
 	NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 	if (error)
 		goto sysctl_failed;
-	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &freqnode,
-	0, CTLTYPE_NODE, "frequency", NULL,
+	error = sysctl_createv(&cpufreq_log, 0, &node, &cpunode,
+	0, CTLTYPE_NODE, cpu_name(ci), NULL,
 	NULL, 0, NULL, 0, CTL_CREATE, CTL_EOL);
 	if (error)
 		goto sysctl_failed;
 
-	error = sysctl_createv(&cpufreq_log, 0, &freqnode, &node,
+	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &node,
 	CTLFLAG_READWRITE, CTLTYPE_INT, "target", NULL,
 	cpufreq_dt_sysctl_helper, 0, (void *)sc, 0,
 	CTL_CREATE, CTL_EOL);
@@ -294,7 +312,7 @@ cpufreq_dt_init_sysctl(struct cpufreq_dt
 		goto sysctl_failed;
 	sc->sc_node_target = node->sysctl_num;
 
-	error = sysctl_createv(&cpufreq_log, 0, &freqnode, &node,
+	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &node,
 	CTLFLAG_READWRITE, CTLTYPE_INT, "current", NULL,
 	cpufreq_dt_sysctl_helper, 0, (void *)sc, 0,
 	CTL_CREATE, CTL_EOL);
@@ -302,7 +320,7 @@ cpufreq_dt_init_sysctl(struct cpufreq_dt
 		goto sysctl_failed;
 	sc->sc_node_current = node->sysctl_num;
 
-	error = sysctl_createv(&cpufreq_log, 0, &freqnode, &node,
+	error = sysctl_createv(&cpufreq_log, 0, &cpunode, &node,
 	0, CTLTYPE_STRING, "available", NULL,
 	NULL, 0, sc->sc_freq_available, 0,
 	CTL_CREATE, CTL_EOL);



CVS commit: [netbsd-9] src/sys/dev/fdt

2019-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Oct  8 16:56:37 UTC 2019

Modified Files:
src/sys/dev/fdt [netbsd-9]: cpufreq_dt.c

Log Message:
Pull up following revision(s) (requested by jmcneill in ticket #291):

sys/dev/fdt/cpufreq_dt.c: revision 1.9
sys/dev/fdt/cpufreq_dt.c: revision 1.10

Change sysctl to be named after the first CPU in the DVFS domain.
  old: machdep.cpu.frequency.*, machdep.cpufreqdt4.frequency.*
  new: machdep.cpufreq.cpu0.*, machdep.cpufreq.cpu4.*


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.8.2.1 src/sys/dev/fdt/cpufreq_dt.c

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



  1   2   3   4   5   >