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

2021-06-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jun  5 10:57:11 UTC 2021

Modified Files:
src/sys/dev/pci [netbsd-8]: if_iwmreg.h

Log Message:
Pull up following revision(s) (requested by nia in ticket #1682):

sys/dev/pci/if_iwmreg.h: revision 1.8

Can't left shift a signed int by 31. Found by kubsan.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.6.1 src/sys/dev/pci/if_iwmreg.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_iwmreg.h
diff -u src/sys/dev/pci/if_iwmreg.h:1.6 src/sys/dev/pci/if_iwmreg.h:1.6.6.1
--- src/sys/dev/pci/if_iwmreg.h:1.6	Tue Mar 14 23:59:26 2017
+++ src/sys/dev/pci/if_iwmreg.h	Sat Jun  5 10:57:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iwmreg.h,v 1.6 2017/03/14 23:59:26 nonaka Exp $	*/
+/*	$NetBSD: if_iwmreg.h,v 1.6.6.1 2021/06/05 10:57:11 martin Exp $	*/
 /*	OpenBSD: if_iwmreg.h,v 1.19 2016/09/20 11:46:09 stsp Exp 	*/
 
 /*-
@@ -191,7 +191,7 @@
 
 /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
  * acknowledged (reset) by host writing "1" to flagged bits. */
-#define IWM_CSR_INT_BIT_FH_RX	(1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
+#define IWM_CSR_INT_BIT_FH_RX	(1U << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
 #define IWM_CSR_INT_BIT_HW_ERR	(1 << 29) /* DMA hardware error FH_INT[31] */
 #define IWM_CSR_INT_BIT_RX_PERIODIC	(1 << 28) /* Rx periodic */
 #define IWM_CSR_INT_BIT_FH_TX	(1 << 27) /* Tx DMA FH_INT[1:0] */
@@ -214,7 +214,7 @@
  IWM_CSR_INT_BIT_RX_PERIODIC)
 
 /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
-#define IWM_CSR_FH_INT_BIT_ERR   (1 << 31) /* Error */
+#define IWM_CSR_FH_INT_BIT_ERR   (1U << 31) /* Error */
 #define IWM_CSR_FH_INT_BIT_HI_PRIOR  (1 << 30) /* High priority Rx, bypass coalescing */
 #define IWM_CSR_FH_INT_BIT_RX_CHNL1  (1 << 17) /* Rx channel 1 */
 #define IWM_CSR_FH_INT_BIT_RX_CHNL0  (1 << 16) /* Rx channel 0 */
@@ -405,7 +405,7 @@
 #define IWM_CSR_DBG_HPET_MEM_REG_VAL	(0x)
 
 /* DRAM INT TABLE */
-#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1 << 31)
+#define IWM_CSR_DRAM_INT_TBL_ENABLE		(1U << 31)
 #define IWM_CSR_DRAM_INIT_TBL_WRITE_POINTER	(1 << 28)
 #define IWM_CSR_DRAM_INIT_TBL_WRAP_CHECK	(1 << 27)
 
@@ -558,7 +558,7 @@ enum iwm_secure_load_status_reg {
 #define IWM_HOST_INT_TIMEOUT_MAX	(0xFF)
 #define IWM_HOST_INT_TIMEOUT_DEF	(0x40)
 #define IWM_HOST_INT_TIMEOUT_MIN	(0x0)
-#define IWM_HOST_INT_OPER_MODE		(1 << 31)
+#define IWM_HOST_INT_OPER_MODE		(1U << 31)
 
 /*
  *7000/3000 series SHR DTS addresses *
@@ -643,7 +643,7 @@ enum iwm_ucode_tlv_flag {
 	IWM_UCODE_TLV_FLAGS_P2P_PS_UAPSD	= (1 << 26),
 	IWM_UCODE_TLV_FLAGS_BCAST_FILTERING	= (1 << 29),
 	IWM_UCODE_TLV_FLAGS_GO_UAPSD		= (1 << 30),
-	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1 << 31),
+	IWM_UCODE_TLV_FLAGS_LTE_COEX		= (1U << 31),
 };
 #define IWM_UCODE_TLV_FLAG_BITS \
 	"\020\1PAN\2NEWSCAN\3MFP\4P2P\5DW_BC_TABLE\6NEWBT_COEX\7PM_CMD\10SHORT_BL\11RX_ENERGY\12TIME_EVENT_V2\13D3_6_IPV6\14BF_UPDATED\15NO_BASIC_SSID\17D3_CONTINUITY\20NEW_NSOFFL_S\21NEW_NSOFFL_L\22SCHED_SCAN\24STA_KEY_CMD\25DEVICE_PS_CMD\26P2P_PS\27P2P_PS_DCM\30P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40LTE_COEX"
@@ -4369,7 +4369,7 @@ enum iwm_tx_flags {
 	IWM_TX_CMD_FLG_FW_DROP		= (1 << 26),
 	IWM_TX_CMD_FLG_EXEC_PAPD	= (1 << 27),
 	IWM_TX_CMD_FLG_PAPD_TYPE	= (1 << 28),
-	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1 << 31)
+	IWM_TX_CMD_FLG_HCCA_CHUNK	= (1U << 31)
 }; /* IWM_TX_FLAGS_BITS_API_S_VER_1 */
 
 /**



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

2021-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 27 13:10:45 UTC 2021

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

Log Message:
Regen for ticket #1667 (BELKIN F5D7050E fix)


To generate a diff of this commit:
cvs rdiff -u -r1.727.2.6 -r1.727.2.7 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.728.2.6 -r1.728.2.7 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.

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.727.2.6 src/sys/dev/usb/usbdevs.h:1.727.2.7
--- src/sys/dev/usb/usbdevs.h:1.727.2.6	Thu Feb 27 14:34:11 2020
+++ src/sys/dev/usb/usbdevs.h	Sat Mar 27 13:10:43 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.727.2.6 2020/02/27 14:34:11 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.727.2.7 2021/03/27 13:10:43 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp
+ *	NetBSD: usbdevs,v 1.736.2.7 2021/03/27 13:09:46 martin Exp
  */
 
 /*-
@@ -1087,7 +1087,7 @@
 #define	USB_PRODUCT_BELKIN_F5D7051	0x7051		/* F5D7051 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_F5D7050A	0x705a		/* F5D705A 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_F5D7050C	0x705c		/* F5D705C 54g USB Network Adapter */
-#define	USB_PRODUCT_BELKIN_F5D7050E	0x705c		/* F5D705E 54g USB Network Adapter */
+#define	USB_PRODUCT_BELKIN_F5D7050E	0x705e		/* F5D705E 54g USB Network Adapter */
 #define	USB_PRODUCT_BELKIN_RT2870_1	0x8053		/* RT2870 */
 #define	USB_PRODUCT_BELKIN_RT2870_2	0x805c		/* RT2870 */
 #define	USB_PRODUCT_BELKIN_F5D8053V3	0x815c		/* F5D8053 v3 */

Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.728.2.6 src/sys/dev/usb/usbdevs_data.h:1.728.2.7
--- src/sys/dev/usb/usbdevs_data.h:1.728.2.6	Thu Feb 27 14:34:11 2020
+++ src/sys/dev/usb/usbdevs_data.h	Sat Mar 27 13:10:43 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.728.2.6 2020/02/27 14:34:11 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.728.2.7 2021/03/27 13:10:43 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp
+ *	NetBSD: usbdevs,v 1.736.2.7 2021/03/27 13:09:46 martin Exp
  */
 
 /*-



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

2021-03-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 27 13:09:46 UTC 2021

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

Log Message:
Pull up following revision(s) (requested by nia in ticket #1667):

sys/dev/usb/usbdevs: revision 1.793

correct usb device id for BELKIN F5D7050E

matches freebsd / openbsd (sources of urtw driver), various online
sources

PR kern/56056


To generate a diff of this commit:
cvs rdiff -u -r1.736.2.6 -r1.736.2.7 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.736.2.6 src/sys/dev/usb/usbdevs:1.736.2.7
--- src/sys/dev/usb/usbdevs:1.736.2.6	Thu Feb 27 14:32:31 2020
+++ src/sys/dev/usb/usbdevs	Sat Mar 27 13:09:46 2021
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp $
+$NetBSD: usbdevs,v 1.736.2.7 2021/03/27 13:09:46 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1080,7 +1080,7 @@ product BELKIN F5D7050		0x7050	F5D7050 5
 product BELKIN F5D7051		0x7051	F5D7051 54g USB Network Adapter
 product BELKIN F5D7050A		0x705a	F5D705A 54g USB Network Adapter
 product BELKIN F5D7050C		0x705c	F5D705C 54g USB Network Adapter
-product BELKIN F5D7050E		0x705c	F5D705E 54g USB Network Adapter
+product BELKIN F5D7050E		0x705e	F5D705E 54g USB Network Adapter
 product BELKIN RT2870_1		0x8053	RT2870
 product BELKIN RT2870_2		0x805c	RT2870
 product BELKIN F5D8053V3	0x815c	F5D8053 v3



CVS commit: [netbsd-8] src/sys/dev/raidframe

2021-02-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 17 09:36:10 UTC 2021

Modified Files:
src/sys/dev/raidframe [netbsd-8]: rf_reconstruct.c

Log Message:
Pull up following revision(s) (requested by oster in ticket #1655):

sys/dev/raidframe/rf_reconstruct.c: revision 1.125

Fix a long long-standing off-by-one error in computing lastPSID.

SUsPerPU is only really supported for a value of 1, and since the
first PSID is 0, the last will be numStripe-1.  Also update the
setting of pending_writes to reflect the change to lastPSID.

Needs pullups to -8 and -9.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.121.12.1 src/sys/dev/raidframe/rf_reconstruct.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/raidframe/rf_reconstruct.c
diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.121 src/sys/dev/raidframe/rf_reconstruct.c:1.121.12.1
--- src/sys/dev/raidframe/rf_reconstruct.c:1.121	Fri Nov 14 14:29:16 2014
+++ src/sys/dev/raidframe/rf_reconstruct.c	Wed Feb 17 09:36:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_reconstruct.c,v 1.121 2014/11/14 14:29:16 oster Exp $	*/
+/*	$NetBSD: rf_reconstruct.c,v 1.121.12.1 2021/02/17 09:36:10 martin Exp $	*/
 /*
  * Copyright (c) 1995 Carnegie-Mellon University.
  * All rights reserved.
@@ -33,7 +33,7 @@
  /
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.121 2014/11/14 14:29:16 oster Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_reconstruct.c,v 1.121.12.1 2021/02/17 09:36:10 martin Exp $");
 
 #include 
 #include 
@@ -616,7 +616,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 	mapPtr = raidPtr->reconControl->reconMap;
 
 	incPSID = RF_RECONMAP_SIZE;
-	lastPSID = raidPtr->Layout.numStripe / raidPtr->Layout.SUsPerPU;
+	lastPSID = raidPtr->Layout.numStripe / raidPtr->Layout.SUsPerPU - 1;
 	RUsPerPU = raidPtr->Layout.SUsPerPU / raidPtr->Layout.SUsPerRU;
 	recon_error = 0;
 	write_error = 0;
@@ -631,7 +631,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 		raidPtr->reconControl->lastPSID = lastPSID;
 
 	if (pending_writes > lastPSID)
-		pending_writes = lastPSID;
+		pending_writes = lastPSID + 1;
 
 	/* start the actual reconstruction */
 
@@ -796,7 +796,6 @@ rf_ContinueReconstructFailedDisk(RF_Raid
 			pending_writes = lastPSID - prev;
 			raidPtr->reconControl->lastPSID = lastPSID;
 		}
-		
 		/* back down curPSID to get ready for the next round... */
 		for (i = 0; i < raidPtr->numCol; i++) {
 			if (i != col) {



CVS commit: [netbsd-8] src/sys/dev/scsipi

2021-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 11 12:54:56 UTC 2021

Modified Files:
src/sys/dev/scsipi [netbsd-8]: cd.c sd.c

Log Message:
Pull up following revision(s) (requested by ryoon in ticket #1652):

sys/dev/scsipi/cd.c: revision 1.350
sys/dev/scsipi/sd.c: revision 1.331

PR 55986: Ryo Onodera: DK_BUSY must have mask as second argument. Make cd.c
consistent by also using __BIT()


To generate a diff of this commit:
cvs rdiff -u -r1.340.6.2 -r1.340.6.3 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.324.6.1 -r1.324.6.2 src/sys/dev/scsipi/sd.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/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.340.6.2 src/sys/dev/scsipi/cd.c:1.340.6.3
--- src/sys/dev/scsipi/cd.c:1.340.6.2	Sun Mar 29 12:10:37 2020
+++ src/sys/dev/scsipi/cd.c	Thu Feb 11 12:54:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $	*/
+/*	$NetBSD: cd.c,v 1.340.6.3 2021/02/11 12:54:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.2 2020/03/29 12:10:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.340.6.3 2021/02/11 12:54:56 martin Exp $");
 
 #include 
 #include 
@@ -1378,7 +1378,7 @@ cdioctl(dev_t dev, u_long cmd, void *add
 		XS_CTL_IGNORE_NOT_READY | XS_CTL_IGNORE_MEDIA_CHANGE));
 	case DIOCEJECT:
 		if (*(int *)addr == 0) {
-			int pmask = 1 << part;
+			int pmask = __BIT(part);
 			/*
 			 * Don't force eject: check that we are the only
 			 * partition open. If so, unlock it.

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.324.6.1 src/sys/dev/scsipi/sd.c:1.324.6.2
--- src/sys/dev/scsipi/sd.c:1.324.6.1	Wed Jun 21 18:18:55 2017
+++ src/sys/dev/scsipi/sd.c	Thu Feb 11 12:54:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.324.6.1 2017/06/21 18:18:55 snj Exp $	*/
+/*	$NetBSD: sd.c,v 1.324.6.2 2021/02/11 12:54:56 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.324.6.1 2017/06/21 18:18:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.324.6.2 2021/02/11 12:54:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -950,11 +950,12 @@ sdioctl(dev_t dev, u_long cmd, void *add
 		if ((periph->periph_flags & PERIPH_REMOVABLE) == 0)
 			return (ENOTTY);
 		if (*(int *)addr == 0) {
+			int pmask = __BIT(part);
 			/*
 			 * Don't force eject: check that we are the only
 			 * partition open. If so, unlock it.
 			 */
-			if (DK_BUSY(dksc, part) == 0) {
+			if (DK_BUSY(dksc, pmask) == 0) {
 error = scsipi_prevent(periph, SPAMR_ALLOW,
 XS_CTL_IGNORE_NOT_READY);
 if (error)



CVS commit: [netbsd-8] src/sys/dev/hyperv

2021-01-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 29 18:18:25 UTC 2021

Modified Files:
src/sys/dev/hyperv [netbsd-8]: hvkbd.c if_hvn.c vmbus.c

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

sys/dev/hyperv/if_hvn.c: revision 1.20 (via patch)
sys/dev/hyperv/hvkbd.c: revision 1.7 (via patch)
sys/dev/hyperv/vmbus.c: revision 1.12 (via patch)

hvkbd(4): Don't wait forever.
vmbus(4): Don't wait forever.
hvn(4): Don't wait forever.


To generate a diff of this commit:
cvs rdiff -u -r1.1.4.6 -r1.1.4.7 src/sys/dev/hyperv/hvkbd.c
cvs rdiff -u -r1.2.2.8 -r1.2.2.9 src/sys/dev/hyperv/if_hvn.c
cvs rdiff -u -r1.2.2.5 -r1.2.2.6 src/sys/dev/hyperv/vmbus.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/hvkbd.c
diff -u src/sys/dev/hyperv/hvkbd.c:1.1.4.6 src/sys/dev/hyperv/hvkbd.c:1.1.4.7
--- src/sys/dev/hyperv/hvkbd.c:1.1.4.6	Sun Nov 24 08:11:06 2019
+++ src/sys/dev/hyperv/hvkbd.c	Fri Jan 29 18:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hvkbd.c,v 1.1.4.6 2019/11/24 08:11:06 martin Exp $	*/
+/*	$NetBSD: hvkbd.c,v 1.1.4.7 2021/01/29 18:18:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 Microsoft Corp.
@@ -36,7 +36,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.1.4.6 2019/11/24 08:11:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.1.4.7 2021/01/29 18:18:25 martin Exp $");
 
 #include 
 #include 
@@ -363,7 +363,8 @@ hvkbd_connect(struct hvkbd_softc *sc)
 			hvkbd_intr(sc);
 			splx(s);
 		} else
-			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon", mstohz(1));
+			tsleep(sc, PRIBIO | PCATCH, "hvkbdcon",
+			max(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_connected == 0);
 
 	if (timo == 0 && sc->sc_connected == 0) {

Index: src/sys/dev/hyperv/if_hvn.c
diff -u src/sys/dev/hyperv/if_hvn.c:1.2.2.8 src/sys/dev/hyperv/if_hvn.c:1.2.2.9
--- src/sys/dev/hyperv/if_hvn.c:1.2.2.8	Fri Dec 11 15:48:02 2020
+++ src/sys/dev/hyperv/if_hvn.c	Fri Jan 29 18:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.2.2.9 2021/01/29 18:18:25 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.2.2.8 2020/12/11 15:48:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.9 2021/01/29 18:18:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1065,7 +1065,8 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			if (cold)
 delay(1000);
 			else
-tsleep(cmd, PRIBIO, "nvsout", mstohz(1));
+tsleep(cmd, PRIBIO, "nvsout",
+max(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: NVSP operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->nvs_type, rv);
@@ -1090,7 +1091,7 @@ hvn_nvs_cmd(struct hvn_softc *sc, void *
 			splx(s);
 		} else
 			tsleep(sc->sc_nvsrsp, PRIBIO | PCATCH, "nvscmd",
-			mstohz(1));
+			max(1, mstohz(1)));
 	} while (--timo > 0 && sc->sc_nvsdone != 1);
 
 	if (timo == 0 && sc->sc_nvsdone != 1) {
@@ -1388,7 +1389,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			if (cold)
 delay(1000);
 			else
-tsleep(rc, PRIBIO, "rndisout", mstohz(1));
+tsleep(rc, PRIBIO, "rndisout",
+max(1, mstohz(1)));
 		} else if (rv) {
 			DPRINTF("%s: RNDIS operation %u send error %d\n",
 			device_xname(sc->sc_dev), hdr->rm_type, rv);
@@ -1413,7 +1415,8 @@ hvn_rndis_cmd(struct hvn_softc *sc, stru
 			hvn_nvs_intr(sc);
 			splx(s);
 		} else
-			tsleep(rc, PRIBIO | PCATCH, "rndiscmd", mstohz(1));
+			tsleep(rc, PRIBIO | PCATCH, "rndiscmd",
+			max(1, mstohz(1)));
 	} while (--timo > 0 && rc->rc_done != 1);
 
 	bus_dmamap_sync(sc->sc_dmat, rc->rc_dmap, 0, PAGE_SIZE,

Index: src/sys/dev/hyperv/vmbus.c
diff -u src/sys/dev/hyperv/vmbus.c:1.2.2.5 src/sys/dev/hyperv/vmbus.c:1.2.2.6
--- src/sys/dev/hyperv/vmbus.c:1.2.2.5	Sun Nov 24 08:11:06 2019
+++ src/sys/dev/hyperv/vmbus.c	Fri Jan 29 18:18:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vmbus.c,v 1.2.2.5 2019/11/24 08:11:06 martin Exp $	*/
+/*	$NetBSD: vmbus.c,v 1.2.2.6 2021/01/29 18:18:25 martin Exp $	*/
 /*	$OpenBSD: hyperv.c,v 1.43 2017/06/27 13:56:15 mikeb Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.2.2.5 2019/11/24 08:11:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vmbus.c,v 1.2.2.6 2021/01/29 18:18:25 martin Exp $");
 
 #include 
 #include 
@@ -604,7 +604,8 @@ vmbus_start(struct vmbus_softc *sc, stru
 			hyperv_intr();
 			splx(s);
 		} else
-			tsleep(wchan, PRIBIO, wchan, mstohz(delays[i]));
+			tsleep(wchan, PRIBIO, wchan,
+			max(1, mstohz(delays[i] / 1000)));
 	}
 	if (status != HYPERCALL_STATUS_SUCCESS) {
 		device_printf(sc->sc_dev,
@@ -667,7 +668,7 @@ vmbus_wait(struct vmbus_softc *sc,
 			splx(s);
 		} else
 			tsleep(wchan, PRIBIO, wmsg ? wmsg : "hvwait",
-		

CVS commit: [netbsd-8] src/sys/dev/scsipi

2020-12-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 19 19:04:49 UTC 2020

Modified Files:
src/sys/dev/scsipi [netbsd-8]: scsiconf.c

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

sys/dev/scsipi/scsiconf.c: revision 1.283

Add NOLUNS quirk for more SEAGATE SCA/WIDE drives.

Tested on NetBSD/luna68k and LUNA with SCA 80pin -> NARROW 50pin and
WIDE 68pin -> NARROW 50pin connectors.


To generate a diff of this commit:
cvs rdiff -u -r1.279.6.2 -r1.279.6.3 src/sys/dev/scsipi/scsiconf.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/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.279.6.2 src/sys/dev/scsipi/scsiconf.c:1.279.6.3
--- src/sys/dev/scsipi/scsiconf.c:1.279.6.2	Mon Jul 13 14:10:25 2020
+++ src/sys/dev/scsipi/scsiconf.c	Sat Dec 19 19:04:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.279.6.3 2020/12/19 19:04:49 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.3 2020/12/19 19:04:49 martin Exp $");
 
 #include 
 #include 
@@ -674,6 +674,12 @@ static const struct scsi_quirk_inquiry_p
 	{{T_DIRECT, T_FIXED,
 	 "SEAGATE ", "ST318404LC  ", ""}, PQUIRK_NOLUNS},
 	{{T_DIRECT, T_FIXED,
+	 "SEAGATE ", "ST336753LC  ", ""}, PQUIRK_NOLUNS},
+	{{T_DIRECT, T_FIXED,
+	 "SEAGATE ", "ST336753LW  ", ""}, PQUIRK_NOLUNS},
+	{{T_DIRECT, T_FIXED,
+	 "SEAGATE ", "ST336754LC  ", ""}, PQUIRK_NOLUNS},
+	{{T_DIRECT, T_FIXED,
 	 "SEAGATE ", "ST39236LC   ", ""}, PQUIRK_NOLUNS},
 	{{T_DIRECT, T_FIXED,
 	 "SEAGATE ", "ST15150N", ""}, PQUIRK_NOTAG},



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

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 20:30:57 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ohci.c ohcivar.h

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

sys/dev/usb/ohci.c: revision 1.311
sys/dev/usb/ohci.c: revision 1.312
sys/dev/usb/ohcivar.h: revision 1.62

Restructure the abort code for TD based transfers (ctrl, bulk, intr).

In PR kern/22646 some TDs can be on the done queue when the abort start
and, if this is the case, they need to processed after the WDH interrupt.
Instead of waiting for WDH we release TDs that have been touched by the
HC and replace them with new ones.  Once WDH happens the floating TDs
will be returned to the free list.

Also addresses the issue seen in PR kern/55835

Thanks to both Andreas Gustafsson and Edgar Fu=C3=9F for testing.  Apologi=
es to
Andreas Gustafsson for not committing this to HEAD for 4y6m.w

Remove leading space that crept in in the last change


To generate a diff of this commit:
cvs rdiff -u -r1.273.6.6 -r1.273.6.7 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.58.10.1 -r1.58.10.2 src/sys/dev/usb/ohcivar.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/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.273.6.6 src/sys/dev/usb/ohci.c:1.273.6.7
--- src/sys/dev/usb/ohci.c:1.273.6.6	Tue Feb 25 18:52:44 2020
+++ src/sys/dev/usb/ohci.c	Sat Dec 12 20:30:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.273.6.6 2020/02/25 18:52:44 martin Exp $	*/
+/*	$NetBSD: ohci.c,v 1.273.6.7 2020/12/12 20:30:57 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.273.6.6 2020/02/25 18:52:44 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.273.6.7 2020/12/12 20:30:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -390,6 +390,7 @@ ohci_detach(struct ohci_softc *sc, int f
 	if (sc->sc_hcca != NULL)
 		usb_freemem(>sc_bus, >sc_hccadma);
 	pool_cache_destroy(sc->sc_xferpool);
+	cv_destroy(>sc_abort_cv);
 
 	return rv;
 }
@@ -492,6 +493,7 @@ ohci_alloc_std(ohci_softc_t *sc)
 	memset(>td, 0, sizeof(ohci_td_t));
 	std->nexttd = NULL;
 	std->xfer = NULL;
+	std->held = NULL;
 
 	return std;
 }
@@ -539,14 +541,17 @@ ohci_alloc_std_chain(ohci_softc_t *sc, s
 
 	DPRINTFN(8, "xfer %#jx nstd %jd", (uintptr_t)xfer, nstd, 0, 0);
 
-	for (size_t j = 0; j < ox->ox_nstd;) {
+	for (size_t j = 0; j < ox->ox_nstd; j++) {
 		ohci_soft_td_t *cur = ohci_alloc_std(sc);
 		if (cur == NULL)
 			goto nomem;
 
-		ox->ox_stds[j++] = cur;
+		ox->ox_stds[j] = cur;
+		cur->held = >ox_stds[j];
 		cur->xfer = xfer;
 		cur->flags = 0;
+		DPRINTFN(10, "xfer=%#jx new std=%#jx held at %#jx", (uintptr_t)ox,
+		(uintptr_t)cur, (uintptr_t)cur->held, 0);
 	}
 
 	return 0;
@@ -797,6 +802,9 @@ ohci_init(ohci_softc_t *sc)
 	for (i = 0; i < OHCI_HASH_SIZE; i++)
 		LIST_INIT(>sc_hash_itds[i]);
 
+	TAILQ_INIT(>sc_abortingxfers);
+	cv_init(>sc_abort_cv, "ohciabt");
+
 	sc->sc_xferpool = pool_cache_init(sizeof(struct ohci_xfer), 0, 0, 0,
 	"ohcixfer", NULL, IPL_USB, NULL, NULL, NULL);
 
@@ -1313,6 +1321,21 @@ ohci_intr1(ohci_softc_t *sc)
 		 */
 		usb_schedsoftintr(>sc_bus);
 	}
+	if (eintrs & OHCI_SF) {
+		struct ohci_xfer *ox, *tmp;
+		TAILQ_FOREACH_SAFE(ox, >sc_abortingxfers, ox_abnext, tmp) {
+			DPRINTFN(10, "SF %#jx xfer %#jx", (uintptr_t)sc,
+			(uintptr_t)ox, 0, 0);
+			ox->ox_abintrs &= ~OHCI_SF;
+			KASSERT(ox->ox_abintrs == 0);
+			TAILQ_REMOVE(>sc_abortingxfers, ox, ox_abnext);
+		}
+		cv_broadcast(>sc_abort_cv);
+
+		KASSERT(TAILQ_EMPTY(>sc_abortingxfers));
+		DPRINTFN(10, "end SOF %#jx", (uintptr_t)sc, 0, 0, 0);
+		/* Don't remove OHIC_SF from eintrs so it is blocked below */
+	}
 	if (eintrs & OHCI_RD) {
 /* 1 argument, but zero format strings */
 		DPRINTFN(5, "resume detect", (uintptr_t)sc, 0, 0, 0);
@@ -1391,12 +1414,22 @@ ohci_softintr(void *v)
 	struct ohci_pipe *opipe;
 	int len, cc;
 	int i, j, actlen, iframes, uedir;
-	ohci_physaddr_t done;
+	ohci_physaddr_t done = 0;
 
 	KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(>sc_lock));
 
 	OHCIHIST_FUNC(); OHCIHIST_CALLED();
 
+	/*
+	 * Only read hccadone if WDH is set - we might get here from places
+	 * other than an interrupt
+	 */
+	if (!(OREAD4(sc, OHCI_INTERRUPT_STATUS) & OHCI_WDH)) {
+		DPRINTFN(10, "no WDH %#jx", (uintptr_t)sc, 0, 0, 0);
+		return;
+	}
+
+	DPRINTFN(10, "WDH %#jx", (uintptr_t)sc, 0, 0, 0);
 	usb_syncmem(>sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
 	sizeof(sc->sc_hcca->hcca_done_head),
 	BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
@@ -1449,11 +1482,19 @@ ohci_softintr(void *v)
 	DPRINTFN(10, "--- TD dump end ---", 0, 0, 0, 0);
 
 	for (std = sdone; std; std = stdnext) {
-		xfer = std->xfer;
 		stdnext = std->dnext;
-		DPRINTFN(10, "std=%#jx xfer=%#jx hcpriv=%#jx", 

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

2020-12-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 12 12:58:51 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ucom.c

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

sys/dev/usb/ucom.c: revision 1.128

properly wait for refcounts to drain.
fixes panic at detach that jmnceill saw.

XXX: pullup-[89].


To generate a diff of this commit:
cvs rdiff -u -r1.118.8.4 -r1.118.8.5 src/sys/dev/usb/ucom.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.118.8.4 src/sys/dev/usb/ucom.c:1.118.8.5
--- src/sys/dev/usb/ucom.c:1.118.8.4	Tue May  7 18:47:01 2019
+++ src/sys/dev/usb/ucom.c	Sat Dec 12 12:58:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.118.8.4 2019/05/07 18:47:01 martin Exp $	*/
+/*	$NetBSD: ucom.c,v 1.118.8.5 2020/12/12 12:58:51 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.4 2019/05/07 18:47:01 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.5 2020/12/12 12:58:51 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -431,7 +431,7 @@ ucom_detach(device_t self, int flags)
 	}
 
 	sc->sc_refcnt--;
-	while (sc->sc_refcnt > 0) {
+	while (sc->sc_refcnt >= 0) {
 		/* Wake up anyone waiting */
 		if (tp != NULL) {
 			mutex_spin_enter(_lock);



CVS commit: [netbsd-8] src/sys/dev/hyperv

2020-12-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Dec 11 15:48:02 UTC 2020

Modified Files:
src/sys/dev/hyperv [netbsd-8]: if_hvn.c

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

sys/dev/hyperv/if_hvn.c: revision 1.19 (via patch)

hvn(4): fix unable to ifconfig up/down.


To generate a diff of this commit:
cvs rdiff -u -r1.2.2.7 -r1.2.2.8 src/sys/dev/hyperv/if_hvn.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.2.2.7 src/sys/dev/hyperv/if_hvn.c:1.2.2.8
--- src/sys/dev/hyperv/if_hvn.c:1.2.2.7	Tue Nov 26 08:25:28 2019
+++ src/sys/dev/hyperv/if_hvn.c	Fri Dec 11 15:48:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_hvn.c,v 1.2.2.7 2019/11/26 08:25:28 martin Exp $	*/
+/*	$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 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.2.2.7 2019/11/26 08:25:28 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.2.2.8 2020/12/11 15:48:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -379,20 +379,6 @@ hvn_ioctl(struct ifnet *ifp, u_long comm
 	s = splnet();
 
 	switch (command) {
-	case SIOCSIFFLAGS:
-		if (ifp->if_flags & IFF_UP) {
-			if (ifp->if_flags & IFF_RUNNING)
-error = ENETRESET;
-			else {
-error = hvn_init(ifp);
-if (error)
-	ifp->if_flags &= ~IFF_UP;
-			}
-		} else {
-			if (ifp->if_flags & IFF_RUNNING)
-hvn_stop(ifp, 1);
-		}
-		break;
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
 		error = ifmedia_ioctl(ifp, ifr, >sc_media, command);



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

2020-12-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec  7 20:05:36 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1633):

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

PR kern/55839:

handle multiple nvme_rescan()s correctly by doing the
name-space identify only once per nsid.
fixes issue where modloading triggers multiple
rescans.


To generate a diff of this commit:
cvs rdiff -u -r1.30.2.8 -r1.30.2.9 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.30.2.8 src/sys/dev/ic/nvme.c:1.30.2.9
--- src/sys/dev/ic/nvme.c:1.30.2.8	Sun Sep 27 10:33:45 2020
+++ src/sys/dev/ic/nvme.c	Mon Dec  7 20:05:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.9 2020/12/07 20:05:36 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.30.2.8 2020/09/27 10:33:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.9 2020/12/07 20:05:36 martin Exp $");
 
 #include 
 #include 
@@ -625,6 +625,12 @@ nvme_ns_identify(struct nvme_softc *sc, 
 
 	KASSERT(nsid > 0);
 
+	ns = nvme_ns_get(sc, nsid);
+	KASSERT(ns);
+
+	if (ns->ident != NULL)
+		return 0;
+
 	ccb = nvme_ccb_get(sc->sc_admin_q, false);
 	KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
 
@@ -662,9 +668,6 @@ nvme_ns_identify(struct nvme_softc *sc, 
 	/* Convert data to host endian */
 	nvme_identify_namespace_swapbytes(identify);
 
-	ns = nvme_ns_get(sc, nsid);
-	KASSERT(ns);
-	KASSERT(ns->ident == NULL);
 	ns->ident = identify;
 
 done:



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

2020-11-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Nov 16 18:18:15 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c

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

sys/dev/pci/if_wm.c: revision 1.696

Fix little-endian dependence in wm_rxeof(), by which packets cannot be
received by 82574 and successors on big-endian machines.

Tested by aarch64eb with I210-T1 on ROCKPro64.

Thanks msaitoh for discussion!
XXX
pullup to netbsd-9 and netbsd-8


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.41 -r1.508.4.42 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.41 src/sys/dev/pci/if_wm.c:1.508.4.42
--- src/sys/dev/pci/if_wm.c:1.508.4.41	Wed Nov  4 11:51:57 2020
+++ src/sys/dev/pci/if_wm.c	Mon Nov 16 18:18:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.42 2020/11/16 18:18:14 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.508.4.41 2020/11/04 11:51:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.42 2020/11/16 18:18:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8790,9 +8790,11 @@ wm_rxdesc_get_status(struct wm_rxqueue *
 	struct wm_softc *sc = rxq->rxq_sc;
 
 	if (sc->sc_type == WM_T_82574)
-		return EXTRXC_STATUS(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat);
+		return EXTRXC_STATUS(
+		le32toh(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat));
 	else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-		return NQRXC_STATUS(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat);
+		return NQRXC_STATUS(
+		le32toh(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat));
 	else
 		return rxq->rxq_descs[idx].wrx_status;
 }
@@ -8803,9 +8805,11 @@ wm_rxdesc_get_errors(struct wm_rxqueue *
 	struct wm_softc *sc = rxq->rxq_sc;
 
 	if (sc->sc_type == WM_T_82574)
-		return EXTRXC_ERROR(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat);
+		return EXTRXC_ERROR(
+		le32toh(rxq->rxq_ext_descs[idx].erx_ctx.erxc_err_stat));
 	else if ((sc->sc_flags & WM_F_NEWQUEUE) != 0)
-		return NQRXC_ERROR(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat);
+		return NQRXC_ERROR(
+		le32toh(rxq->rxq_nq_descs[idx].nqrx_ctx.nrxc_err_stat));
 	else
 		return rxq->rxq_descs[idx].wrx_errors;
 }



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

2020-11-04 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov  4 11:51:57 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c if_wmvar.h

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #1620):

sys/dev/pci/if_wm.c: revision 1.694
sys/dev/pci/if_wm.c: revision 1.695 (via patch)
sys/dev/pci/if_wmvar.h: revision 1.47

Add WMPHY_I350. Not used yet.

Workaround for ihphy and atphy(ICH*/PCH*, 82580 and I350).
These phys stop DMA while link is down which causes device timeout.
Fix PR/kern 40981
Reviewed and tested by msaitoh@n.o, thanks.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.40 -r1.508.4.41 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.33.6.6 -r1.33.6.7 src/sys/dev/pci/if_wmvar.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.40 src/sys/dev/pci/if_wm.c:1.508.4.41
--- src/sys/dev/pci/if_wm.c:1.508.4.40	Fri Oct 16 08:06:02 2020
+++ src/sys/dev/pci/if_wm.c	Wed Nov  4 11:51:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 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.508.4.40 2020/10/16 08:06:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.41 2020/11/04 11:51:57 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -374,7 +374,8 @@ struct wm_txqueue {
 	 * to manage Tx H/W queue's busy flag.
 	 */
 	int txq_flags;			/* flags for H/W queue, see below */
-#define	WM_TXQ_NO_SPACE	0x1
+#define	WM_TXQ_NO_SPACE		0x1
+#define	WM_TXQ_LINKDOWN_DISCARD	0x2
 
 	bool txq_stopping;
 
@@ -1018,6 +1019,9 @@ static void	wm_toggle_lanphypc_pch_lpt(s
 static int	wm_platform_pm_pch_lpt(struct wm_softc *, bool);
 static void	wm_pll_workaround_i210(struct wm_softc *);
 static void	wm_legacy_irq_quirk_spt(struct wm_softc *);
+static bool	wm_phy_need_linkdown_discard(struct wm_softc *);
+static void	wm_set_linkdown_discard(struct wm_softc *);
+static void	wm_clear_linkdown_discard(struct wm_softc *);
 
 CFATTACH_DECL3_NEW(wm, sizeof(struct wm_softc),
 wm_match, wm_attach, wm_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN);
@@ -3041,6 +3045,9 @@ alloc_retry:
 
 	sc->sc_txrx_use_workqueue = false;
 
+	if (wm_phy_need_linkdown_discard(sc))
+		wm_set_linkdown_discard(sc);
+
 	wm_init_sysctls(sc);
 
 	if (pmf_device_register(self, wm_suspend, wm_resume))
@@ -3399,6 +3406,49 @@ out:
 	return rc;
 }
 
+static bool
+wm_phy_need_linkdown_discard(struct wm_softc *sc)
+{
+
+	switch(sc->sc_phytype) {
+	case WMPHY_82577: /* ihphy */
+	case WMPHY_82578: /* atphy */
+	case WMPHY_82579: /* ihphy */
+	case WMPHY_I217: /* ihphy */
+	case WMPHY_82580: /* ihphy */
+	case WMPHY_I350: /* ihphy */
+		return true;
+	default:
+		return false;
+	}
+}
+
+static void
+wm_set_linkdown_discard(struct wm_softc *sc)
+{
+
+	for (int i = 0; i < sc->sc_nqueues; i++) {
+		struct wm_txqueue *txq = >sc_queue[i].wmq_txq;
+
+		mutex_enter(txq->txq_lock);
+		txq->txq_flags |= WM_TXQ_LINKDOWN_DISCARD;
+		mutex_exit(txq->txq_lock);
+	}
+}
+
+static void
+wm_clear_linkdown_discard(struct wm_softc *sc)
+{
+
+	for (int i = 0; i < sc->sc_nqueues; i++) {
+		struct wm_txqueue *txq = >sc_queue[i].wmq_txq;
+
+		mutex_enter(txq->txq_lock);
+		txq->txq_flags &= ~WM_TXQ_LINKDOWN_DISCARD;
+		mutex_exit(txq->txq_lock);
+	}
+}
+
 /*
  * wm_ioctl:		[ifnet interface function]
  *
@@ -3442,6 +3492,12 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 #ifdef WM_MPSAFE
 		splx(s);
 #endif
+		if (error == 0 && wm_phy_need_linkdown_discard(sc)) {
+			if (IFM_SUBTYPE(ifr->ifr_media) == IFM_NONE)
+wm_set_linkdown_discard(sc);
+			else
+wm_clear_linkdown_discard(sc);
+		}
 		break;
 	case SIOCINITIFADDR:
 		WM_CORE_LOCK(sc);
@@ -3456,8 +3512,17 @@ 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)) {
+wm_set_linkdown_discard(sc);
+			}
+		}
 #ifdef WM_MPSAFE
 		s = splnet();
 #endif
@@ -7542,6 +7607,16 @@ wm_select_txqueue(struct ifnet *ifp, str
 	return ((cpuid + ncpu - sc->sc_affinity_offset) % ncpu) % sc->sc_nqueues;
 }
 
+static inline bool
+wm_linkdown_discard(struct wm_txqueue *txq)
+{
+
+	if ((txq->txq_flags & WM_TXQ_LINKDOWN_DISCARD) != 0)
+		return true;
+
+	return false;
+}
+
 /*
  * wm_start:		[ifnet interface function]
  *
@@ -7636,6 +7711,23 @@ 

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

2020-10-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 16 08:06:02 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c

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

sys/dev/pci/if_wm.c: revision 1.691

  Fixes a problem that the attach function reported
"wm_gmii_setup_phytype: Unknown PHY model. OUI=00, model=" and
"PHY type is still unknown." Don't call wm_gmii_setup_phytype() three times if
the interface uses SGMII with internal MDIO.

  Tested with I354(Rangeley(SGMII(MDIO))) and I350(SERDES(SFP), SGMII(SFP)).


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.39 -r1.508.4.40 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.39 src/sys/dev/pci/if_wm.c:1.508.4.40
--- src/sys/dev/pci/if_wm.c:1.508.4.39	Wed Aug  5 17:22:45 2020
+++ src/sys/dev/pci/if_wm.c	Fri Oct 16 08:06:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.39 2020/08/05 17:22:45 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 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.508.4.39 2020/08/05 17:22:45 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.40 2020/10/16 08:06:02 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2847,7 +2847,8 @@ alloc_retry:
 			reg &= ~CTRL_EXT_I2C_ENA;
 		CSR_WRITE(sc, WMREG_CTRL_EXT, reg);
 		if ((sc->sc_flags & WM_F_SGMII) != 0) {
-			wm_gmii_setup_phytype(sc, 0, 0);
+			if (!wm_sgmii_uses_mdio(sc))
+wm_gmii_setup_phytype(sc, 0, 0);
 			wm_reset_mdicnfg_82580(sc);
 		}
 	} else if (sc->sc_type < WM_T_82543 ||



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

2020-09-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 27 10:33:45 UTC 2020

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

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1610):

sys/dev/ic/ld_nvme.c: revision 1.24 (patch)
sys/dev/ic/nvme.c: revision 1.50 (patch)

PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.


To generate a diff of this commit:
cvs rdiff -u -r1.16.2.4 -r1.16.2.5 src/sys/dev/ic/ld_nvme.c
cvs rdiff -u -r1.30.2.7 -r1.30.2.8 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/ld_nvme.c
diff -u src/sys/dev/ic/ld_nvme.c:1.16.2.4 src/sys/dev/ic/ld_nvme.c:1.16.2.5
--- src/sys/dev/ic/ld_nvme.c:1.16.2.4	Mon Oct 28 18:27:47 2019
+++ src/sys/dev/ic/ld_nvme.c	Sun Sep 27 10:33:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 martin Exp $	*/
+/*	$NetBSD: ld_nvme.c,v 1.16.2.5 2020/09/27 10:33:45 martin Exp $	*/
 
 /*-
  * Copyright (C) 2016 NONAKA Kimihiro 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.5 2020/09/27 10:33:45 martin Exp $");
 
 #include 
 #include 
@@ -86,7 +86,6 @@ ld_nvme_attach(device_t parent, device_t
 	struct nvme_attach_args *naa = aux;
 	struct nvme_namespace *ns;
 	struct nvm_namespace_format *f;
-	int error;
 
 	ld->sc_dv = self;
 	sc->sc_nvme = nsc;
@@ -95,28 +94,11 @@ ld_nvme_attach(device_t parent, device_t
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	error = nvme_ns_identify(sc->sc_nvme, sc->sc_nsid);
-	if (error) {
-		aprint_error_dev(self, "couldn't identify namespace\n");
-		return;
-	}
-
 	ns = nvme_ns_get(sc->sc_nvme, sc->sc_nsid);
 	KASSERT(ns);
-	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
 
-	/*
-	 * NVME1.0e 6.11 Identify command
-	 *
-	 * LBADS values smaller than 9 are not supported, a value
-	 * of zero means that the format is not used.
-	 */
-	if (f->lbads < 9) {
-		if (f->lbads > 0)
-			aprint_error_dev(self,
-			"unsupported logical data size %u\n", f->lbads);
-		return;
-	}
+	f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+	KASSERT(f->lbads >= 9); /* only valid LBA data sizes allowed here */
 
 	ld->sc_secsize = 1 << f->lbads;
 	ld->sc_secperunit = ns->ident->nsze;

Index: src/sys/dev/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.30.2.7 src/sys/dev/ic/nvme.c:1.30.2.8
--- src/sys/dev/ic/nvme.c:1.30.2.7	Mon Nov 11 17:17:22 2019
+++ src/sys/dev/ic/nvme.c	Sun Sep 27 10:33:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 martin Exp $	*/
+/*	$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 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.30.2.7 2019/11/11 17:17:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $");
 
 #include 
 #include 
@@ -469,23 +469,52 @@ nvme_rescan(device_t self, const char *a
 {
 	struct nvme_softc *sc = device_private(self);
 	struct nvme_attach_args naa;
+	struct nvm_namespace_format *f;
+	struct nvme_namespace *ns;
 	uint64_t cap;
 	int ioq_entries = nvme_ioq_size;
 	int i;
+	int error;
 
 	cap = nvme_read8(sc, NVME_CAP);
 	if (ioq_entries > NVME_CAP_MQES(cap))
 		ioq_entries = NVME_CAP_MQES(cap);
 
-	for (i = 0; i < sc->sc_nn; i++) {
-		if (sc->sc_namespaces[i].dev)
+	for (i = 1; i <= sc->sc_nn; i++) {
+		if (sc->sc_namespaces[i - 1].dev)
 			continue;
-		memset(, 0, sizeof(naa));
-		naa.naa_nsid = i + 1;
-		naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
-		naa.naa_maxphys = sc->sc_mdts;
-		sc->sc_namespaces[i].dev = config_found(sc->sc_dev, ,
-		nvme_print);
+
+		/* identify to check for availability */
+		error = nvme_ns_identify(sc, i);
+		if (error) {
+			aprint_error_dev(self, "couldn't identify namespace #%d\n", i);
+			continue;
+		}
+
+		ns = nvme_ns_get(sc, i);
+		KASSERT(ns);
+
+		f = >ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+
+		/*
+		 * NVME1.0e 6.11 Identify command
+		 *
+		 * LBADS values smaller than 9 are not supported, a value
+		 * of zero means that the format is not used.
+		 */
+		if (f->lbads < 9) {
+			if (f->lbads > 0)
+aprint_error_dev(self,
+		 "unsupported logical data size %u\n", f->lbads);
+ 			continue;
+		}
+
+ 		memset(, 0, sizeof(naa));
+		naa.naa_nsid = i;
+ 		naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
+ 		naa.naa_maxphys = sc->sc_mdts;
+		sc->sc_namespaces[i - 1].dev = config_found(sc->sc_dev, ,
+ 		nvme_print);
 	}
 	return 0;
 }



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

2020-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 23 14:31:47 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: virtio.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1609):

sys/dev/pci/virtio_pci.c: revision 1.13 (patch)
(applied to sys/dev/pci/virtio.c)

Ensure MSI-X is disabled if allocation of MSI-X interrupts fail.

The virtio device config space moves out from under us when MSI-X
remains enabled, and/or INTx interrupts are masked if we don't ensure
this.

This un-breaks virtio devices that run out of MSI-X interrupts.
Particularly a problem on uniproc x86, where there are only 8 or 9
vectors available, allowing for only about 4 virtio devices to use
MSI-X.


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.2 -r1.28.2.3 src/sys/dev/pci/virtio.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/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.28.2.2 src/sys/dev/pci/virtio.c:1.28.2.3
--- src/sys/dev/pci/virtio.c:1.28.2.2	Sun Sep 20 10:14:20 2020
+++ src/sys/dev/pci/virtio.c	Wed Sep 23 14:31:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $	*/
+/*	$NetBSD: virtio.c,v 1.28.2.3 2020/09/23 14:31:46 martin Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.3 2020/09/23 14:31:46 martin Exp $");
 
 #include 
 #include 
@@ -280,10 +280,13 @@ virtio_setup_interrupts(struct virtio_so
 {
 	device_t self = sc->sc_dev;
 	pci_chipset_tag_t pc = sc->sc_pa.pa_pc;
+	pcitag_t tag = sc->sc_pa.pa_tag;
 	int error;
 	int nmsix;
+	int off;
 	int counts[PCI_INTR_TYPE_SIZE];
 	pci_intr_type_t max_type;
+	pcireg_t ctl;
 
 	nmsix = pci_msix_count(sc->sc_pa.pa_pc, sc->sc_pa.pa_tag);
 	aprint_debug_dev(self, "pci_msix_count=%d\n", nmsix);
@@ -338,6 +341,13 @@ virtio_setup_interrupts(struct virtio_so
 
 		sc->sc_ihs_num = 1;
 		sc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_NOMSI;
+
+		error = pci_get_capability(pc, tag, PCI_CAP_MSIX, , NULL);
+		if (error != 0) {
+			ctl = pci_conf_read(pc, tag, off + PCI_MSIX_CTL);
+			ctl &= ~PCI_MSIX_CTL_ENABLE;
+			pci_conf_write(pc, tag, off + PCI_MSIX_CTL, ctl);
+		}
 	}
 
 	KASSERT(sc->sc_soft_ih == NULL);



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

2020-09-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 20 10:14:20 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: virtio.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1608):

sys/dev/pci/virtio_pci.c: revision 1.12

Ensure interrupt handles buffer is zeroed on allocation
Prevents crashes trying to deallocate interrupts at shutdown.

Found by kim and mlelstv, confirmed by me


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.1 -r1.28.2.2 src/sys/dev/pci/virtio.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/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.28.2.1 src/sys/dev/pci/virtio.c:1.28.2.2
--- src/sys/dev/pci/virtio.c:1.28.2.1	Mon Feb 19 18:19:15 2018
+++ src/sys/dev/pci/virtio.c	Sun Sep 20 10:14:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.28.2.1 2018/02/19 18:19:15 snj Exp $	*/
+/*	$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.1 2018/02/19 18:19:15 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.28.2.2 2020/09/20 10:14:20 martin Exp $");
 
 #include 
 #include 
@@ -309,7 +309,7 @@ virtio_setup_interrupts(struct virtio_so
 	}
 
 	if (pci_intr_type(pc, sc->sc_ihp[0]) == PCI_INTR_TYPE_MSIX) {
-		sc->sc_ihs = kmem_alloc(sizeof(*sc->sc_ihs) * 2,
+		sc->sc_ihs = kmem_zalloc(sizeof(*sc->sc_ihs) * 2,
 		KM_SLEEP);
 
 		error = virtio_setup_msix_interrupts(sc, >sc_pa);
@@ -326,7 +326,7 @@ virtio_setup_interrupts(struct virtio_so
 		sc->sc_ihs_num = 2;
 		sc->sc_config_offset = VIRTIO_CONFIG_DEVICE_CONFIG_MSI;
 	} else if (pci_intr_type(pc, sc->sc_ihp[0]) == PCI_INTR_TYPE_INTX) {
-		sc->sc_ihs = kmem_alloc(sizeof(*sc->sc_ihs) * 1,
+		sc->sc_ihs = kmem_zalloc(sizeof(*sc->sc_ihs) * 1,
 		KM_SLEEP);
 
 		error = virtio_setup_intx_interrupt(sc, >sc_pa);



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

2020-09-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 19 12:20:36 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ukbdmap.c

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

sys/dev/hid/hidkbdmap.c: revision 1.11 (patch)
(applied to sys/dev/usb/ukbdmap.c)

for jp keymap map also scan code 49 to right bracket to handle ARCHISS model
PR kern/55608 by Shinichi Doyashiki


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.31.10.1 src/sys/dev/usb/ukbdmap.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/ukbdmap.c
diff -u src/sys/dev/usb/ukbdmap.c:1.31 src/sys/dev/usb/ukbdmap.c:1.31.10.1
--- src/sys/dev/usb/ukbdmap.c:1.31	Sat Apr 23 10:15:32 2016
+++ src/sys/dev/usb/ukbdmap.c	Sat Sep 19 12:20:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $	*/
+/*	$NetBSD: ukbdmap.c,v 1.31.10.1 2020/09/19 12:20:36 martin Exp $	*/
 
 /*
  * Copyright (c) 1999,2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ukbdmap.c,v 1.31 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukbdmap.c,v 1.31.10.1 2020/09/19 12:20:36 martin Exp $");
 
 #include 
 #include 
@@ -171,7 +171,8 @@ Static const keysym_t ukbd_keydesc_jp[] 
 KC(46),			KS_asciicircum,		KS_asciitilde,
 KC(47),			KS_at,			KS_grave,
 KC(48),			KS_bracketleft,		KS_braceleft,
-KC(50),			KS_bracketright,	KS_braceright,
+KC(49), /* ARCHISS */	KS_bracketright,	KS_braceright,
+KC(50), /* other model */	KS_bracketright,	KS_braceright,
 KC(51),			KS_semicolon,		KS_plus,
 KC(52),			KS_colon,		KS_asterisk,
 KC(53), 			KS_Zenkaku_Hankaku, /* replace grave/tilde */



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

2020-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 16 13:31:20 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: mpt_netbsd.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1605):

sys/dev/ic/mpt_netbsd.c: revision 1.37

max_devices is a 8bit value and zero is interpreted as 256. This value
can be reported by an mpt device emulated by VMware ESXi.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.33.10.1 src/sys/dev/ic/mpt_netbsd.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/mpt_netbsd.c
diff -u src/sys/dev/ic/mpt_netbsd.c:1.33 src/sys/dev/ic/mpt_netbsd.c:1.33.10.1
--- src/sys/dev/ic/mpt_netbsd.c:1.33	Mon May  2 19:18:29 2016
+++ src/sys/dev/ic/mpt_netbsd.c	Wed Sep 16 13:31:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpt_netbsd.c,v 1.33 2016/05/02 19:18:29 christos Exp $	*/
+/*	$NetBSD: mpt_netbsd.c,v 1.33.10.1 2020/09/16 13:31:20 martin Exp $	*/
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.33 2016/05/02 19:18:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt_netbsd.c,v 1.33.10.1 2020/09/16 13:31:20 martin Exp $");
 
 #include "bio.h"
 
@@ -151,7 +151,7 @@ mpt_scsipi_attach(mpt_softc_t *mpt)
 	chan->chan_channel = 0;
 	chan->chan_flags = 0;
 	chan->chan_nluns = 8;
-	chan->chan_ntargets = mpt->mpt_max_devices;
+	chan->chan_ntargets = mpt->mpt_max_devices ? mpt->mpt_max_devices : 256;
 	chan->chan_id = mpt->mpt_ini_id;
 
 	/*



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

2020-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep  2 12:27:54 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ixgbe.c ixgbe_82598.c ixgbe_82599.c
ixgbe_phy.c ixgbe_type.h ixgbe_x550.c

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

sys/dev/pci/ixgbe/ixgbe_82598.c: revision 1.13
sys/dev/pci/ixgbe/ixgbe.c: revision 1.219
sys/dev/pci/ixgbe/ixgbe_phy.c: revision 1.20
sys/dev/pci/ixgbe/ixgbe_x550.c: revision 1.17
sys/dev/pci/ixgbe/ixgbe_82599.c: revision 1.22
sys/dev/pci/ixgbe/ixgbe_type.h: revision 1.44

Add recovery code for unsupported SFP+.

Before this commit:
   If an unsupported SFP module is inserted before booting, the driver attach
   failed and there was no way to recover form it without rebooting or
   detaching/reattaching driver (drvctl -d && drvctl -r pciN).

After this commit:
   We can automatically recover any time by replacing it with a supported
   module.


To generate a diff of this commit:
cvs rdiff -u -r1.88.2.41 -r1.88.2.42 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.8.8.4 -r1.8.8.5 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.14.8.5 -r1.14.8.6 src/sys/dev/pci/ixgbe/ixgbe_82599.c
cvs rdiff -u -r1.11.6.6 -r1.11.6.7 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.22.2.11 -r1.22.2.12 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.5.6.8 -r1.5.6.9 src/sys/dev/pci/ixgbe/ixgbe_x550.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.41 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.42
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.41	Wed Sep  2 12:24:08 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Sep  2 12:27:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.41 2020/09/02 12:24:08 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.42 2020/09/02 12:27:54 martin Exp $ */
 
 /**
 
@@ -776,6 +776,7 @@ ixgbe_attach(device_t parent, device_t d
 	pcireg_t	id, subid;
 	const ixgbe_vendor_info_t *ent;
 	struct pci_attach_args *pa = aux;
+	bool unsupported_sfp = false;
 	const char *str;
 	char buf[256];
 
@@ -956,8 +957,8 @@ ixgbe_attach(device_t parent, device_t d
 		error = IXGBE_SUCCESS;
 	} else if (error == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		aprint_error_dev(dev, "Unsupported SFP+ module detected!\n");
-		error = EIO;
-		goto err_late;
+		unsupported_sfp = true;
+		error = IXGBE_SUCCESS;
 	} else if (error) {
 		aprint_error_dev(dev, "Hardware initialization failed\n");
 		error = EIO;
@@ -1126,13 +1127,6 @@ ixgbe_attach(device_t parent, device_t d
 		"please contact your Intel or hardware representative "
 		"who provided you with this hardware.\n");
 		break;
-	case IXGBE_ERR_SFP_NOT_SUPPORTED:
-		aprint_error_dev(dev, "Unsupported SFP+ Module\n");
-		error = EIO;
-		goto err_late;
-	case IXGBE_ERR_SFP_NOT_PRESENT:
-		aprint_error_dev(dev, "No SFP+ Module found\n");
-		/* falls thru */
 	default:
 		break;
 	}
@@ -1165,16 +1159,22 @@ ixgbe_attach(device_t parent, device_t d
 			oui, model, rev);
 	}
 
-	/* Enable the optics for 82599 SFP+ fiber */
-	ixgbe_enable_tx_laser(hw);
-
 	/* Enable EEE power saving */
 	if (adapter->feat_cap & IXGBE_FEATURE_EEE)
 		hw->mac.ops.setup_eee(hw,
 		adapter->feat_en & IXGBE_FEATURE_EEE);
 
 	/* Enable power to the phy. */
-	ixgbe_set_phy_power(hw, TRUE);
+	if (!unsupported_sfp) {
+		/* Enable the optics for 82599 SFP+ fiber */
+		ixgbe_enable_tx_laser(hw);
+
+		/*
+		 * XXX Currently, ixgbe_set_phy_power() supports only copper
+		 * PHY, so it's not required to test with !unsupported_sfp.
+		 */
+		ixgbe_set_phy_power(hw, TRUE);
+	}
 
 	/* Initialize statistics */
 	ixgbe_update_stats_counters(adapter);
@@ -3860,6 +3860,7 @@ ixgbe_init_locked(struct adapter *adapte
 	u32		txdctl, mhadd;
 	u32		rxdctl, rxctrl;
 	u32		ctrl_ext;
+	bool		unsupported_sfp = false;
 	int		i, j, err;
 
 	/* XXX check IFF_UP and IFF_RUNNING, power-saving state! */
@@ -3867,6 +3868,7 @@ ixgbe_init_locked(struct adapter *adapte
 	KASSERT(mutex_owned(>core_mtx));
 	INIT_DEBUGOUT("ixgbe_init_locked: begin");
 
+	hw->need_unsupported_sfp_recovery = false;
 	hw->adapter_stopped = FALSE;
 	ixgbe_stop_adapter(hw);
 	callout_stop(>timer);
@@ -4040,12 +4042,14 @@ ixgbe_init_locked(struct adapter *adapte
 	 */
 	if (hw->phy.type == ixgbe_phy_none) {
 		err = hw->phy.ops.identify(hw);
-		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
-			device_printf(dev,
-			"Unsupported SFP+ module type was detected.\n");
-			return;
-		}
-	}
+		if (err == IXGBE_ERR_SFP_NOT_SUPPORTED)
+			unsupported_sfp = true;
+	} else if (hw->phy.type == ixgbe_phy_sfp_unsupported)
+		unsupported_sfp = true;
+
+	if (unsupported_sfp)
+		device_printf(dev,
+		"Unsupported SFP+ module type was detected.\n");
 
 	/* Set moderation on the Link 

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

2020-09-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep  2 12:24:09 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: if_bypass.c ixgbe.c ixgbe_common.c

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

sys/dev/pci/ixgbe/if_bypass.c: revision 1.6
sys/dev/pci/ixgbe/ixgbe_common.c: revision 1.28
sys/dev/pci/ixgbe/ixgbe.c: revision 1.246

Fix checking return value of atomic_cas_uint().

This change fixes a bug that extra delay() is called only once even if
atomic_cas_uint() isn't failed or delay() isn't called when atomic_cas_uint()
failed.

The reason of this bug was that I simply converted FreeBSD' atomic_cmpset_int()
to atomic_cas_uint(). The return value's semantics is different.

 -

Minor change.
  - Print "X550EM X" instead of "X550EM" for Xeon D devices.
  - Fix typo in comment. Same as FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.5 -r1.2.4.6 src/sys/dev/pci/ixgbe/if_bypass.c
cvs rdiff -u -r1.88.2.40 -r1.88.2.41 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.13.2.9 -r1.13.2.10 src/sys/dev/pci/ixgbe/ixgbe_common.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/ixgbe/if_bypass.c
diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.5 src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.6
--- src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.5	Fri Jan 24 18:37:31 2020
+++ src/sys/dev/pci/ixgbe/if_bypass.c	Wed Sep  2 12:24:08 2020
@@ -45,9 +45,9 @@
 static void
 ixgbe_bypass_mutex_enter(struct adapter *adapter)
 {
-	while (atomic_cas_uint(>bypass.low, 0, 1) == 0)
+	while (atomic_cas_uint(>bypass.low, 0, 1) != 0)
 		usec_delay(3000);
-	while (atomic_cas_uint(>bypass.high, 0, 1) == 0)
+	while (atomic_cas_uint(>bypass.high, 0, 1) != 0)
 		usec_delay(3000);
 	return;
 } /* ixgbe_bypass_mutex_enter */
@@ -58,9 +58,9 @@ ixgbe_bypass_mutex_enter(struct adapter 
 static void
 ixgbe_bypass_mutex_clear(struct adapter *adapter)
 {
-	while (atomic_cas_uint(>bypass.high, 1, 0) == 0)
+	while (atomic_cas_uint(>bypass.high, 1, 0) != 1)
 		usec_delay(6000);
-	while (atomic_cas_uint(>bypass.low, 1, 0) == 0)
+	while (atomic_cas_uint(>bypass.low, 1, 0) != 1)
 		usec_delay(6000);
 	return;
 } /* ixgbe_bypass_mutex_clear */
@@ -73,7 +73,7 @@ ixgbe_bypass_mutex_clear(struct adapter 
 static void
 ixgbe_bypass_wd_mutex_enter(struct adapter *adapter)
 {
-	while (atomic_cas_uint(>bypass.high, 0, 1) == 0)
+	while (atomic_cas_uint(>bypass.high, 0, 1) != 0)
 		usec_delay(3000);
 	return;
 } /* ixgbe_bypass_wd_mutex_enter */
@@ -84,7 +84,7 @@ ixgbe_bypass_wd_mutex_enter(struct adapt
 static void
 ixgbe_bypass_wd_mutex_clear(struct adapter *adapter)
 {
-	while (atomic_cas_uint(>bypass.high, 1, 0) == 0)
+	while (atomic_cas_uint(>bypass.high, 1, 0) != 1)
 		usec_delay(6000);
 	return;
 } /* ixgbe_bypass_wd_mutex_clear */
@@ -585,7 +585,7 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
 		return (error);
 
 	/* Keep the log display single-threaded */
-	while (atomic_cas_uint(>bypass.log, 0, 1) == 0)
+	while (atomic_cas_uint(>bypass.log, 0, 1) != 0)
 		usec_delay(3000);
 
 	ixgbe_bypass_mutex_enter(adapter);
@@ -713,14 +713,14 @@ ixgbe_bp_log(SYSCTLFN_ARGS)
 
 	status = 0; /* reset */
 	/* Another log command can now run */
-	while (atomic_cas_uint(>bypass.log, 1, 0) == 0)
+	while (atomic_cas_uint(>bypass.log, 1, 0) != 1)
 		usec_delay(3000);
 	return (error);
 
 unlock_err:
 	ixgbe_bypass_mutex_clear(adapter);
 	status = 0; /* reset */
-	while (atomic_cas_uint(>bypass.log, 1, 0) == 0)
+	while (atomic_cas_uint(>bypass.log, 1, 0) != 1)
 		usec_delay(3000);
 	return (EINVAL);
 } /* ixgbe_bp_log */

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.40 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.41
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.40	Wed Aug  5 15:58:02 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Sep  2 12:24:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.40 2020/08/05 15:58:02 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.41 2020/09/02 12:24:08 martin Exp $ */
 
 /**
 
@@ -858,7 +858,7 @@ ixgbe_attach(device_t parent, device_t d
 		str = "X550";
 		break;
 	case ixgbe_mac_X550EM_x:
-		str = "X550EM";
+		str = "X550EM X";
 		break;
 	case ixgbe_mac_X550EM_a:
 		str = "X550EM A";

Index: src/sys/dev/pci/ixgbe/ixgbe_common.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.13.2.9 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.13.2.10
--- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.13.2.9	Wed Aug  5 15:58:02 2020
+++ src/sys/dev/pci/ixgbe/ixgbe_common.c	Wed Sep  2 12:24:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_common.c,v 1.13.2.9 2020/08/05 15:58:02 martin Exp $ */
+/* $NetBSD: ixgbe_common.c,v 1.13.2.10 2020/09/02 12:24:08 martin Exp $ */
 
 /**
   SPDX-License-Identifier: BSD-3-Clause
@@ -5234,7 

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

2020-08-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Aug 28 19:44:22 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_atu.c if_axe.c if_axen.c

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

sys/dev/usb/if_atu.c: revision 1.73
sys/dev/usb/if_axe.c: apply patch
sys/dev/usb/if_axen.c: apply patch

atu(4): Reject packets larger than MCLBYTES.


To generate a diff of this commit:
cvs rdiff -u -r1.55.8.3 -r1.55.8.4 src/sys/dev/usb/if_atu.c
cvs rdiff -u -r1.82.6.4 -r1.82.6.5 src/sys/dev/usb/if_axe.c
cvs rdiff -u -r1.11.8.8 -r1.11.8.9 src/sys/dev/usb/if_axen.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_atu.c
diff -u src/sys/dev/usb/if_atu.c:1.55.8.3 src/sys/dev/usb/if_atu.c:1.55.8.4
--- src/sys/dev/usb/if_atu.c:1.55.8.3	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_atu.c	Fri Aug 28 19:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_atu.c,v 1.55.8.3 2018/08/08 10:28:35 martin Exp $ */
+/*	$NetBSD: if_atu.c,v 1.55.8.4 2020/08/28 19:44:22 martin Exp $ */
 /*	$OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
 /*
  * Copyright (c) 2003, 2004
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.55.8.3 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.55.8.4 2020/08/28 19:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1687,6 +1687,10 @@ atu_rxeof(struct usbd_xfer *xfer, void *
 		DPRINTF(("%s: atu_rxeof: too short\n",
 		device_xname(sc->atu_dev)));
 		goto done;
+	} else if (len > MCLBYTES) {
+		DPRINTF(("%s: atu_rxeof: too long\n",
+		device_xname(sc->atu_dev)));
+		goto done;
 	}
 
 	h = (struct atu_rx_hdr *)c->atu_buf;

Index: src/sys/dev/usb/if_axe.c
diff -u src/sys/dev/usb/if_axe.c:1.82.6.4 src/sys/dev/usb/if_axe.c:1.82.6.5
--- src/sys/dev/usb/if_axe.c:1.82.6.4	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_axe.c	Fri Aug 28 19:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axe.c,v 1.82.6.4 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_axe.c,v 1.82.6.5 2020/08/28 19:44:22 martin Exp $	*/
 /*	$OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.4 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.82.6.5 2020/08/28 19:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1382,7 +1382,8 @@ axe_rxeof(struct usbd_xfer *xfer, void *
 		}
 
 		if (pktlen > MHLEN - ETHER_ALIGN) {
-			MCLGET(m, M_DONTWAIT);
+			if (pktlen <= MCLBYTES)
+MCLGET(m, M_DONTWAIT);
 			if ((m->m_flags & M_EXT) == 0) {
 m_freem(m);
 ifp->if_ierrors++;

Index: src/sys/dev/usb/if_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.11.8.8 src/sys/dev/usb/if_axen.c:1.11.8.9
--- src/sys/dev/usb/if_axen.c:1.11.8.8	Mon May 13 12:40:13 2019
+++ src/sys/dev/usb/if_axen.c	Fri Aug 28 19:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.11.8.8 2019/05/13 12:40:13 martin Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.11.8.9 2020/08/28 19:44:22 martin Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.8 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.9 2020/08/28 19:44:22 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1097,6 +1097,12 @@ axen_rxeof(struct usbd_xfer *xfer, void 
 			pkt_count));
 			goto nextpkt;
 		}
+		if (pkt_len > MCLBYTES) {
+			ifp->if_ierrors++;
+			DPRINTF(("%s: oversize frame %d\n",
+			device_xname(sc->axen_dev), pkt_len));
+			goto nextpkt;
+		}
 
 		/* process each packet */
 		/* allocate mbuf */



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

2020-08-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Aug 11 17:07:55 UTC 2020

Modified Files:
src/sys/dev [netbsd-8]: dev_verbose.h

Log Message:
Additionally pull up following revision(s) (requested by uwe in ticket #1584):

sys/dev/dev_verbose.h: revision 1.4

DEV_VERBOSE_DEFINE - use MODULE_CLASS_DRIVER to match the definition.
Catch up with previous to unbreak autoloading of verbose modules.
PR kern/55535


To generate a diff of this commit:
cvs rdiff -u -r1.2.10.1 -r1.2.10.2 src/sys/dev/dev_verbose.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/dev_verbose.h
diff -u src/sys/dev/dev_verbose.h:1.2.10.1 src/sys/dev/dev_verbose.h:1.2.10.2
--- src/sys/dev/dev_verbose.h:1.2.10.1	Wed Aug  5 14:48:35 2020
+++ src/sys/dev/dev_verbose.h	Tue Aug 11 17:07:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dev_verbose.h,v 1.2.10.1 2020/08/05 14:48:35 martin Exp $ */
+/*	$NetBSD: dev_verbose.h,v 1.2.10.2 2020/08/11 17:07:55 martin Exp $ */
 
 /*
  * Redistribution and use in source and binary forms, with or without
@@ -96,7 +96,7 @@ tag ## _load_verbose(void)		\
 {	\
 	\
 	if (tag ## verbose_loaded == 0)	\
-		module_autoload(# tag "verbose", MODULE_CLASS_MISC);	\
+		module_autoload(# tag "verbose", MODULE_CLASS_DRIVER);	\
 }	\
 	\
 static const char *			\



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

2020-08-09 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug  9 14:17:48 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: mpii.c

Log Message:
Pull up following revision(s) (requested by jnemeth in ticket #1596):

sys/dev/pci/mpii.c: revision 1.25

make this compile without bio(4)


To generate a diff of this commit:
cvs rdiff -u -r1.8.10.5 -r1.8.10.6 src/sys/dev/pci/mpii.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/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.8.10.5 src/sys/dev/pci/mpii.c:1.8.10.6
--- src/sys/dev/pci/mpii.c:1.8.10.5	Fri Mar 15 14:50:36 2019
+++ src/sys/dev/pci/mpii.c	Sun Aug  9 14:17:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $ */
+/* $NetBSD: mpii.c,v 1.8.10.6 2020/08/09 14:17:48 martin Exp $ */
 /*	OpenBSD: mpii.c,v 1.115 2012/04/11 13:29:14 naddy Exp 	*/
 /*
  * Copyright (c) 2010 Mike Belopuhov 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.6 2020/08/09 14:17:48 martin Exp $");
 
 #include "bio.h"
 
@@ -243,8 +243,10 @@ struct mpii_softc {
 	struct workqueue	*sc_evt_ack_wq;
 	struct work		sc_evt_ack_work;
 
+#if NBIO > 0
 	struct sysmon_envsys	*sc_sme;
 	envsys_data_t		*sc_sensors;
+#endif
 };
 
 int	mpii_match(device_t, cfdata_t, void *);



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 17:22:46 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: igphy.c igphyreg.h makphy.c makphyreg.h
src/sys/dev/pci [netbsd-8]: if_wm.c if_wmreg.h if_wmvar.h

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

sys/dev/pci/if_wm.c 1.655-1.658, 1.660,
1.662, 1.664-1.668,
1.671-1.674, 1.678,
1.680-1.685 via patch
sys/dev/pci/if_wmreg.c  1.118-1.119 via patch
sys/dev/pci/if_wmvar.c  1.45 via patch
sys/dev/mii/igphy.c 1.35-1.36 via patch
sys/dev/mii/igphyreg.h  1.12-1.13
sys/dev/mii/makphy.c1.66 via patch
sys/dev/mii/makphyreg.h 1.11

- Add SFP support. Module insertion/removal is not supported yet.
  Currently, SFP detection is only done in the driver's attach phase.
- Detect the Media Auto Sense feature. Not supported yet.
- Fix SFF_SFP_ETH_FLAGS_100FX. It's not 0x10 but 0x20.
- Add extra delay in wm_serdes_power_up_link_82575().
- Add Intel I219 LM10-LM15 and V10-V14.
- wm(4) can use workqueue as deferred Rx/Tx handler).
  Set hw.wm*.txrx_workqueue=1 to use workqueue instead of softint.
  The default value of hw.wm*.txrx_workqueue is 0 which use softint
  as before.
- Unset RSS UDP flags like ixg(4) and other OSes. To handle IP
  fragmented UDP, first packet and second packet should be processed
  in the same Rx queue.
- It's useless to not to set PCI_PMCSR_PME_STS bit when writing because
  the bit is W1C. Instead, always write PCI_PMCSR_PME_STS bit to clear
  in case it's already set.
- Actually writing always the checksum offload context descriptor
  makes the HW do extra processing, avoid doing that if possible.
- Fix a bug that the WMREG_EEARBC_I210 register is incorrectly set if
  the system uses iNVM.
- "wmX: 0" on 82542 is difficult to understand, so don't print it.
- Explicitly cast from uint16_t to uint32_t before shifting 16bit left
  when printing Image Unique ID to avoid undefined behavior.
- Set if_baudrate for non-MII device.
- Rename some macros and function.
- KNF. Add comment.


To generate a diff of this commit:
cvs rdiff -u -r1.26.10.1 -r1.26.10.2 src/sys/dev/mii/igphy.c
cvs rdiff -u -r1.10 -r1.10.8.1 src/sys/dev/mii/igphyreg.h
cvs rdiff -u -r1.42.8.4 -r1.42.8.5 src/sys/dev/mii/makphy.c
cvs rdiff -u -r1.6.20.2 -r1.6.20.3 src/sys/dev/mii/makphyreg.h
cvs rdiff -u -r1.508.4.38 -r1.508.4.39 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.98.6.11 -r1.98.6.12 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.33.6.5 -r1.33.6.6 src/sys/dev/pci/if_wmvar.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/igphy.c
diff -u src/sys/dev/mii/igphy.c:1.26.10.1 src/sys/dev/mii/igphy.c:1.26.10.2
--- src/sys/dev/mii/igphy.c:1.26.10.1	Tue Aug  1 23:33:18 2017
+++ src/sys/dev/mii/igphy.c	Wed Aug  5 17:22:46 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: igphy.c,v 1.26.10.1 2017/08/01 23:33:18 snj Exp $	*/
+/*	$NetBSD: igphy.c,v 1.26.10.2 2020/08/05 17:22:46 martin Exp $	*/
 
 /*
  * The Intel copyright applies to the analog register setup, and the
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.26.10.1 2017/08/01 23:33:18 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igphy.c,v 1.26.10.2 2020/08/05 17:22:46 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mii.h"
@@ -274,7 +274,7 @@ igphy_load_dspcode(struct mii_softc *sc)
 
 	delay(2);
 
-	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT, 0x);
+	PHY_WRITE(sc, IGPHY_PAGE_SELECT, 0x);
 	PHY_WRITE(sc, 0x, 0x0140);
 
 	delay(5000);
@@ -282,7 +282,7 @@ igphy_load_dspcode(struct mii_softc *sc)
 	for (i = 0; !((code[i].reg == 0) && (code[i].val == 0)); i++)
 		IGPHY_WRITE(sc, code[i].reg, code[i].val);
 
-	PHY_WRITE(sc, MII_IGPHY_PAGE_SELECT, 0x);
+	PHY_WRITE(sc, IGPHY_PAGE_SELECT, 0x);
 	PHY_WRITE(sc, 0x, 0x3300);
 
 	delay(2);
@@ -327,9 +327,9 @@ igphy_reset(struct mii_softc *sc)
 	}
 
 	if (igsc->sc_mactype == WM_T_82547) {
-		fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_SPARE_FUSE_STATUS);
+		fused = IGPHY_READ(sc, IGPHY_ANALOG_SPARE_FUSE_STATUS);
 		if ((fused & ANALOG_SPARE_FUSE_ENABLED) == 0) {
-			fused = IGPHY_READ(sc, MII_IGPHY_ANALOG_FUSE_STATUS);
+			fused = IGPHY_READ(sc, IGPHY_ANALOG_FUSE_STATUS);
 
 			fine = fused & ANALOG_FUSE_FINE_MASK;
 			coarse = fused & ANALOG_FUSE_COARSE_MASK;
@@ -344,12 +344,12 @@ igphy_reset(struct mii_softc *sc)
 			(fine & ANALOG_FUSE_FINE_MASK) |
 			(coarse & ANALOG_FUSE_COARSE_MASK);
 
-			IGPHY_WRITE(sc, MII_IGPHY_ANALOG_FUSE_CONTROL, fused);
-			IGPHY_WRITE(sc, MII_IGPHY_ANALOG_FUSE_BYPASS,
+			IGPHY_WRITE(sc, IGPHY_ANALOG_FUSE_CONTROL, fused);
+			

CVS commit: [netbsd-8] src/sys/dev/sdmmc

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:14:25 UTC 2020

Modified Files:
src/sys/dev/sdmmc [netbsd-8]: sdhc.c sdhcreg.h

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

sys/dev/sdmmc/sdhc.c: revision 1.107
sys/dev/sdmmc/sdhcreg.h: revision 1.21

Identify SDHC 4.1 and 4.2. From {DragonFly,Free}BSD.


To generate a diff of this commit:
cvs rdiff -u -r1.100.4.1 -r1.100.4.2 src/sys/dev/sdmmc/sdhc.c
cvs rdiff -u -r1.18.10.1 -r1.18.10.2 src/sys/dev/sdmmc/sdhcreg.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/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.100.4.1 src/sys/dev/sdmmc/sdhc.c:1.100.4.2
--- src/sys/dev/sdmmc/sdhc.c:1.100.4.1	Sun Jan  7 09:24:59 2018
+++ src/sys/dev/sdmmc/sdhc.c	Wed Aug  5 16:14:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.100.4.1 2018/01/07 09:24:59 snj Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.100.4.2 2020/08/05 16:14:25 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.100.4.1 2018/01/07 09:24:59 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.100.4.2 2020/08/05 16:14:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -316,6 +316,12 @@ sdhc_host_found(struct sdhc_softc *sc, b
 	case SDHC_SPEC_VERS_400:
 		aprint_normal("4.0");
 		break;
+	case SDHC_SPEC_VERS_410:
+		aprint_normal("4.1");
+		break;
+	case SDHC_SPEC_VERS_420:
+		aprint_normal("4.2");
+		break;
 	case SDHC_SPEC_NOVERS:
 		hp->specver = -1;
 		aprint_normal("NO-VERS");

Index: src/sys/dev/sdmmc/sdhcreg.h
diff -u src/sys/dev/sdmmc/sdhcreg.h:1.18.10.1 src/sys/dev/sdmmc/sdhcreg.h:1.18.10.2
--- src/sys/dev/sdmmc/sdhcreg.h:1.18.10.1	Sun Jan  7 09:24:59 2018
+++ src/sys/dev/sdmmc/sdhcreg.h	Wed Aug  5 16:14:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhcreg.h,v 1.18.10.1 2018/01/07 09:24:59 snj Exp $	*/
+/*	$NetBSD: sdhcreg.h,v 1.18.10.2 2020/08/05 16:14:25 martin Exp $	*/
 /*	$OpenBSD: sdhcreg.h,v 1.4 2006/07/30 17:20:40 fgsch Exp $	*/
 
 /*
@@ -246,6 +246,8 @@
 #define SDHC_SPEC_VERS_200		0x01
 #define SDHC_SPEC_VERS_300		0x02
 #define SDHC_SPEC_VERS_400		0x03
+#define SDHC_SPEC_VERS_410		0x04
+#define SDHC_SPEC_VERS_420		0x05
 #define SDHC_SPEC_NOVERS		0xff	/* dummy */
 
 /* SDHC_CAPABILITIES decoding */



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:11:56 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: piixpm.c piixpmreg.h

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

sys/dev/pci/piixpm.c1.57-1.59,
1.61-1.63 via patch
sys/dev/pci/piixpmreg.h 1.9-1.12

- Fix number of port for Hudson rev. 0x1f and newer.
- Read SB800_SMB_HOSTC correctly. This register is not in the PCI
  config space but in the I/O space.
- The bit 0 of SB800_SMB_HOSTC is 0 on SMI or 1 on IRQ, so invert the
  check.
- Don't force using SMBUS0SEL register.
- Acquire/release host semaphore to share SMBus between the host and
  the embedded controller (IMC). Without this change, "shutdown -r"
  does power off and not boot on some machines.
- Save/restore port number before selecting port.
- Modify comment.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.52.6.1 -r1.52.6.2 src/sys/dev/pci/piixpm.c
cvs rdiff -u -r1.7.22.1 -r1.7.22.2 src/sys/dev/pci/piixpmreg.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/piixpm.c
diff -u src/sys/dev/pci/piixpm.c:1.52.6.1 src/sys/dev/pci/piixpm.c:1.52.6.2
--- src/sys/dev/pci/piixpm.c:1.52.6.1	Tue Aug  6 16:02:54 2019
+++ src/sys/dev/pci/piixpm.c	Wed Aug  5 16:11:56 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: piixpm.c,v 1.52.6.1 2019/08/06 16:02:54 martin Exp $ */
+/* $NetBSD: piixpm.c,v 1.52.6.2 2020/08/05 16:11:56 martin Exp $ */
 /*	$OpenBSD: piixpm.c,v 1.39 2013/10/01 20:06:02 sf Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.52.6.1 2019/08/06 16:02:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1.52.6.2 2020/08/05 16:11:56 martin Exp $");
 
 #include 
 #include 
@@ -70,8 +70,11 @@ __KERNEL_RCSID(0, "$NetBSD: piixpm.c,v 1
 
 #define PIIXPM_IS_FCHGRP(sc)	(PIIXPM_IS_HUDSON(sc) || PIIXPM_IS_KERNCZ(sc))
 
+#define PIIX_SB800_TIMEOUT 500
+
 struct piixpm_smbus {
 	int			sda;
+	int			sda_save;
 	struct			piixpm_softc *softc;
 };
 
@@ -86,6 +89,7 @@ struct piixpm_softc {
 	bus_space_handle_t	sc_smb_ioh;
 	void *			sc_smb_ih;
 	int			sc_poll;
+	bool			sc_sb800_selen; /* Use SMBUS0SEL */
 
 	pci_chipset_tag_t	sc_pc;
 	pcitag_t		sc_pcitag;
@@ -119,8 +123,8 @@ static bool	piixpm_resume(device_t, cons
 
 static int	piixpm_sb800_init(struct piixpm_softc *);
 static void	piixpm_csb5_reset(void *);
-static int	piixpm_i2c_acquire_bus(void *, int);
-static void	piixpm_i2c_release_bus(void *, int);
+static int	piixpm_i2c_sb800_acquire_bus(void *, int);
+static void	piixpm_i2c_sb800_release_bus(void *, int);
 static int	piixpm_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *,
 size_t, void *, size_t, int);
 
@@ -231,15 +235,10 @@ nopowermanagement:
 	/* SB800 rev 0x40+, AMD HUDSON and newer need special initialization */
 	if (PIIXPM_IS_FCHGRP(sc) || PIIXPM_IS_SB800GRP(sc)) {
 		if (piixpm_sb800_init(sc) == 0) {
-			sc->sc_numbusses = 4;
-
 			/* Read configuration */
-			conf = pci_conf_read(pa->pa_pc, pa->pa_tag,
-			SB800_SMB_HOSTC);
-			DPRINTF(("%s: conf 0x%08x\n", device_xname(self),
-conf));
-
-			usesmi = conf & SB800_SMB_HOSTC_SMI;
+			conf = bus_space_read_1(sc->sc_iot,
+			sc->sc_smb_ioh, SB800_SMB_HOSTC);
+			usesmi = ((conf & SB800_SMB_HOSTC_IRQ) == 0);
 			goto setintr;
 		}
 		aprint_normal_dev(self, "SMBus initialization failed\n");
@@ -328,17 +327,24 @@ piixpm_rescan(device_t self, const char 
 	/* Attach I2C bus */
 
 	for (i = 0; i < sc->sc_numbusses; i++) {
+		struct i2c_controller *tag = >sc_i2c_tags[i];
+
 		if (sc->sc_i2c_device[i])
 			continue;
 		sc->sc_busses[i].sda = i;
 		sc->sc_busses[i].softc = sc;
-		sc->sc_i2c_tags[i].ic_cookie = >sc_busses[i];
-		sc->sc_i2c_tags[i].ic_acquire_bus = piixpm_i2c_acquire_bus;
-		sc->sc_i2c_tags[i].ic_release_bus = piixpm_i2c_release_bus;
-		sc->sc_i2c_tags[i].ic_exec = piixpm_i2c_exec;
+		tag->ic_cookie = >sc_busses[i];
+		if (PIIXPM_IS_SB800GRP(sc) || PIIXPM_IS_FCHGRP(sc)) {
+			tag->ic_acquire_bus = piixpm_i2c_sb800_acquire_bus;
+			tag->ic_release_bus = piixpm_i2c_sb800_release_bus;
+		} else {
+			tag->ic_acquire_bus = NULL;
+			tag->ic_release_bus = NULL;
+		}
+		tag->ic_exec = piixpm_i2c_exec;
 		memset(, 0, sizeof(iba));
 		iba.iba_type = I2C_TYPE_SMBUS;
-		iba.iba_tag = >sc_i2c_tags[i];
+		iba.iba_tag = tag;
 		sc->sc_i2c_device[i] = config_found_ia(self, ifattr, ,
 		piixpm_iicbus_print);
 	}
@@ -401,6 +407,12 @@ piixpm_sb800_init(struct piixpm_softc *s
 	uint16_t val, base_addr;
 	bool enabled;
 
+	if (PIIXPM_IS_KERNCZ(sc) ||
+	(PIIXPM_IS_HUDSON(sc) && (sc->sc_rev >= 0x1f)))
+		sc->sc_numbusses = 2;
+	else
+		sc->sc_numbusses = 4;
+
 	/* Fetch SMB base address */
 	if (bus_space_map(iot,
 	SB800_INDIRECTIO_BASE, SB800_INDIRECTIO_SIZE, 0, )) {
@@ 

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 16:08:10 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_ti.c if_tireg.h

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

sys/dev/pci/if_ti.c 1.103, 1.106, 1.108,
1.116-1.120 via patch
sys/dev/pci/if_tireg.h  1.26

- Use pci_intr_establish_xname()
- Don't clear CFI and priority bit to pass them to the upper layer.
- Add support for Farallon PN9000SX from FreeBSD.
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- Fix typo in comment.
- Style fix.


To generate a diff of this commit:
cvs rdiff -u -r1.101.8.2 -r1.101.8.3 src/sys/dev/pci/if_ti.c
cvs rdiff -u -r1.20 -r1.20.30.1 src/sys/dev/pci/if_tireg.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_ti.c
diff -u src/sys/dev/pci/if_ti.c:1.101.8.2 src/sys/dev/pci/if_ti.c:1.101.8.3
--- src/sys/dev/pci/if_ti.c:1.101.8.2	Mon May 13 12:40:13 2019
+++ src/sys/dev/pci/if_ti.c	Wed Aug  5 16:08:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ti.c,v 1.101.8.2 2019/05/13 12:40:13 martin Exp $ */
+/* $NetBSD: if_ti.c,v 1.101.8.3 2020/08/05 16:08:09 martin Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.101.8.2 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ti.c,v 1.101.8.3 2020/08/05 16:08:09 martin Exp $");
 
 #include "opt_inet.h"
 
@@ -140,6 +140,8 @@ static const struct ti_type ti_devs[] = 
 		"Netgear GA620 1000BASE-T Ethernet" },
 	{ PCI_VENDOR_SGI, PCI_PRODUCT_SGI_TIGON,
 		"Silicon Graphics Gigabit Ethernet" },
+	{ PCI_VENDOR_DEC, PCI_PRODUCT_DEC_PN9000SX,
+		"Farallon PN9000SX Gigabit Ethernet" },
 	{ 0, 0, NULL }
 };
 
@@ -152,8 +154,8 @@ static void ti_txeof_tigon2(struct ti_so
 static void ti_rxeof(struct ti_softc *);
 
 static void ti_stats_update(struct ti_softc *);
-static int ti_encap_tigon1(struct ti_softc *, struct mbuf *, u_int32_t *);
-static int ti_encap_tigon2(struct ti_softc *, struct mbuf *, u_int32_t *);
+static int ti_encap_tigon1(struct ti_softc *, struct mbuf *, uint32_t *);
+static int ti_encap_tigon2(struct ti_softc *, struct mbuf *, uint32_t *);
 
 static int ti_intr(void *);
 static void ti_start(struct ifnet *);
@@ -165,15 +167,15 @@ static void ti_watchdog(struct ifnet *);
 static int ti_ifmedia_upd(struct ifnet *);
 static void ti_ifmedia_sts(struct ifnet *, struct ifmediareq *);
 
-static u_int32_t ti_eeprom_putbyte(struct ti_softc *, int);
-static u_int8_t	ti_eeprom_getbyte(struct ti_softc *, int, u_int8_t *);
+static uint32_t ti_eeprom_putbyte(struct ti_softc *, int);
+static uint8_t	ti_eeprom_getbyte(struct ti_softc *, int, uint8_t *);
 static int ti_read_eeprom(struct ti_softc *, void *, int, int);
 
 static void ti_add_mcast(struct ti_softc *, struct ether_addr *);
 static void ti_del_mcast(struct ti_softc *, struct ether_addr *);
 static void ti_setmulti(struct ti_softc *);
 
-static void ti_mem(struct ti_softc *, u_int32_t, u_int32_t, const void *);
+static void ti_mem(struct ti_softc *, uint32_t, uint32_t, const void *);
 static void ti_loadfw(struct ti_softc *);
 static void ti_cmd(struct ti_softc *, struct ti_cmd_desc *);
 static void ti_cmd_ext(struct ti_softc *, struct ti_cmd_desc *, void *, int);
@@ -205,7 +207,7 @@ CFATTACH_DECL_NEW(ti, sizeof(struct ti_s
 /*
  * Send an instruction or address to the EEPROM, check for ACK.
  */
-static u_int32_t
+static uint32_t
 ti_eeprom_putbyte(struct ti_softc *sc, int byte)
 {
 	int i, ack = 0;
@@ -216,7 +218,7 @@ ti_eeprom_putbyte(struct ti_softc *sc, i
 	TI_SETBIT(sc, TI_MISC_LOCAL_CTL, TI_MLC_EE_TXEN);
 
 	/*
-	 * Feed in each bit and stobe the clock.
+	 * Feed in each bit and strobe the clock.
 	 */
 	for (i = 0x80; i; i >>= 1) {
 		if (byte & i) {
@@ -250,11 +252,11 @@ ti_eeprom_putbyte(struct ti_softc *sc, i
  * We have to send two address bytes since the EEPROM can hold
  * more than 256 bytes of data.
  */
-static u_int8_t
-ti_eeprom_getbyte(struct ti_softc *sc, int addr, u_int8_t *dest)
+static uint8_t
+ti_eeprom_getbyte(struct ti_softc *sc, int addr, uint8_t *dest)
 {
 	int		i;
-	u_int8_t		byte = 0;
+	uint8_t		byte = 0;
 
 	EEPROM_START();
 
@@ -327,7 +329,7 @@ ti_read_eeprom(struct ti_softc *sc, void
 {
 	char *dest = destv;
 	int err = 0, i;
-	u_int8_t byte = 0;
+	uint8_t byte = 0;
 
 	for (i = 0; i < cnt; i++) {
 		err = ti_eeprom_getbyte(sc, off + i, );
@@ -344,7 +346,7 @@ ti_read_eeprom(struct ti_softc *sc, void
  * of NIC local memory or (if tbuf is non-NULL) copy data into it.
  */
 static void
-ti_mem(struct ti_softc *sc, u_int32_t addr, u_int32_t len, const void *xbuf)
+ti_mem(struct ti_softc *sc, uint32_t addr, uint32_t len, const void *xbuf)
 {
 	int			segptr, segsize, cnt;
 	const void		*ptr;
@@ -368,11 +370,11 @@ ti_mem(struct 

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 15:58:03 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ix_txrx.c ixgbe.c ixgbe.h
ixgbe_82598.c ixgbe_common.c ixgbe_netbsd.c ixgbe_osdep.h
ixgbe_phy.c ixgbe_vf.c ixgbe_x550.c ixv.c

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

sys/dev/pci/ixgbe/ix_txrx.c 1.62-1.63 via patch
sys/dev/pci/ixgbe/ixgbe.c   1.225, 1.228-1.229,
1.232 via patch
sys/dev/pci/ixgbe/ixgbe.h   1.64, 1.66
sys/dev/pci/ixgbe/ixv.c 1.146, 1.148-1.150
via patch
sys/dev/pci/ixgbe/ixgbe_common.c1.27
sys/dev/pci/ixgbe/ixgbe_vf.c1.23
sys/dev/pci/ixgbe/ixgbe_82598.c 1.15
sys/dev/pci/ixgbe/ixgbe_x550.c  1.18
sys/dev/pci/ixgbe/ixgbe_netbsd.c1.14
sys/dev/pci/ixgbe/ixgbe_phy.c   1.21
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.26

- Fix IXGBE_LE32_TO_CPUS() macro for big endian machine. This problem
  was only on X550.
- Add debug printf()s.
- Use unsigned to avoid undefined behavior in
  ixgbe_fc_enable_generic().
- Modify a little to reduce diff between ixgbe.c and ixv.c.
  No functional change.
- Modify comment.
- Remove unused macros.
- Whitespace fix.
- Fix typos.


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.19 -r1.24.2.20 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.88.2.39 -r1.88.2.40 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.24.6.19 -r1.24.6.20 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.8.8.3 -r1.8.8.4 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.13.2.8 -r1.13.2.9 src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.6.2.5 -r1.6.2.6 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
cvs rdiff -u -r1.17.6.6 -r1.17.6.7 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.11.6.5 -r1.11.6.6 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.12.8.4 -r1.12.8.5 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.5.6.7 -r1.5.6.8 src/sys/dev/pci/ixgbe/ixgbe_x550.c
cvs rdiff -u -r1.56.2.29 -r1.56.2.30 src/sys/dev/pci/ixgbe/ixv.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/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.19 src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.20
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.19	Fri Jan 24 18:37:31 2020
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Wed Aug  5 15:58:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.24.2.19 2020/01/24 18:37:31 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.24.2.20 2020/08/05 15:58:02 martin Exp $ */
 
 /**
 
@@ -926,7 +926,7 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, 
 	vlan_macip_lens |= ip_hlen;
 
 	/* No support for offloads for non-L4 next headers */
- 	switch (ipproto) {
+	switch (ipproto) {
 	case IPPROTO_TCP:
 		if (mp->m_pkthdr.csum_flags &
 		(M_CSUM_TCPv4 | M_CSUM_TCPv6))
@@ -1569,7 +1569,6 @@ ixgbe_setup_receive_ring(struct rx_ring 
 		rxbuf->addr = htole64(rxbuf->pmap->dm_segs[0].ds_addr);
 	}
 
-
 	/* Setup our descriptor indices */
 	rxr->next_to_check = 0;
 	rxr->next_to_refresh = 0;
@@ -1625,6 +1624,7 @@ ixgbe_setup_receive_structures(struct ad
 	struct rx_ring *rxr = adapter->rx_rings;
 	intj;
 
+	INIT_DEBUGOUT("ixgbe_setup_receive_structures");
 	for (j = 0; j < adapter->num_queues; j++, rxr++)
 		if (ixgbe_setup_receive_ring(rxr))
 			goto fail;
@@ -2233,7 +2233,7 @@ ixgbe_allocate_queues(struct adapter *ad
 
 	/* First, allocate the top level queue structs */
 	adapter->queues = (struct ix_queue *)malloc(sizeof(struct ix_queue) *
-adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO);
+	adapter->num_queues, M_DEVBUF, M_NOWAIT | M_ZERO);
 if (adapter->queues == NULL) {
 		aprint_error_dev(dev, "Unable to allocate queue memory\n");
 error = ENOMEM;
@@ -2300,7 +2300,7 @@ ixgbe_allocate_queues(struct adapter *ad
 			"Critical Failure setting up transmit buffers\n");
 			error = ENOMEM;
 			goto err_tx_desc;
-	}
+		}
 		if (!(adapter->feat_en & IXGBE_FEATURE_LEGACY_TX)) {
 			/* Allocate a buf ring */
 			txr->txr_interq = pcq_create(IXGBE_BR_SIZE, KM_SLEEP);

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.39 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.40
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.39	Fri Jan 24 18:37:31 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Aug  5 15:58:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.39 2020/01/24 18:37:31 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.40 2020/08/05 15:58:02 martin Exp $ */
 
 

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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 15:54:30 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: ichsmb.c

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

sys/dev/pci/ichsmb.c1.66-1.68 via patch

- Add Comet Lake, Whiskey Lake U and Amber Lake Y support.
- Whitespace fix.


To generate a diff of this commit:
cvs rdiff -u -r1.50.6.3 -r1.50.6.4 src/sys/dev/pci/ichsmb.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/ichsmb.c
diff -u src/sys/dev/pci/ichsmb.c:1.50.6.3 src/sys/dev/pci/ichsmb.c:1.50.6.4
--- src/sys/dev/pci/ichsmb.c:1.50.6.3	Thu Jul 26 20:32:38 2018
+++ src/sys/dev/pci/ichsmb.c	Wed Aug  5 15:54:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichsmb.c,v 1.50.6.3 2018/07/26 20:32:38 snj Exp $	*/
+/*	$NetBSD: ichsmb.c,v 1.50.6.4 2020/08/05 15:54:30 martin Exp $	*/
 /*	$OpenBSD: ichiic.c,v 1.18 2007/05/03 09:36:26 dlg Exp $	*/
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.50.6.3 2018/07/26 20:32:38 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.50.6.4 2020/08/05 15:54:30 martin Exp $");
 
 #include 
 #include 
@@ -118,8 +118,10 @@ ichsmb_match(device_t parent, cfdata_t m
 		case PCI_PRODUCT_INTEL_100SERIES_LP_SMB:
 		case PCI_PRODUCT_INTEL_2HS_SMB:
 		case PCI_PRODUCT_INTEL_3HS_SMB:
+		case PCI_PRODUCT_INTEL_3HS_U_SMB:
 		case PCI_PRODUCT_INTEL_CORE4G_M_SMB:
 		case PCI_PRODUCT_INTEL_CORE5G_M_SMB:
+		case PCI_PRODUCT_INTEL_CMTLK_SMB:
 		case PCI_PRODUCT_INTEL_BAYTRAIL_PCU_SMB:
 		case PCI_PRODUCT_INTEL_BSW_PCU_SMB:
 		case PCI_PRODUCT_INTEL_APL_SMB:
@@ -237,7 +239,6 @@ ichsmb_chdet(device_t self, device_t chi
 
 	if (sc->sc_i2c_device == child)
 		sc->sc_i2c_device = NULL;
-
 }
 
 static int
@@ -282,7 +283,7 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
 	LPCIB_SMB_HS_INTR | LPCIB_SMB_HS_DEVERR |
 	LPCIB_SMB_HS_BUSERR | LPCIB_SMB_HS_FAILED);
 	bus_space_barrier(sc->sc_iot, sc->sc_ioh, LPCIB_SMB_HS, 1,
-	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);  
+	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
 
 	/* Wait for bus to be idle */
 	for (retries = 100; retries > 0; retries--) {



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

2020-08-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Aug  5 14:48:35 UTC 2020

Modified Files:
src/sys/dev [netbsd-8]: dev_verbose.h

Log Message:
Pull up following revision(s) (requested by uwe in ticket #1584):

sys/dev/dev_verbose.h: revision 1.3

DEV_VERBOSE_MODULE_DEFINE - use MODULE_CLASS_DRIVER.

This makes built-in verbose modules available before the start of the
autoconfiguration, when they are needed.  From pgoyette@

PR kern/55535


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.2.10.1 src/sys/dev/dev_verbose.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/dev_verbose.h
diff -u src/sys/dev/dev_verbose.h:1.2 src/sys/dev/dev_verbose.h:1.2.10.1
--- src/sys/dev/dev_verbose.h:1.2	Fri Nov 13 01:37:19 2015
+++ src/sys/dev/dev_verbose.h	Wed Aug  5 14:48:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dev_verbose.h,v 1.2 2015/11/13 01:37:19 christos Exp $ */
+/*	$NetBSD: dev_verbose.h,v 1.2.10.1 2020/08/05 14:48:35 martin Exp $ */
 
 /*
  * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,7 @@ tag ## verbose_modcmd(modcmd_t cmd, void
 		return ENOTTY;		\
 	}\
 }	\
-MODULE(MODULE_CLASS_MISC, tag ## verbose, deps)
+MODULE(MODULE_CLASS_DRIVER, tag ## verbose, deps)
 
 #endif /* KERNEL */
 



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 19:00:40 UTC 2020

Modified Files:
src/sys/dev/i2c [netbsd-8]: sdtemp.c

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

sys/dev/i2c/sdtemp.c1.35, 1.37-1.39

- Check the return value of iic_acquire_bus() because this function
  may fail.
- Fix typo in comment.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.32.8.1 -r1.32.8.2 src/sys/dev/i2c/sdtemp.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/sdtemp.c
diff -u src/sys/dev/i2c/sdtemp.c:1.32.8.1 src/sys/dev/i2c/sdtemp.c:1.32.8.2
--- src/sys/dev/i2c/sdtemp.c:1.32.8.1	Thu Mar  8 14:29:12 2018
+++ src/sys/dev/i2c/sdtemp.c	Mon Jul 20 19:00:40 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: sdtemp.c,v 1.32.8.1 2018/03/08 14:29:12 martin Exp $*/
+/*  $NetBSD: sdtemp.c,v 1.32.8.2 2020/07/20 19:00:40 martin Exp $*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.32.8.1 2018/03/08 14:29:12 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.32.8.2 2020/07/20 19:00:40 martin Exp $");
 
 #include 
 #include 
@@ -214,8 +214,13 @@ sdtemp_match(device_t parent, cfdata_t c
 	if ((ia->ia_addr & SDTEMP_ADDRMASK) != SDTEMP_ADDR)
 		return 0;
 
-	/* Verify that we can read the manufacturer ID, Device ID and the capability */
-	iic_acquire_bus(sc.sc_tag, 0);
+	/*
+	 * Verify that we can read the manufacturer ID, Device ID and the
+	 * capability
+	 */
+	error = iic_acquire_bus(sc.sc_tag, 0);
+	if (error)
+		return 0;
 	error = sdtemp_read_16(, SDTEMP_REG_MFG_ID,  ) |
 		sdtemp_read_16(, SDTEMP_REG_DEV_REV, ) |
 		sdtemp_read_16(, SDTEMP_REG_CAPABILITY, );
@@ -234,8 +239,8 @@ sdtemp_match(device_t parent, cfdata_t c
 	}
 
 	/*
-	 * Check by SDTEMP_IS_TSE2004AV() might not be enough, so check the alarm
-	 * capability, too.
+	 * Check by SDTEMP_IS_TSE2004AV() might not be enough, so check the
+	 * alarm capability, too.
 	 */
 	if ((cap & SDTEMP_CAP_HAS_ALARM) == 0)
 		return 0;
@@ -255,7 +260,10 @@ sdtemp_attach(device_t parent, device_t 
 	sc->sc_address = ia->ia_addr;
 	sc->sc_dev = self;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error)
+		return;
+
 	if ((error = sdtemp_read_16(sc, SDTEMP_REG_MFG_ID,  )) != 0 ||
 	(error = sdtemp_read_16(sc, SDTEMP_REG_DEV_REV, )) != 0) {
 		iic_release_bus(sc->sc_tag, 0);
@@ -297,7 +305,7 @@ sdtemp_attach(device_t parent, device_t 
 	 * IDT's devices and some Microchip's devices have the resolution
 	 * register in the vendor specific registers area. The devices'
 	 * resolution bits in the capability register are not the maximum
-	 * resolution but the current vaule of the setting.
+	 * resolution but the current value of the setting.
 	 */
 	if (sdtemp_dev_table[i].sdtemp_config != NULL)
 		sdtemp_dev_table[i].sdtemp_config(sc);
@@ -428,7 +436,9 @@ sdtemp_get_limits(struct sysmon_envsys *
 	uint16_t lim;
 
 	*props = 0;
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0)
+		return;
+
 	if (sdtemp_read_16(sc, SDTEMP_REG_LOWER_LIM, ) == 0 && lim != 0) {
 		limits->sel_warnmin = sdtemp_decode_temp(sc, lim);
 		*props |= PROP_WARNMIN;
@@ -458,7 +468,9 @@ sdtemp_set_limits(struct sysmon_envsys *
 		limits = >sc_deflims;
 		props  = >sc_defprops;
 	}
-	iic_acquire_bus(sc->sc_tag, 0);
+	if (iic_acquire_bus(sc->sc_tag, 0) != 0)
+		return;
+
 	if (*props & PROP_WARNMIN) {
 		val = __UK2C(limits->sel_warnmin);
 		(void)sdtemp_write_16(sc, SDTEMP_REG_LOWER_LIM,
@@ -570,7 +582,12 @@ sdtemp_refresh(struct sysmon_envsys *sme
 	uint16_t val;
 	int error;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error) {
+		edata->state = ENVSYS_SINVALID;
+		return;
+	}
+
 	error = sdtemp_read_16(sc, SDTEMP_REG_AMBIENT_TEMP, );
 	iic_release_bus(sc->sc_tag, 0);
 
@@ -598,7 +615,7 @@ sdtemp_refresh(struct sysmon_envsys *sme
 }
 
 /*
- * power management functions
+ * Power management functions
  *
  * We go into "shutdown" mode at suspend time, and return to normal
  * mode upon resume.  This reduces power consumption by disabling
@@ -612,7 +629,10 @@ sdtemp_pmf_suspend(device_t dev, const p
 	int error;
 	uint16_t config;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error != 0)
+		return false;
+
 	error = sdtemp_read_16(sc, SDTEMP_REG_CONFIG, );
 	if (error == 0) {
 		config |= SDTEMP_CONFIG_SHUTDOWN_MODE;
@@ -629,7 +649,10 @@ sdtemp_pmf_resume(device_t dev, const pm
 	int error;
 	uint16_t config;
 
-	iic_acquire_bus(sc->sc_tag, 0);
+	error = iic_acquire_bus(sc->sc_tag, 0);
+	if (error != 0)
+		return false;
+
 	error = sdtemp_read_16(sc, SDTEMP_REG_CONFIG, );
 	if (error == 0) {
 		config &= ~SDTEMP_CONFIG_SHUTDOWN_MODE;



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:53:56 UTC 2020

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

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

sys/dev/pci/pcidevs 1.1392-1.1403, 1.1406-1.1419

- Add Intel Xeon D-1500 NTB-secondary and Xeon D NS QuickData DMA
  channel 0-7.
- Add Intel I219 LM10-LM15 and V10-V14.
- Add AMD Family14h PCIe.
- Add Realtek Killer E3000.
- Add Aquantia AQC 10G network adapters.
- Add Radeon HD4290
- Add Farallon PN9000SX Ethernet.
- NVIDIA 0x036[0-7] are nForce MCP55 LPC Bridge.
- Add VIA VX900 chipset.
- Add some NVIDIA devices.
- Add some Intel UHD Graphics devices.
- Add Intel Comet Lake, Whiskey Lake U and Amber Lake Y devices.
- Modify description of Intel 0x591e from HD Graphics to UHD Graphics.
- Add Intel XMM 7360 LTE Modem.
- Add Western Digital WD Blue SN550 NVMe SSD.
- Add ATI Radeon R5/R6/R7 Graphics.
- Add IDs for Ampere eMAG PCIe Root Ports.
- Add RTL8192EE Wireless LAN 802.11n PCI-E NIC.
- Add ASIX AX99100 Multi I/O (Serial,Parallel,I2C,SPI,LocalBus,GPIO)
  Controller.
- Add a couple of additional device IDs for the AMD Cryptographic
  Coprocessor.
- Remove duplicated entries.


To generate a diff of this commit:
cvs rdiff -u -r1.1289.2.18 -r1.1289.2.19 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.1289.2.18 src/sys/dev/pci/pcidevs:1.1289.2.19
--- src/sys/dev/pci/pcidevs:1.1289.2.18	Mon Jul 20 18:47:16 2020
+++ src/sys/dev/pci/pcidevs	Mon Jul 20 18:53:56 2020
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1289.2.18 2020/07/20 18:47:16 martin Exp $
+$NetBSD: pcidevs,v 1.1289.2.19 2020/07/20 18:53:56 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -651,8 +651,10 @@ vendor SYMPHONY2	0x1c1c	Symphony Labs (2
 vendor HGST		0x1c58	HGST, Inc.
 vendor BEIJING_MEMBLAZE	0x1c5f	Beijing Memblaze Technology Co. Ltd.
 vendor AMAZON		0x1d0f	Amazon.com, Inc.
+vendor AQUANTIA		0x1d6a	Aquantia
 vendor ROCKCHIP		0x1d87	Rockchip
 vendor TEKRAM2		0x1de1	Tekram Technology (2nd PCI Vendor ID)
+vendor AMPERE		0x1def	Ampere Computing
 vendor SUNIX2		0x1fd4	SUNIX Co
 vendor HINT		0x3388	HiNT
 vendor 3DLABS		0x3d3d	3D Labs
@@ -1023,13 +1025,20 @@ product AMD F17_DF_5		0x1464	Family17h D
 product AMD F17_DF_6		0x1465	Family17h Data Fabric
 product AMD F17_DF_7		0x1466	Family17h Data Fabric
 product AMD F17_DF_8		0x1467	Family17h Data Fabric
+product AMD F17_CCP_2		0x1468	Family17h Crypto
 product AMD F17_PCIE_4		0x1470	Family17h PCIe
 product AMD F17_PCIE_5		0x1471	Family17h PCIe
 product AMD F17_7X_RC		0x1480	Family17h/7xh Root Complex
 product AMD F17_7X_IOMMU	0x1481	Family17h/7xh IOMMU
 product AMD F17_7X_RESV_SPP	0x1485	Family17h/7xh Reserved SPP
+product AMD F17_7X_CCP		0x1486	Family17h/7xh Crypto
 product AMD F17_7X_USB3		0x149c	Family17h/7xh USB 3.0 Host Controller
 product AMD F14_RC		0x1510	Family14h Root Complex
+product AMD F14_PCIE_1		0x1512	Family14h PCIe
+product AMD F14_PCIE_2		0x1513	Family14h PCIe
+product AMD F14_PCIE_3		0x1514	Family14h PCIe
+product AMD F14_PCIE_4		0x1515	Family14h PCIe
+product AMD F14_PCIE_5		0x1516	Family14h PCIe
 product AMD F16_HT		0x1530	Family16h HyperTransport Configuration
 product AMD F16_ADDR		0x1531	Family16h Address Map Configuration
 product AMD F16_DRAM		0x1532	Family16h DRAM Configuration
@@ -1103,7 +1112,7 @@ product AMD PCSCSI_PCI		0x2020	PCscsi-PC
 product AMD GEODELX_PCHB	0x2080	Geode LX Host-PCI Bridge
 product AMD GEODELX_VGA 	0x2081	Geode LX VGA Controller
 product AMD GEODELX_AES 	0x2082	Geode LX AES Security Block
-product	AMD CS5536_PCISB	0x208f	CS5536 GeodeLink PCI South Bridge
+product AMD CS5536_PCISB	0x208f	CS5536 GeodeLink PCI South Bridge
 product AMD CS5536_PCIB		0x2090	CS5536 PCI-ISA Bridge
 product AMD CS5536_FLASH	0x2091	CS5536 Flash
 product AMD CS5536_AUDIO	0x2093	CS5536 Audio
@@ -1213,6 +1222,16 @@ product AMI MEGARAID3		0x1960	MegaRAID 3
 product AMI MEGARAID		0x9010	MegaRAID
 product AMI MEGARAID2		0x9060	MegaRAID 2
 
+/* Ampere Computing products */
+product AMPERE EMAG_PCIE_0	0xe005	eMAG PCIe Root Port 0
+product AMPERE EMAG_PCIE_1	0xe006	eMAG PCIe Root Port 1
+product AMPERE EMAG_PCIE_2	0xe007	eMAG PCIe Root Port 2
+product AMPERE EMAG_PCIE_3	0xe008	eMAG PCIe Root Port 3
+product AMPERE EMAG_PCIE_4	0xe009	eMAG PCIe Root Port 4
+product AMPERE EMAG_PCIE_5	0xe00a	eMAG PCIe Root Port 5
+product AMPERE EMAG_PCIE_6	0xe00b	eMAG PCIe Root Port 6
+product AMPERE EMAG_PCIE_7	0xe00c	eMAG PCIe Root Port 7
+
 /* Analog Devices products */
 product ANALOG AD1889	0x1889	AD1889 PCI SoundMAX Controller
 product ANALOG SAFENET	0x2f44	SafeNet Crypto Accelerator ADSP-2141
@@ -1282,6 +1301,24 @@ product APPLE INTREPID2_FW	0x006a	Intrep
 product APPLE INTREPID2_GMAC	0x006b	Intrepid 2 GMAC
 product APPLE BCM5701		0x1645	BCM5701

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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:55:52 UTC 2020

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

Log Message:
Regen for ticket #1579


To generate a diff of this commit:
cvs rdiff -u -r1.1281.2.18 -r1.1281.2.19 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1280.2.18 -r1.1280.2.19 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-8] src/sys/dev/mii

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:43:25 UTC 2020

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

Log Message:
regen for ticket #1577


To generate a diff of this commit:
cvs rdiff -u -r1.128.6.9 -r1.128.6.10 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.116.6.9 -r1.116.6.10 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.128.6.9 src/sys/dev/mii/miidevs.h:1.128.6.10
--- src/sys/dev/mii/miidevs.h:1.128.6.9	Tue Apr 14 18:11:35 2020
+++ src/sys/dev/mii/miidevs.h	Mon Jul 20 18:43:25 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.128.6.9 2020/04/14 18:11:35 martin Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.128.6.10 2020/07/20 18:43:25 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.10 2020/07/20 18:42:47 martin Exp
  */
 
 /*-
@@ -616,8 +616,28 @@
 #define	MII_STR_xxVITESSE_VSC8601	"VSC8601 10/100/1000 PHY"
 #define	MII_MODEL_xxVITESSE_VSC8641	0x0003
 #define	MII_STR_xxVITESSE_VSC8641	"Vitesse VSC8641 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8504	0x000c
+#define	MII_STR_xxVITESSE_VSC8504	"Vitesse VSC8504 quad 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8552	0x000e
+#define	MII_STR_xxVITESSE_VSC8552	"Vitesse VSC8552 dual 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8502	0x0012
+#define	MII_STR_xxVITESSE_VSC8502	"Vitesse VSC8502 dual 10/100/1000TX PHY"
 #define	MII_MODEL_xxVITESSE_VSC8501	0x0013
 #define	MII_STR_xxVITESSE_VSC8501	"Vitesse VSC8501 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8531	0x0017
+#define	MII_STR_xxVITESSE_VSC8531	"Vitesse VSC8531 10/100/1000TX PHY"
+#define	MII_MODEL_xxVITESSE_VSC8662	0x0026
+#define	MII_STR_xxVITESSE_VSC8662	"Vitesse VSC866[24] dual/quad 1000T 100FX 1000X PHY"
+#define	MII_MODEL_xxVITESSE_VSC8514	0x0027
+#define	MII_STR_xxVITESSE_VSC8514	"Vitesse VSC8514 quad 1000T PHY"
+#define	MII_MODEL_xxVITESSE_VSC8512	0x002e
+#define	MII_STR_xxVITESSE_VSC8512	"Vitesse VSC8512 12port 1000T PHY"
+#define	MII_MODEL_xxVITESSE_VSC8522	0x002f
+#define	MII_STR_xxVITESSE_VSC8522	"Vitesse VSC8522 12port 1000T PHY"
+#define	MII_MODEL_xxVITESSE_VSC8658	0x0035
+#define	MII_STR_xxVITESSE_VSC8658	"Vitesse VSC8658 octal 1000T 100FX 1000X PHY"
+#define	MII_MODEL_xxVITESSE_VSC8541	0x0037
+#define	MII_STR_xxVITESSE_VSC8541	"Vitesse VSC8541 1000T PHY"
 
 /* XaQti Corp. PHYs */
 #define	MII_MODEL_xxXAQTI_XMACII	0x

Index: src/sys/dev/mii/miidevs_data.h
diff -u src/sys/dev/mii/miidevs_data.h:1.116.6.9 src/sys/dev/mii/miidevs_data.h:1.116.6.10
--- src/sys/dev/mii/miidevs_data.h:1.116.6.9	Tue Apr 14 18:11:35 2020
+++ src/sys/dev/mii/miidevs_data.h	Mon Jul 20 18:43:25 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs_data.h,v 1.116.6.9 2020/04/14 18:11:35 martin Exp $	*/
+/*	$NetBSD: miidevs_data.h,v 1.116.6.10 2020/07/20 18:43:25 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.10 2020/07/20 18:42:47 martin Exp
  */
 
 /*-
@@ -246,7 +246,17 @@ struct mii_knowndev mii_knowndevs[] = {
  { MII_OUI_xxVIA, MII_MODEL_xxVIA_VT6103_2, MII_STR_xxVIA_VT6103_2 },
  { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8601, MII_STR_xxVITESSE_VSC8601 },
  { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8641, MII_STR_xxVITESSE_VSC8641 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8504, MII_STR_xxVITESSE_VSC8504 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8552, MII_STR_xxVITESSE_VSC8552 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8502, MII_STR_xxVITESSE_VSC8502 },
  { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8501, MII_STR_xxVITESSE_VSC8501 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8531, MII_STR_xxVITESSE_VSC8531 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8662, MII_STR_xxVITESSE_VSC8662 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8514, MII_STR_xxVITESSE_VSC8514 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8512, MII_STR_xxVITESSE_VSC8512 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8522, MII_STR_xxVITESSE_VSC8522 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8658, MII_STR_xxVITESSE_VSC8658 },
+ { MII_OUI_xxVITESSE, MII_MODEL_xxVITESSE_VSC8541, MII_STR_xxVITESSE_VSC8541 },
  { MII_OUI_xxXAQTI, MII_MODEL_xxXAQTI_XMACII, MII_STR_xxXAQTI_XMACII },
  { 0, 0, NULL }
 };



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

2020-07-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 20 18:42:47 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: miidevs

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1577):
sys/dev/mii/miidevs: revision 1.168
  Add some Microsemi (Vitesse) devices.


To generate a diff of this commit:
cvs rdiff -u -r1.125.6.9 -r1.125.6.10 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/miidevs
diff -u src/sys/dev/mii/miidevs:1.125.6.9 src/sys/dev/mii/miidevs:1.125.6.10
--- src/sys/dev/mii/miidevs:1.125.6.9	Tue Apr 14 17:57:17 2020
+++ src/sys/dev/mii/miidevs	Mon Jul 20 18:42:47 2020
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp $
+$NetBSD: miidevs,v 1.125.6.10 2020/07/20 18:42:47 martin Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -400,7 +400,17 @@ model xxVIA VT6103_2		0x0034	VT6103 10/1
 /* Vitesse PHYs (Now Microsemi) */
 model xxVITESSE VSC8601		0x0002 VSC8601 10/100/1000 PHY
 model xxVITESSE VSC8641		0x0003 Vitesse VSC8641 10/100/1000TX PHY
+model xxVITESSE VSC8504		0x000c Vitesse VSC8504 quad 10/100/1000TX PHY
+model xxVITESSE VSC8552		0x000e Vitesse VSC8552 dual 10/100/1000TX PHY
+model xxVITESSE VSC8502		0x0012 Vitesse VSC8502 dual 10/100/1000TX PHY
 model xxVITESSE VSC8501		0x0013 Vitesse VSC8501 10/100/1000TX PHY
+model xxVITESSE VSC8531		0x0017 Vitesse VSC8531 10/100/1000TX PHY
+model xxVITESSE VSC8662		0x0026 Vitesse VSC866[24] dual/quad 1000T 100FX 1000X PHY
+model xxVITESSE VSC8514		0x0027 Vitesse VSC8514 quad 1000T PHY
+model xxVITESSE VSC8512		0x002e Vitesse VSC8512 12port 1000T PHY
+model xxVITESSE VSC8522		0x002f Vitesse VSC8522 12port 1000T PHY
+model xxVITESSE VSC8658		0x0035 Vitesse VSC8658 octal 1000T 100FX 1000X PHY
+model xxVITESSE VSC8541		0x0037 Vitesse VSC8541 1000T PHY
 
 /* XaQti Corp. PHYs */
 model xxXAQTI XMACII		0x XaQti Corp. XMAC II gigabit interface



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

2020-07-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 13 14:35:29 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ualea.c

Log Message:
Pull up following revision(s) (requested by simonb in ticket #1573):

sys/dev/usb/ualea.c: revision 1.12

Set up the USB xfer for every transfer, not just once in the attach
function.  Caught by DIAGNOSTIC on a similar driver.  Thanks to mrg@
for USB xfer clue and martin@ for testing.


To generate a diff of this commit:
cvs rdiff -u -r1.6.8.1 -r1.6.8.2 src/sys/dev/usb/ualea.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/ualea.c
diff -u src/sys/dev/usb/ualea.c:1.6.8.1 src/sys/dev/usb/ualea.c:1.6.8.2
--- src/sys/dev/usb/ualea.c:1.6.8.1	Wed Jan 31 18:01:54 2018
+++ src/sys/dev/usb/ualea.c	Mon Jul 13 14:35:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ualea.c,v 1.6.8.1 2018/01/31 18:01:54 martin Exp $	*/
+/*	$NetBSD: ualea.c,v 1.6.8.2 2020/07/13 14:35:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.6.8.1 2018/01/31 18:01:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ualea.c,v 1.6.8.2 2020/07/13 14:35:29 martin Exp $");
 
 #include 
 #include 
@@ -144,11 +144,6 @@ ualea_attach(device_t parent, device_t s
 		return;
 	}
 
-	/* Setup the xfer to call ualea_xfer_done with sc.  */
-	usbd_setup_xfer(sc->sc_xfer, sc, usbd_get_buffer(sc->sc_xfer),
-	sc->sc_maxpktsize, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
-	ualea_xfer_done);
-
 	/* Success!  We are ready to run.  */
 	mutex_enter(>sc_lock);
 	sc->sc_attached = true;
@@ -197,6 +192,11 @@ ualea_xfer(struct ualea_softc *sc)
 	if (sc->sc_needed == 0)
 		return;
 
+	/* Setup the xfer to call ualea_xfer_done with sc.  */
+	usbd_setup_xfer(sc->sc_xfer, sc, usbd_get_buffer(sc->sc_xfer),
+	sc->sc_maxpktsize, USBD_SHORT_XFER_OK, USBD_NO_TIMEOUT,
+	ualea_xfer_done);
+
 	/* Issue xfer or complain if we can't.  */
 	/*
 	 * XXX Does USBD_NORMAL_COMPLETION (= 0) make sense here?  The



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

2020-07-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 13 14:13:12 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: vioscsi.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1572):

sys/dev/pci/vioscsi.c: revision 1.22

Fix off-by-one SCSI target reporting

Use max_target as the controller ID instead of zero, so that the device
located at SCSI ID zero (e.g. a disk) is not obscured through not being
probed by scsi_probe_bus() (which skips the controller ID).

Copy the target requested onto the wire without decrementing it by one.

ok christos@


To generate a diff of this commit:
cvs rdiff -u -r1.19.2.1 -r1.19.2.2 src/sys/dev/pci/vioscsi.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/vioscsi.c
diff -u src/sys/dev/pci/vioscsi.c:1.19.2.1 src/sys/dev/pci/vioscsi.c:1.19.2.2
--- src/sys/dev/pci/vioscsi.c:1.19.2.1	Mon Jul 15 08:23:23 2019
+++ src/sys/dev/pci/vioscsi.c	Mon Jul 13 14:13:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vioscsi.c,v 1.19.2.1 2019/07/15 08:23:23 martin Exp $	*/
+/*	$NetBSD: vioscsi.c,v 1.19.2.2 2020/07/13 14:13:12 martin Exp $	*/
 /*	$OpenBSD: vioscsi.c,v 1.3 2015/03/14 03:38:49 jsg Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.19.2.1 2019/07/15 08:23:23 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vioscsi.c,v 1.19.2.2 2020/07/13 14:13:12 martin Exp $");
 
 #include 
 #include 
@@ -198,7 +198,7 @@ vioscsi_attach(device_t parent, device_t
 	chan->chan_channel = 0;
 	chan->chan_ntargets = MIN(max_target, 16);	/* cap reasonably */
 	chan->chan_nluns = MIN(max_lun, 1024);		/* cap reasonably */
-	chan->chan_id = 0;
+	chan->chan_id = max_target;
 	chan->chan_flags = SCSIPI_CHAN_NOSETTLE;
 
 	config_found(self, >sc_channel, scsiprint);
@@ -322,7 +322,7 @@ vioscsi_scsipi_request(struct scsipi_cha
 	}
 
 	req->lun[0] = 1;
-	req->lun[1] = periph->periph_target - 1;
+	req->lun[1] = periph->periph_target;
 	req->lun[2] = 0x40 | ((periph->periph_lun >> 8) & 0x3F);
 	req->lun[3] = periph->periph_lun & 0xFF;
 	memset(req->lun + 4, 0, 4);



CVS commit: [netbsd-8] src/sys/dev/scsipi

2020-07-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Jul 13 14:10:25 UTC 2020

Modified Files:
src/sys/dev/scsipi [netbsd-8]: scsiconf.c

Log Message:
Pull up following revision(s) (requested by kim in ticket #1571):

sys/dev/scsipi/scsiconf.c: revision 1.288

Continue scanning a SCSI bus when a LUN is reported not present

This fixes disk attachment under Qemu when there is no disk on LUN 0 on
a SCSI bus but there is a disk on LUN 1. The inquiry for LUN 0 returns
SID_QUAL_LU_NOTPRESENT & T_NODEVICE.  Quirks are only checked if neither
one of those are set, so cannot use a quirk entry.

Use case 1: Proxmox 6 configures each disk on its own bus when using
the "Virtio SCSI single" SCSI controller. However, while the "scsi0"
disk is on LUN 0, the "scsi1" disk is on LUN 1.

Use case 2: A Linode boot profile with multiple disks results in
the first disk ("sda") on LUN 1, while the second disk ("sdb") is
on LUN 0, each on their own bus.


To generate a diff of this commit:
cvs rdiff -u -r1.279.6.1 -r1.279.6.2 src/sys/dev/scsipi/scsiconf.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/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.279.6.1 src/sys/dev/scsipi/scsiconf.c:1.279.6.2
--- src/sys/dev/scsipi/scsiconf.c:1.279.6.1	Wed Jun 21 18:18:55 2017
+++ src/sys/dev/scsipi/scsiconf.c	Mon Jul 13 14:10:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.279.6.1 2017/06/21 18:18:55 snj Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.1 2017/06/21 18:18:55 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.279.6.2 2020/07/13 14:10:25 martin Exp $");
 
 #include 
 #include 
@@ -869,6 +869,8 @@ scsi_probe_device(struct scsibus_softc *
 		break;
 
 	case SID_QUAL_LU_NOTPRESENT:
+		docontinue = 1;
+		/* FALLTHROUGH */
 	case SID_QUAL_reserved:
 	case SID_QUAL_LU_NOT_SUPP:
 		goto bad;



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

2020-06-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jun 30 17:41:01 UTC 2020

Modified Files:
src/sys/dev/acpi [netbsd-8]: acpi_display.c

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

sys/dev/acpi/acpi_display.c: revision 1.18

Only need to set brightness if reading the initial state fails
to sync firmware and the driver. Avoids black screen at boot time.

Thanks to jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.2.1 src/sys/dev/acpi/acpi_display.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_display.c
diff -u src/sys/dev/acpi/acpi_display.c:1.16 src/sys/dev/acpi/acpi_display.c:1.16.2.1
--- src/sys/dev/acpi/acpi_display.c:1.16	Thu Jun  1 02:45:09 2017
+++ src/sys/dev/acpi/acpi_display.c	Tue Jun 30 17:41:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: acpi_display.c,v 1.16 2017/06/01 02:45:09 chs Exp $	*/
+/*	$NetBSD: acpi_display.c,v 1.16.2.1 2020/06/30 17:41:01 martin Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.16 2017/06/01 02:45:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_display.c,v 1.16.2.1 2020/06/30 17:41:01 martin Exp $");
 
 #include 
 #include 
@@ -647,8 +647,8 @@ acpidisp_out_attach(device_t parent, dev
 		 * Synchronize ACPI and driver brightness levels, and
 		 * check that brightness control is working.
 		 */
-		(void)acpidisp_get_brightness(osc, >bc_current);
-		if (acpidisp_set_brightness(osc, bc->bc_current)) {
+		if (acpidisp_get_brightness(osc, >bc_current) &&
+		acpidisp_set_brightness(osc, bc->bc_current)) {
 			kmem_free(bc->bc_level,
 			bc->bc_level_count * sizeof(*bc->bc_level));
 			kmem_free(bc, sizeof(*bc));



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

2020-06-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Jun 16 10:28:29 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_run.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1559):
sys/dev/usb/if_run.c: revision 1.41
Better bounds checking for oversized packets, to avoid kernel memory
corruption. Pointed out by Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.22.2.2 -r1.22.2.3 src/sys/dev/usb/if_run.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_run.c
diff -u src/sys/dev/usb/if_run.c:1.22.2.2 src/sys/dev/usb/if_run.c:1.22.2.3
--- src/sys/dev/usb/if_run.c:1.22.2.2	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_run.c	Tue Jun 16 10:28:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_run.c,v 1.22.2.2 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_run.c,v 1.22.2.3 2020/06/16 10:28:29 bouyer Exp $	*/
 /*	$OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.22.2.2 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.22.2.3 2020/06/16 10:28:29 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2255,7 +2255,8 @@ run_rx_frame(struct run_softc *sc, uint8
 		return;
 	}
 	if (len > MHLEN) {
-		MCLGET(m, M_DONTWAIT);
+		if (__predict_true(len <= MCLBYTES))
+			MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
 			ifp->if_ierrors++;
 			m_freem(m);



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

2020-06-16 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Tue Jun 16 10:27:04 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_otus.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1558):
sys/dev/usb/if_otus.c: revision 1.45 via patch
Stricter bounds check for some packet length we get from the usb chip,
to make sure we do not corrupt kernel memory.
Pointed out by Ilja Van Sprundel.


To generate a diff of this commit:
cvs rdiff -u -r1.31.2.2 -r1.31.2.3 src/sys/dev/usb/if_otus.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_otus.c
diff -u src/sys/dev/usb/if_otus.c:1.31.2.2 src/sys/dev/usb/if_otus.c:1.31.2.3
--- src/sys/dev/usb/if_otus.c:1.31.2.2	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_otus.c	Tue Jun 16 10:27:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_otus.c,v 1.31.2.2 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_otus.c,v 1.31.2.3 2020/06/16 10:27:03 bouyer Exp $	*/
 /*	$OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $	*/
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.31.2.2 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.31.2.3 2020/06/16 10:27:03 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1745,6 +1745,10 @@ otus_sub_rxeof(struct otus_softc *sc, ui
 	}
 	/* Compute MPDU's length. */
 	mlen = len - AR_PLCP_HDR_LEN - sizeof(*tail);
+	if (__predict_false(mlen < IEEE80211_CRC_LEN)) {
+		ifp->if_ierrors++;
+		return;
+	}
 	mlen -= IEEE80211_CRC_LEN;	/* strip 802.11 FCS */
 	/* Make sure there's room for an 802.11 header. */
 	/*
@@ -1765,7 +1769,8 @@ otus_sub_rxeof(struct otus_softc *sc, ui
 		return;
 	}
 	if (align + mlen > MHLEN) {
-		MCLGET(m, M_DONTWAIT);
+		if (__predict_true(align + mlen <= MCLBYTES))
+			MCLGET(m, M_DONTWAIT);
 		if (__predict_false(!(m->m_flags & M_EXT))) {
 			ifp->if_ierrors++;
 			m_freem(m);



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

2020-06-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jun  7 16:41:24 UTC 2020

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

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

sys/dev/sysmon/sysmon_envsys.c: revision 1.145

Don't queue sysmon refresh until the rndsource is attached.

Using the rndsource, as refreshing the sensors will do, is not
allowed until _after_ rnd_source_attach.

XXX pullup-7
XXX pullup-8
XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.139.10.1 -r1.139.10.2 src/sys/dev/sysmon/sysmon_envsys.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_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.139.10.1 src/sys/dev/sysmon/sysmon_envsys.c:1.139.10.2
--- src/sys/dev/sysmon/sysmon_envsys.c:1.139.10.1	Sat Sep 23 17:22:48 2017
+++ src/sys/dev/sysmon/sysmon_envsys.c	Sun Jun  7 16:41:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysmon_envsys.c,v 1.139.10.1 2017/09/23 17:22:48 snj Exp $	*/
+/*	$NetBSD: sysmon_envsys.c,v 1.139.10.2 2020/06/07 16:41:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.139.10.1 2017/09/23 17:22:48 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.139.10.2 2020/06/07 16:41:24 martin Exp $");
 
 #include 
 #include 
@@ -824,16 +824,6 @@ out:
 	if (error == 0) {
 		nevent = 0;
 
-		if (sme->sme_flags & SME_INIT_REFRESH) {
-			sysmon_task_queue_sched(0, sme_initial_refresh, sme);
-			DPRINTF(("%s: scheduled initial refresh for '%s'\n",
-__func__, sme->sme_name));
-		}
-		SLIST_FOREACH(evdv, _evdrv_list, evdrv_head) {
-			sysmon_task_queue_sched(0,
-			sme_event_drvadd, evdv->evdrv);
-			nevent++;
-		}
 		/*
 		 * Hook the sensor into rnd(4) entropy pool if requested
 		 */
@@ -889,6 +879,17 @@ out:
 rnd_type, rnd_flag);
 			}
 		}
+
+		if (sme->sme_flags & SME_INIT_REFRESH) {
+			sysmon_task_queue_sched(0, sme_initial_refresh, sme);
+			DPRINTF(("%s: scheduled initial refresh for '%s'\n",
+__func__, sme->sme_name));
+		}
+		SLIST_FOREACH(evdv, _evdrv_list, evdrv_head) {
+			sysmon_task_queue_sched(0,
+			sme_event_drvadd, evdv->evdrv);
+			nevent++;
+		}
 		DPRINTF(("%s: driver '%s' registered (nsens=%d nevent=%d)\n",
 		__func__, sme->sme_name, sme->sme_nsensors, nevent));
 	}



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

2020-05-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May 31 10:27:26 UTC 2020

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

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

sys/dev/usb/usb.c: revision 1.187

Don't allow open of /dev/usb if there are no attached busses.
PR kern/55303 mutex_vector_enter,512: uninitialized lock


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

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

Modified files:

Index: src/sys/dev/usb/usb.c
diff -u src/sys/dev/usb/usb.c:1.165.6.5 src/sys/dev/usb/usb.c:1.165.6.6
--- src/sys/dev/usb/usb.c:1.165.6.5	Sat Nov 16 16:30:09 2019
+++ src/sys/dev/usb/usb.c	Sun May 31 10:27:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb.c,v 1.165.6.5 2019/11/16 16:30:09 martin Exp $	*/
+/*	$NetBSD: usb.c,v 1.165.6.6 2020/05/31 10:27:26 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.165.6.5 2019/11/16 16:30:09 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.165.6.6 2020/05/31 10:27:26 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -179,6 +179,11 @@ Static void	usb_create_event_thread(devi
 Static void	usb_event_thread(void *);
 Static void	usb_task_thread(void *);
 
+/*
+ * Count of USB busses
+ */
+int nusbbusses = 0;
+
 #define USB_MAX_EVENTS 100
 struct usb_event_q {
 	struct usb_event ue;
@@ -331,6 +336,9 @@ usb_doattach(device_t self)
 
 	USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
 
+	/* Protected by KERNEL_LOCK */
+	nusbbusses++;
+
 	sc->sc_bus->ub_usbctl = self;
 	sc->sc_port.up_power = USB_MAX_POWER;
 
@@ -639,6 +647,9 @@ usbopen(dev_t dev, int flag, int mode, s
 	int unit = minor(dev);
 	struct usb_softc *sc;
 
+	if (nusbbusses == 0)
+		return ENXIO;
+
 	if (unit == USB_DEV_MINOR) {
 		if (usb_dev_open)
 			return EBUSY;



CVS commit: [netbsd-8] src/sys/dev/dkwedge

2020-04-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 24 16:15:24 UTC 2020

Modified Files:
src/sys/dev/dkwedge [netbsd-8]: dk.c

Log Message:
Pull up following revision(s) (requested by maya in ticket #1541):

sys/dev/dkwedge/dk.c: revision 1.98

Update sc->sc_parent->dk_rawvp while the lock named dk_rawlock held
to prevent a race condition

Fixes PR kern/55026

OKed by mlelstv@, thanks


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.96.6.1 src/sys/dev/dkwedge/dk.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/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.96 src/sys/dev/dkwedge/dk.c:1.96.6.1
--- src/sys/dev/dkwedge/dk.c:1.96	Sun Mar  5 23:07:12 2017
+++ src/sys/dev/dkwedge/dk.c	Fri Apr 24 16:15:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $	*/
+/*	$NetBSD: dk.c,v 1.96.6.1 2020/04/24 16:15:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.96.6.1 2020/04/24 16:15:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -1152,21 +1152,23 @@ dkopen(dev_t dev, int flags, int fmt, st
 static int
 dklastclose(struct dkwedge_softc *sc)
 {
-	int error = 0, doclose;
+	struct vnode *vp;
+	int error = 0;
 
-	doclose = 0;
+	vp = NULL;
 	if (sc->sc_parent->dk_rawopens > 0) {
-		if (--sc->sc_parent->dk_rawopens == 0)
-			doclose = 1;
+		if (--sc->sc_parent->dk_rawopens == 0) {
+			KASSERT(sc->sc_parent->dk_rawvp != NULL);
+			vp = sc->sc_parent->dk_rawvp;
+			sc->sc_parent->dk_rawvp = NULL;
+		}
 	}
 
 	mutex_exit(>sc_parent->dk_rawlock);
 	mutex_exit(>sc_dk.dk_openlock);
 
-	if (doclose) {
-		KASSERT(sc->sc_parent->dk_rawvp != NULL);
-		dk_close_parent(sc->sc_parent->dk_rawvp, FREAD | FWRITE);
-		sc->sc_parent->dk_rawvp = NULL;
+	if (vp) {
+		dk_close_parent(vp, FREAD | FWRITE);
 	}
 
 	return error;



CVS commit: [netbsd-8] src/sys/dev/wsfb

2020-04-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 15 14:44:52 UTC 2020

Modified Files:
src/sys/dev/wsfb [netbsd-8]: genfb.c

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

sys/dev/wsfb/genfb.c: revision 1.72

  Get genfb's address offset correctly when the value >= 4G. OK's by jmcneill.

  Tested on Intel BXNUC10I3FNK (Comet Lake U).


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.61.2.1 src/sys/dev/wsfb/genfb.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/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.61 src/sys/dev/wsfb/genfb.c:1.61.2.1
--- src/sys/dev/wsfb/genfb.c:1.61	Thu Jun  1 02:45:12 2017
+++ src/sys/dev/wsfb/genfb.c	Wed Apr 15 14:44:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.61 2017/06/01 02:45:12 chs Exp $ */
+/*	$NetBSD: genfb.c,v 1.61.2.1 2020/04/15 14:44:52 martin Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.61 2017/06/01 02:45:12 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.61.2.1 2020/04/15 14:44:52 martin Exp $");
 
 #include 
 #include 
@@ -95,7 +95,7 @@ genfb_init(struct genfb_softc *sc)
 {
 	prop_dictionary_t dict;
 	uint64_t cmap_cb, pmf_cb, mode_cb, bl_cb, br_cb, fbaddr;
-	uint32_t fboffset;
+	uint64_t fboffset;
 	bool console;
 
 	dict = device_properties(sc->sc_dev);
@@ -117,13 +117,12 @@ genfb_init(struct genfb_softc *sc)
 		return;
 	}
 
-	/* XXX should be a 64bit value */
-	if (!prop_dictionary_get_uint32(dict, "address", )) {
+	if (!prop_dictionary_get_uint64(dict, "address", )) {
 		GPRINTF("no address property\n");
 		return;
 	}
 
-	sc->sc_fboffset = fboffset;
+	sc->sc_fboffset = (bus_addr_t)fboffset;
 
 	sc->sc_fbaddr = NULL;
 	if (prop_dictionary_get_uint64(dict, "virtual_address", )) {



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

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 18:11:35 UTC 2020

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

Log Message:
Regen for ticket #1529


To generate a diff of this commit:
cvs rdiff -u -r1.128.6.8 -r1.128.6.9 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.116.6.8 -r1.116.6.9 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.128.6.8 src/sys/dev/mii/miidevs.h:1.128.6.9
--- src/sys/dev/mii/miidevs.h:1.128.6.8	Mon Nov 25 15:57:49 2019
+++ src/sys/dev/mii/miidevs.h	Tue Apr 14 18:11:35 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.128.6.8 2019/11/25 15:57:49 martin Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.128.6.9 2020/04/14 18:11:35 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.8 2019/11/25 15:57:23 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.9 2020/04/14 17:57:17 martin Exp
  */
 
 /*-
@@ -60,10 +60,12 @@
 #define	MII_OUI_TRIDIUM	0x0001f0	/* Tridium */
 #define	MII_OUI_DATATRACK	0x0002c6	/* Data Track Technology */
 #define	MII_OUI_AGERE	0x00053d	/* Agere */
+#define	MII_OUI_QUAKE	0x000897	/* Quake Technologies */
 #define	MII_OUI_BANKSPEED	0x0006b8	/* Bankspeed Pty */
 #define	MII_OUI_NETEXCELL	0x0008bb	/* NetExcell */
 #define	MII_OUI_NETAS	0x0009c3	/* Netas */
 #define	MII_OUI_BROADCOM2	0x000af7	/* Broadcom Corporation */
+#define	MII_OUI_AELUROS	0x000b25	/* Aeluros */
 #define	MII_OUI_RALINK	0x000c43	/* Ralink Technology */
 #define	MII_OUI_ASIX	0x000ec6	/* ASIX */
 #define	MII_OUI_BROADCOM	0x001018	/* Broadcom Corporation */
@@ -71,13 +73,11 @@
 #define	MII_OUI_ALTIMA	0x0010a9	/* Altima Communications */
 #define	MII_OUI_ENABLESEMI	0x0010dd	/* Enable Semiconductor */
 #define	MII_OUI_SUNPLUS	0x001105	/* Sunplus Technology */
-#define	MII_OUI_ATHEROS	0x001374	/* Atheros */
 #define	MII_OUI_TERANETICS	0x0014a6	/* Teranetics */
 #define	MII_OUI_RALINK2	0x0017a5	/* Ralink Technology */
 #define	MII_OUI_AQUANTIA	0x0017b6	/* Aquantia Corporation */
 #define	MII_OUI_BROADCOM3	0x001be9	/* Broadcom Corporation */
 #define	MII_OUI_LEVEL1	0x00207b	/* Level 1 */
-#define	MII_OUI_VIA	0x004063	/* VIA Technologies */
 #define	MII_OUI_MARVELL	0x005043	/* Marvell Semiconductor */
 #define	MII_OUI_QUALSEMI	0x006051	/* Quality Semiconductor */
 #define	MII_OUI_AMLOGIC	0x006051	/* Amlogic */
@@ -89,7 +89,6 @@
 #define	MII_OUI_TSC	0x00c039	/* TDK Semiconductor */
 #define	MII_OUI_MYSON	0x00c0b4	/* Myson Technology */
 #define	MII_OUI_ATTANSIC	0x00c82e	/* Attansic Technology */
-#define	MII_OUI_RDC	0x00d02d	/* RDC Semiconductor */
 #define	MII_OUI_JMICRON	0x00d831	/* JMicron */
 #define	MII_OUI_PMCSIERRA	0x00e004	/* PMC-Sierra */
 #define	MII_OUI_SIS	0x00e006	/* Silicon Integrated Systems */
@@ -104,6 +103,7 @@
 /* Unregistered or wrong OUI */
 #define	MII_OUI_yyREALTEK	0x04	/* Realtek */
 #define	MII_OUI_yyAMD	0x58	/* Advanced Micro Devices */
+#define	MII_OUI_xxVIA	0x0002c6	/* VIA Technologies */
 #define	MII_OUI_xxMYSON	0x00032d	/* Myson Technology */
 #define	MII_OUI_xxTSC	0x00039c	/* TDK Semiconductor */
 #define	MII_OUI_xxASIX	0x000674	/* Asix Semiconductor */
@@ -122,6 +122,7 @@
 #define	MII_OUI_xxVITESSE	0x008083	/* Vitesse Semiconductor */
 #define	MII_OUI_xxPMCSIERRA2	0x009057	/* PMC-Sierra */
 #define	MII_OUI_xxCICADA	0x00c08f	/* Cicada Semiconductor */
+#define	MII_OUI_xxRDC	0x00d02d	/* RDC Semiconductor */
 #define	MII_OUI_xxNATSEMI	0x1000e8	/* National Semiconductor */
 #define	MII_OUI_xxLEVEL1	0x782000	/* Level 1 */
 #define	MII_OUI_xxXAQTI	0xace000	/* XaQti Corp. */
@@ -133,8 +134,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
@@ -166,13 +169,7 @@
 #define	MII_MODEL_xxAMLOGIC_GXL	0x
 #define	MII_STR_xxAMLOGIC_GXL	"Meson GXL internal PHY"
 
-/* Atheros PHYs */
-#define	MII_MODEL_ATHEROS_F1	0x0001
-#define	MII_STR_ATHEROS_F1	"F1 10/100/1000 PHY"
-#define	MII_MODEL_ATHEROS_F2	0x0002
-#define	MII_STR_ATHEROS_F2	"F2 10/100 PHY"
-
-/* Attansic PHYs */
+/* Attansic/Atheros PHYs */
 #define	MII_MODEL_ATTANSIC_L1	0x0001
 #define	MII_STR_ATTANSIC_L1	"L1 10/100/1000 PHY"
 #define	MII_MODEL_ATTANSIC_L2	0x0002
@@ -300,6 +297,8 @@
 #define	MII_STR_BROADCOM3_BCM53125	"BCM53125 1000BASE-T switch"
 #define	MII_MODEL_BROADCOM3_BCM5720C	0x0036
 #define	MII_STR_BROADCOM3_BCM5720C	"BCM5720C 1000BASE-T media interface"
+#define	MII_MODEL_BROADCOM4_BCM54213PE	0x000a
+#define	MII_STR_BROADCOM4_BCM54213PE	"BCM54213PE 1000BASE-T media interface"
 

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

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 17:57:17 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: atphy.c brgphy.c etphy.c miidevs rdcphy.c

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

sys/dev/mii/miidevs 1.154, 1.162-1.167
sys/dev/mii/atphy.c 1.28 via patch
sys/dev/mii/brgphy.c1.87 via patch
sys/dev/mii/etphy.c 1.5, 1.6 via patch
sys/dev/mii/rdcphy.c1.6, 1.8 via patch

- Add support Broadcom BCM54213PE and some new RDC devices.
- Rename RDC to xxRDC.
- Use xxVIA instead of VIA.
- etphy(4):
  - Rename ET1011 to ET1011C and add ET1011 support.
  - Use mii_phy_flowstatus() to reflect flow status from negotiated
result.
- Use static.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.18.8.1 -r1.18.8.2 src/sys/dev/mii/atphy.c
cvs rdiff -u -r1.76.20.2 -r1.76.20.3 src/sys/dev/mii/brgphy.c
cvs rdiff -u -r1.1 -r1.1.54.1 src/sys/dev/mii/etphy.c \
src/sys/dev/mii/rdcphy.c
cvs rdiff -u -r1.125.6.8 -r1.125.6.9 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/atphy.c
diff -u src/sys/dev/mii/atphy.c:1.18.8.1 src/sys/dev/mii/atphy.c:1.18.8.2
--- src/sys/dev/mii/atphy.c:1.18.8.1	Thu Nov 21 14:06:16 2019
+++ src/sys/dev/mii/atphy.c	Tue Apr 14 17:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: atphy.c,v 1.18.8.1 2019/11/21 14:06:16 martin Exp $ */
+/*	$NetBSD: atphy.c,v 1.18.8.2 2020/04/14 17:57:17 martin Exp $ */
 /*	$OpenBSD: atphy.c,v 1.1 2008/09/25 20:47:16 brad Exp $	*/
 
 /*-
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.18.8.1 2019/11/21 14:06:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atphy.c,v 1.18.8.2 2020/04/14 17:57:17 martin Exp $");
 
 #include 
 #include 
@@ -91,8 +91,6 @@ const struct mii_phy_funcs atphy_funcs =
 };
 
 static const struct mii_phydesc atphys[] = {
-	{ MII_OUI_ATHEROS,	MII_MODEL_ATHEROS_F1,
-	  MII_STR_ATHEROS_F1 },
 	{ MII_OUI_ATTANSIC,	MII_MODEL_ATTANSIC_L1,
 	  MII_STR_ATTANSIC_L1 },
 	{ MII_OUI_ATTANSIC,	MII_MODEL_ATTANSIC_L2,

Index: src/sys/dev/mii/brgphy.c
diff -u src/sys/dev/mii/brgphy.c:1.76.20.2 src/sys/dev/mii/brgphy.c:1.76.20.3
--- src/sys/dev/mii/brgphy.c:1.76.20.2	Mon May 13 12:40:13 2019
+++ src/sys/dev/mii/brgphy.c	Tue Apr 14 17:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: brgphy.c,v 1.76.20.2 2019/05/13 12:40:13 martin Exp $	*/
+/*	$NetBSD: brgphy.c,v 1.76.20.3 2020/04/14 17:57:17 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.76.20.2 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.76.20.3 2020/04/14 17:57:17 martin Exp $");
 
 #include 
 #include 
@@ -246,6 +246,9 @@ static const struct mii_phydesc brgphys[
 	{ MII_OUI_BROADCOM3,		MII_MODEL_BROADCOM3_BCM57780,
 	  MII_STR_BROADCOM3_BCM57780 },
 
+	{ MII_OUI_BROADCOM4,		MII_MODEL_BROADCOM4_BCM54213PE,
+	  MII_STR_BROADCOM4_BCM54213PE },
+
 	{ MII_OUI_BROADCOM4,		MII_MODEL_BROADCOM4_BCM5725C,
 	  MII_STR_BROADCOM4_BCM5725C },
 

Index: src/sys/dev/mii/etphy.c
diff -u src/sys/dev/mii/etphy.c:1.1 src/sys/dev/mii/etphy.c:1.1.54.1
--- src/sys/dev/mii/etphy.c:1.1	Sat Nov 13 00:47:24 2010
+++ src/sys/dev/mii/etphy.c	Tue Apr 14 17:57:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: etphy.c,v 1.1 2010/11/13 00:47:24 jnemeth Exp $	*/
+/*	$NetBSD: etphy.c,v 1.1.54.1 2020/04/14 17:57:17 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.1 2010/11/13 00:47:24 jnemeth Exp $");
+__KERNEL_RCSID(0, "$NetBSD: etphy.c,v 1.1.54.1 2020/04/14 17:57:17 martin Exp $");
 
 #include 
 #include 
@@ -77,19 +77,21 @@ __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_OUI_AGERE,	MII_MODEL_AGERE_ET1011,
 	  MII_STR_AGERE_ET1011 },
+	{ MII_OUI_AGERE,	MII_MODEL_AGERE_ET1011C,
+	  MII_STR_AGERE_ET1011C },
 	{ 0,			0,
 	  NULL },
 };
@@ -135,7 +137,7 @@ static const 

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

2020-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Apr 14 17:39:28 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: spdmem.c spdmemvar.h

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

sys/dev/ic/spdmemvar.h: revision 1.15
sys/dev/ic/spdmemvar.h: revision 1.16
sys/dev/ic/spdmem.c: revision 1.31
sys/dev/ic/spdmem.c: revision 1.32
sys/dev/ic/spdmem.c: revision 1.33
sys/dev/ic/spdmem.c: revision 1.34
sys/dev/ic/spdmem.c: revision 1.35

Fix spelling of symeti^Hric

  Print DDR3's row and column correctly.

KNF. No functional change.

- Define some new parameters of DDR3 SPD ROM.
- Use fine timebase parameters for time calculation on DDR3. This change
   makes PC3- value more correctly on newer DDR3.

Calculate DDR3's tRAS correctly.

  Fix unused area size found by pgoyette@.


To generate a diff of this commit:
cvs rdiff -u -r1.24.6.2 -r1.24.6.3 src/sys/dev/ic/spdmem.c
cvs rdiff -u -r1.13.6.1 -r1.13.6.2 src/sys/dev/ic/spdmemvar.h

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

Modified files:

Index: src/sys/dev/ic/spdmem.c
diff -u src/sys/dev/ic/spdmem.c:1.24.6.2 src/sys/dev/ic/spdmem.c:1.24.6.3
--- src/sys/dev/ic/spdmem.c:1.24.6.2	Thu Jan  3 11:23:54 2019
+++ src/sys/dev/ic/spdmem.c	Tue Apr 14 17:39:28 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: spdmem.c,v 1.24.6.2 2019/01/03 11:23:54 martin Exp $ */
+/* $NetBSD: spdmem.c,v 1.24.6.3 2020/04/14 17:39:28 martin Exp $ */
 
 /*
  * Copyright (c) 2007 Nicolas Joly
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.24.6.2 2019/01/03 11:23:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.24.6.3 2020/04/14 17:39:28 martin Exp $");
 
 #include 
 #include 
@@ -340,12 +340,12 @@ spdmem_common_attach(struct spdmem_softc
 	device_xname(self), NULL, NULL, 0, NULL, 0,
 	CTL_HW, CTL_CREATE, CTL_EOL);
 	if (node != NULL && spd_len != 0)
-sysctl_createv(>sc_sysctl_log, 0, NULL, NULL,
-0,
-CTLTYPE_STRUCT, "spd_data",
+		sysctl_createv(>sc_sysctl_log, 0, NULL, NULL,
+		0,
+		CTLTYPE_STRUCT, "spd_data",
 		SYSCTL_DESCR("raw spd data"), NULL,
-0, s, spd_len,
-CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
+		0, s, spd_len,
+		CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL);
 
 	/*
 	 * Decode and print key SPD contents
@@ -411,7 +411,7 @@ spdmem_common_attach(struct spdmem_softc
 			strlcat(sc->sc_type, " NVDIMM hybrid",
 			SPDMEM_TYPE_MAXLEN);
 	}
-	
+
 	if (node != NULL)
 		sysctl_createv(>sc_sysctl_log, 0, NULL, NULL,
 		0,
@@ -615,7 +615,7 @@ decode_sdram(const struct sysctlnode *no
 		freq = 0;
 	switch (freq) {
 		/*
-		 * Must check cycle time since some PC-133 DIMMs 
+		 * Must check cycle time since some PC-133 DIMMs
 		 * actually report PC-100
 		 */
 	case 100:
@@ -756,6 +756,30 @@ print_part(const char *part, size_t pnsi
 	aprint_normal(": %.*s\n", (int)(p - part), part);
 }
 
+static u_int
+ddr3_value_pico(struct spdmem *s, uint8_t txx_mtb, uint8_t txx_ftb)
+{
+	u_int mtb, ftb; /* in picoseconds */
+	intmax_t signed_txx_ftb;
+	u_int val;
+
+	mtb = (u_int)s->sm_ddr3.ddr3_mtb_dividend * 1000 /
+	s->sm_ddr3.ddr3_mtb_divisor;
+	ftb = (u_int)s->sm_ddr3.ddr3_ftb_dividend * 1000 /
+	s->sm_ddr3.ddr3_ftb_divisor;
+
+	/* tXX_ftb is signed value */
+	signed_txx_ftb = (int8_t)txx_ftb;
+	val = txx_mtb * mtb +
+	((txx_ftb > 127) ? signed_txx_ftb : txx_ftb) * ftb / 1000;
+
+	return val;
+}
+
+#define __DDR3_VALUE_PICO(s, field)\
+	ddr3_value_pico(s, s->sm_ddr3.ddr3_##field##_mtb,	\
+	s->sm_ddr3.ddr3_##field##_ftb)
+
 static void
 decode_ddr3(const struct sysctlnode *node, device_t self, struct spdmem *s)
 {
@@ -786,10 +810,7 @@ decode_ddr3(const struct sysctlnode *nod
 		(s->sm_ddr3.ddr3_chipwidth + 2);
 	dimm_size = (1 << dimm_size) * (s->sm_ddr3.ddr3_physbanks + 1);
 
-	cycle_time = (1000 * s->sm_ddr3.ddr3_mtb_dividend + 
-			(s->sm_ddr3.ddr3_mtb_divisor / 2)) /
-		 s->sm_ddr3.ddr3_mtb_divisor;
-	cycle_time *= s->sm_ddr3.ddr3_tCKmin;
+	cycle_time = __DDR3_VALUE_PICO(s, tCKmin);
 	bits = 1 << (s->sm_ddr3.ddr3_datawidth + 3);
 	decode_size_speed(self, node, dimm_size, cycle_time, 2, bits, FALSE,
 			  "PC3", 0);
@@ -797,17 +818,21 @@ decode_ddr3(const struct sysctlnode *nod
 	aprint_verbose_dev(self,
 	"%d rows, %d cols, %d log. banks, %d phys. banks, "
 	"%d.%03dns cycle time\n",
-	s->sm_ddr3.ddr3_rows + 9, s->sm_ddr3.ddr3_cols + 12,
+	s->sm_ddr3.ddr3_rows + 12, s->sm_ddr3.ddr3_cols + 9,
 	1 << (s->sm_ddr3.ddr3_logbanks + 3),
 	s->sm_ddr3.ddr3_physbanks + 1,
 	cycle_time/1000, cycle_time % 1000);
 
-#define	__DDR3_CYCLES(field) (s->sm_ddr3.field / s->sm_ddr3.ddr3_tCKmin)
+#define	__DDR3_CYCLES(val)		\
+	((val / cycle_time) + ((val % cycle_time) ? 1 : 0))
 
-	

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

2020-03-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Mar  8 09:57:50 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: tms320av110.c

Log Message:
Pull up following revision(s) (requested by is in ticket #1516):

sys/dev/ic/tms320av110.c: revision 1.24

Make it compilable (remove unused variables).


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.23.30.1 src/sys/dev/ic/tms320av110.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/tms320av110.c
diff -u src/sys/dev/ic/tms320av110.c:1.23 src/sys/dev/ic/tms320av110.c:1.23.30.1
--- src/sys/dev/ic/tms320av110.c:1.23	Sat Oct 27 17:18:23 2012
+++ src/sys/dev/ic/tms320av110.c	Sun Mar  8 09:57:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tms320av110.c,v 1.23 2012/10/27 17:18:23 chs Exp $	*/
+/*	$NetBSD: tms320av110.c,v 1.23.30.1 2020/03/08 09:57:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tms320av110.c,v 1.23 2012/10/27 17:18:23 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tms320av110.c,v 1.23.30.1 2020/03/08 09:57:50 martin Exp $");
 
 #include 
 #include 
@@ -251,9 +251,7 @@ tav_drain(void *hdl)
 int
 tav_query_encoding(void *hdl, struct audio_encoding *ae)
 {
-	struct tav_softc *sc;
 
-	sc = hdl;
 	if (ae->index >= sizeof(tav_encodings)/sizeof(*ae))
 		return EINVAL;
 
@@ -473,9 +471,7 @@ tav_set_params(void *hdl, int setmode, i
 int
 tav_set_port(void *hdl, mixer_ctrl_t *mc)
 {
-	struct tav_softc *sc;
 
-	sc = hdl;
 	/* dummy */
 	return 0;
 }
@@ -483,9 +479,7 @@ tav_set_port(void *hdl, mixer_ctrl_t *mc
 int
 tav_get_port(void *hdl, mixer_ctrl_t *mc)
 {
-	struct tav_softc *sc;
 
-	sc = hdl;
 	/* dummy */
 	return 0;
 }



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

2020-02-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 27 14:34:13 UTC 2020

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

Log Message:
regen (for ticket #1508)


To generate a diff of this commit:
cvs rdiff -u -r1.727.2.5 -r1.727.2.6 src/sys/dev/usb/usbdevs.h
cvs rdiff -u -r1.728.2.5 -r1.728.2.6 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.

Modified files:

Index: src/sys/dev/usb/usbdevs.h
diff -u src/sys/dev/usb/usbdevs.h:1.727.2.5 src/sys/dev/usb/usbdevs.h:1.727.2.6
--- src/sys/dev/usb/usbdevs.h:1.727.2.5	Thu Aug  1 13:41:54 2019
+++ src/sys/dev/usb/usbdevs.h	Thu Feb 27 14:34:11 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs.h,v 1.727.2.5 2019/08/01 13:41:54 martin Exp $	*/
+/*	$NetBSD: usbdevs.h,v 1.727.2.6 2020/02/27 14:34:11 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.736.2.5 2019/08/01 13:40:54 martin Exp
+ *	NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp
  */
 
 /*-
@@ -1432,8 +1432,10 @@
 #define	USB_PRODUCT_DLINK_DSB650TX3	0x400b		/* 10/100 ethernet adapter */
 #define	USB_PRODUCT_DLINK_DSB650TX2	0x4102		/* 10/100 ethernet adapter */
 #define	USB_PRODUCT_DLINK_DSB650	0xabc1		/* 10/100 ethernet adapter */
+#define	USB_PRODUCT_DLINK_DWM157E_CD	0xa407		/* DWM-157 CD-ROM Mode */
 #define	USB_PRODUCT_DLINK_DWM157_CD	0xa707		/* DWM-157 CD-ROM Mode */
 #define	USB_PRODUCT_DLINK_DWM157	0x7d02		/* DWM-157 LTE */
+#define	USB_PRODUCT_DLINK_DWM157E	0x7d0e		/* DWM-157 LTE */
 #define	USB_PRODUCT_DLINK_DWM222_CD	0xab00		/* DWM-222 CD-ROM Mode */
 #define	USB_PRODUCT_DLINK_DWM222	0x7e35		/* DWM-222 LTE */
 #define	USB_PRODUCT_DLINK_DWR510_CD	0xa805		/* DWR-510 CD-ROM Mode */

Index: src/sys/dev/usb/usbdevs_data.h
diff -u src/sys/dev/usb/usbdevs_data.h:1.728.2.5 src/sys/dev/usb/usbdevs_data.h:1.728.2.6
--- src/sys/dev/usb/usbdevs_data.h:1.728.2.5	Thu Aug  1 13:41:54 2019
+++ src/sys/dev/usb/usbdevs_data.h	Thu Feb 27 14:34:11 2020
@@ -1,10 +1,10 @@
-/*	$NetBSD: usbdevs_data.h,v 1.728.2.5 2019/08/01 13:41:54 martin Exp $	*/
+/*	$NetBSD: usbdevs_data.h,v 1.728.2.6 2020/02/27 14:34:11 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: usbdevs,v 1.736.2.5 2019/08/01 13:40:54 martin Exp
+ *	NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp
  */
 
 /*-
@@ -1796,10 +1796,14 @@ static const uint16_t usb_products[] = {
 	6668, 5155, 4911, 0,
 	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650, 
 	6668, 5155, 4911, 0,
+	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E_CD, 
+	9312, 9320, 9327, 0,
 	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157_CD, 
 	9312, 9320, 9327, 0,
 	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157, 
 	9312, 9332, 0,
+	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E, 
+	9312, 9332, 0,
 	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM222_CD, 
 	9336, 9320, 9327, 0,
 	USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM222, 
@@ -6171,10 +6175,10 @@ static const char usb_words[] = { "." 
 	"B2\0" /* 1 refs @ 9293 */
 	"DWA-127\0" /* 1 refs @ 9296 */
 	"DWA-162\0" /* 1 refs @ 9304 */
-	"DWM-157\0" /* 2 refs @ 9312 */
-	"CD-ROM\0" /* 4 refs @ 9320 */
-	"Mode\0" /* 3 refs @ 9327 */
-	"LTE\0" /* 3 refs @ 9332 */
+	"DWM-157\0" /* 4 refs @ 9312 */
+	"CD-ROM\0" /* 5 refs @ 9320 */
+	"Mode\0" /* 4 refs @ 9327 */
+	"LTE\0" /* 4 refs @ 9332 */
 	"DWM-222\0" /* 2 refs @ 9336 */
 	"DWR-510\0" /* 2 refs @ 9344 */
 	"A1\0" /* 3 refs @ 9352 */



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

2020-02-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Feb 27 14:32:31 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: u3g.c umodeswitch.c usbdevs

Log Message:
Pull up following revision(s) (requested by manu in ticket #1508):

sys/dev/usb/usbdevs: revision 1.776
sys/dev/usb/u3g.c: revision 1.40
sys/dev/usb/umodeswitch.c: revision 1.5

Add UE version of D-Link DWM-157
 -
Add support for D-Link DWM-157 3G USB modem


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.34.2.1 src/sys/dev/usb/u3g.c
cvs rdiff -u -r1.1 -r1.1.2.1 src/sys/dev/usb/umodeswitch.c
cvs rdiff -u -r1.736.2.5 -r1.736.2.6 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/u3g.c
diff -u src/sys/dev/usb/u3g.c:1.34 src/sys/dev/usb/u3g.c:1.34.2.1
--- src/sys/dev/usb/u3g.c:1.34	Wed May 24 20:23:58 2017
+++ src/sys/dev/usb/u3g.c	Thu Feb 27 14:32:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: u3g.c,v 1.34 2017/05/24 20:23:58 christos Exp $	*/
+/*	$NetBSD: u3g.c,v 1.34.2.1 2020/02/27 14:32:31 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.34 2017/05/24 20:23:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.34.2.1 2020/02/27 14:32:31 martin Exp $");
 
 #include 
 #include 
@@ -258,6 +258,10 @@ static const struct usb_devno u3g_devs[]
 	/* 4G Systems */
 	{ USB_VENDOR_4GSYSTEMS, USB_PRODUCT_4GSYSTEMS_XSSTICK_P14 },
 	{ USB_VENDOR_4GSYSTEMS, USB_PRODUCT_4GSYSTEMS_XSSTICK_W14 },
+
+	/* DLink */
+	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157 },
+	{ USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E },
 };
 
 /*

Index: src/sys/dev/usb/umodeswitch.c
diff -u src/sys/dev/usb/umodeswitch.c:1.1 src/sys/dev/usb/umodeswitch.c:1.1.2.1
--- src/sys/dev/usb/umodeswitch.c:1.1	Wed May 24 20:23:58 2017
+++ src/sys/dev/usb/umodeswitch.c	Thu Feb 27 14:32:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: umodeswitch.c,v 1.1 2017/05/24 20:23:58 christos Exp $	*/
+/*	$NetBSD: umodeswitch.c,v 1.1.2.1 2020/02/27 14:32:31 martin Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umodeswitch.c,v 1.1 2017/05/24 20:23:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umodeswitch.c,v 1.1.2.1 2020/02/27 14:32:31 martin Exp $");
 
 #include 
 #include 
@@ -428,6 +428,17 @@ umodeswitch_match(device_t parent, cfdat
 			return u3g_4gsystems_reinit(uaa->uaa_device);
 		break;
 
+	case USB_VENDOR_DLINK:
+		switch (uaa->uaa_product) {
+		case USB_PRODUCT_DLINK_DWM157E_CD:
+		case USB_PRODUCT_DLINK_DWM157_CD:
+			(void)u3g_bulk_ata_eject(uaa->uaa_device);
+			(void)u3g_bulk_scsi_eject(uaa->uaa_device);
+			return UMATCH_HIGHEST;
+		default:
+			break;
+		}
+
 	default:
 		break;
 	}

Index: src/sys/dev/usb/usbdevs
diff -u src/sys/dev/usb/usbdevs:1.736.2.5 src/sys/dev/usb/usbdevs:1.736.2.6
--- src/sys/dev/usb/usbdevs:1.736.2.5	Thu Aug  1 13:40:54 2019
+++ src/sys/dev/usb/usbdevs	Thu Feb 27 14:32:31 2020
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.736.2.5 2019/08/01 13:40:54 martin Exp $
+$NetBSD: usbdevs,v 1.736.2.6 2020/02/27 14:32:31 martin Exp $
 
 /*-
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1425,8 +1425,10 @@ product DLINK DSB650TX_PNA	0x4003	1/10/1
 product DLINK DSB650TX3		0x400b	10/100 ethernet adapter
 product DLINK DSB650TX2		0x4102	10/100 ethernet adapter
 product DLINK DSB650		0xabc1	10/100 ethernet adapter
+product DLINK DWM157E_CD	0xa407	DWM-157 CD-ROM Mode
 product DLINK DWM157_CD		0xa707	DWM-157 CD-ROM Mode
 product DLINK DWM157		0x7d02	DWM-157 LTE
+product DLINK DWM157E		0x7d0e	DWM-157 LTE
 product DLINK DWM222_CD		0xab00	DWM-222 CD-ROM Mode
 product DLINK DWM222		0x7e35	DWM-222 LTE
 product DLINK DWR510_CD		0xa805	DWR-510 CD-ROM Mode



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

2020-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 11 08:44:11 UTC 2020

Modified Files:
src/sys/dev/ic [netbsd-8]: elinkxl.c

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

sys/dev/ic/elinkxl.c: revision 1.137

  Restore an register read for RX_FRAMES_OK which was removed in rev. 1.133.

All statistics registers should be read to ACK the interrupt. Fixes PR#54920.
XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.121.6.2 -r1.121.6.3 src/sys/dev/ic/elinkxl.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/elinkxl.c
diff -u src/sys/dev/ic/elinkxl.c:1.121.6.2 src/sys/dev/ic/elinkxl.c:1.121.6.3
--- src/sys/dev/ic/elinkxl.c:1.121.6.2	Wed Nov  6 10:04:46 2019
+++ src/sys/dev/ic/elinkxl.c	Tue Feb 11 08:44:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: elinkxl.c,v 1.121.6.2 2019/11/06 10:04:46 martin Exp $	*/
+/*	$NetBSD: elinkxl.c,v 1.121.6.3 2020/02/11 08:44:11 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.121.6.2 2019/11/06 10:04:46 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: elinkxl.c,v 1.121.6.3 2020/02/11 08:44:11 martin Exp $");
 
 #include 
 #include 
@@ -1510,6 +1510,7 @@ ex_getstats(struct ex_softc *sc)
 	(void)bus_space_read_1(iot, ioh, TX_AFTER_1_COLLISION);
 	(void)bus_space_read_1(iot, ioh, TX_NO_SQE);
 	(void)bus_space_read_1(iot, ioh, TX_CD_LOST);
+	(void)bus_space_read_1(iot, ioh, RX_FRAMES_OK);
 	GO_WINDOW(4);
 	(void)bus_space_read_1(iot, ioh, ELINK_W4_BADSSD);
 	GO_WINDOW(1);



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

2020-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 11 08:39:01 UTC 2020

Modified Files:
src/sys/dev [netbsd-8]: ld.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1500):

sys/dev/ld.c: revision 1.108

Reject open when attach didn't complete successfully.


To generate a diff of this commit:
cvs rdiff -u -r1.101.2.2 -r1.101.2.3 src/sys/dev/ld.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/ld.c
diff -u src/sys/dev/ld.c:1.101.2.2 src/sys/dev/ld.c:1.101.2.3
--- src/sys/dev/ld.c:1.101.2.2	Tue Dec  4 12:00:41 2018
+++ src/sys/dev/ld.c	Tue Feb 11 08:39:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ld.c,v 1.101.2.2 2018/12/04 12:00:41 martin Exp $	*/
+/*	$NetBSD: ld.c,v 1.101.2.3 2020/02/11 08:39:01 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.101.2.2 2018/12/04 12:00:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.101.2.3 2020/02/11 08:39:01 martin Exp $");
 
 #include 
 #include 
@@ -290,6 +290,10 @@ ldopen(dev_t dev, int flags, int fmt, st
 	unit = DISKUNIT(dev);
 	if ((sc = device_lookup_private(_cd, unit)) == NULL)
 		return (ENXIO);
+
+	if ((sc->sc_flags & LDF_ENABLED) == 0)
+		return (ENODEV);
+
 	dksc = >sc_dksc;
 
 	return dk_open(dksc, dev, flags, fmt, l);



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

2020-01-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 31 10:57:29 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_stgereg.h

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

sys/dev/pci/if_stgereg.h: revision 1.7

 Fix address of STGE_MaxFrameSize. Same as other OSes.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.80.1 src/sys/dev/pci/if_stgereg.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_stgereg.h
diff -u src/sys/dev/pci/if_stgereg.h:1.5 src/sys/dev/pci/if_stgereg.h:1.5.80.1
--- src/sys/dev/pci/if_stgereg.h:1.5	Mon Apr 28 20:23:55 2008
+++ src/sys/dev/pci/if_stgereg.h	Fri Jan 31 10:57:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_stgereg.h,v 1.5 2008/04/28 20:23:55 martin Exp $	*/
+/*	$NetBSD: if_stgereg.h,v 1.5.80.1 2020/01/31 10:57:28 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -319,7 +319,7 @@ struct stge_rfd {
 
 #define	STGE_VLANId			0x80
 
-#define	STGE_MaxFrameSize		0x84
+#define	STGE_MaxFrameSize		0x86
 
 #define	STGE_ReceiveMode		0x88	/* 16-bit */
 #define	RM_ReceiveUnicast		(1U << 0)



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

2020-01-31 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 31 10:55:37 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: if_urlreg.h

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

sys/dev/usb/if_urlreg.h: revision 1.16

URL_TCR_IFG0 is not bit 4 but bit3. From OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.11.10.1 src/sys/dev/usb/if_urlreg.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_urlreg.h
diff -u src/sys/dev/usb/if_urlreg.h:1.11 src/sys/dev/usb/if_urlreg.h:1.11.10.1
--- src/sys/dev/usb/if_urlreg.h:1.11	Sat Apr 23 10:15:31 2016
+++ src/sys/dev/usb/if_urlreg.h	Fri Jan 31 10:55:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urlreg.h,v 1.11 2016/04/23 10:15:31 skrll Exp $	*/
+/*	$NetBSD: if_urlreg.h,v 1.11.10.1 2020/01/31 10:55:37 martin Exp $	*/
 /*
  * Copyright (c) 2001, 2002
  * Shingo WATANABE .  All rights reserved.
@@ -84,7 +84,7 @@
 #define	 URL_TCR_TXRR1		(1<<7) /* TX Retry Count */
 #define	 URL_TCR_TXRR0		(1<<6) /* TX Retry Count */
 #define	 URL_TCR_IFG1		(1<<4) /* Interframe Gap Time */
-#define	 URL_TCR_IFG0		(1<<4) /* Interframe Gap Time */
+#define	 URL_TCR_IFG0		(1<<3) /* Interframe Gap Time */
 #define	 URL_TCR_NOCRC		(1<<0) /* no CRC Append */
 
 #define	URL_RCR			0x0130 /* Receive Configuration Register */



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

2020-01-28 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Jan 28 09:34:29 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: makphy.c makphyreg.h

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

sys/dev/mii/makphy.c1.61, 1.63-1.64 via patch
sys/dev/mii/makphyreg.h 1.10

- Remove ESSR_FIBER_LINK bit check in makphyattach(). This bit is
  valid only when the link is up, so it's not good to check in the
  attach function.
- There is an environment that both copper and fiber bits are set in
  EXTSR but it support copper only. To resolve this problem, check the
  ESSR register's HWCFG_MODE bit and drop unsupported bits.
- If the chip is in Fiber/Copper auto select mode, check which media is
  selected. Currently, the code supports 88E1011, 88E and 88E1112
  only.
- Fix comment. KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.42.8.3 -r1.42.8.4 src/sys/dev/mii/makphy.c
cvs rdiff -u -r1.6.20.1 -r1.6.20.2 src/sys/dev/mii/makphyreg.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/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.42.8.3 src/sys/dev/mii/makphy.c:1.42.8.4
--- src/sys/dev/mii/makphy.c:1.42.8.3	Thu Aug  1 14:27:30 2019
+++ src/sys/dev/mii/makphy.c	Tue Jan 28 09:34:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.42.8.3 2019/08/01 14:27:30 martin Exp $	*/
+/*	$NetBSD: makphy.c,v 1.42.8.4 2020/01/28 09:34:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.3 2019/08/01 14:27:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.4 2020/01/28 09:34:29 martin Exp $");
 
 #include 
 #include 
@@ -204,7 +204,7 @@ makphyattach(device_t parent, device_t s
 	const struct mii_phydesc *mpd;
 	struct makphy_softc *maksc = (struct makphy_softc *)sc;
 	const char *name;
-	int model, val;
+	int reg, model;
 
 	mpd = mii_phy_match(ma, makphys);
 	aprint_naive(": Media interface\n");
@@ -245,24 +245,61 @@ page0:
 		break;
 	}
 
-	switch (model) {
-	case MII_MODEL_xxMARVELL_E1011:
-	case MII_MODEL_xxMARVELL_E1112:
-		val = PHY_READ(sc, MAKPHY_ESSR);
-		if ((val != 0) && (((u_int)val & 0xU) != 0xU)
-		&& ((val & ESSR_FIBER_LINK) != 0))
-			sc->mii_flags |= MIIF_HAVEFIBER;
-		break;
-	default:
-		break;
-	}
-
 	PHY_RESET(sc);
 
 	sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
 	if (sc->mii_capabilities & BMSR_EXTSTAT)
 		sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
 
+	if (((sc->mii_extcapabilities & (EXTSR_1000TFDX | EXTSR_1000THDX))
+		!= 0)
+	&& ((sc->mii_extcapabilities & (EXTSR_1000XFDX | EXTSR_1000XHDX))
+		!= 0)) {
+		bool fiberonly = false, copperonly = false;
+
+		/* Both copper and fiber are set. check MODE[] */
+		switch (sc->mii_mpd_model) {
+		case MII_MODEL_xxMARVELL_E1011:
+		case MII_MODEL_xxMARVELL_E:
+			/* These devices have ESSR register */
+			reg = PHY_READ(sc, MAKPHY_ESSR);
+			if ((reg & ESSR_AUTOSEL_DISABLE) != 0) {
+switch (reg & ESSR_HWCFG_MODE) {
+case ESSR_RTBI_FIBER:
+case ESSR_RGMII_FIBER:
+case ESSR_RGMII_SGMII: /* right? */
+case ESSR_TBI_FIBER:
+case ESSR_GMII_FIBER:
+	fiberonly = true;
+	break;
+case ESSR_SGMII_WC_COPPER:
+case ESSR_SGMII_WOC_COPPER:
+case ESSR_RTBI_COPPER:
+case ESSR_RGMII_COPPER:
+case ESSR_GMII_COPPER:
+	copperonly = true;
+default:
+	break;
+}
+			}
+			break;
+		default:
+			break;
+		}
+		if (fiberonly || copperonly)
+			aprint_debug_dev(self, "both copper and fiber are set "
+			"but MODE[] is %s only.\n",
+			fiberonly ? "fiber" : "copper");
+		if (fiberonly)
+			sc->mii_extcapabilities
+			&= ~(EXTSR_1000TFDX | EXTSR_1000THDX);
+		else if (copperonly) {
+			sc->mii_extcapabilities
+			&= ~(EXTSR_1000XFDX | EXTSR_1000XHDX);
+			sc->mii_flags &= ~MIIF_IS_1000X;
+		}
+	}
+
 	aprint_normal_dev(self, "");
 	if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
 	(sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
@@ -280,9 +317,7 @@ makphy_reset(struct mii_softc *sc)
 
 	mii_phy_reset(sc);
 
-	/*
-	 * Initialize PHY Specific Control Register.
-	 */
+	/* Initialize PHY Specific Control Register. */
 	reg = PHY_READ(sc, MAKPHY_PSCR);
 
 	/* Assert CRS on transmit. */
@@ -425,7 +460,7 @@ static void
 makphy_status(struct mii_softc *sc)
 {
 	struct mii_data *mii = sc->mii_pdata;
-	int bmcr, gsr, pssr;
+	int bmcr, gsr, pssr, essr;
 
 	mii->mii_media_status = IFM_AVALID;
 	mii->mii_media_active = IFM_ETHER;
@@ -463,10 +498,45 @@ makphy_status(struct mii_softc *sc)
 		}
 	}
 
-	/* XXX FIXME: Use different page for Fiber on newer chips */
+	/*
+	 * XXX The following code support Fiber/Copper auto select mode
+	 * only for 88E1011, 88E and 88E1112. For other chips, the document
+	 * is required.
+	 

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

2020-01-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 24 18:43:35 UTC 2020

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

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

sys/dev/pci/if_wm.c 1.650, 1.652-1.654 via patch
sys/dev/pci/if_wmreg.h  1.116-1.117

- Set CTRL_ILOS(Invert loss of signal) bit correctly on 82580
  port 1, 2, 3 and newer chips. This change fixes a bug that some
  fiber, serdes or SFP devices don't detect the link status correctly.
- Simplify code by using "struct mii_data *mii" more. No functional
  change.
- MSI-X doesn't use sc->sc_icr variable, so move the code into
  non-MSI-X part. No functional change intended.
- Modify debug printfs a bit.
- Rename macro.
- Use __BIT()
- Fix comment. Add comment.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.37 -r1.508.4.38 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.98.6.10 -r1.98.6.11 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/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.37 src/sys/dev/pci/if_wm.c:1.508.4.38
--- src/sys/dev/pci/if_wm.c:1.508.4.37	Thu Jan 23 10:17:41 2020
+++ src/sys/dev/pci/if_wm.c	Fri Jan 24 18:43:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.37 2020/01/23 10:17:41 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.38 2020/01/24 18:43:35 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.508.4.37 2020/01/23 10:17:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.38 2020/01/24 18:43:35 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2645,10 +2645,11 @@ alloc_retry:
 		}
 	}
 
-	/* XXX For other than 82580? */
-	if (sc->sc_type == WM_T_82580) {
-		wm_nvm_read(sc, NVM_OFF_CFG3_PORTA, 1, );
-		if (nvmword & __BIT(13))
+	if ((sc->sc_type >= WM_T_82580) && (sc->sc_type <= WM_T_I211)) {
+		wm_nvm_read(sc,
+		NVM_OFF_LAN_FUNC_82580(sc->sc_funcid) + NVM_OFF_CFG3_PORTA,
+		1, );
+		if (nvmword & NVM_CFG3_ILOS)
 			sc->sc_ctrl |= CTRL_ILOS;
 	}
 
@@ -5981,8 +5982,7 @@ wm_init_locked(struct ifnet *ifp)
 
 	/* Set up the interrupt registers. */
 	CSR_WRITE(sc, WMREG_IMC, 0xU);
-	sc->sc_icr = ICR_TXDW | ICR_LSC | ICR_RXSEQ | ICR_RXDMT0 |
-	ICR_RXO | ICR_RXT0;
+
 	if (wm_is_using_msix(sc)) {
 		uint32_t mask;
 		struct wm_queue *wmq;
@@ -6022,8 +6022,11 @@ wm_init_locked(struct ifnet *ifp)
 			CSR_WRITE(sc, WMREG_IMS, ICR_LSC);
 			break;
 		}
-	} else
+	} else {
+		sc->sc_icr = ICR_TXDW | ICR_LSC | ICR_RXSEQ | ICR_RXDMT0 |
+		ICR_RXO | ICR_RXT0;
 		CSR_WRITE(sc, WMREG_IMS, sc->sc_icr);
+	}
 
 	/* Set up the inter-packet gap. */
 	CSR_WRITE(sc, WMREG_TIPG, sc->sc_tipg);
@@ -9098,7 +9101,7 @@ wm_linkintr_serdes(struct wm_softc *sc, 
 {
 	struct ifnet *ifp = >sc_ethercom.ec_if;
 	struct mii_data *mii = >sc_mii;
-	struct ifmedia_entry *ife = sc->sc_mii.mii_media.ifm_cur;
+	struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
 	uint32_t pcs_adv, pcs_lpab, reg;
 
 	DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev),
@@ -9441,11 +9444,12 @@ wm_linkintr_msix(void *arg)
 	uint32_t reg;
 	bool has_rxo;
 
-	DPRINTF(WM_DEBUG_LINK,
-	("%s: LINK: got link intr\n", device_xname(sc->sc_dev)));
-
 	reg = CSR_READ(sc, WMREG_ICR);
 	WM_CORE_LOCK(sc);
+	DPRINTF(WM_DEBUG_LINK,
+	("%s: LINK: got link intr. ICR = %08x\n",
+		device_xname(sc->sc_dev), reg));
+
 	if (sc->sc_core_stopping)
 		goto out;
 
@@ -11180,7 +11184,7 @@ wm_gmii_statchg(struct ifnet *ifp)
 			sc->sc_ctrl |= CTRL_RFCE;
 	}
 
-	if (sc->sc_mii.mii_media_active & IFM_FDX) {
+	if (mii->mii_media_active & IFM_FDX) {
 		DPRINTF(WM_DEBUG_LINK,
 		("%s: LINK: statchg: FDX\n", ifp->if_xname));
 		sc->sc_tctl |= TCTL_COLD(TX_COLLISION_DISTANCE_FDX);
@@ -11195,7 +11199,7 @@ wm_gmii_statchg(struct ifnet *ifp)
 	CSR_WRITE(sc, (sc->sc_type < WM_T_82543) ? WMREG_OLD_FCRTL
 		 : WMREG_FCRTL, sc->sc_fcrtl);
 	if (sc->sc_type == WM_T_80003) {
-		switch (IFM_SUBTYPE(sc->sc_mii.mii_media_active)) {
+		switch (IFM_SUBTYPE(mii->mii_media_active)) {
 		case IFM_1000_T:
 			wm_kmrn_writereg(sc, KUMCTRLSTA_OFFSET_HD_CTRL,
 			KUMCTRLSTA_HD_CTRL_1000_DEFAULT);
@@ -11784,7 +11788,8 @@ wm_tbi_tick(struct wm_softc *sc)
 		if ((IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO)
 		&& (++sc->sc_tbi_serdes_ticks
 			>= sc->sc_tbi_serdes_anegticks)) {
-			DPRINTF(WM_DEBUG_LINK, ("EXPIRE\n"));
+			DPRINTF(WM_DEBUG_LINK, ("%s: %s: EXPIRE\n",
+device_xname(sc->sc_dev), __func__));
 			sc->sc_tbi_serdes_ticks = 0;
 			/*
 			 * Reset the link, and let autonegotiation do
@@ -11891,7 +11896,7 @@ wm_serdes_mediastatus(struct ifnet *ifp,
 {
 	struct wm_softc *sc = ifp->if_softc;
 	struct mii_data *mii = >sc_mii;
-	struct ifmedia_entry *ife = 

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

2020-01-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 24 18:37:32 UTC 2020

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: if_bypass.c ix_txrx.c ixgbe.c ixgbe.h
ixgbe_82598.c ixgbe_api.c ixgbe_common.c ixgbe_netbsd.c
ixgbe_osdep.c ixgbe_osdep.h ixgbe_phy.c ixv.c

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

sys/dev/pci/ixgbe/if_bypass.c   1.5
sys/dev/pci/ixgbe/ixgbe_osdep.c 1.5
sys/dev/pci/ixgbe/ix_txrx.c 1.58-1.60
sys/dev/pci/ixgbe/ixgbe.c   1.195,1.220-1.221 via patch
sys/dev/pci/ixgbe/ixgbe.h   1.60-1.2
sys/dev/pci/ixgbe/ixgbe_api.c   1.24
sys/dev/pci/ixgbe/ixgbe_common.c1.26
sys/dev/pci/ixgbe/ixgbe_netbsd.c1.11-1.12
sys/dev/pci/ixgbe/ixgbe_osdep.h 1.24
sys/dev/pci/ixgbe/ixgbe_phy.c   1.19
sys/dev/pci/ixgbe/ixgbe_82598.c 1.14
sys/dev/pci/ixgbe/ixv.c 1.122,1.142,1.144 via patch

- Use unsigned to avoid undefined behavior in
  ix{gbe,v}_[un]register_vlan().
- Free RX structure correctly when detaching.
- Remove unused code.
- Remove extra spaces.
- Fix some typos in comment.
- KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.2.4.4 -r1.2.4.5 src/sys/dev/pci/ixgbe/if_bypass.c
cvs rdiff -u -r1.24.2.18 -r1.24.2.19 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.88.2.38 -r1.88.2.39 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.24.6.18 -r1.24.6.19 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.8.8.2 -r1.8.8.3 src/sys/dev/pci/ixgbe/ixgbe_82598.c
cvs rdiff -u -r1.15.8.5 -r1.15.8.6 src/sys/dev/pci/ixgbe/ixgbe_api.c
cvs rdiff -u -r1.13.2.7 -r1.13.2.8 src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.6.2.4 -r1.6.2.5 src/sys/dev/pci/ixgbe/ixgbe_netbsd.c
cvs rdiff -u -r1.1.12.3 -r1.1.12.4 src/sys/dev/pci/ixgbe/ixgbe_osdep.c
cvs rdiff -u -r1.17.6.5 -r1.17.6.6 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.11.6.4 -r1.11.6.5 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.56.2.28 -r1.56.2.29 src/sys/dev/pci/ixgbe/ixv.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/ixgbe/if_bypass.c
diff -u src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.4 src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.5
--- src/sys/dev/pci/ixgbe/if_bypass.c:1.2.4.4	Sat Apr 14 10:25:11 2018
+++ src/sys/dev/pci/ixgbe/if_bypass.c	Fri Jan 24 18:37:31 2020
@@ -101,7 +101,7 @@ ixgbe_get_bypass_time(u32 *year, u32 *se
 	nanotime();
 	*sec = current.tv_sec;
 
-	while(*sec > SEC_THIS_YEAR(*year)) {
+	while (*sec > SEC_THIS_YEAR(*year)) {
 		*sec -= SEC_THIS_YEAR(*year);
 		(*year)++;
 	}

Index: src/sys/dev/pci/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.18 src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.19
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.18	Sun Nov 10 13:36:29 2019
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Fri Jan 24 18:37:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.24.2.18 2019/11/10 13:36:29 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.24.2.19 2020/01/24 18:37:31 martin Exp $ */
 
 /**
 
@@ -148,7 +148,7 @@ ixgbe_legacy_start_locked(struct ifnet *
 		return (ENETDOWN);
 	if (txr->txr_no_space)
 		return (ENETDOWN);
-	
+
 	while (!IFQ_IS_EMPTY(>if_snd)) {
 		if (txr->tx_avail <= IXGBE_QUEUE_MIN_FREE)
 			break;
@@ -1693,6 +1693,10 @@ ixgbe_free_receive_buffers(struct rx_rin
 rxbuf->pmap = NULL;
 			}
 		}
+
+		/* NetBSD specific. See ixgbe_netbsd.c */
+		ixgbe_jcl_destroy(adapter, rxr);
+
 		if (rxr->rx_buffers != NULL) {
 			free(rxr->rx_buffers, M_DEVBUF);
 			rxr->rx_buffers = NULL;
@@ -2379,3 +2383,24 @@ tx_fail:
 fail:
 	return (error);
 } /* ixgbe_allocate_queues */
+
+/
+ * ixgbe_free_queues
+ *
+ *   Free descriptors for the transmit and receive rings, and then
+ *   the memory associated with each.
+ /
+void
+ixgbe_free_queues(struct adapter *adapter)
+{
+	struct ix_queue *que;
+	int i;
+
+	ixgbe_free_transmit_structures(adapter);
+	ixgbe_free_receive_structures(adapter);
+	for (i = 0; i < adapter->num_queues; i++) {
+		que = >queues[i];
+		mutex_destroy(>dc_mtx);
+	}
+	free(adapter->queues, M_DEVBUF);
+} /* ixgbe_free_queues */

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.38 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.39
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.38	Thu Dec 26 20:25:07 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Jan 24 18:37:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.38 2019/12/26 20:25:07 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.39 2020/01/24 18:37:31 martin Exp $ */
 
 /**
 

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

2020-01-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Jan 24 18:40:46 UTC 2020

Modified Files:
src/sys/dev/mii [netbsd-8]: ihphy.c

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

sys/dev/mii/ihphy.c: revision 1.15

 Remove extra 10ms delay in ihphy_reset(). The delay are in if_wm.c side.
It's required for hardware full reset and it's not required on soft reset.

 When ihphy.c was added in 9 years ago, some workaround code were not in
if_wm.c yet and the initialization code was not good.


To generate a diff of this commit:
cvs rdiff -u -r1.10.8.1 -r1.10.8.2 src/sys/dev/mii/ihphy.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/mii/ihphy.c
diff -u src/sys/dev/mii/ihphy.c:1.10.8.1 src/sys/dev/mii/ihphy.c:1.10.8.2
--- src/sys/dev/mii/ihphy.c:1.10.8.1	Thu Aug  1 14:27:30 2019
+++ src/sys/dev/mii/ihphy.c	Fri Jan 24 18:40:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ihphy.c,v 1.10.8.1 2019/08/01 14:27:30 martin Exp $	*/
+/*	$NetBSD: ihphy.c,v 1.10.8.2 2020/01/24 18:40:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.10.8.1 2019/08/01 14:27:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihphy.c,v 1.10.8.2 2020/01/24 18:40:45 martin Exp $");
 
 #include 
 #include 
@@ -296,14 +296,6 @@ ihphy_reset(struct mii_softc *sc)
 
 	PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_ISO);
 
-	/*
-	 * Regarding reset, the data sheet specifies (page 55):
-	 *
-	 * "After PHY reset, a delay of 10 ms is required before
-	 *  any register access using MDIO."
-	 */
-	delay(1);
-
 	/* Wait another 100ms for it to complete. */
 	for (i = 0; i < 100; i++) {
 		reg = PHY_READ(sc, MII_BMCR);



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

2020-01-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 23 10:17:42 UTC 2020

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c

Log Message:
Pull up following revision(s) (requested by knakahara in ticket #1488):

sys/dev/pci/if_wm.c: revision 1.661

fix softint_disestablish() in wm_detach().

ok by msaitoh@n.o
XXX pullup-8, pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.36 -r1.508.4.37 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.36 src/sys/dev/pci/if_wm.c:1.508.4.37
--- src/sys/dev/pci/if_wm.c:1.508.4.36	Wed Nov  6 10:23:06 2019
+++ src/sys/dev/pci/if_wm.c	Thu Jan 23 10:17:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.36 2019/11/06 10:23:06 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.37 2020/01/23 10:17:41 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.508.4.36 2019/11/06 10:23:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.37 2020/01/23 10:17:41 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3017,6 +3017,9 @@ wm_detach(device_t self, int flags __unu
 	}
 	pci_intr_release(sc->sc_pc, sc->sc_intrs, sc->sc_nintrs);
 
+	for (i = 0; i < sc->sc_nqueues; i++)
+		softint_disestablish(sc->sc_queue[i].wmq_si);
+
 	wm_free_txrx_queues(sc);
 
 	/* Unmap the registers */



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

2020-01-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jan  5 15:11:29 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: uthum.c

Log Message:
use min() instead of uimin() - the latter does not exist on this branch.


To generate a diff of this commit:
cvs rdiff -u -r1.13.8.1 -r1.13.8.2 src/sys/dev/usb/uthum.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/uthum.c
diff -u src/sys/dev/usb/uthum.c:1.13.8.1 src/sys/dev/usb/uthum.c:1.13.8.2
--- src/sys/dev/usb/uthum.c:1.13.8.1	Thu Jan  2 09:43:56 2020
+++ src/sys/dev/usb/uthum.c	Sun Jan  5 15:11:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uthum.c,v 1.13.8.1 2020/01/02 09:43:56 martin Exp $   */
+/*	$NetBSD: uthum.c,v 1.13.8.2 2020/01/05 15:11:29 martin Exp $   */
 /*	$OpenBSD: uthum.c,v 1.6 2010/01/03 18:43:02 deraadt Exp $   */
 
 /*
@@ -22,7 +22,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.13.8.1 2020/01/02 09:43:56 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uthum.c,v 1.13.8.2 2020/01/05 15:11:29 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -267,7 +267,7 @@ uthum_read_data(struct uthum_softc *sc, 
 	if ((buf == NULL) || len == 0)
 		return 0;
 
-	olen = uimin(sc->sc_olen, sizeof(cmdbuf));
+	olen = min(sc->sc_olen, sizeof(cmdbuf));
 
 	/* issue query */
 	memset(cmdbuf, 0, sizeof(cmdbuf));
@@ -298,7 +298,7 @@ uthum_read_data(struct uthum_softc *sc, 
 		tsleep(>sc_sme, 0, "uthum", (need_delay*hz+999)/1000 + 1);
 
 	/* get answer */
-	flen = uimin(sc->sc_flen, sizeof(report));
+	flen = min(sc->sc_flen, sizeof(report));
 	if (uhidev_get_report(>sc_hdev, UHID_FEATURE_REPORT,
 	report, flen))
 		return EIO;



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

2020-01-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan  2 09:43:56 UTC 2020

Modified Files:
src/sys/dev/usb [netbsd-8]: ucycom.c uhid.c uthum.c

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

sys/dev/usb/uthum.c: revision 1.18
sys/dev/usb/ucycom.c: revision 1.49
sys/dev/usb/uhid.c: revision 1.111

Fix buffer overflows. sc_{o,f}len are controlled by the USB device. By
crafting the former the device can leak stack data. By crafting the latter
the device can overwrite the stack. The combination of the two means the
device can ROP the kernel and obtain code execution (demonstrated with an
actual exploit over vHCI).

Truncate the lengths to the size of the buffers, and also drop sc_ilen
since it is unused. Patch tested with vHCI+kASan.

 -

Fix buffer overflows. Also add missing mutex_exit.

 -

Fix buffer overflows: validate the lengths at attach time, given that they
are apparently not supposed to be variable. Drop sc_ilen since it is
unused.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.45.8.1 src/sys/dev/usb/ucycom.c
cvs rdiff -u -r1.99 -r1.99.6.1 src/sys/dev/usb/uhid.c
cvs rdiff -u -r1.13 -r1.13.8.1 src/sys/dev/usb/uthum.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/ucycom.c
diff -u src/sys/dev/usb/ucycom.c:1.45 src/sys/dev/usb/ucycom.c:1.45.8.1
--- src/sys/dev/usb/ucycom.c:1.45	Fri Nov 25 12:56:29 2016
+++ src/sys/dev/usb/ucycom.c	Thu Jan  2 09:43:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucycom.c,v 1.45 2016/11/25 12:56:29 skrll Exp $	*/
+/*	$NetBSD: ucycom.c,v 1.45.8.1 2020/01/02 09:43:56 martin Exp $	*/
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.45 2016/11/25 12:56:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucycom.c,v 1.45.8.1 2020/01/02 09:43:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -121,11 +121,15 @@ struct ucycom_softc {
 
 	struct tty		*sc_tty;
 
+	enum {
+		UCYCOM_INIT_NONE,
+		UCYCOM_INIT_INITED
+	} sc_init_state;
+
 	kmutex_t sc_lock;	/* protects refcnt, others */
 
 	/* uhidev parameters */
 	size_t			sc_flen; /* feature report length */
-	size_t			sc_ilen; /* input report length */
 	size_t			sc_olen; /* output report length */
 
 	uint8_t			*sc_obuf;
@@ -219,13 +223,18 @@ ucycom_attach(device_t parent, device_t 
 	sc->sc_hdev.sc_intr = ucycom_intr;
 	sc->sc_hdev.sc_parent = uha->parent;
 	sc->sc_hdev.sc_report_id = uha->reportid;
+	sc->sc_init_state = UCYCOM_INIT_NONE;
 
 	uhidev_get_report_desc(uha->parent, , );
 	repid = uha->reportid;
-	sc->sc_ilen = hid_report_size(desc, size, hid_input, repid);
 	sc->sc_olen = hid_report_size(desc, size, hid_output, repid);
 	sc->sc_flen = hid_report_size(desc, size, hid_feature, repid);
 
+	if (sc->sc_olen != 8 && sc->sc_olen != 32)
+		return;
+	if (sc->sc_flen != 5)
+		return;
+
 	sc->sc_msr = sc->sc_mcr = 0;
 
 	/* set up tty */
@@ -238,6 +247,8 @@ ucycom_attach(device_t parent, device_t 
 
 	/* Nothing interesting to report */
 	aprint_normal("\n");
+
+	sc->sc_init_state = UCYCOM_INIT_INITED;
 }
 
 
@@ -334,10 +345,10 @@ ucycomopen(dev_t dev, int flag, int mode
 
 	if (sc == NULL)
 		return ENXIO;
-
 	if (sc->sc_dying)
 		return EIO;
-
+	if (sc->sc_init_state != UCYCOM_INIT_INITED)
+		return ENXIO;
 	if (!device_is_active(sc->sc_hdev.sc_dev))
 		return ENXIO;
 

Index: src/sys/dev/usb/uhid.c
diff -u src/sys/dev/usb/uhid.c:1.99 src/sys/dev/usb/uhid.c:1.99.6.1
--- src/sys/dev/usb/uhid.c:1.99	Sat Mar 11 12:41:14 2017
+++ src/sys/dev/usb/uhid.c	Thu Jan  2 09:43:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhid.c,v 1.99 2017/03/11 12:41:14 maya Exp $	*/
+/*	$NetBSD: uhid.c,v 1.99.6.1 2020/01/02 09:43:56 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.99 2017/03/11 12:41:14 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.99.6.1 2020/01/02 09:43:56 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -393,6 +393,8 @@ uhid_do_read(struct uhid_softc *sc, stru
 	if (sc->sc_state & UHID_IMMED) {
 		DPRINTFN(1, ("uhidread immed\n"));
 		extra = sc->sc_hdev.sc_report_id != 0;
+		if (sc->sc_isize + extra > sizeof(buffer))
+			return ENOBUFS;
 		err = uhidev_get_report(>sc_hdev, UHID_INPUT_REPORT,
 	buffer, sc->sc_isize + extra);
 		if (err)
@@ -536,8 +538,10 @@ uhid_do_ioctl(struct uhid_softc *sc, u_l
 	case FIOASYNC:
 		mutex_enter(proc_lock);
 		if (*(int *)addr) {
-			if (sc->sc_async != NULL)
+			if (sc->sc_async != NULL) {
+mutex_exit(proc_lock);
 return EBUSY;
+			}
 			sc->sc_async = l->l_proc;
 			DPRINTF(("uhid_do_ioctl: FIOASYNC %p\n", l->l_proc));
 		} else
@@ -584,6 +588,8 @@ uhid_do_ioctl(struct uhid_softc *sc, u_l
 	case USB_SET_IMMED:
 		if (*(int *)addr) {
 			extra = 

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

2019-12-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Dec 26 20:25:07 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ixgbe.c

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

sys/dev/pci/ixgbe/ixgbe.c: revision 1.218

 Add missing core lock in ixgbe_handle_mod().


To generate a diff of this commit:
cvs rdiff -u -r1.88.2.37 -r1.88.2.38 src/sys/dev/pci/ixgbe/ixgbe.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.37 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.38
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.37	Tue Nov 19 10:48:15 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Thu Dec 26 20:25:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.37 2019/11/19 10:48:15 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.38 2019/12/26 20:25:07 martin Exp $ */
 
 /**
 
@@ -4572,6 +4572,7 @@ ixgbe_handle_mod(void *context)
 	device_t	dev = adapter->dev;
 	u32		err, cage_full = 0;
 
+	IXGBE_CORE_LOCK(adapter);
 	++adapter->mod_sicount.ev_count;
 	if (adapter->hw.need_crosstalk_fix) {
 		switch (hw->mac.type) {
@@ -4589,14 +4590,14 @@ ixgbe_handle_mod(void *context)
 		}
 
 		if (!cage_full)
-			return;
+			goto out;
 	}
 
 	err = hw->phy.ops.identify_sfp(hw);
 	if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		device_printf(dev,
 		"Unsupported SFP+ module type was detected.\n");
-		return;
+		goto out;
 	}
 
 	if (hw->mac.type == ixgbe_mac_82598EB)
@@ -4607,9 +4608,11 @@ ixgbe_handle_mod(void *context)
 	if (err == IXGBE_ERR_SFP_NOT_SUPPORTED) {
 		device_printf(dev,
 		"Setup failure - unsupported SFP+ module type.\n");
-		return;
+		goto out;
 	}
 	softint_schedule(adapter->msf_si);
+out:
+	IXGBE_CORE_UNLOCK(adapter);
 } /* ixgbe_handle_mod */
 
 



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

2019-12-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Dec 17 16:18:50 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-8]: ath.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1475):

sys/dev/ic/ath.c: revision 1.129

Protect network ioctls from non-authorized users. (Ilja Van Sprundel)


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.123.6.1 src/sys/dev/ic/ath.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/ath.c
diff -u src/sys/dev/ic/ath.c:1.123 src/sys/dev/ic/ath.c:1.123.6.1
--- src/sys/dev/ic/ath.c:1.123	Thu Feb  2 10:05:35 2017
+++ src/sys/dev/ic/ath.c	Tue Dec 17 16:18:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ath.c,v 1.123 2017/02/02 10:05:35 nonaka Exp $	*/
+/*	$NetBSD: ath.c,v 1.123.6.1 2019/12/17 16:18:50 martin Exp $	*/
 
 /*-
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
 __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.123 2017/02/02 10:05:35 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.123.6.1 2019/12/17 16:18:50 martin Exp $");
 #endif
 
 /*
@@ -69,6 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.12
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -5435,6 +5436,12 @@ ath_ioctl(struct ifnet *ifp, u_long cmd,
 		return copyout(>sc_stats,
 ifr->ifr_data, sizeof (sc->sc_stats));
 	case SIOCGATHDIAG:
+		error = kauth_authorize_network(curlwp->l_cred,
+		KAUTH_NETWORK_INTERFACE,
+		KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, KAUTH_ARG(cmd),
+		NULL);
+		if (error)
+			break;
 		error = ath_ioctl_diag(sc, (struct ath_diag *) ifr);
 		break;
 	default:



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

2019-12-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 14 12:33:47 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_urtwn.c

Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #1472):

sys/dev/usb/if_urtwn.c: revision 1.76

Reset MCU ready status before resetting the MCU.
Fixes PR kern/54728


To generate a diff of this commit:
cvs rdiff -u -r1.53.2.5 -r1.53.2.6 src/sys/dev/usb/if_urtwn.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_urtwn.c
diff -u src/sys/dev/usb/if_urtwn.c:1.53.2.5 src/sys/dev/usb/if_urtwn.c:1.53.2.6
--- src/sys/dev/usb/if_urtwn.c:1.53.2.5	Tue Dec 18 18:32:00 2018
+++ src/sys/dev/usb/if_urtwn.c	Sat Dec 14 12:33:47 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_urtwn.c,v 1.53.2.5 2018/12/18 18:32:00 martin Exp $	*/
+/*	$NetBSD: if_urtwn.c,v 1.53.2.6 2019/12/14 12:33:47 martin Exp $	*/
 /*	$OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $	*/
 
 /*-
@@ -25,7 +25,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.53.2.5 2018/12/18 18:32:00 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.53.2.6 2019/12/14 12:33:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3412,6 +3412,8 @@ urtwn_load_firmware(struct urtwn_softc *
 	}
 
 	if (urtwn_read_1(sc, R92C_MCUFWDL) & R92C_MCUFWDL_RAM_DL_SEL) {
+		/* Reset MCU ready status */
+		urtwn_write_1(sc, R92C_MCUFWDL, 0);
 		if (ISSET(sc->chip, URTWN_CHIP_88E) ||
 		ISSET(sc->chip, URTWN_CHIP_92EU))
 			urtwn_r88e_fw_reset(sc);



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

2019-12-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Dec  8 10:30:31 UTC 2019

Modified Files:
src/sys/dev [netbsd-8]: cons.c

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

sys/dev/cons.c: revision 1.76
sys/dev/cons.c: revision 1.77

Fix reference count leak in cons(4).
Don't forget to vrele after you're done, folks!
Restore historical $Hdr$ tag after git cvsexportcommit nixed it.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.75.10.1 src/sys/dev/cons.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/cons.c
diff -u src/sys/dev/cons.c:1.75 src/sys/dev/cons.c:1.75.10.1
--- src/sys/dev/cons.c:1.75	Fri May 29 16:26:45 2015
+++ src/sys/dev/cons.c	Sun Dec  8 10:30:31 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cons.c,v 1.75 2015/05/29 16:26:45 macallan Exp $	*/
+/*	$NetBSD: cons.c,v 1.75.10.1 2019/12/08 10:30:31 martin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.75 2015/05/29 16:26:45 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cons.c,v 1.75.10.1 2019/12/08 10:30:31 martin Exp $");
 
 #include 
 #include 
@@ -158,6 +158,7 @@ cnclose(dev_t dev, int flag, int mode, s
 	if (error == 0) {
 		error = VOP_CLOSE(vp, flag, kauth_cred_get());
 		VOP_UNLOCK(vp);
+		vrele(vp);
 	}
 	return error;
 }



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

2019-12-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Dec  5 16:50:54 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: if_alc.c if_ale.c if_cas.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1464):
sys/dev/pci/if_alc.c1.44 via patch
sys/dev/pci/if_ale.c1.35-1.36 via patch
sys/dev/pci/if_cas.c1.36 via patch
- Fix a bug that IFF_ALLMULTI is almost always set.
- Whitespace fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.24.8.4 -r1.24.8.5 src/sys/dev/pci/if_alc.c
cvs rdiff -u -r1.22.2.2 -r1.22.2.3 src/sys/dev/pci/if_ale.c
cvs rdiff -u -r1.26 -r1.26.8.1 src/sys/dev/pci/if_cas.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_alc.c
diff -u src/sys/dev/pci/if_alc.c:1.24.8.4 src/sys/dev/pci/if_alc.c:1.24.8.5
--- src/sys/dev/pci/if_alc.c:1.24.8.4	Wed Nov  6 10:04:47 2019
+++ src/sys/dev/pci/if_alc.c	Thu Dec  5 16:50:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_alc.c,v 1.24.8.4 2019/11/06 10:04:47 martin Exp $	*/
+/*	$NetBSD: if_alc.c,v 1.24.8.5 2019/12/05 16:50:54 bouyer Exp $	*/
 /*	$OpenBSD: if_alc.c,v 1.1 2009/08/08 09:31:13 kevlo Exp $	*/
 /*-
  * Copyright (c) 2009, Pyun YongHyeon 
@@ -745,7 +745,6 @@ alc_get_macaddr_816x(struct alc_softc *s
 	alc_get_macaddr_par(sc);
 }
 
-
 static void
 alc_get_macaddr_par(struct alc_softc *sc)
 {
@@ -2776,7 +2775,6 @@ alc_init_backend(struct ifnet *ifp, bool
 	} else
 		CSR_WRITE_4(sc, ALC_CLK_GATING_CFG, 0);
  
-
 	/* Reprogram the station address. */
 	memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr));
 	CSR_WRITE_4(sc, ALC_PAR0,
@@ -2832,7 +2830,7 @@ alc_init_backend(struct ifnet *ifp, bool
 		CSR_WRITE_4(sc, ALC_RRD1_HEAD_ADDR_LO, 0);
 		CSR_WRITE_4(sc, ALC_RRD2_HEAD_ADDR_LO, 0);
 		CSR_WRITE_4(sc, ALC_RRD3_HEAD_ADDR_LO, 0);
-	}\
+	}
 	/* Set Rx return descriptor counter. */
 	CSR_WRITE_4(sc, ALC_RRD_RING_CNT,
 	(ALC_RR_RING_CNT << RRD_RING_CNT_SHIFT) & RRD_RING_CNT_MASK);
@@ -3403,25 +3401,35 @@ alc_iff(struct alc_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		ETHER_NEXT_MULTI(step, enm);
+	}
+
+update:
+	if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+		if (ifp->if_flags & IFF_PROMISC) {
 			rxcfg |= MAC_CFG_PROMISC;
-		else
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+		} else
 			rxcfg |= MAC_CFG_ALLMULTI;
 		mchash[0] = mchash[1] = 0x;
-	} else {
-		/* Program new filter. */
-		memset(mchash, 0, sizeof(mchash));
-
-		ETHER_FIRST_MULTI(step, ec, enm);
-		while (enm != NULL) {
-			crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
-			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-			ETHER_NEXT_MULTI(step, enm);
-		}
 	}
-
 	CSR_WRITE_4(sc, ALC_MAR0, mchash[0]);
 	CSR_WRITE_4(sc, ALC_MAR1, mchash[1]);
 	CSR_WRITE_4(sc, ALC_MAC_CFG, rxcfg);

Index: src/sys/dev/pci/if_ale.c
diff -u src/sys/dev/pci/if_ale.c:1.22.2.2 src/sys/dev/pci/if_ale.c:1.22.2.3
--- src/sys/dev/pci/if_ale.c:1.22.2.2	Wed Nov  6 10:04:47 2019
+++ src/sys/dev/pci/if_ale.c	Thu Dec  5 16:50:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ale.c,v 1.22.2.2 2019/11/06 10:04:47 martin Exp $	*/
+/*	$NetBSD: if_ale.c,v 1.22.2.3 2019/12/05 16:50:54 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2008, Pyun YongHyeon 
@@ -32,7 +32,7 @@
 /* Driver for Atheros AR8121/AR8113/AR8114 PCIe Ethernet. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.22.2.2 2019/11/06 10:04:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ale.c,v 1.22.2.3 2019/12/05 16:50:54 bouyer Exp $");
 
 #include "vlan.h"
 
@@ -1990,25 +1990,35 @@ ale_rxfilter(struct ale_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		

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

2019-12-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Dec  5 16:47:17 UTC 2019

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

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1462):
sys/dev/pci/if_age.c: revision 1.61, 1.63-1.64 via patch

- Fix direction of the loop in age_get_macaddr().
- Fix multicast handling. All Atheros controllers use big-endian form
  when computing multicast hash.
- Fix a bug that IFF_ALLMULTI is almost always set.


To generate a diff of this commit:
cvs rdiff -u -r1.50.8.2 -r1.50.8.3 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.50.8.2 src/sys/dev/pci/if_age.c:1.50.8.3
--- src/sys/dev/pci/if_age.c:1.50.8.2	Wed Nov  6 10:04:47 2019
+++ src/sys/dev/pci/if_age.c	Thu Dec  5 16:47:17 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_age.c,v 1.50.8.2 2019/11/06 10:04:47 martin Exp $ */
+/*	$NetBSD: if_age.c,v 1.50.8.3 2019/12/05 16:47:17 bouyer 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.50.8.2 2019/11/06 10:04:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_age.c,v 1.50.8.3 2019/12/05 16:47:17 bouyer Exp $");
 
 #include "vlan.h"
 
@@ -572,7 +572,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)
@@ -2274,25 +2274,35 @@ age_rxfilter(struct age_softc *sc)
 	 */
 	rxcfg |= MAC_CFG_BCAST;
 
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		if (ifp->if_flags & IFF_PROMISC)
+	/* Program new filter. */
+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		goto update;
+
+	memset(mchash, 0, sizeof(mchash));
+
+	ETHER_FIRST_MULTI(step, ec, enm);
+	while (enm != NULL) {
+		if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+			ETHER_UNLOCK(ec);
+			goto update;
+		}
+		crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN);
+		mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+		ETHER_NEXT_MULTI(step, enm);
+	}
+
+update:
+	if ((ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) != 0) {
+		if (ifp->if_flags & IFF_PROMISC) {
 			rxcfg |= MAC_CFG_PROMISC;
-		else
+			/* XXX Use ETHER_F_ALLMULTI in future. */
+			ifp->if_flags |= IFF_ALLMULTI;
+		} else
 			rxcfg |= MAC_CFG_ALLMULTI;
 		mchash[0] = mchash[1] = 0x;
-	} else {
-		/* Program new filter. */
-		memset(mchash, 0, sizeof(mchash));
-
-		ETHER_FIRST_MULTI(step, ec, enm);
-		while (enm != NULL) {
-			crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
-			mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-			ETHER_NEXT_MULTI(step, enm);
-		}
 	}
-
 	CSR_WRITE_4(sc, AGE_MAR0, mchash[0]);
 	CSR_WRITE_4(sc, AGE_MAR1, mchash[1]);
 	CSR_WRITE_4(sc, AGE_MAC_CFG, rxcfg);



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

2019-12-05 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Thu Dec  5 16:44:32 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: if_bge.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1462):
sys/dev/pci/if_bge.c: revision 1.340
sys/dev/pci/if_bge.c: revision 1.341
sys/dev/pci/if_bge.c: revision 1.336
- Avoid undefined behavior in bge_setmulti(). found by kUBSan.
- Avoid undefined behavior when setting the MAC address in bge_init().
  found by kUBSan.
 Fix a bug that SK-9D41 can't detect fiber media. Check the subsystem ID
correctly. This bug was added in if_bge.c rev. 1.161.
- Use *_FLUSH() more. The main purpose is to wait following delay() correctly.
- Add missing DELAY(80) after writing BGE_MI_MODE register.


To generate a diff of this commit:
cvs rdiff -u -r1.310.2.7 -r1.310.2.8 src/sys/dev/pci/if_bge.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_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.310.2.7 src/sys/dev/pci/if_bge.c:1.310.2.8
--- src/sys/dev/pci/if_bge.c:1.310.2.7	Mon May 13 12:40:13 2019
+++ src/sys/dev/pci/if_bge.c	Thu Dec  5 16:44:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.310.2.7 2019/05/13 12:40:13 martin Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.310.2.8 2019/12/05 16:44:32 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.7 2019/05/13 12:40:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.8 2019/12/05 16:44:32 bouyer Exp $");
 
 #include 
 #include 
@@ -1030,10 +1030,10 @@ bge_eeprom_getbyte(struct bge_softc *sc,
 	 * Enable use of auto EEPROM access so we can avoid
 	 * having to use the bitbang method.
 	 */
-	BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
+	BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
 
 	/* Reset the EEPROM, load the clock period. */
-	CSR_WRITE_4(sc, BGE_EE_ADDR,
+	CSR_WRITE_4_FLUSH(sc, BGE_EE_ADDR,
 	BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL));
 	DELAY(20);
 
@@ -1825,7 +1825,7 @@ bge_setmulti(struct bge_softc *sc)
 		/* Just want the 7 least-significant bits. */
 		h &= 0x7f;
 
-		hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
+		hashes[(h & 0x60) >> 5] |= 1U << (h & 0x1F);
 		ETHER_NEXT_MULTI(step, enm);
 	}
 
@@ -2283,7 +2283,7 @@ bge_chipinit(struct bge_softc *sc)
 #endif
 
 	/* Set the timer prescaler (always 66MHz) */
-	CSR_WRITE_4(sc, BGE_MISC_CFG, BGE_32BITTIME_66MHZ);
+	CSR_WRITE_4_FLUSH(sc, BGE_MISC_CFG, BGE_32BITTIME_66MHZ);
 
 	if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) {
 		DELAY(40);	/* XXX */
@@ -3439,6 +3439,7 @@ bge_attach(device_t parent, device_t sel
 	else
 		mimode |= BGE_MIMODE_BASE;
 	CSR_WRITE_4(sc, BGE_MI_MODE, mimode);
+	DELAY(80);
 
 	/*
 	 * When using the BCM5701 in PCI-X mode, data corruption has
@@ -3638,10 +3639,10 @@ alloc_retry:
 	 * Reset NVRAM before bge_reset(). It's required to acquire NVRAM
 	 * lock in bge_reset().
 	 */
-	CSR_WRITE_4(sc, BGE_EE_ADDR,
+	CSR_WRITE_4_FLUSH(sc, BGE_EE_ADDR,
 	BGE_EEADDR_RESET | BGE_EEHALFCLK(BGE_HALFCLK_384SCL));
 	delay(1000);
-	BGE_SETBIT(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
+	BGE_SETBIT_FLUSH(sc, BGE_MISC_LOCAL_CTL, BGE_MLC_AUTO_EEPROM);
 
 	bge_stop_fw(sc);
 	bge_sig_pre_reset(sc, BGE_RESET_START);
@@ -3854,7 +3855,7 @@ alloc_retry:
 	 * by its PCI subsystem ID, as we do below for the SysKonnect SK-9D41.
 	 * The SysKonnect SK-9D41 is a 1000baseSX card.
 	 */
-	if (PCI_PRODUCT(pa->pa_id) == SK_SUBSYSID_9D41 ||
+	if (PCI_PRODUCT(subid) == SK_SUBSYSID_9D41 ||
 	(hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) {
 		if (BGE_IS_5705_PLUS(sc)) {
 			sc->bge_flags |= BGEF_FIBER_MII;
@@ -5534,7 +5535,8 @@ bge_init(struct ifnet *ifp)
 	/* Load our MAC address. */
 	m = (const uint16_t *)&(CLLADDR(ifp->if_sadl)[0]);
 	CSR_WRITE_4(sc, BGE_MAC_ADDR1_LO, htons(m[0]));
-	CSR_WRITE_4(sc, BGE_MAC_ADDR1_HI, (htons(m[1]) << 16) | htons(m[2]));
+	CSR_WRITE_4(sc, BGE_MAC_ADDR1_HI,
+	((uint32_t)htons(m[1]) << 16) | htons(m[2]));
 
 	/* Enable or disable promiscuous mode as needed. */
 	if (ifp->if_flags & IFF_PROMISC)
@@ -5680,10 +5682,10 @@ bge_ifmedia_upd(struct ifnet *ifp)
 			break;
 		case IFM_1000_SX:
 			if ((ifm->ifm_media & IFM_FDX) != 0) {
-BGE_CLRBIT(sc, BGE_MAC_MODE,
+BGE_CLRBIT_FLUSH(sc, BGE_MAC_MODE,
 BGE_MACMODE_HALF_DUPLEX);
 			} else {
-BGE_SETBIT(sc, BGE_MAC_MODE,
+BGE_SETBIT_FLUSH(sc, BGE_MAC_MODE,
 BGE_MACMODE_HALF_DUPLEX);
 			}
 			DELAY(40);
@@ -6081,7 +6083,7 @@ bge_link_upd(struct bge_softc *sc)
 BGE_STS_SETBIT(sc, BGE_STS_LINK);
 if (BGE_ASICREV(sc->bge_chipid)
 == BGE_ASICREV_BCM5704) {
-	BGE_CLRBIT(sc, BGE_MAC_MODE,
+	BGE_CLRBIT_FLUSH(sc, BGE_MAC_MODE,
 	BGE_MACMODE_TBI_SEND_CFGS);
 	DELAY(40);
 }



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

2019-05-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue May  7 18:47:01 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: ucom.c umodem_common.c umodemvar.h

Log Message:
Backout the following changes (requested by mrg in ticket #1240):

sys/dev/usb/umodem_common.c: revision 1.27
sys/dev/usb/umodemvar.h: revision 1.10
sys/dev/usb/ucom.c: revision 1.122

fix umodem(4) detach.
There are different fixes upcoming.


To generate a diff of this commit:
cvs rdiff -u -r1.118.8.3 -r1.118.8.4 src/sys/dev/usb/ucom.c
cvs rdiff -u -r1.25.8.1 -r1.25.8.2 src/sys/dev/usb/umodem_common.c
cvs rdiff -u -r1.9.10.1 -r1.9.10.2 src/sys/dev/usb/umodemvar.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.118.8.3 src/sys/dev/usb/ucom.c:1.118.8.4
--- src/sys/dev/usb/ucom.c:1.118.8.3	Mon Apr 22 08:17:50 2019
+++ src/sys/dev/usb/ucom.c	Tue May  7 18:47:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.118.8.3 2019/04/22 08:17:50 martin Exp $	*/
+/*	$NetBSD: ucom.c,v 1.118.8.4 2019/05/07 18:47:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.3 2019/04/22 08:17:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.4 2019/05/07 18:47:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -441,8 +441,10 @@ ucom_detach(device_t self, int flags)
 			mutex_spin_exit(_lock);
 		}
 		/* Wait for processes to go away. */
-		if (cv_timedwait(>sc_detachcv, >sc_lock, hz * 60))
-			aprint_error_dev(self, ": didn't detach\n");
+		if (cv_timedwait(>sc_detachcv, >sc_lock, hz * 60)) {
+			printf("%s: %s didn't detach\n", __func__,
+			device_xname(sc->sc_dev));
+		}
 	}
 
 	softint_disestablish(sc->sc_si);
@@ -1269,9 +1271,7 @@ ucomhwiflow(struct tty *tp, int block)
 
 	if (old && !block) {
 		sc->sc_rx_unblock = 1;
-		kpreempt_disable();
 		softint_schedule(sc->sc_si);
-		kpreempt_enable();
 	}
 	mutex_exit(>sc_lock);
 
@@ -1339,9 +1339,7 @@ ucomstart(struct tty *tp)
 
 	SIMPLEQ_INSERT_TAIL(>sc_obuff_full, ub, ub_link);
 
-	kpreempt_disable();
 	softint_schedule(sc->sc_si);
-	kpreempt_enable();
 
  out:
 	DPRINTF("... done", 0, 0, 0, 0);
@@ -1383,9 +1381,7 @@ ucom_write_status(struct ucom_softc *sc,
 		break;
 	case USBD_STALLED:
 		ub->ub_index = 0;
-		kpreempt_disable();
 		softint_schedule(sc->sc_si);
-		kpreempt_enable();
 		break;
 	case USBD_NORMAL_COMPLETION:
 		usbd_get_xfer_status(ub->ub_xfer, NULL, NULL, , NULL);

Index: src/sys/dev/usb/umodem_common.c
diff -u src/sys/dev/usb/umodem_common.c:1.25.8.1 src/sys/dev/usb/umodem_common.c:1.25.8.2
--- src/sys/dev/usb/umodem_common.c:1.25.8.1	Mon Apr 22 08:17:50 2019
+++ src/sys/dev/usb/umodem_common.c	Tue May  7 18:47:01 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: umodem_common.c,v 1.25.8.1 2019/04/22 08:17:50 martin Exp $	*/
+/*	$NetBSD: umodem_common.c,v 1.25.8.2 2019/05/07 18:47:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.25.8.1 2019/04/22 08:17:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.25.8.2 2019/05/07 18:47:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -94,16 +94,16 @@ int	umodemdebug = 0;
 #define UMODEMIBUFSIZE 4096
 #define UMODEMOBUFSIZE 4096
 
-static usbd_status umodem_set_comm_feature(struct umodem_softc *,
+Static usbd_status umodem_set_comm_feature(struct umodem_softc *,
 	   int, int);
-static usbd_status umodem_set_line_coding(struct umodem_softc *,
+Static usbd_status umodem_set_line_coding(struct umodem_softc *,
 	  usb_cdc_line_state_t *);
 
-static void	umodem_dtr(struct umodem_softc *, int);
-static void	umodem_rts(struct umodem_softc *, int);
-static void	umodem_break(struct umodem_softc *, int);
-static void	umodem_set_line_state(struct umodem_softc *);
-static void	umodem_intr(struct usbd_xfer *, void *, usbd_status);
+Static void	umodem_dtr(struct umodem_softc *, int);
+Static void	umodem_rts(struct umodem_softc *, int);
+Static void	umodem_break(struct umodem_softc *, int);
+Static void	umodem_set_line_state(struct umodem_softc *);
+Static void	umodem_intr(struct usbd_xfer *, void *, usbd_status);
 
 int
 umodem_common_attach(device_t self, struct umodem_softc *sc,
@@ -120,15 +120,10 @@ umodem_common_attach(device_t self, stru
 	sc->sc_dev = self;
 	sc->sc_udev = dev;
 	sc->sc_ctl_iface = uiaa->uiaa_iface;
-	sc->sc_refcnt = 0;
-	sc->sc_dying = false;
 
 	aprint_naive("\n");
 	aprint_normal("\n");
 
-	mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
-	cv_init(>sc_detach_cv, "umodemdet");
-
 	id = usbd_get_interface_descriptor(sc->sc_ctl_iface);
 	devinfop = usbd_devinfo_alloc(uiaa->uiaa_device, 0);
 	aprint_normal_dev(self, "%s, iclass %d/%d\n",
@@ -261,7 +256,7 @@ 

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

2019-05-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May  5 08:20:08 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: pucdata.c

Log Message:
Pull up following revision(s) (requested by jdolecek in ticket #1255):

sys/dev/pci/pucdata.c: revision 1.104

add NetMos NM9912 entries

PR kern/54149 by Mouse


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

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

Modified files:

Index: src/sys/dev/pci/pucdata.c
diff -u src/sys/dev/pci/pucdata.c:1.99.8.3 src/sys/dev/pci/pucdata.c:1.99.8.4
--- src/sys/dev/pci/pucdata.c:1.99.8.3	Thu Jun  7 18:12:17 2018
+++ src/sys/dev/pci/pucdata.c	Sun May  5 08:20:08 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pucdata.c,v 1.99.8.3 2018/06/07 18:12:17 martin Exp $	*/
+/*	$NetBSD: pucdata.c,v 1.99.8.4 2019/05/05 08:20:08 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.99.8.3 2018/06/07 18:12:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pucdata.c,v 1.99.8.4 2019/05/05 08:20:08 martin Exp $");
 
 #include 
 #include 
@@ -999,6 +999,23 @@ const struct puc_device_description puc_
 	},
 	},
 
+	/* NetMos PCIe NM9912 */
+	{ "NetMos NM9912 Dual PCI-E UART and 1284 Printer Port",
+	{   PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9912, 0, 0x1000 },
+	{   0x, 0x, 0, 0x },
+	{
+		{ PUC_PORT_TYPE_COM, 0x10, 0x, 0 },
+	},
+	},
+
+	{ "NetMos NM9912 Dual PCI-E UART and 1284 Printer Port",
+	{   PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9912, 0, 0x2000 },
+	{   0x, 0x, 0, 0x },
+	{
+		{ PUC_PORT_TYPE_LPT, 0x10, 0x, 0 },
+	},
+	},
+
 	/* NetMos PCIe NM9922 (PCI multi function): 2S */
 	{   "NetMos NM9922 UART",
 	{   PCI_VENDOR_NETMOS, PCI_PRODUCT_NETMOS_NM9922, 0, 0 },



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

2019-05-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed May  1 09:04:24 UTC 2019

Added Files:
src/sys/dev [netbsd-8]: veriexec.config

Log Message:
Pull up following revision(s) via patch, as options differ between
current and this branch (requested by sevan in ticket #1251):

sys/dev/veriexec.config: revision 1.1

Add a configuration file for enabling Veriexec in kernel config(5) files.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.2.2 src/sys/dev/veriexec.config

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

Added files:

Index: src/sys/dev/veriexec.config
diff -u /dev/null src/sys/dev/veriexec.config:1.1.2.2
--- /dev/null	Wed May  1 09:04:24 2019
+++ src/sys/dev/veriexec.config	Wed May  1 09:04:24 2019
@@ -0,0 +1,21 @@
+# $NetBSD: veriexec.config,v 1.1.2.2 2019/05/01 09:04:24 martin Exp $
+#
+# This file contains all Veriexec related configuration.
+# It is suitable for inclusion in a kernel config(5) file.
+#
+
+options 	FILEASSOC		# fileassoc(9) - needed by Veriexec
+	# and PAX_SEGVGUARD
+
+# a pseudo device needed for veriexec
+pseudo-device	veriexec
+#
+# Note that removing fingerprint methods will have almost no impact on the
+# kernel code size.
+#
+options VERIFIED_EXEC_FP_MD5
+options VERIFIED_EXEC_FP_RMD160
+options VERIFIED_EXEC_FP_SHA1
+options VERIFIED_EXEC_FP_SHA256
+options VERIFIED_EXEC_FP_SHA384
+options VERIFIED_EXEC_FP_SHA512



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

2019-04-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Apr 26 19:04:19 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: mfii.c

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

sys/dev/pci/mfii.c: revision 1.4

Clean up timeout logic. Now the system survives to a ccb timeout; before
the filesystem would stall because one I/O did never completes.


To generate a diff of this commit:
cvs rdiff -u -r1.3.2.3 -r1.3.2.4 src/sys/dev/pci/mfii.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/mfii.c
diff -u src/sys/dev/pci/mfii.c:1.3.2.3 src/sys/dev/pci/mfii.c:1.3.2.4
--- src/sys/dev/pci/mfii.c:1.3.2.3	Sat Dec  8 12:17:13 2018
+++ src/sys/dev/pci/mfii.c	Fri Apr 26 19:04:19 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.3.2.3 2018/12/08 12:17:13 martin Exp $ */
+/* $NetBSD: mfii.c,v 1.3.2.4 2019/04/26 19:04:19 martin Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.3.2.3 2018/12/08 12:17:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.3.2.4 2019/04/26 19:04:19 martin Exp $");
 
 #include "bio.h"
 
@@ -264,7 +264,6 @@ struct mfii_ccb {
 	u_int32_t		ccb_flags;
 #define MFI_CCB_F_ERR			(1<<0)
 	u_int			ccb_smid;
-	u_int			ccb_refcnt;
 	SIMPLEQ_ENTRY(mfii_ccb)	ccb_link;
 };
 SIMPLEQ_HEAD(mfii_ccb_list, mfii_ccb);
@@ -2159,7 +2158,6 @@ mfii_scsipi_request(struct scsipi_channe
 		return;
 	}
 
-	ccb->ccb_refcnt = 2; /* one for the chip, one for the timeout */
 	mfii_start(sc, ccb);
 
 	return;
@@ -2176,10 +2174,9 @@ mfii_scsi_cmd_done(struct mfii_softc *sc
 	struct scsipi_xfer *xs = ccb->ccb_cookie;
 	struct mpii_msg_scsi_io *io = ccb->ccb_request;
 	struct mfii_raid_context *ctx = (struct mfii_raid_context *)(io + 1);
-	u_int refs = 2;
 
 	if (callout_stop(>xs_callout) != 0)
-		refs = 1;
+		return;
 
 	switch (ctx->status) {
 	case MFI_STAT_OK:
@@ -2201,10 +2198,8 @@ mfii_scsi_cmd_done(struct mfii_softc *sc
 		break;
 	}
 
-	if (atomic_add_int_nv(>ccb_refcnt, -refs) == 0) {
-		scsipi_done(xs);
-		mfii_put_ccb(sc, ccb);
-	}
+	scsipi_done(xs);
+	mfii_put_ccb(sc, ccb);
 }
 
 int
@@ -2343,7 +2338,6 @@ mfii_pd_scsi_cmd(struct scsipi_xfer *xs)
 		return;
 	}
 
-	ccb->ccb_refcnt = 2; /* one for the chip, one for the timeout */
 	// XXX timeout_add_msec(>stimeout, xs->timeout);
 	mfii_start(sc, ccb);
 
@@ -2543,10 +2537,9 @@ mfii_abort_task(struct work *wk, void *s
 
 		if (!sc->sc_ld[periph->periph_target].ld_present) {
 			/* device is gone */
-			if (atomic_dec_uint_nv(>ccb_refcnt) == 0) {
-scsipi_done(xs);
-mfii_put_ccb(sc, ccb);
-			}
+			xs->error = XS_SELTIMEOUT;
+			scsipi_done(xs);
+			mfii_put_ccb(sc, ccb);
 			continue;
 		}
 
@@ -2591,12 +2584,11 @@ mfii_scsi_cmd_abort_done(struct mfii_sof
 	/* XXX check accb completion? */
 
 	mfii_put_ccb(sc, accb);
+	printf("%s: cmd aborted ccb %p\n", DEVNAME(sc), ccb);
 
-	if (atomic_dec_uint_nv(>ccb_refcnt) == 0) {
-		xs->error = XS_TIMEOUT;
-		scsipi_done(xs);
-		mfii_put_ccb(sc, ccb);
-	}
+	xs->error = XS_TIMEOUT;
+	scsipi_done(xs);
+	mfii_put_ccb(sc, ccb);
 }
 
 struct mfii_ccb *
@@ -2627,8 +2619,6 @@ mfii_scrub_ccb(struct mfii_ccb *ccb)
 	ccb->ccb_dma64 = false;
 	ccb->ccb_len = 0;
 	ccb->ccb_sgl_len = 0;
-	ccb->ccb_refcnt = 1;
-
 	memset(>ccb_req, 0, sizeof(ccb->ccb_req));
 	memset(ccb->ccb_request, 0, MFII_REQUEST_SIZE);
 	memset(ccb->ccb_mfi, 0, MFI_FRAME_SIZE);



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

2019-04-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 22 08:17:50 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: ucom.c umodem_common.c umodemvar.h

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

sys/dev/usb/umodem_common.c: revision 1.27
sys/dev/usb/umodemvar.h: revision 1.10
sys/dev/usb/ucom.c: revision 1.122

fix umodem(4) detach:

- ucom(4) needs kpreempt disabled around softint_schedule()
- switch a copied printf() to aprint_error_dev()
- use static normally in umodem_common.c
- remove unused sc_openings in softc, convert sc_dying to real bool
- add sc_refcnt, sc_lock and sc_detach_cv to softc.  usage is:
  - sc_dying is protected by sc_lock
  - sc_detach_cv is matched with sc_lock for cv operations
  - sc_refcnt is increased in open and decreased in close, any time
it is decreased, it is checked for less than zero, and a broadcast
performed on sc_detach_cv.  detach waits for sc_refcnt.
- umodem_param() and umodem_set() check for sc_dying

this fixes pullout out an open ucom@umodem.

@skrll.

XXX: pullup


To generate a diff of this commit:
cvs rdiff -u -r1.118.8.2 -r1.118.8.3 src/sys/dev/usb/ucom.c
cvs rdiff -u -r1.25 -r1.25.8.1 src/sys/dev/usb/umodem_common.c
cvs rdiff -u -r1.9 -r1.9.10.1 src/sys/dev/usb/umodemvar.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/ucom.c
diff -u src/sys/dev/usb/ucom.c:1.118.8.2 src/sys/dev/usb/ucom.c:1.118.8.3
--- src/sys/dev/usb/ucom.c:1.118.8.2	Wed Jan 31 18:01:54 2018
+++ src/sys/dev/usb/ucom.c	Mon Apr 22 08:17:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucom.c,v 1.118.8.2 2018/01/31 18:01:54 martin Exp $	*/
+/*	$NetBSD: ucom.c,v 1.118.8.3 2019/04/22 08:17:50 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.2 2018/01/31 18:01:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucom.c,v 1.118.8.3 2019/04/22 08:17:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -441,10 +441,8 @@ ucom_detach(device_t self, int flags)
 			mutex_spin_exit(_lock);
 		}
 		/* Wait for processes to go away. */
-		if (cv_timedwait(>sc_detachcv, >sc_lock, hz * 60)) {
-			printf("%s: %s didn't detach\n", __func__,
-			device_xname(sc->sc_dev));
-		}
+		if (cv_timedwait(>sc_detachcv, >sc_lock, hz * 60))
+			aprint_error_dev(self, ": didn't detach\n");
 	}
 
 	softint_disestablish(sc->sc_si);
@@ -1271,7 +1269,9 @@ ucomhwiflow(struct tty *tp, int block)
 
 	if (old && !block) {
 		sc->sc_rx_unblock = 1;
+		kpreempt_disable();
 		softint_schedule(sc->sc_si);
+		kpreempt_enable();
 	}
 	mutex_exit(>sc_lock);
 
@@ -1339,7 +1339,9 @@ ucomstart(struct tty *tp)
 
 	SIMPLEQ_INSERT_TAIL(>sc_obuff_full, ub, ub_link);
 
+	kpreempt_disable();
 	softint_schedule(sc->sc_si);
+	kpreempt_enable();
 
  out:
 	DPRINTF("... done", 0, 0, 0, 0);
@@ -1381,7 +1383,9 @@ ucom_write_status(struct ucom_softc *sc,
 		break;
 	case USBD_STALLED:
 		ub->ub_index = 0;
+		kpreempt_disable();
 		softint_schedule(sc->sc_si);
+		kpreempt_enable();
 		break;
 	case USBD_NORMAL_COMPLETION:
 		usbd_get_xfer_status(ub->ub_xfer, NULL, NULL, , NULL);

Index: src/sys/dev/usb/umodem_common.c
diff -u src/sys/dev/usb/umodem_common.c:1.25 src/sys/dev/usb/umodem_common.c:1.25.8.1
--- src/sys/dev/usb/umodem_common.c:1.25	Fri Nov 25 12:56:29 2016
+++ src/sys/dev/usb/umodem_common.c	Mon Apr 22 08:17:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: umodem_common.c,v 1.25 2016/11/25 12:56:29 skrll Exp $	*/
+/*	$NetBSD: umodem_common.c,v 1.25.8.1 2019/04/22 08:17:50 martin Exp $	*/
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.25 2016/11/25 12:56:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umodem_common.c,v 1.25.8.1 2019/04/22 08:17:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -94,16 +94,16 @@ int	umodemdebug = 0;
 #define UMODEMIBUFSIZE 4096
 #define UMODEMOBUFSIZE 4096
 
-Static usbd_status umodem_set_comm_feature(struct umodem_softc *,
+static usbd_status umodem_set_comm_feature(struct umodem_softc *,
 	   int, int);
-Static usbd_status umodem_set_line_coding(struct umodem_softc *,
+static usbd_status umodem_set_line_coding(struct umodem_softc *,
 	  usb_cdc_line_state_t *);
 
-Static void	umodem_dtr(struct umodem_softc *, int);
-Static void	umodem_rts(struct umodem_softc *, int);
-Static void	umodem_break(struct umodem_softc *, int);
-Static void	umodem_set_line_state(struct umodem_softc *);
-Static void	umodem_intr(struct usbd_xfer *, void *, usbd_status);
+static void	umodem_dtr(struct umodem_softc *, int);
+static void	umodem_rts(struct umodem_softc *, int);
+static void	umodem_break(struct umodem_softc *, int);
+static void	umodem_set_line_state(struct umodem_softc *);
+static void	umodem_intr(struct 

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

2019-04-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  7 13:46:39 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: if_bge.c

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

sys/dev/pci/if_bge.c: revision 1.328

Fix ASIC check, BGE_ASICREV(sc->bge_chipid) is not a chipid.

Fixes bogus input error reporting in stat. This is cosmetic, exept for
routed(8) which thinks that the interface is broken and stops accepting routes
from it.


To generate a diff of this commit:
cvs rdiff -u -r1.310.2.5 -r1.310.2.6 src/sys/dev/pci/if_bge.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_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.310.2.5 src/sys/dev/pci/if_bge.c:1.310.2.6
--- src/sys/dev/pci/if_bge.c:1.310.2.5	Thu Mar  7 17:38:59 2019
+++ src/sys/dev/pci/if_bge.c	Sun Apr  7 13:46:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.310.2.5 2019/03/07 17:38:59 martin Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.310.2.6 2019/04/07 13:46:39 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.5 2019/03/07 17:38:59 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.6 2019/04/07 13:46:39 martin Exp $");
 
 #include 
 #include 
@@ -4769,8 +4769,8 @@ bge_stats_update_regs(struct bge_softc *
 	 * ignore the counter
 	 */
 	if (BGE_ASICREV(sc->bge_chipid) != BGE_ASICREV_BCM5717 &&
-	BGE_ASICREV(sc->bge_chipid) != BGE_CHIPID_BCM5719_A0 &&
-	BGE_ASICREV(sc->bge_chipid) != BGE_CHIPID_BCM5720_A0) {
+	sc->bge_chipid != BGE_CHIPID_BCM5719_A0 &&
+	sc->bge_chipid != BGE_CHIPID_BCM5720_A0) {
 		ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_DROPS);
 	}
 	ifp->if_ierrors += CSR_READ_4(sc, BGE_RXLP_LOCSTAT_IFIN_ERRORS);



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

2019-04-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr  7 10:55:24 UTC 2019

Modified Files:
src/sys/dev/ic [netbsd-8]: msm6242b.c

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

sys/dev/ic/msm6242b.c: revision 1.4

Remove misplaced semicolon, found by GCC 6.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.3.22.1 src/sys/dev/ic/msm6242b.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/msm6242b.c
diff -u src/sys/dev/ic/msm6242b.c:1.3 src/sys/dev/ic/msm6242b.c:1.3.22.1
--- src/sys/dev/ic/msm6242b.c:1.3	Wed Dec  4 07:48:59 2013
+++ src/sys/dev/ic/msm6242b.c	Sun Apr  7 10:55:24 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: msm6242b.c,v 1.3 2013/12/04 07:48:59 rkujawa Exp $ */
+/*  $NetBSD: msm6242b.c,v 1.3.22.1 2019/04/07 10:55:24 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msm6242b.c,v 1.3 2013/12/04 07:48:59 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msm6242b.c,v 1.3.22.1 2019/04/07 10:55:24 martin Exp $");
 
 /* 
  * Driver for OKI MSM6242B Real Time Clock. Somewhat based on an ancient, amiga
@@ -123,7 +123,7 @@ msm6242b_gettime_ymdhms(todr_chip_handle
 		MSM6242B_PMAM_BIT) == 0 && dt->dt_hour == 12)
 			dt->dt_hour = 0;
 		else if ((msm6242b_read(sc, MSM6242B_10HOUR_PMAM) & 
-		MSM6242B_PMAM_BIT) && dt->dt_hour != 12);
+		MSM6242B_PMAM_BIT) && dt->dt_hour != 12)
 			dt->dt_hour += 12;
 	}
 



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

2019-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  1 12:35:38 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ixgbe.c ixgbe_type.h ixv.c

Log Message:
Pull up the following, requested by msaitohin ticket #1225:

sys/dev/pci/ixgbe/ixgbe.c   1.175-1.178
sys/dev/pci/ixgbe/ixv.c 1.110-1.111 via patch

- NetBSD currently uses traffic class 0 only. Other traffic classes
  aren't used yet. When IXGBE_TC_COUNTER_NUM is set to lower than
  IXGBE_DCB_MAX_TRAFFIC_CLASS (e.g. 1), other traffic classes' counters
  are not used. It means we don't generate evcnt for them and don't
  add the values in ixgbe_update_stats_counters().
- It's not required to calculate unused queues' statistics.
- Fix a bug that the VLAN HW tagging function is not correctly disabled
  when all vlan is detached.
- Fix a bug that VLAN HW tagging function is not correctly controlled
  on 82598.
- Control VLAN HW filter function correctly. Note that currently
  VLAN HW filter function doesn't work because NetBSD doesn't support
  it yet.
- Don't clear IXGBE_VLNCTRL_CFIEN bit When ETHERCAP_VLAN_HWFILTER is
  set. I think it's not required (and Linux doesn't do it). This change
  has no effect to NetBSD because ETHERCAP_VLAN_HWFILTER is not
  supported yet.


To generate a diff of this commit:
cvs rdiff -u -r1.88.2.28 -r1.88.2.29 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.22.2.7 -r1.22.2.8 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.56.2.20 -r1.56.2.21 src/sys/dev/pci/ixgbe/ixv.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/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.28 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.29
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.28	Fri Mar  1 17:33:24 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Apr  1 12:35:38 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.28 2019/03/01 17:33:24 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.29 2019/04/01 12:35:38 martin Exp $ */
 
 /**
 
@@ -1558,8 +1558,8 @@ ixgbe_update_stats_counters(struct adapt
 		}
 	}
 
-	/* 8 registers */
-	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+	/* 8 registers exist */
+	for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
 		uint32_t mp;
 
 		/* MPC */
@@ -1739,7 +1739,7 @@ ixgbe_add_hw_stats(struct adapter *adapt
 
 	/* Max number of traffic class is 8 */
 	KASSERT(IXGBE_DCB_MAX_TRAFFIC_CLASS == 8);
-	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+	for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
 		snprintf(adapter->tcs[i].evnamebuf,
 		sizeof(adapter->tcs[i].evnamebuf), "%s tc%d",
 		xname, i);
@@ -2038,7 +2038,7 @@ ixgbe_clear_evcnt(struct adapter *adapte
 	adapter->msf_sicount.ev_count = 0;
 	adapter->phy_sicount.ev_count = 0;
 
-	for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
+	for (i = 0; i < IXGBE_TC_COUNTER_NUM; i++) {
 		if (i < __arraycount(stats->mpc)) {
 			stats->mpc[i].ev_count = 0;
 			if (hw->mac.type == ixgbe_mac_82598EB)
@@ -2310,33 +2310,34 @@ ixgbe_setup_vlan_hw_support(struct adapt
 	struct rx_ring	*rxr;
 	int i;
 	u32		ctrl;
-
+	bool		hwtagging;
 
 	/*
-	 * We get here thru init_locked, meaning
-	 * a soft reset, this has already cleared
-	 * the VFTA and other state, so if there
-	 * have been no vlan's registered do nothing.
+	 *  This function is called from both if_init and ifflags_cb()
+	 * on NetBSD.
 	 */
-	if (!VLAN_ATTACHED(>osdep.ec))
-		return;
+
+	/* Enable HW tagging only if any vlan is attached */
+	hwtagging = (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING)
+	&& VLAN_ATTACHED(ec);
 
 	/* Setup the queues for vlans */
-	if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) {
-		for (i = 0; i < adapter->num_queues; i++) {
-			rxr = >rx_rings[i];
-			/* On 82599 the VLAN enable is per/queue in RXDCTL */
-			if (hw->mac.type != ixgbe_mac_82598EB) {
-ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+	for (i = 0; i < adapter->num_queues; i++) {
+		rxr = >rx_rings[i];
+		/*
+		 * On 82599 and later, the VLAN enable is per/queue in RXDCTL.
+		 */
+		if (hw->mac.type != ixgbe_mac_82598EB) {
+			ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+			if (hwtagging)
 ctrl |= IXGBE_RXDCTL_VME;
-IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
-			}
-			rxr->vtag_strip = TRUE;
+			else
+ctrl &= ~IXGBE_RXDCTL_VME;
+			IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
 		}
+		rxr->vtag_strip = hwtagging ? TRUE : FALSE;
 	}
 
-	if ((ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) == 0)
-		return;
 	/*
 	 * A soft reset zero's out the VFTA, so
 	 * we need to repopulate it now.
@@ -2348,12 +2349,17 @@ ixgbe_setup_vlan_hw_support(struct adapt
 
 	ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
 	/* Enable the Filter Table if enabled */
-	if (ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) {
-		ctrl &= ~IXGBE_VLNCTRL_CFIEN;
+	if 

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

2019-03-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 29 19:48:36 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-8]: tlphy.c
src/sys/dev/usb [netbsd-8]: if_aue.c if_url.c

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

sys/dev/mii/tlphy.c: revision 1.65
sys/dev/usb/if_url.c: revision 1.62
sys/dev/usb/if_aue.c: revision 1.148

  mii_phy_add_media() automatically install power handler, but if_media_add()
doesn't. When mii_phy_add_media() isn't used, call pmf_device_register().

 -

  Use pmf(9).

 -

  Use pmf(9).


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.62.20.1 src/sys/dev/mii/tlphy.c
cvs rdiff -u -r1.141.8.2 -r1.141.8.3 src/sys/dev/usb/if_aue.c
cvs rdiff -u -r1.56.8.2 -r1.56.8.3 src/sys/dev/usb/if_url.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/mii/tlphy.c
diff -u src/sys/dev/mii/tlphy.c:1.62 src/sys/dev/mii/tlphy.c:1.62.20.1
--- src/sys/dev/mii/tlphy.c:1.62	Mon Jun 16 16:48:16 2014
+++ src/sys/dev/mii/tlphy.c	Fri Mar 29 19:48:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tlphy.c,v 1.62 2014/06/16 16:48:16 msaitoh Exp $	*/
+/*	$NetBSD: tlphy.c,v 1.62.20.1 2019/03/29 19:48:35 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.62 2014/06/16 16:48:16 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tlphy.c,v 1.62.20.1 2019/03/29 19:48:35 martin Exp $");
 
 #include 
 #include 
@@ -183,12 +183,19 @@ tlphyattach(device_t parent, device_t se
 	if (sc->mii_capabilities & BMSR_MEDIAMASK) {
 		aprint_normal("%s", sep);
 		mii_phy_add_media(sc);
-	} else if ((tsc->sc_tlphycap &
+	} else {
+		if ((tsc->sc_tlphycap &
 		(TLPHY_MEDIA_10_2 | TLPHY_MEDIA_10_5)) == 0)
-		aprint_error("no media present");
-	else if (!pmf_device_register(self, NULL, mii_phy_resume)) {
-		aprint_normal("\n");
-		aprint_error_dev(self, "couldn't establish power handler");
+			aprint_error("no media present");
+		/*
+		 * mii_phy_add_media() automatically install power handler,
+		 * but if_media_add() doesn't. Do it now.
+		 */
+		if (!pmf_device_register(self, NULL, mii_phy_resume)) {
+			aprint_normal("\n");
+			aprint_error_dev(self,
+			"couldn't establish power handler");
+		}
 	}
 	aprint_normal("\n");
 #undef ADD

Index: src/sys/dev/usb/if_aue.c
diff -u src/sys/dev/usb/if_aue.c:1.141.8.2 src/sys/dev/usb/if_aue.c:1.141.8.3
--- src/sys/dev/usb/if_aue.c:1.141.8.2	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_aue.c	Fri Mar 29 19:48:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_aue.c,v 1.141.8.2 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_aue.c,v 1.141.8.3 2019/03/29 19:48:36 martin Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.141.8.2 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.141.8.3 2019/03/29 19:48:36 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -869,6 +869,9 @@ aue_attach(device_t parent, device_t sel
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->aue_udev, sc->aue_dev);
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 }
 
@@ -886,6 +889,8 @@ aue_detach(device_t self, int flags)
 		return 0;
 	}
 
+	pmf_device_deregister(self);
+
 	/*
 	 * XXX Halting callout guarantees no more tick tasks.  What
 	 * guarantees no more stop tasks?  What guarantees no more

Index: src/sys/dev/usb/if_url.c
diff -u src/sys/dev/usb/if_url.c:1.56.8.2 src/sys/dev/usb/if_url.c:1.56.8.3
--- src/sys/dev/usb/if_url.c:1.56.8.2	Wed Aug  8 10:28:35 2018
+++ src/sys/dev/usb/if_url.c	Fri Mar 29 19:48:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_url.c,v 1.56.8.2 2018/08/08 10:28:35 martin Exp $	*/
+/*	$NetBSD: if_url.c,v 1.56.8.3 2019/03/29 19:48:35 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.56.8.2 2018/08/08 10:28:35 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.56.8.3 2019/03/29 19:48:35 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -325,6 +325,9 @@ url_attach(device_t parent, device_t sel
 
 	usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, dev, sc->sc_dev);
 
+	if (!pmf_device_register(self, NULL, NULL))
+		aprint_error_dev(self, "couldn't establish power handler\n");
+
 	return;
 
  bad:
@@ -346,6 +349,8 @@ url_detach(device_t self, int flags)
 	if (!sc->sc_attached)
 		return 0;
 
+	pmf_device_deregister(self);
+
 	/*
 	 * XXX Halting callout guarantees no more tick tasks.  What
 	 * guarantees no more stop tasks?  What guarantees no more



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

2019-03-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar 15 14:50:36 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: mpii.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1217):

sys/dev/pci/mpii.c: revision 1.22

PR/54045

fix mpii to adhere to physio diagnostic invariant that
fully processed data must not post an error:

1) verify expected scspi state via KASSERT() instead of just
setting the variables.
2) set xs->resid only in known good conditions
3) insure setting errors in all error paths and refrain
from clearing xs->resid in error paths.

While there do some cosmectic clean up:
1) extend and relocate some debug output
2) mpii HBAs can also manage non-disk devices like tapes etc,
so log that physical "devices" instead of physical "disks" are
attached or detached.

Tested with NEOSeries FlexStor II and luckily a broken tape drive 8-(

mpii0 at pci1 dev 0 function 0: vendor 1000 product 00ab (rev. 0x01)
mpii0: interrupting at irq 11
mpii0: HBA 9400-8i8e, firmware 3.0.4.0, MPI 2.6
mpii0: physical device inserted in slot 9
mpii0: physical device inserted in slot 13
mpii0: physical device inserted in slot 16
st0 at scsibus0 target 9 lun 0:  tape removable
st0: density code 92, variable blocks, write-enabled
ch0 at scsibus0 target 9 lun 1:  changer removable
ch0: 23 slots, 2 drives, 1 picker, 1 portal
st0: tagged queueing
ch0: tagged queueing
st1 at scsibus0 target 13 lun 0:  tape removable
st1: density code 92, variable blocks, write-enabled
st1: tagged queueing
ses0 at scsibus0 target 16 lun 0:  enclosure
services fixed

Note: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.8.10.4 -r1.8.10.5 src/sys/dev/pci/mpii.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/mpii.c
diff -u src/sys/dev/pci/mpii.c:1.8.10.4 src/sys/dev/pci/mpii.c:1.8.10.5
--- src/sys/dev/pci/mpii.c:1.8.10.4	Mon Jan  7 13:49:39 2019
+++ src/sys/dev/pci/mpii.c	Fri Mar 15 14:50:36 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: mpii.c,v 1.8.10.4 2019/01/07 13:49:39 martin Exp $ */
+/* $NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $ */
 /*	OpenBSD: mpii.c,v 1.115 2012/04/11 13:29:14 naddy Exp 	*/
 /*
  * Copyright (c) 2010 Mike Belopuhov 
@@ -20,7 +20,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.4 2019/01/07 13:49:39 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpii.c,v 1.8.10.5 2019/03/15 14:50:36 martin Exp $");
 
 #include "bio.h"
 
@@ -1920,7 +1920,7 @@ mpii_event_sas(struct mpii_softc *sc, st
 free(dev, M_DEVBUF);
 break;
 			}
-			printf("%s: physical disk inserted in slot %d\n",
+			printf("%s: physical device inserted in slot %d\n",
 			DEVNAME(sc), dev->slot);
 			mutex_exit(>sc_devs_mtx);
 			break;
@@ -1994,7 +1994,7 @@ mpii_event_sas_work(struct work *wq, voi
 }
 
 printf(
-"%s: physical disk removed from slot %d\n",
+"%s: physical device removed from slot %d\n",
 DEVNAME(sc), dev->slot);
 mpii_remove_dev(sc, dev);
 mutex_exit(>sc_devs_mtx);
@@ -3021,8 +3021,8 @@ mpii_scsipi_request(struct scsipi_channe
 		scsipi_done(xs);
 		return;
 	}
-	DNPRINTF(MPII_D_CMD, "%s: ccb_smid: %d xs->xs_control: 0x%x\n",
-	DEVNAME(sc), ccb->ccb_smid, xs->xs_control);
+	DNPRINTF(MPII_D_CMD, "%s: ccb_smid: %d xs->cmd->opcode: 0x%02x xs->xs_control: 0x%x\n",
+	DEVNAME(sc), ccb->ccb_smid, xs->cmd->opcode, xs->xs_control);
 
 	ccb->ccb_cookie = xs;
 	ccb->ccb_done = mpii_scsi_cmd_done;
@@ -3220,13 +3220,14 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
 
 		bus_dmamap_unload(sc->sc_dmat, dmap);
 	}
-
-	xs->error = XS_NOERROR;
-	xs->resid = 0;
-
+	
+	KASSERT(xs->error == XS_NOERROR);
+	KASSERT(xs->resid == xs->datalen);
+	KASSERT(xs->status == SCSI_OK);
+	
 	if (ccb->ccb_rcb == NULL) {
 		/* no scsi error, we're ok so drop out early */
-		xs->status = SCSI_OK;
+		xs->resid = 0;
 		goto done;
 	}
 
@@ -3276,9 +3277,11 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
 	case MPII_IOCSTATUS_SCSI_RECOVERED_ERROR:
 		switch (sie->scsi_status) {
 		case MPII_SCSIIO_STATUS_GOOD:
+			xs->resid = 0;
 			break;
 
 		case MPII_SCSIIO_STATUS_CHECK_COND:
+			xs->resid = 0;
 			xs->error = XS_SENSE;
 			break;
 
@@ -3317,12 +3320,14 @@ mpii_scsi_cmd_done(struct mpii_ccb *ccb)
 	if (sie->scsi_state & MPII_SCSIIO_STATE_AUTOSENSE_VALID)
 		memcpy(>sense, sense, sizeof(xs->sense));
 
-	DNPRINTF(MPII_D_CMD, "%s:  xs err: %d status: %#x\n", DEVNAME(sc),
-	xs->error, xs->status);
-
 	mpii_push_reply(sc, ccb->ccb_rcb);
-done:
+
+ done:
 	mpii_put_ccb(sc, ccb);
+
+	DNPRINTF(MPII_D_CMD, "%s: xs err: %d status: %#x len: %d resid: %d\n",
+		 DEVNAME(sc), xs->error, xs->status, xs->datalen, xs->resid);
+
 	scsipi_done(xs);
 }
 



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

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:38:59 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: if_bge.c if_bgereg.h

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

sys/dev/pci/if_bge.c1.323-1.327
sys/dev/pci/if_bgereg.h 1.95
sys/dev/mii/brgphy.c1.80
share/man/man4/bge.41.16

- Add BCM5717's another device ID support.
- Add BCM5702FE, another BCM5704S and SysKonnect SK-9Mxx support.
- Add support for BCM5762 ASIC devices.
- Add BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787.
- Simplify PCI device table.
- Add /* FALLTHROUGH */


To generate a diff of this commit:
cvs rdiff -u -r1.310.2.4 -r1.310.2.5 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.93.4.1 -r1.93.4.2 src/sys/dev/pci/if_bgereg.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_bge.c
diff -u src/sys/dev/pci/if_bge.c:1.310.2.4 src/sys/dev/pci/if_bge.c:1.310.2.5
--- src/sys/dev/pci/if_bge.c:1.310.2.4	Sat Dec  8 12:10:22 2018
+++ src/sys/dev/pci/if_bge.c	Thu Mar  7 17:38:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.310.2.4 2018/12/08 12:10:22 martin Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.310.2.5 2019/03/07 17:38:59 martin Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.4 2018/12/08 12:10:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.310.2.5 2019/03/07 17:38:59 martin Exp $");
 
 #include 
 #include 
@@ -297,371 +297,116 @@ void		bge_debug_info(struct bge_softc *)
 #define	BGE_EVCNT_UPD(ev, val)	/* nothing */
 #endif
 
+#define VIDDID(a, b) PCI_VENDOR_ ## a, PCI_PRODUCT_ ## a ## _ ## b
+/*
+ * The BCM5700 documentation seems to indicate that the hardware still has the
+ * Alteon vendor ID burned into it, though it should always be overridden by
+ * the value in the EEPROM.  We'll check for it anyway.
+ */
 static const struct bge_product {
 	pci_vendor_id_t		bp_vendor;
 	pci_product_id_t	bp_product;
 	const char		*bp_name;
 } bge_products[] = {
-	/*
-	 * The BCM5700 documentation seems to indicate that the hardware
-	 * still has the Alteon vendor ID burned into it, though it
-	 * should always be overridden by the value in the EEPROM.  We'll
-	 * check for it anyway.
-	 */
-	{ PCI_VENDOR_ALTEON,
-	  PCI_PRODUCT_ALTEON_BCM5700,
-	  "Broadcom BCM5700 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_ALTEON,
-	  PCI_PRODUCT_ALTEON_BCM5701,
-	  "Broadcom BCM5701 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_ALTIMA,
-	  PCI_PRODUCT_ALTIMA_AC1000,
-	  "Altima AC1000 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_ALTIMA,
-	  PCI_PRODUCT_ALTIMA_AC1001,
-	  "Altima AC1001 Gigabit Ethernet",
-	   },
-	{ PCI_VENDOR_ALTIMA,
-	  PCI_PRODUCT_ALTIMA_AC1003,
-	  "Altima AC1003 Gigabit Ethernet",
-	   },
-	{ PCI_VENDOR_ALTIMA,
-	  PCI_PRODUCT_ALTIMA_AC9100,
-	  "Altima AC9100 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_APPLE,
-	  PCI_PRODUCT_APPLE_BCM5701,
-	  "APPLE BCM5701 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5700,
-	  "Broadcom BCM5700 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5701,
-	  "Broadcom BCM5701 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5702,
-	  "Broadcom BCM5702 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5702X,
-	  "Broadcom BCM5702X Gigabit Ethernet" },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5703,
-	  "Broadcom BCM5703 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5703X,
-	  "Broadcom BCM5703X Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5703_ALT,
-	  "Broadcom BCM5703 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5704C,
-	  "Broadcom BCM5704C Dual Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5704S,
-	  "Broadcom BCM5704S Dual Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5705,
-	  "Broadcom BCM5705 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5705F,
-	  "Broadcom BCM5705F Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5705K,
-	  "Broadcom BCM5705K Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5705M,
-	  "Broadcom BCM5705M Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5705M_ALT,
-	  "Broadcom BCM5705M Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5714,
-	  "Broadcom BCM5714 Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5714S,
-	  "Broadcom BCM5714S Gigabit Ethernet",
-	  },
-	{ PCI_VENDOR_BROADCOM,
-	  PCI_PRODUCT_BROADCOM_BCM5715,
-	  "Broadcom BCM5715 

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

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:17:09 UTC 2019

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

Log Message:
Regen for ticket #1207


To generate a diff of this commit:
cvs rdiff -u -r1.128.6.4 -r1.128.6.5 src/sys/dev/mii/miidevs.h
cvs rdiff -u -r1.116.6.4 -r1.116.6.5 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.128.6.4 src/sys/dev/mii/miidevs.h:1.128.6.5
--- src/sys/dev/mii/miidevs.h:1.128.6.4	Thu Jan 17 17:23:36 2019
+++ src/sys/dev/mii/miidevs.h	Thu Mar  7 17:17:09 2019
@@ -1,10 +1,10 @@
-/*	$NetBSD: miidevs.h,v 1.128.6.4 2019/01/17 17:23:36 martin Exp $	*/
+/*	$NetBSD: miidevs.h,v 1.128.6.5 2019/03/07 17:17:09 martin Exp $	*/
 
 /*
  * THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: miidevs,v 1.125.6.4 2019/01/17 17:23:02 martin Exp
+ *	NetBSD: miidevs,v 1.125.6.5 2019/03/07 17:16:40 martin Exp
  */
 
 /*-
@@ -57,16 +57,25 @@
  */
 
 #define	MII_OUI_AMD	0x1a	/* Advanced Micro Devices */
+#define	MII_OUI_VITESSE	0x0001c1	/* Vitesse */
+#define	MII_OUI_TRIDIUM	0x0001f0	/* Tridium */
+#define	MII_OUI_DATATRACK	0x0002c6	/* Data Track Technology */
 #define	MII_OUI_CICADA	0x0003f1	/* Cicada Semiconductor */
 #define	MII_OUI_AGERE	0x00053d	/* Agere */
+#define	MII_OUI_NETAS	0x0009c3	/* Netas */
 #define	MII_OUI_BROADCOM2	0x000af7	/* Broadcom Corporation */
+#define	MII_OUI_RALINK	0x000c43	/* Ralink Technology */
+#define	MII_OUI_ASIX	0x000ec6	/* ASIX */
 #define	MII_OUI_BROADCOM	0x001018	/* Broadcom Corporation */
 #define	MII_OUI_MICREL	0x0010a1	/* Micrel */
 #define	MII_OUI_ALTIMA	0x0010a9	/* Altima Communications */
 #define	MII_OUI_ENABLESEMI	0x0010dd	/* Enable Semiconductor */
+#define	MII_OUI_SUNPLUS	0x001105	/* Sunplus Technology */
 #define	MII_OUI_ATHEROS	0x001374	/* Atheros */
+#define	MII_OUI_RALINK2	0x0017a5	/* Ralink Technology */
 #define	MII_OUI_BROADCOM3	0x001be9	/* Broadcom Corporation */
 #define	MII_OUI_LEVEL1	0x00207b	/* Level 1 */
+#define	MII_OUI_VIA	0x004063	/* VIA Technologies */
 #define	MII_OUI_MARVELL	0x005043	/* Marvell Semiconductor */
 #define	MII_OUI_QUALSEMI	0x006051	/* Quality Semiconductor */
 #define	MII_OUI_DAVICOM	0x00606e	/* Davicom Semiconductor */
@@ -83,9 +92,11 @@
 #define	MII_OUI_PMCSIERRA	0x00e004	/* PMC-Sierra */
 #define	MII_OUI_SIS	0x00e006	/* Silicon Integrated Systems */
 #define	MII_OUI_REALTEK	0x00e04c	/* RealTek */
+#define	MII_OUI_ADMTEK	0x00e092	/* ADMtek */
 #define	MII_OUI_XAQTI	0x00e0ae	/* XaQti Corp. */
 #define	MII_OUI_NATSEMI	0x080017	/* National Semiconductor */
 #define	MII_OUI_TI	0x080028	/* Texas Instruments */
+#define	MII_OUI_BROADCOM4	0x18c086	/* Broadcom Corporation */
 
 /* Some Intel 82553's use an alternative OUI. */
 #define	MII_OUI_xxINTEL	0x001f00	/* Intel */
@@ -130,6 +141,20 @@
 #define	MII_MODEL_xxASIX_AX88X9X	0x0031
 #define	MII_STR_xxASIX_AX88X9X	"Ax88x9x internal PHY"
 
+/* Altima Communications PHYs */
+/* Don't know the model for ACXXX */
+#define	MII_MODEL_ALTIMA_ACXXX	0x0001
+#define	MII_STR_ALTIMA_ACXXX	"ACXXX 10/100 media interface"
+#define	MII_MODEL_ALTIMA_AC101L	0x0012
+#define	MII_STR_ALTIMA_AC101L	"AC101L 10/100 media interface"
+#define	MII_MODEL_ALTIMA_AC101	0x0021
+#define	MII_STR_ALTIMA_AC101	"AC101 10/100 media interface"
+/* AMD Am79C87[45] have ALTIMA OUI */
+#define	MII_MODEL_ALTIMA_Am79C875	0x0014
+#define	MII_STR_ALTIMA_Am79C875	"Am79C875 10/100 media interface"
+#define	MII_MODEL_ALTIMA_Am79C874	0x0021
+#define	MII_STR_ALTIMA_Am79C874	"Am79C874 10/100 media interface"
+
 /* Atheros PHYs */
 #define	MII_MODEL_ATHEROS_F1	0x0001
 #define	MII_STR_ATHEROS_F1	"F1 10/100/1000 PHY"
@@ -146,20 +171,6 @@
 #define	MII_MODEL_ATTANSIC_AR8035	0x0007
 #define	MII_STR_ATTANSIC_AR8035	"Atheros AR8035 10/100/1000 PHY"
 
-/* Altima Communications PHYs */
-/* Don't know the model for ACXXX */
-#define	MII_MODEL_ALTIMA_ACXXX	0x0001
-#define	MII_STR_ALTIMA_ACXXX	"ACXXX 10/100 media interface"
-#define	MII_MODEL_ALTIMA_AC101	0x0021
-#define	MII_STR_ALTIMA_AC101	"AC101 10/100 media interface"
-#define	MII_MODEL_ALTIMA_AC101L	0x0012
-#define	MII_STR_ALTIMA_AC101L	"AC101L 10/100 media interface"
-/* AMD Am79C87[45] have ALTIMA OUI */
-#define	MII_MODEL_ALTIMA_Am79C875	0x0014
-#define	MII_STR_ALTIMA_Am79C875	"Am79C875 10/100 media interface"
-#define	MII_MODEL_ALTIMA_Am79C874	0x0021
-#define	MII_STR_ALTIMA_Am79C874	"Am79C874 10/100 media interface"
-
 /* Advanced Micro Devices PHYs */
 /* see Davicom DM9101 for Am79C873 */
 #define	MII_MODEL_yyAMD_79C972_10T	0x0001
@@ -176,12 +187,12 @@
 #define	MII_STR_xxBROADCOM_3C905B	"Broadcom 3c905B internal PHY"
 #define	MII_MODEL_xxBROADCOM_3C905C	0x0017
 #define	MII_STR_xxBROADCOM_3C905C	"Broadcom 3c905C internal PHY"
+#define	MII_MODEL_xxBROADCOM_BCM5221	0x001e
+#define	MII_STR_xxBROADCOM_BCM5221	

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

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:16:40 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-8]: miidevs

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

sys/dev/mii/miidevs: revision 1.140
sys/dev/mii/miidevs: revision 1.141
sys/dev/mii/miidevs: revision 1.142
sys/dev/mii/miidevs: revision 1.143
sys/dev/mii/miidevs: revision 1.144
sys/dev/mii/miidevs: revision 1.133
sys/dev/mii/miidevs: revision 1.134
sys/dev/mii/miidevs: revision 1.135
sys/dev/mii/miidevs: revision 1.136
sys/dev/mii/miidevs: revision 1.137
sys/dev/mii/miidevs: revision 1.138
sys/dev/mii/miidevs: revision 1.139

- Add Marvell 88E1240.
- Marvell model 0x0029 is not 88E1116R but E1318S.

Add RTL8201E from OpenBSD.

 From OpenBSD:
  - Add ASIX OUI.
  - Add VIA OUI and devices.
  - Add Vitesse OUI and devices.
 From FreeBSD:
  - Add BROADCOM4.

- Add Tridium, Data Track Technology, Netas, Ralink Technology,
   Sunplus Technology and ADMtek's OUI.

- Sort by OUI.
  Sort by model number.

 From FreeBSD:
  - Add Broadcom BCM540[24], BCM5424, BCM5466 and BCM54[78]8.
  - Add ICS1893C.
  - Add Micrel KSZ8081 and KSZ9031.

- Sort by model number.

- Add missing white space.

  Change CS8244's OUI from xxCICADA to CICADA. I don't know whether this
change is correct or not...
  Sort in alphabetical order a bit.
  Add non-xx'ed DAVICOM DM9101.

- Add SMSC LAN83C185 10/100 PHY from OpenBSD
- Add SMSC LAN8740 10/100 media interface
  Add SMSC(now Microchip) LAN8741A and LAN8742


To generate a diff of this commit:
cvs rdiff -u -r1.125.6.4 -r1.125.6.5 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/miidevs
diff -u src/sys/dev/mii/miidevs:1.125.6.4 src/sys/dev/mii/miidevs:1.125.6.5
--- src/sys/dev/mii/miidevs:1.125.6.4	Thu Jan 17 17:23:02 2019
+++ src/sys/dev/mii/miidevs	Thu Mar  7 17:16:40 2019
@@ -1,4 +1,4 @@
-$NetBSD: miidevs,v 1.125.6.4 2019/01/17 17:23:02 martin Exp $
+$NetBSD: miidevs,v 1.125.6.5 2019/03/07 17:16:40 martin Exp $
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -50,16 +50,25 @@ $NetBSD: miidevs,v 1.125.6.4 2019/01/17 
  */
 
 oui AMD0x1a	Advanced Micro Devices
+oui VITESSE			0x0001c1	Vitesse
+oui TRIDIUM			0x0001f0	Tridium
+oui DATATRACK			0x0002c6	Data Track Technology
 oui CICADA			0x0003f1	Cicada Semiconductor
 oui AGERE			0x00053d	Agere
+oui NETAS			0x0009c3	Netas
 oui BROADCOM2			0x000af7	Broadcom Corporation
+oui RALINK			0x000c43	Ralink Technology
+oui ASIX			0x000ec6	ASIX
 oui BROADCOM			0x001018	Broadcom Corporation
 oui MICREL			0x0010a1	Micrel
 oui ALTIMA			0x0010a9	Altima Communications
 oui ENABLESEMI			0x0010dd	Enable Semiconductor
+oui SUNPLUS			0x001105	Sunplus Technology
 oui ATHEROS			0x001374	Atheros
+oui RALINK2			0x0017a5	Ralink Technology
 oui BROADCOM3			0x001be9	Broadcom Corporation
 oui LEVEL1			0x00207b	Level 1
+oui VIA0x004063	VIA Technologies
 oui MARVELL			0x005043	Marvell Semiconductor
 oui QUALSEMI			0x006051	Quality Semiconductor
 oui DAVICOM			0x00606e	Davicom Semiconductor
@@ -76,9 +85,11 @@ oui JMICRON			0x00d831	JMicron
 oui PMCSIERRA			0x00e004	PMC-Sierra
 oui SIS0x00e006	Silicon Integrated Systems
 oui REALTEK			0x00e04c	RealTek
+oui ADMTEK			0x00e092	ADMtek
 oui XAQTI			0x00e0ae	XaQti Corp.
 oui NATSEMI			0x080017	National Semiconductor
 oui TI0x080028	Texas Instruments
+oui BROADCOM4			0x18c086	Broadcom Corporation
 
 /* Some Intel 82553's use an alternative OUI. */
 oui xxINTEL			0x001f00	Intel
@@ -121,6 +132,15 @@ model AGERE ET1011		0x0004 Agere ET1011 
 /* Asix semiconductor PHYs */
 model xxASIX AX88X9X		0x0031 Ax88x9x internal PHY
 
+/* Altima Communications PHYs */
+/* Don't know the model for ACXXX */
+model ALTIMA ACXXX		0x0001 ACXXX 10/100 media interface
+model ALTIMA AC101L		0x0012 AC101L 10/100 media interface
+model ALTIMA AC101		0x0021 AC101 10/100 media interface
+/* AMD Am79C87[45] have ALTIMA OUI */
+model ALTIMA Am79C875		0x0014 Am79C875 10/100 media interface
+model ALTIMA Am79C874		0x0021 Am79C874 10/100 media interface
+
 /* Atheros PHYs */
 model ATHEROS F1		0x0001 F1 10/100/1000 PHY
 model ATHEROS F2		0x0002 F2 10/100 PHY
@@ -131,15 +151,6 @@ model ATTANSIC L2		0x0002 L2 10/100 PHY
 model ATTANSIC AR8021		0x0004 Atheros AR8021 10/100/1000 PHY
 model ATTANSIC AR8035		0x0007 Atheros AR8035 10/100/1000 PHY
 
-/* Altima Communications PHYs */
-/* Don't know the model for ACXXX */
-model ALTIMA ACXXX		0x0001 ACXXX 10/100 media interface
-model ALTIMA AC101		0x0021 AC101 10/100 media interface
-model ALTIMA AC101L		0x0012 AC101L 10/100 media interface
-/* AMD Am79C87[45] have ALTIMA OUI */
-model ALTIMA Am79C875		0x0014 Am79C875 10/100 media interface
-model ALTIMA Am79C874		0x0021 Am79C874 10/100 media interface
-
 /* Advanced Micro 

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

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:19:38 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-8]: makphy.c

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

sys/dev/mii/makphy.c: revision 1.53

- Add 88E1240.
- Rename E1116R_29 to E1318S


To generate a diff of this commit:
cvs rdiff -u -r1.42.8.1 -r1.42.8.2 src/sys/dev/mii/makphy.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/mii/makphy.c
diff -u src/sys/dev/mii/makphy.c:1.42.8.1 src/sys/dev/mii/makphy.c:1.42.8.2
--- src/sys/dev/mii/makphy.c:1.42.8.1	Thu Jan 17 17:23:02 2019
+++ src/sys/dev/mii/makphy.c	Thu Mar  7 17:19:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: makphy.c,v 1.42.8.1 2019/01/17 17:23:02 martin Exp $	*/
+/*	$NetBSD: makphy.c,v 1.42.8.2 2019/03/07 17:19:38 martin Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.1 2019/01/17 17:23:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.42.8.2 2019/03/07 17:19:38 martin Exp $");
 
 #include 
 #include 
@@ -128,8 +128,8 @@ static const struct mii_phydesc makphys[
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1116R,
 	  MII_STR_xxMARVELL_E1116R },
 
-	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1116R_29,
-	  MII_STR_xxMARVELL_E1116R_29 },
+	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1318S,
+	  MII_STR_xxMARVELL_E1318S },
 
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1118,
 	  MII_STR_xxMARVELL_E1118 },
@@ -143,6 +143,9 @@ static const struct mii_phydesc makphys[
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1149R,
 	  MII_STR_xxMARVELL_E1149R },
 
+	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1240,
+	  MII_STR_xxMARVELL_E1240 },
+
 	{ MII_OUI_xxMARVELL,		MII_MODEL_xxMARVELL_E1512,
 	  MII_STR_xxMARVELL_E1512 },
 



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

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:11:53 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c if_wmreg.h if_wmvar.h

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

sys/dev/pci/if_wmreg.h  1.113
sys/dev/pci/if_wmvar.h  1.43-1.44
sys/dev/pci/if_wm.c 1.626-1.627, 1.629-1.636 via 
patch

- Add support for I210 SGMII Flash-less device.
- Add I219 variations for Cannon Lake.
- Add missing rnd_detach_source().
- Use  do { ... } while (0) for DPRINTF(x, y).
- Swap enumeration of 82578 and 82577 PHY in if_wmvar.h. No functional
  change.
- Add KASSERT.
- Update TODO list. Add comment. Fix typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.30 -r1.508.4.31 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.98.6.7 -r1.98.6.8 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.33.6.4 -r1.33.6.5 src/sys/dev/pci/if_wmvar.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.30 src/sys/dev/pci/if_wm.c:1.508.4.31
--- src/sys/dev/pci/if_wm.c:1.508.4.30	Mon Feb 11 13:44:34 2019
+++ src/sys/dev/pci/if_wm.c	Thu Mar  7 17:11:53 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.30 2019/02/11 13:44:34 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.31 2019/03/07 17:11:53 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -79,11 +79,10 @@
  *	- Virtual Function
  *	- Set LED correctly (based on contents in EEPROM)
  *	- Rework how parameters are loaded from the EEPROM.
- *	- Image Unique ID
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.30 2019/02/11 13:44:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.31 2019/03/07 17:11:53 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -157,7 +156,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.
 int	wm_debug = WM_DEBUG_TX | WM_DEBUG_RX | WM_DEBUG_LINK | WM_DEBUG_GMII
 | WM_DEBUG_MANAGE | WM_DEBUG_NVM | WM_DEBUG_INIT | WM_DEBUG_LOCK;
 
-#define	DPRINTF(x, y)	if (wm_debug & (x)) printf y
+#define	DPRINTF(x, y)	do { if (wm_debug & (x)) printf y; } while (0)
 #else
 #define	DPRINTF(x, y)	__nothing
 #endif /* WM_DEBUG */
@@ -1465,7 +1464,7 @@ static const struct wm_product {
 	  WM_T_I210,		WMP_F_COPPER },
 
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I210_COPPER_WOF,
-	  "I210 Ethernet (FLASH less)",
+	  "I210 Ethernet (Copper, FLASH less)",
 	  WM_T_I210,		WMP_F_COPPER },
 
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I210_FIBER,
@@ -1477,13 +1476,17 @@ static const struct wm_product {
 	  WM_T_I210,		WMP_F_SERDES },
 
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I210_SERDES_WOF,
-	  "I210 Gigabit Ethernet (FLASH less)",
+	  "I210 Gigabit Ethernet (SERDES, FLASH less)",
 	  WM_T_I210,		WMP_F_SERDES },
 
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I210_SGMII,
 	  "I210 Gigabit Ethernet (SGMII)",
 	  WM_T_I210,		WMP_F_COPPER },
 
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I210_SGMII_WOF,
+	  "I210 Gigabit Ethernet (SGMII, FLASH less)",
+	  WM_T_I210,		WMP_F_COPPER },
+
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I211_COPPER,
 	  "I211 Ethernet (COPPER)",
 	  WM_T_I211,		WMP_F_COPPER },
@@ -1511,18 +1514,6 @@ static const struct wm_product {
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I218_LM3,
 	  "I218 LM Ethernet Connection",
 	  WM_T_PCH_LPT,		WMP_F_COPPER },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V,
-	  "I219 V Ethernet Connection",
-	  WM_T_PCH_SPT,		WMP_F_COPPER },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V2,
-	  "I219 V Ethernet Connection",
-	  WM_T_PCH_SPT,		WMP_F_COPPER },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V4,
-	  "I219 V Ethernet Connection",
-	  WM_T_PCH_SPT,		WMP_F_COPPER },
-	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V5,
-	  "I219 V Ethernet Connection",
-	  WM_T_PCH_SPT,		WMP_F_COPPER },
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM,
 	  "I219 LM Ethernet Connection",
 	  WM_T_PCH_SPT,		WMP_F_COPPER },
@@ -1538,17 +1529,41 @@ static const struct wm_product {
 	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM5,
 	  "I219 LM Ethernet Connection",
 	  WM_T_PCH_SPT,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM6,
+	  "I219 LM Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM7,
+	  "I219 LM Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM8,
+	  "I219 LM Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_LM9,
+	  "I219 LM Ethernet Connection",
+	  WM_T_PCH_CNP,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V,
+	  "I219 V Ethernet Connection",
+	  WM_T_PCH_SPT,		WMP_F_COPPER },
+	{ PCI_VENDOR_INTEL,	PCI_PRODUCT_INTEL_I219_V2,
+	  "I219 V Ethernet Connection",
+	  WM_T_PCH_SPT,		WMP_F_COPPER },
+	{ 

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

2019-03-07 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Mar  7 17:03:52 UTC 2019

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

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

sys/dev/pci/pcidevs: revision 1.1363
sys/dev/pci/pcidevs: revision 1.1364
sys/dev/pci/pcidevs: revision 1.1365
sys/dev/pci/pcidevs: revision 1.1366

  Add Tundra (now IDT) TSI381 and PEB383 from OpenBSD.

  Add some Broadcom Ethernet devices from {Open,Free}BSD.

  Add SK-NET SK-9Mxx Gigabit Ethernet.

  Add Intel I219 variations for Cannon Lake.


To generate a diff of this commit:
cvs rdiff -u -r1.1289.2.13 -r1.1289.2.14 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.1289.2.13 src/sys/dev/pci/pcidevs:1.1289.2.14
--- src/sys/dev/pci/pcidevs:1.1289.2.13	Mon Feb 11 13:34:09 2019
+++ src/sys/dev/pci/pcidevs	Thu Mar  7 17:03:52 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1289.2.13 2019/02/11 13:34:09 martin Exp $
+$NetBSD: pcidevs,v 1.1289.2.14 2019/03/07 17:03:52 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1861,6 +1861,12 @@ product BROADCOM BCM5709	0x1639	BCM5709 
 product BROADCOM BCM5709S	0x163a	BCM5709 NetXtreme II 1000baseSX Ethernet
 product BROADCOM BCM5716	0x163b	BCM5716 NetXtreme II 1000baseT Ethernet
 product BROADCOM BCM5716S	0x163c	BCM5716 NetXtreme II 1000baseSX Ethernet
+product BROADCOM BCM57811	0x163d	BCM57811 10Gb Ethernet
+product BROADCOM BCM57811_MF	0x163e	BCM57811 10Gb MF Ethernet
+product BROADCOM BCM57811_VF	0x163f	BCM57811 10Gb Ehternet VF
+product BROADCOM BCM57787	0x1641	BCM57787 Gigabit Ethernet
+product BROADCOM BCM57764	0x1642	BCM57764 Gigabit Ethernet
+product BROADCOM BCM5725	0x1643	BCM5725 Gigabit Ethernet
 product BROADCOM BCM5700	0x1644	BCM5700 10/100/1000 Ethernet
 product BROADCOM BCM5701	0x1645	BCM5701 10/100/1000 Ethernet
 product BROADCOM BCM5702	0x1646	BCM5702 10/100/1000 Ethernet
@@ -1886,11 +1892,13 @@ product BROADCOM BCM5705M	0x165d	BCM5705
 product BROADCOM BCM5705M_ALT	0x165e	BCM5705M 10/100/1000 Ethernet
 product BROADCOM BCM5720	0x165f	BCM5720 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM57712	0x1662	BCM57712 NetXtreme II 10Gb Ethernet
-product BROADCOM BCM57712E	0x1663	BCM57712E NetXtreme II 10Gb Ethernet
+product BROADCOM BCM57712_MF	0x1663	BCM57712 NetXtreme II 10Gb Ethernet MF
+product BROADCOM BCM5717C	0x1665	BCM5717 10/100/1000 Ethernet
 product BROADCOM BCM5714	0x1668	BCM5714 1000baseT Ethernet
 product BROADCOM BCM5714S	0x1669	BCM5714S 1000baseSX Ethernet
 product BROADCOM BCM5780	0x166a	BCM5780 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5780S	0x166b	BCM5780S NetXtreme 1000baseSX Ethernet
+product BROADCOM BCM57712_VF	0x166f	BCM57712 NetXtreme II 10Gb Ethernet VF
 product BROADCOM BCM5705F	0x166e	BCM5705F 10/100 Ethernet
 product BROADCOM BCM5754M	0x1672	BCM5754M NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5755M	0x1673	BCM5755M NetXtreme 1000baseT Ethernet
@@ -1908,11 +1916,15 @@ product BROADCOM BCM5787F	0x167f	BCM5787
 product BROADCOM BCM5761E	0x1680	BCM5761E 10/100/1000 Ethernet
 product BROADCOM BCM5761	0x1681	BCM5761 10/100/1000 Ethernet
 product BROADCOM BCM57762	0x1682	BCM57762 Gigabit Ethernet
+product BROADCOM BCM57767	0x1683	BCM57767 Gigabit Ethernet
 product BROADCOM BCM5764	0x1684	BCM5764 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM57766	0x1686	BCM57766 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5762	0x1687	BCM5762 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM5761S	0x1688	BCM5761S 10/100/1000 Ethernet
 product BROADCOM BCM5761SE	0x1689	BCM5761SE 10/100/1000 Ethernet
+product BROADCOM BCM57800	0x168a	BCM57800 NetXtreme II 10Gb Ethernet
+product BROADCOM BCM57840_OBS	0x168d	BCM57840 10Gb Ethernet
+product BROADCOM BCM57810	0x168e	BCM57810 10Gb Ethernet
 product BROADCOM BCM57760	0x1690	BCM57760 NetXtreme 1000baseT Ethernet
 product BROADCOM BCM57788	0x1691	BCM57788 NetLink 1000baseT Ethernet
 product BROADCOM BCM57780	0x1692	BCM57780 NetXtreme 1000baseT Ethernet
@@ -1926,11 +1938,20 @@ product BROADCOM BCM5787	0x169b	BCM5787 
 product BROADCOM BCM5788	0x169c	BCM5788 10/100/1000 Ethernet
 product BROADCOM BCM5789	0x169d	BCM5789 NetLink 1000baseT Ethernet
 product BROADCOM BCM5785F	0x16a0	BCM5785F 10/100 Ethernet
+product BROADCOM BCM57840_4_10	0x16a1	BCM57840 4x10Gb Ethernet
+product BROADCOM BCM57840_2_20	0x16a2	BCM57840 2x20Gb Ethernet
+product BROADCOM BCM57840_MF	0x16a4	BCM57840 10Gb Ethernet MF
+product BROADCOM BCM57800_MF	0x16a5	BCM57800 10Gb Ethernet MF
 product BROADCOM BCM5702X	0x16a6	BCM5702X 10/100/1000 Ethernet
 product BROADCOM BCM5703X	0x16a7	BCM5703X 10/100/1000 Ethernet
 product BROADCOM BCM5704S	0x16a8	BCM5704S 1000baseSX Ethernet
+product BROADCOM BCM57800_VF	0x16a9	BCM57800 10Gb Ethernet VF
 product BROADCOM BCM5706S	0x16aa	

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

2019-03-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar  1 17:33:25 UTC 2019

Modified Files:
src/sys/dev/pci/ixgbe [netbsd-8]: ix_txrx.c ixgbe.c ixgbe.h ixv.c

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

sys/dev/pci/ixgbe/ixv.c: revision 1.109
sys/dev/pci/ixgbe/ixgbe.h: revision 1.54
sys/dev/pci/ixgbe/ix_txrx.c: revision 1.52
sys/dev/pci/ixgbe/ixgbe.c: revision 1.174

  Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.


To generate a diff of this commit:
cvs rdiff -u -r1.24.2.14 -r1.24.2.15 src/sys/dev/pci/ixgbe/ix_txrx.c
cvs rdiff -u -r1.88.2.27 -r1.88.2.28 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.24.6.15 -r1.24.6.16 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.56.2.19 -r1.56.2.20 src/sys/dev/pci/ixgbe/ixv.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/ixgbe/ix_txrx.c
diff -u src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.14 src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.15
--- src/sys/dev/pci/ixgbe/ix_txrx.c:1.24.2.14	Thu Dec 20 11:34:33 2018
+++ src/sys/dev/pci/ixgbe/ix_txrx.c	Fri Mar  1 17:33:24 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ix_txrx.c,v 1.24.2.14 2018/12/20 11:34:33 martin Exp $ */
+/* $NetBSD: ix_txrx.c,v 1.24.2.15 2019/03/01 17:33:24 martin Exp $ */
 
 /**
 
@@ -136,7 +136,7 @@ ixgbe_legacy_start_locked(struct ifnet *
 
 	IXGBE_TX_LOCK_ASSERT(txr);
 
-	if (!adapter->link_active) {
+	if (adapter->link_active != LINK_STATE_UP) {
 		/*
 		 * discard all packets buffered in IFQ to avoid
 		 * sending old packets at next link up timing.
@@ -282,7 +282,7 @@ ixgbe_mq_start_locked(struct ifnet *ifp,
 	struct mbuf*next;
 	intenqueued = 0, err = 0;
 
-	if (!txr->adapter->link_active) {
+	if (txr->adapter->link_active != LINK_STATE_UP) {
 		/*
 		 * discard all packets buffered in txr_interq to avoid
 		 * sending old packets at next link up timing.

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.27 src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.28
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.88.2.27	Mon Jan 28 13:03:02 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Fri Mar  1 17:33:24 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.27 2019/01/28 13:03:02 martin Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.28 2019/03/01 17:33:24 martin Exp $ */
 
 /**
 
@@ -1594,7 +1594,7 @@ ixgbe_update_stats_counters(struct adapt
 	stats->mpctotal.ev_count += total_missed_rx;
 
 	/* Document says M[LR]FC are valid when link is up and 10Gbps */
-	if ((adapter->link_active == TRUE)
+	if ((adapter->link_active == LINK_STATE_UP)
 	&& (adapter->link_speed == IXGBE_LINK_SPEED_10GB_FULL)) {
 		stats->mlfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MLFC);
 		stats->mrfc.ev_count += IXGBE_READ_REG(hw, IXGBE_MRFC);
@@ -2692,7 +2692,7 @@ ixgbe_media_status(struct ifnet *ifp, st
 	ifmr->ifm_status = IFM_AVALID;
 	ifmr->ifm_active = IFM_ETHER;
 
-	if (!adapter->link_active) {
+	if (adapter->link_active != LINK_STATE_UP) {
 		ifmr->ifm_active |= IFM_NONE;
 		IXGBE_CORE_UNLOCK(adapter);
 		return;
@@ -4665,7 +4665,7 @@ ixgbe_update_link_status(struct adapter 
 	KASSERT(mutex_owned(>core_mtx));
 
 	if (adapter->link_up) {
-		if (adapter->link_active == FALSE) {
+		if (adapter->link_active != LINK_STATE_UP) {
 			/*
 			 * To eliminate influence of the previous state
 			 * in the same way as ixgbe_init_locked().
@@ -4714,7 +4714,7 @@ ixgbe_update_link_status(struct adapter 
 device_printf(dev, "Link is up %s %s \n",
 bpsmsg, "Full Duplex");
 			}
-			adapter->link_active = TRUE;
+			adapter->link_active = LINK_STATE_UP;
 			/* Update any Flow Control changes */
 			ixgbe_fc_enable(>hw);
 			/* Update DMA coalescing config */
@@ -4724,12 +4724,17 @@ ixgbe_update_link_status(struct adapter 
 			if (adapter->feat_en & IXGBE_FEATURE_SRIOV)
 ixgbe_ping_all_vfs(adapter);
 		}
-	} else { /* Link down */
-		if (adapter->link_active == TRUE) {
+	} else {
+		/*
+		 * Do it when link active changes to DOWN. i.e.
+		 * a) LINK_STATE_UNKNOWN -> LINK_STATE_DOWN
+		 * b) LINK_STATE_UP  -> LINK_STATE_DOWN
+		 */
+		if (adapter->link_active != LINK_STATE_DOWN) {
 			if (bootverbose)
 device_printf(dev, "Link is Down\n");
 			if_link_state_change(ifp, LINK_STATE_DOWN);
-			adapter->link_active = FALSE;
+			adapter->link_active = LINK_STATE_DOWN;
 			if (adapter->feat_en & IXGBE_FEATURE_SRIOV)
 ixgbe_ping_all_vfs(adapter);
 			ixgbe_drain_all(adapter);

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.24.6.15 src/sys/dev/pci/ixgbe/ixgbe.h:1.24.6.16
--- 

CVS commit: [netbsd-8] src/sys/dev/scsipi

2019-03-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Mar  1 17:29:32 UTC 2019

Modified Files:
src/sys/dev/scsipi [netbsd-8]: files.scsipi st.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1197):

sys/dev/scsipi/st.c: revision 1.236
sys/dev/scsipi/st.c: revision 1.237
sys/dev/scsipi/files.scsipi: revision 1.42

Fix PR kern/53949:

Fix inconsistent/incomplete file mark handling to conform again
to mtio(4) at close(2) time. This was necessary as the PREVENT/ALLOW
bracket was reduced from a whole mount session to cover only the
open(2)/close(2) time on ~2002-03-22. The rationale was to allow
robots and humans to change the media during a mount session.

Unfortunately this lead to file marks being written to potentially other
media at the beginning on drives that used the two file marks as EOM
pattern. In order for that to happen the media had to be removed after
data and at most one file mark had been written before removal.

The mount error message has been clarified and a warning about
potential data/file mark lossage on UNIT ATTENTION
during an active mount session with unfinished file marks has been
added.

While there, fix, but disable the commented SUN compatibility to write
final file marks by opening and immediately closing the device
in O_WRONLY mode. That code has not been working since around 1998.
It can now be enabled with options ST_SUNCOMPAT.
Additionally debug output coverage has been extended.

 -

Correct printing type of b_blkno (int64_t) in st.c

Fixes build with kUBSan on NetBSD/i386.
  Fix, but disable the commented SUN compatibility in st.c to write
  final file marks by opening and immediately closing the device
  in O_WRONLY mode. That code has not been working since around 1998.
  It can now be enabled with options ST_SUNCOMPAT.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.156.1 src/sys/dev/scsipi/files.scsipi
cvs rdiff -u -r1.230.8.2 -r1.230.8.3 src/sys/dev/scsipi/st.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/scsipi/files.scsipi
diff -u src/sys/dev/scsipi/files.scsipi:1.41 src/sys/dev/scsipi/files.scsipi:1.41.156.1
--- src/sys/dev/scsipi/files.scsipi:1.41	Sun Dec 11 12:23:50 2005
+++ src/sys/dev/scsipi/files.scsipi	Fri Mar  1 17:29:32 2019
@@ -1,11 +1,12 @@
-#	$NetBSD: files.scsipi,v 1.41 2005/12/11 12:23:50 christos Exp $
+#	$NetBSD: files.scsipi,v 1.41.156.1 2019/03/01 17:29:32 martin Exp $
 #
 # Config file and device description for machine-independent SCSI code.
 # Included by ports that need it.  Ports that use it must provide
 # their own "major" declarations for the appropriate devices.
 
 defflag	opt_scsi.h		SCSIVERBOSE ST_ENABLE_EARLYWARN
-SES_ENABLE_PASSTHROUGH SCSI_OLD_NOINQUIRY
+ST_SUNCOMPAT SES_ENABLE_PASSTHROUGH
+SCSI_OLD_NOINQUIRY
 defparam opt_scsi.h		ST_MOUNT_DELAY SDRETRIES SD_IO_TIMEOUT
 
 defflag	opt_scsipi_debug.h	SCSIPI_DEBUG

Index: src/sys/dev/scsipi/st.c
diff -u src/sys/dev/scsipi/st.c:1.230.8.2 src/sys/dev/scsipi/st.c:1.230.8.3
--- src/sys/dev/scsipi/st.c:1.230.8.2	Sun Apr  8 06:11:41 2018
+++ src/sys/dev/scsipi/st.c	Fri Mar  1 17:29:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: st.c,v 1.230.8.2 2018/04/08 06:11:41 snj Exp $ */
+/*	$NetBSD: st.c,v 1.230.8.3 2019/03/01 17:29:32 martin Exp $ */
 
 /*-
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.230.8.2 2018/04/08 06:11:41 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.230.8.3 2019/03/01 17:29:32 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_scsi.h"
@@ -615,8 +615,30 @@ stopen(dev_t dev, int flags, int mode, s
 		 */
 		if ((st->flags & ST_MOUNTED) || ST_MOUNT_DELAY == 0 ||
 		(st->mt_key != SKEY_NOT_READY)) {
-			device_printf(st->sc_dev, "mount error (key=%d)\n",
-st->mt_key);
+			device_printf(st->sc_dev,
+  "mount error (sense key=%d) - "
+  "terminating mount session\n",
+  st->mt_key);
+			/*
+			 * the following should not trigger unless
+			 * something serious happened while the device
+			 * was open (PREVENT MEDIUM REMOVAL in effect)
+			 */
+			if (st->flags & ST_WRITTEN &&
+			st->mt_key == SKEY_UNIT_ATTENTION) {
+/*
+ * device / media state may have changed
+ * refrain from writing missing file marks
+ * onto potentially newly inserted/formatted
+ * media (e. g. emergency EJECT/RESET/etc.)
+ */
+st->flags &= ~(ST_WRITTEN|ST_FM_WRITTEN);
+
+device_printf(st->sc_dev,
+"CAUTION: file marks/data may be missing"
+" - ASC = 0x%02x, ASCQ = 0x%02x\n",
+	  st->asc, st->ascq);
+			}
 			goto bad;
 		}
 
@@ -727,15 +749,30 @@ stclose(dev_t dev, int flags, int mode, 
 	 */
 
 	stxx = st->flags & (ST_WRITTEN | ST_FM_WRITTEN);
-	if (((flags & FWRITE) && stxx == 

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

2019-02-20 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 20 09:49:49 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_axen.c if_axenreg.h

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

sys/dev/usb/if_axen.c: revision 1.26
sys/dev/usb/if_axenreg.h: revision 1.7

Remove unused variable in axen_softc.

Drop AXEN_MEDIUM_ALWAYS_ONE (from Linux), which reduces drop erros in RX.


To generate a diff of this commit:
cvs rdiff -u -r1.11.8.6 -r1.11.8.7 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.3.10.2 -r1.3.10.3 src/sys/dev/usb/if_axenreg.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_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.11.8.6 src/sys/dev/usb/if_axen.c:1.11.8.7
--- src/sys/dev/usb/if_axen.c:1.11.8.6	Tue Feb 19 15:09:51 2019
+++ src/sys/dev/usb/if_axen.c	Wed Feb 20 09:49:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.11.8.6 2019/02/19 15:09:51 martin Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.11.8.7 2019/02/20 09:49:48 martin Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.6 2019/02/19 15:09:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.7 2019/02/20 09:49:48 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -271,9 +271,8 @@ axen_miibus_statchg(struct ifnet *ifp)
 	if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
 		val |= AXEN_MEDIUM_FDX;
 
-	val |= (AXEN_MEDIUM_RECV_EN | AXEN_MEDIUM_ALWAYS_ONE);
-	val |= (AXEN_MEDIUM_RXFLOW_CTRL_EN | AXEN_MEDIUM_TXFLOW_CTRL_EN);
-
+	val |= AXEN_MEDIUM_RXFLOW_CTRL_EN | AXEN_MEDIUM_TXFLOW_CTRL_EN |
+	AXEN_MEDIUM_RECV_EN;
 	switch (IFM_SUBTYPE(mii->mii_media_active)) {
 	case IFM_1000_T:
 		val |= AXEN_MEDIUM_GIGA | AXEN_MEDIUM_EN_125MHZ;
@@ -588,9 +587,9 @@ axen_ax88179_init(struct axen_softc *sc)
 	DPRINTF(("axen: Monitor mode = 0x%02x\n", val));
 
 	/* set medium type */
-	ctl = AXEN_MEDIUM_GIGA | AXEN_MEDIUM_FDX | AXEN_MEDIUM_ALWAYS_ONE |
-	  AXEN_MEDIUM_RXFLOW_CTRL_EN | AXEN_MEDIUM_TXFLOW_CTRL_EN;
-	ctl |= AXEN_MEDIUM_RECV_EN;
+	ctl = AXEN_MEDIUM_GIGA | AXEN_MEDIUM_FDX | AXEN_MEDIUM_EN_125MHZ |
+	AXEN_MEDIUM_RXFLOW_CTRL_EN | AXEN_MEDIUM_TXFLOW_CTRL_EN |
+	AXEN_MEDIUM_RECV_EN;
 	wval = htole16(ctl);
 	DPRINTF(("axen: set to medium mode: 0x%04x\n", ctl));
 	axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, );

Index: src/sys/dev/usb/if_axenreg.h
diff -u src/sys/dev/usb/if_axenreg.h:1.3.10.2 src/sys/dev/usb/if_axenreg.h:1.3.10.3
--- src/sys/dev/usb/if_axenreg.h:1.3.10.2	Tue Feb 19 15:09:51 2019
+++ src/sys/dev/usb/if_axenreg.h	Wed Feb 20 09:49:48 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axenreg.h,v 1.3.10.2 2019/02/19 15:09:51 martin Exp $	*/
+/*	$NetBSD: if_axenreg.h,v 1.3.10.3 2019/02/20 09:49:48 martin Exp $	*/
 /*	$OpenBSD: if_axenreg.h,v 1.1 2013/10/07 05:37:41 yuo Exp $	*/
 
 /*
@@ -289,7 +289,6 @@ struct axen_softc {
 
 	int			axen_link;
 
-	uint8_t			axen_ipgs[3];
 	int			axen_phyno;
 	struct timeval		axen_rx_notice;
 	struct timeval		axen_tx_notice;



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

2019-02-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 19 15:09:52 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_axen.c if_axenreg.h

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

sys/dev/usb/if_axen.c: revision 1.27
sys/dev/usb/if_axenreg.h: revision 1.6
sys/dev/usb/if_axen.c: revision 1.32
sys/dev/usb/if_axen.c: revision 1.35
sys/dev/usb/if_axen.c: revision 1.37
sys/dev/usb/if_axenreg.h: revision 1.10
sys/dev/usb/if_axenreg.h: revision 1.11
sys/dev/usb/if_axen.c: revision 1.24

Correct error bits in RX packet header:
- Drop error is bit 31.
- CRC error is bit 29.
- Distinguish the two errors in debug printf.

Cosmetic changes; no functional changes.

Add couple of error printf.

XXX We should not to use aprint_xxx() for non-autoconf staffs.

Add ratecheck for TX errors for axen(4) and mue(4).

Remove unused.


To generate a diff of this commit:
cvs rdiff -u -r1.11.8.5 -r1.11.8.6 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.3.10.1 -r1.3.10.2 src/sys/dev/usb/if_axenreg.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_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.11.8.5 src/sys/dev/usb/if_axen.c:1.11.8.6
--- src/sys/dev/usb/if_axen.c:1.11.8.5	Tue Feb 19 15:05:52 2019
+++ src/sys/dev/usb/if_axen.c	Tue Feb 19 15:09:51 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.11.8.5 2019/02/19 15:05:52 martin Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.11.8.6 2019/02/19 15:09:51 martin Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.5 2019/02/19 15:05:52 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.6 2019/02/19 15:09:51 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -950,7 +950,6 @@ axen_rx_list_init(struct axen_softc *sc)
 	for (i = 0; i < AXEN_RX_LIST_CNT; i++) {
 		c = >axen_rx_chain[i];
 		c->axen_sc = sc;
-		c->axen_idx = i;
 		if (c->axen_xfer == NULL) {
 			int err = usbd_create_xfer(sc->axen_ep[AXEN_ENDPT_RX],
 			sc->axen_rx_bufsz, 0, 0, >axen_xfer);
@@ -976,7 +975,6 @@ axen_tx_list_init(struct axen_softc *sc)
 	for (i = 0; i < AXEN_TX_LIST_CNT; i++) {
 		c = >axen_tx_chain[i];
 		c->axen_sc = sc;
-		c->axen_idx = i;
 		if (c->axen_xfer == NULL) {
 			int err = usbd_create_xfer(sc->axen_ep[AXEN_ENDPT_TX],
 			sc->axen_tx_bufsz, USBD_FORCE_SHORT_XFER, 0,
@@ -1021,10 +1019,9 @@ axen_rxeof(struct usbd_xfer *xfer, void 
 	if (status != USBD_NORMAL_COMPLETION) {
 		if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
 			return;
-		if (usbd_ratecheck(>axen_rx_notice)) {
+		if (usbd_ratecheck(>axen_rx_notice))
 			aprint_error_dev(sc->axen_dev, "usb errors on rx: %s\n",
 			usbd_errstr(status));
-		}
 		if (status == USBD_STALLED)
 			usbd_clear_endpoint_stall_async(sc->axen_ep[AXEN_ENDPT_RX]);
 		goto done;
@@ -1033,6 +1030,7 @@ axen_rxeof(struct usbd_xfer *xfer, void 
 	usbd_get_xfer_status(xfer, NULL, NULL, _len, NULL);
 
 	if (total_len < sizeof(pkt_hdr)) {
+		aprint_error_dev(sc->axen_dev, "rxeof: too short transfer\n");
 		ifp->if_ierrors++;
 		goto done;
 	}
@@ -1054,6 +1052,7 @@ axen_rxeof(struct usbd_xfer *xfer, void 
 
 	/* sanity check */
 	if (hdr_offset > total_len) {
+		aprint_error_dev(sc->axen_dev, "rxeof: invalid hdr offset\n");
 		ifp->if_ierrors++;
 		usbd_delay_ms(sc->axen_udev, 100);
 		goto done;
@@ -1090,12 +1089,13 @@ axen_rxeof(struct usbd_xfer *xfer, void 
 		("%s: rxeof: packet#%d, pkt_hdr 0x%08x, pkt_len %zu\n",
 		   device_xname(sc->axen_dev), pkt_count, pkt_hdr, pkt_len));
 
-		if ((pkt_hdr & AXEN_RXHDR_CRC_ERR) ||
-		(pkt_hdr & AXEN_RXHDR_DROP_ERR)) {
+		if (pkt_hdr & (AXEN_RXHDR_CRC_ERR | AXEN_RXHDR_DROP_ERR)) {
 			ifp->if_ierrors++;
 			/* move to next pkt header */
-			DPRINTF(("%s: crc err (pkt#%d)\n",
-			device_xname(sc->axen_dev), pkt_count));
+			DPRINTF(("%s: %s err (pkt#%d)\n",
+			device_xname(sc->axen_dev),
+			(pkt_hdr & AXEN_RXHDR_CRC_ERR) ? "crc" : "drop",
+			pkt_count));
 			goto nextpkt;
 		}
 
@@ -1208,8 +1208,9 @@ axen_txeof(struct usbd_xfer *xfer, void 
 			return;
 		}
 		ifp->if_oerrors++;
-		aprint_error_dev(sc->axen_dev, "usb error on tx: %s\n",
-		usbd_errstr(status));
+		if (usbd_ratecheck(>axen_tx_notice))
+			aprint_error_dev(sc->axen_dev, "usb error on tx: %s\n",
+			usbd_errstr(status));
 		if (status == USBD_STALLED)
 			usbd_clear_endpoint_stall_async(sc->axen_ep[AXEN_ENDPT_TX]);
 		splx(s);
@@ -1547,6 +1548,7 @@ static void
 axen_stop(struct ifnet *ifp, int disable)
 {
 	struct axen_softc *sc = ifp->if_softc;
+	struct axen_chain *c;
 	usbd_status err;
 	int i;
 	uint16_t rxmode, wval;
@@ -1595,17 +1597,19 @@ axen_stop(struct ifnet *ifp, int disable
 
 	/* Free RX resources. */
 	for (i = 0; i < AXEN_RX_LIST_CNT; i++) {
-		if 

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

2019-02-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 19 15:05:52 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_axen.c if_axenreg.h

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

sys/dev/usb/if_axen.c: revision 1.28
sys/dev/usb/if_axen.c: revision 1.29
sys/dev/usb/if_axenreg.h: revision 1.4
sys/dev/usb/if_axenreg.h: revision 1.5
sys/dev/usb/if_axen.c: revision 1.19
sys/dev/usb/if_axenreg.h: revision 1.8
sys/dev/usb/if_axen.c: revision 1.30
sys/dev/usb/if_axen.c: revision 1.31
sys/dev/usb/if_axen.c: revision 1.36
sys/dev/usb/if_axen.c: revision 1.20
sys/dev/usb/if_axen.c: revision 1.23
sys/dev/usb/if_axen.c: revision 1.25

Fix HW checksum offloading.
- Enable ones specified in if_capenable and remove AXEN_TOE macro.
- Check correct bit and set appropriate csum_flags.
- Pass packets of wrong checksum to upper layer instead of dropping them.
- Fix value of AXEN_RXHDR_L3_TYPE_MASK.

Tested on ASIX Elec. Corp. (0xb95) AX88179 (0x1790).

Fix previous:
- axen_coe() should be called from axen_init(), not axen_ax88179_init().
- Simplify logic in axen_coe(); AXEN_[RT]XCOE_OFF = 0.

Enable hash-table-based multicast filter:
- Drop AXEN_RXCTL_ACPT_PHY_MCAST bit (neither Linux nor FreeBSD sets it).
- 0x0010 bit is not AXEN_RXCTL_ACPT_BCAST ("accept broadcast") but
   AXEN_RXCTL_ACPT_MCAST ("accept multicast (hash-table-based)").

Remove useless memset.

Fix padding for a full length USB packet in TX:
- Update boundary length for SS mode, taken from OpenBSD.
- Make sure everything passed to the adapter is little endian.
- Specify padding bits in a similar manner to Linux.

XXX I wonder whether this is really necessary...

Support TSOv4 (They call it LSOv1).
The adapter does not support TSOv6 (aka LSOv2).

Fix previous.

Oops, fix previous again. Really support TSOv4.

Use unsigned variables for buffer length to avoid compiler warnings.


To generate a diff of this commit:
cvs rdiff -u -r1.11.8.4 -r1.11.8.5 src/sys/dev/usb/if_axen.c
cvs rdiff -u -r1.3 -r1.3.10.1 src/sys/dev/usb/if_axenreg.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_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.11.8.4 src/sys/dev/usb/if_axen.c:1.11.8.5
--- src/sys/dev/usb/if_axen.c:1.11.8.4	Tue Feb 19 14:51:24 2019
+++ src/sys/dev/usb/if_axen.c	Tue Feb 19 15:05:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.11.8.4 2019/02/19 14:51:24 martin Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.11.8.5 2019/02/19 15:05:52 martin Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.4 2019/02/19 14:51:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.5 2019/02/19 15:05:52 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -50,6 +50,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 
 
 #include 
 
+#include 		/* XXX for netinet/ip.h */
+#include 		/* XXX for IP_MAXPACKET */
+
 #include 
 #include 
 
@@ -70,8 +73,6 @@ int	axendebug = 0;
 #define DPRINTFN(n,x)
 #endif
 
-#define AXEN_TOE	/* enable checksum offload function */
-
 /*
  * Various supported device vendors/products.
  */
@@ -98,6 +99,7 @@ static int	axen_rx_list_init(struct axen
 static struct mbuf *axen_newbuf(void);
 static int	axen_encap(struct axen_softc *, struct mbuf *, int);
 static void	axen_rxeof(struct usbd_xfer *, void *, usbd_status);
+static int	axen_csum_flags_rx(struct ifnet *, uint32_t);
 static void	axen_txeof(struct usbd_xfer *, void *, usbd_status);
 static void	axen_tick(void *);
 static void	axen_tick_task(void *);
@@ -122,6 +124,7 @@ static void	axen_lock_mii(struct axen_so
 static void	axen_unlock_mii(struct axen_softc *);
 
 static void	axen_ax88179_init(struct axen_softc *);
+static void	axen_setcoe(struct axen_softc *);
 
 /* Get exclusive access to the MII registers */
 static void
@@ -353,32 +356,38 @@ axen_iff(struct axen_softc *sc)
 	axen_lock_mii(sc);
 	axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, );
 	rxmode = le16toh(wval);
-	rxmode &= ~(AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_ACPT_PHY_MCAST |
-		  AXEN_RXCTL_PROMISC);
+	rxmode &= ~(AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_PROMISC |
+	AXEN_RXCTL_ACPT_MCAST);
 	ifp->if_flags &= ~IFF_ALLMULTI;
 
-	/*
-	 * Always accept broadcast frames.
-	 * Always accept frames destined to our station address.
-	 */
-	rxmode |= AXEN_RXCTL_ACPT_BCAST;
-
-	if (ifp->if_flags & IFF_PROMISC || ec->ec_multicnt > 0 /* XXX */) {
-		ifp->if_flags |= IFF_ALLMULTI;
-		rxmode |= AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_ACPT_PHY_MCAST;
-		if (ifp->if_flags & IFF_PROMISC)
-			rxmode |= AXEN_RXCTL_PROMISC;
+	if (ifp->if_flags & IFF_PROMISC) {
+		DPRINTF(("%s: promisc\n", device_xname(sc->axen_dev)));
+		rxmode |= AXEN_RXCTL_PROMISC;
+allmulti:	ifp->if_flags 

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

2019-02-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Feb 19 14:51:25 UTC 2019

Modified Files:
src/sys/dev/usb [netbsd-8]: if_axen.c

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

sys/dev/usb/if_axen.c: revision 1.21
sys/dev/usb/if_axen.c: revision 1.22

Enable AXEN_RXCTL_START bit only when RX is ready. Otherwise,
the adapter eventually falls into "no carrier" state while it
is not running.

In axen_tick_task(), call axen_miibus_statchg() when link is lost
(like other drivers). Otherwise, link can be lost forever, which
results in sysmtem freeze.

Drop AXEN_MEDIUM_ALWAYS_ONE (from Linux), which reduces drop erros in RX.


To generate a diff of this commit:
cvs rdiff -u -r1.11.8.3 -r1.11.8.4 src/sys/dev/usb/if_axen.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_axen.c
diff -u src/sys/dev/usb/if_axen.c:1.11.8.3 src/sys/dev/usb/if_axen.c:1.11.8.4
--- src/sys/dev/usb/if_axen.c:1.11.8.3	Thu Feb  7 06:14:34 2019
+++ src/sys/dev/usb/if_axen.c	Tue Feb 19 14:51:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_axen.c,v 1.11.8.3 2019/02/07 06:14:34 msaitoh Exp $	*/
+/*	$NetBSD: if_axen.c,v 1.11.8.4 2019/02/19 14:51:24 martin Exp $	*/
 /*	$OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.3 2019/02/07 06:14:34 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.11.8.4 2019/02/19 14:51:24 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -587,7 +587,6 @@ axen_ax88179_init(struct axen_softc *sc)
 	/* Set RX control register */
 	ctl = AXEN_RXCTL_IPE | AXEN_RXCTL_DROPCRCERR | AXEN_RXCTL_AUTOB;
 	ctl |= AXEN_RXCTL_ACPT_PHY_MCAST | AXEN_RXCTL_ACPT_ALL_MCAST;
-	ctl |= AXEN_RXCTL_START;
 	wval = htole16(ctl);
 	axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, );
 
@@ -1212,15 +1211,8 @@ axen_tick_task(void *xsc)
 	s = splnet();
 
 	mii_tick(mii);
-	if (sc->axen_link == 0 &&
-	(mii->mii_media_status & IFM_ACTIVE) != 0 &&
-	IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
-		DPRINTF(("%s: %s: got link\n", device_xname(sc->axen_dev),
-		__func__));
-		sc->axen_link++;
-		if (!IFQ_IS_EMPTY(>if_snd))
-			axen_start(ifp);
-	}
+	if (sc->axen_link == 0)
+		axen_miibus_statchg(ifp);
 
 	callout_schedule(>axen_stat_ch, hz);
 
@@ -1479,9 +1471,19 @@ axen_stop(struct ifnet *ifp, int disable
 	struct axen_softc *sc = ifp->if_softc;
 	usbd_status err;
 	int i;
+	uint16_t rxmode, wval;
 
 	axen_reset(sc);
 
+	/* Disable receiver, set RX mode */
+	axen_lock_mii(sc);
+	axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, );
+	rxmode = le16toh(wval);
+	rxmode &= ~AXEN_RXCTL_START;
+	wval = htole16(rxmode);
+	axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, );
+	axen_unlock_mii(sc);
+
 	ifp->if_timer = 0;
 	ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 



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

2019-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Feb 11 13:44:34 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: if_wm.c

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

sys/dev/pci/if_wm.c: revision 1.622
sys/dev/pci/if_wm.c: revision 1.624
sys/dev/pci/if_wm.c: revision 1.625

 We now have IFM_2500_KX and IFM_1000_KX, so use them.

 -

 I21[01]'s RAL size is not 15 but 16(== 82575's value). Same as other OSes.

 -

 Fix a bug that WOL didn't work on some chips since if_wm.c rev. 1.610.

Set WUC_APME bit older than PCH. Will fixes PR kern/53945 reported by kardel@.
Tested with my own 82574 card.


To generate a diff of this commit:
cvs rdiff -u -r1.508.4.29 -r1.508.4.30 src/sys/dev/pci/if_wm.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_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.508.4.29 src/sys/dev/pci/if_wm.c:1.508.4.30
--- src/sys/dev/pci/if_wm.c:1.508.4.29	Thu Jan 31 06:43:48 2019
+++ src/sys/dev/pci/if_wm.c	Mon Feb 11 13:44:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.508.4.29 2019/01/31 06:43:48 martin Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.508.4.30 2019/02/11 13:44:34 martin Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.29 2019/01/31 06:43:48 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.30 2019/02/11 13:44:34 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3597,6 +3597,8 @@ wm_rar_count(struct wm_softc *sc)
 		size = WM_RAL_TABSIZE_PCH_LPT;
 		break;
 	case WM_T_82575:
+	case WM_T_I210:
+	case WM_T_I211:
 		size = WM_RAL_TABSIZE_82575;
 		break;
 	case WM_T_82576:
@@ -11895,9 +11897,9 @@ wm_serdes_mediastatus(struct ifnet *ifp,
 		status = CSR_READ(sc, WMREG_STATUS);
 		if (((status & STATUS_2P5_SKU) != 0)
 		&& ((status & STATUS_2P5_SKU_OVER) == 0)) {
-			ifmr->ifm_active |= IFM_2500_SX; /* XXX KX */
+			ifmr->ifm_active |= IFM_2500_KX;
 		} else
-			ifmr->ifm_active |= IFM_1000_SX; /* XXX KX */
+			ifmr->ifm_active |= IFM_1000_KX;
 	} else {
 		switch (__SHIFTOUT(reg, PCS_LSTS_SPEED)) {
 		case PCS_LSTS_SPEED_10:
@@ -14700,7 +14702,7 @@ wm_enable_wakeup(struct wm_softc *sc)
 			goto pme;
 	} else {
 		/* Enable wakeup by the MAC */
-		CSR_WRITE(sc, WMREG_WUC, WUC_PME_EN);
+		CSR_WRITE(sc, WMREG_WUC, WUC_APME | WUC_PME_EN);
 		CSR_WRITE(sc, WMREG_WUFC, WUFC_MAG);
 	}
 



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

2019-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Feb 11 13:38:19 UTC 2019

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

Log Message:
Regen for ticket #1188


To generate a diff of this commit:
cvs rdiff -u -r1.1281.2.12 -r1.1281.2.13 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1280.2.12 -r1.1280.2.13 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-8] src/sys/dev/pci

2019-02-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Feb 11 13:34:09 UTC 2019

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

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

sys/dev/pci/pcidevs: revision 1.1360
sys/dev/pci/pcidevs: revision 1.1361
sys/dev/pci/pcidevs: revision 1.1362
sys/dev/pci/pcidevs: revision 1.1357
sys/dev/pci/pcidevs: revision 1.1359

 Add yet another Intel Core QuickPath Generic Non-Core Register.

 Add some RADEON devices. Mainly taken from OpenBSD.

 Add AMD Family 17h devices from OpenBSD.

>From OpenBSD:
- Add NetXen's vendor ID and devices.
- Add Sun Neptune.

- Add Some Freescale MPC834x devices from OpenBSD.

- Add Intel I210 SGMII Flash-less device from the spec update document.


To generate a diff of this commit:
cvs rdiff -u -r1.1289.2.12 -r1.1289.2.13 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.1289.2.12 src/sys/dev/pci/pcidevs:1.1289.2.13
--- src/sys/dev/pci/pcidevs:1.1289.2.12	Tue Dec  4 12:02:12 2018
+++ src/sys/dev/pci/pcidevs	Mon Feb 11 13:34:09 2019
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1289.2.12 2018/12/04 12:02:12 martin Exp $
+$NetBSD: pcidevs,v 1.1289.2.13 2019/02/11 13:34:09 martin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -657,6 +657,7 @@ vendor HINT		0x3388	HiNT
 vendor 3DLABS		0x3d3d	3D Labs
 vendor AVANCE2		0x4005	Avance Logic (2nd PCI Vendor ID)
 vendor ADDTRON		0x4033	Addtron Technology
+vendor NETXEN		0x4040	NetXen
 vendor QINHENG		0x4348	Nanjing QinHeng Electronics
 vendor ICOMPRESSION	0x	Conexant (iCompression)
 vendor INDCOMPSRC	0x494f	Industrial Computer Source
@@ -1002,6 +1003,24 @@ product AMD F15_30_HB	0x1424	Family15h H
 product AMD F15_30_RP_5	0x1425	Family15h Root Port
 product AMD F15_30_RP_6	0x1426	Family15h Root Port
 product AMD F16_GPPB	0x1439	Family16h GPP Bridge
+product AMD F17_RC	0x1450	Family17h Root Complex
+product AMD F17_IOMMU	0x1451	Family17h IOMMU
+product AMD F17_PCIE_1	0x1452	Family17h PCIE
+product AMD F17_PCIE_2	0x1453	Family17h PCIE
+product AMD F17_PCIE_3	0x1454	Family17h PCIE
+product AMD F17_HDA	0x1457	Family17h HD Audio
+product AMD F17_XHCI	0x145c	Family17h xHCI
+product AMD F17_XHCI_2	0x145f	Family17h xHCI
+product AMD F17_DF_1	0x1460	Family17h Data Fabric
+product AMD F17_DF_2	0x1461	Family17h Data Fabric
+product AMD F17_DF_3	0x1462	Family17h Data Fabric
+product AMD F17_DF_4	0x1463	Family17h Data Fabric
+product AMD F17_DF_5	0x1464	Family17h Data Fabric
+product AMD F17_DF_6	0x1465	Family17h Data Fabric
+product AMD F17_DF_7	0x1466	Family17h Data Fabric
+product AMD F17_DF_8	0x1467	Family17h Data Fabric
+product AMD F17_PCIE_4	0x1470	Family17h PCIE
+product AMD F17_PCIE_5	0x1471	Family17h PCIE
 product AMD F14_RC	0x1510	Family14h Root Complex
 product AMD F16_HT	0x1530	Family16h HyperTransport Configuration
 product AMD F16_ADDR	0x1531	Family16h Address Map Configuration
@@ -1033,6 +1052,21 @@ product AMD F16_30_DRAM	0x1582	Family16h
 product AMD F16_30_NB	0x1583	Family16h North Bridge Configuration
 product AMD F16_30_CSTATE	0x1584	Family16h CPU C-state Configuration
 product AMD F16_30_MISC	0x1585	Family16h Miscellaneous Configuration
+product AMD F17_1X_RC	0x15d0	Family17h/1xh Root Complex
+product AMD F17_1X_IOMMU 0x15d1	Family17h/1xh IOMMU
+product AMD F17_1X_PCIE_1 0x15d3 Family17h/1xh PCIE
+product AMD F17_1X_PCIE_2 0x15db Family17h/1xh PCIE
+product AMD F17_1X_PCIE_3 0x15dc Family17h/1xh PCIE
+product AMD F17_1X_XHCI_1 0x15e0 Family17h/1xh xHCI
+product AMD F17_1X_XHCI_2 0x15e1 Family17h/1xh xHCI
+product AMD F17_1X_DF_0	0x15e8	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_1	0x15e9	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_2	0x15ea	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_3	0x15eb	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_4	0x15ec	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_5	0x15ed	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_6	0x15ee	Family17h/1xh Data Fabric
+product AMD F17_1X_DF_7	0x15ef	Family17h/1xh Data Fabric
 product AMD F15_HT	0x1600	Family15h HyperTransport Configuration
 product AMD F15_ADDR	0x1601	Family15h Address Map Configuration
 product AMD F15_DRAM	0x1602	Family15h DRAM Configuration
@@ -1576,7 +1610,44 @@ product ATI RADEON_HD8530M	0x6607	Radeon
 product ATI RADEON_HD8600	0x6610	Radeon HD 8600
 product ATI RADEON_HD8570	0x6611	Radeon HD 8570
 product ATI RADEON_HD8500	0x6613	Radeon HD 8500
+product ATI RADEON_HD6970	0x6718	Radeon HD 6970
+product ATI RADEON_HD6950	0x6719	Radeon HD 6950
+product ATI RADEON_HD6990_1	0x671c	Radeon HD 6990
+product ATI RADEON_HD6990_2	0x671d	Radeon HD 6990
+product ATI RADEON_HD6930	0x671f	Radeon HD 6930
+product ATI RADEON_HD6970M	0x6720	Radeon HD 6970M
+product ATI RADEON_HD6900M	0x6725	Radeon HD 6900M
+product ATI 

CVS commit: [netbsd-8] src/sys/dev/raidframe

2019-02-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Feb  8 16:03:04 UTC 2019

Modified Files:
src/sys/dev/raidframe [netbsd-8]: rf_disks.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1183):

sys/dev/raidframe/rf_disks.c: revision 1.90

PR/53956: Havard Eidnes: raidframe fails to create raid set on disks.
The test to check if force was reversed when the code was factored out.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.89.8.1 src/sys/dev/raidframe/rf_disks.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/raidframe/rf_disks.c
diff -u src/sys/dev/raidframe/rf_disks.c:1.89 src/sys/dev/raidframe/rf_disks.c:1.89.8.1
--- src/sys/dev/raidframe/rf_disks.c:1.89	Fri Jan 13 13:01:13 2017
+++ src/sys/dev/raidframe/rf_disks.c	Fri Feb  8 16:03:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_disks.c,v 1.89 2017/01/13 13:01:13 christos Exp $	*/
+/*	$NetBSD: rf_disks.c,v 1.89.8.1 2019/02/08 16:03:04 martin Exp $	*/
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -60,7 +60,7 @@
  ***/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.89 2017/01/13 13:01:13 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_disks.c,v 1.89.8.1 2019/02/08 16:03:04 martin Exp $");
 
 #include 
 
@@ -705,7 +705,7 @@ rf_handle_hosed(RF_Raid_t *raidPtr, RF_C
 int again)
 {
 	printf("Hosed component: %s\n", >devnames[0][hosed_column][0]);
-	if (!cfgPtr->force)
+	if (cfgPtr->force)
 		return;
 
 	/* we'll fail this component, as if there are



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

2019-02-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Feb  7 06:13:26 UTC 2019

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

Log Message:
Pullup the following revision (requested by martin in ticket #1182):
sys/dev/usb/usbdevs 1.753

Andrius V in Pr kern/53461: add D-Link DUB-1312


To generate a diff of this commit:
cvs rdiff -u -r1.736.2.2 -r1.736.2.3 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.736.2.2 src/sys/dev/usb/usbdevs:1.736.2.3
--- src/sys/dev/usb/usbdevs:1.736.2.2	Mon Nov 12 16:01:35 2018
+++ src/sys/dev/usb/usbdevs	Thu Feb  7 06:13:26 2019
@@ -1,4 +1,4 @@
-$NetBSD: usbdevs,v 1.736.2.2 2018/11/12 16:01:35 martin Exp $
+$NetBSD: usbdevs,v 1.736.2.3 2019/02/07 06:13:26 msaitoh Exp $
 
 /*
  * Copyright (c) 1998-2004 The NetBSD Foundation, Inc.
@@ -1373,6 +1373,7 @@ product DISPLAYLINK FYDVI	0x8060	Display
 /*product DLINK DSBS25		0x0100	DSB-S25 serial adapter*/
 product DLINK DUBE100		0x1a00	10/100 ethernet adapter
 product DLINK DUBE100C1		0x1a02	DUB-E100 rev C1
+product DLINK DUB1312		0x4a00	DUB-1312
 product DLINK DSB650TX4		0x200c	10/100 ethernet adapter
 product DLINK DWL120E		0x3200	DWL-120 rev E
 product DLINK DWA130C		0x3301	DWA-130 rev C



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

2019-02-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Feb  1 11:25:13 UTC 2019

Modified Files:
src/sys/dev/pci [netbsd-8]: ppb.c

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

sys/dev/pci/ppb.c: revision 1.66
sys/dev/pci/ppb.c: revision 1.67

  Explicitly enable bus masterling in case BIOS, UEFI or firmware don't enable
it. Might fix PR kern/53811.

 -

  If the secondary bus is configured and the bus mastering is not enabled,
enable it. Suggested by thorpej@.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.63.2.1 src/sys/dev/pci/ppb.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/ppb.c
diff -u src/sys/dev/pci/ppb.c:1.63 src/sys/dev/pci/ppb.c:1.63.2.1
--- src/sys/dev/pci/ppb.c:1.63	Wed May 10 03:24:31 2017
+++ src/sys/dev/pci/ppb.c	Fri Feb  1 11:25:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ppb.c,v 1.63 2017/05/10 03:24:31 msaitoh Exp $	*/
+/*	$NetBSD: ppb.c,v 1.63.2.1 2019/02/01 11:25:13 martin Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.63 2017/05/10 03:24:31 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ppb.c,v 1.63.2.1 2019/02/01 11:25:13 martin Exp $");
 
 #include 
 #include 
@@ -214,6 +214,7 @@ ppbattach(device_t parent, device_t self
 	char intrbuf[PCI_INTRSTR_LEN];
 #endif
 	pcireg_t busdata, reg;
+	bool second_configured = false;
 
 	pci_aprint_devinfo(pa, NULL);
 
@@ -350,6 +351,73 @@ ppbattach(device_t parent, device_t self
 	}
 #endif /* PPB_USEINTR */
 
+	/* Configuration test */
+	if (PPB_BUSINFO_SECONDARY(busdata) != 0) {
+		uint32_t base, limit;
+
+		/* I/O region test */
+		reg = pci_conf_read(pc, pa->pa_tag, PCI_BRIDGE_STATIO_REG);
+		base = (reg & PCI_BRIDGE_STATIO_IOBASE_MASK) << 8;
+		limit = ((reg >> PCI_BRIDGE_STATIO_IOLIMIT_SHIFT)
+		& PCI_BRIDGE_STATIO_IOLIMIT_MASK) << 8;
+		limit |= 0x0fff;
+		if (PCI_BRIDGE_IO_32BITS(reg)) {
+			reg = pci_conf_read(pc, pa->pa_tag,
+			PCI_BRIDGE_IOHIGH_REG);
+			base |= ((reg >> PCI_BRIDGE_IOHIGH_BASE_SHIFT)
+			& 0x) << 16;
+			limit |= ((reg >> PCI_BRIDGE_IOHIGH_LIMIT_SHIFT)
+			& 0x) << 16;
+		}
+		if (base < limit) {
+			second_configured = true;
+			goto configure;
+		}
+
+		/* Non-prefetchable memory region test */
+		reg = pci_conf_read(pc, pa->pa_tag, PCI_BRIDGE_MEMORY_REG);
+		base = ((reg >> PCI_BRIDGE_MEMORY_BASE_SHIFT)
+		& PCI_BRIDGE_MEMORY_BASE_MASK) << 20;
+		limit = (((reg >> PCI_BRIDGE_MEMORY_LIMIT_SHIFT)
+		& PCI_BRIDGE_MEMORY_LIMIT_MASK) << 20) | 0x000f;
+		if (base < limit) {
+			second_configured = true;
+			goto configure;
+		}
+
+		/* Prefetchable memory region test */
+		reg = pci_conf_read(pc, pa->pa_tag,
+		PCI_BRIDGE_PREFETCHMEM_REG);
+		base = ((reg >> PCI_BRIDGE_PREFETCHMEM_BASE_SHIFT)
+		& PCI_BRIDGE_PREFETCHMEM_BASE_MASK) << 20;
+		limit = (((reg >> PCI_BRIDGE_PREFETCHMEM_LIMIT_SHIFT)
+			& PCI_BRIDGE_PREFETCHMEM_LIMIT_MASK) << 20) | 0x000f;
+		if (PCI_BRIDGE_PREFETCHMEM_64BITS(reg)) {
+			reg = pci_conf_read(pc, pa->pa_tag,
+			PCI_BRIDGE_IOHIGH_REG);
+			base |= (uint64_t)pci_conf_read(pc, pa->pa_tag,
+			PCI_BRIDGE_PREFETCHBASE32_REG) << 32;
+			limit |= (uint64_t)pci_conf_read(pc, pa->pa_tag,
+			PCI_BRIDGE_PREFETCHLIMIT32_REG) << 32;
+		}
+		if (base < limit) {
+			second_configured = true;
+			goto configure;
+		}
+	}
+
+configure:
+	/*
+	 * If the secondary bus is configured and the bus mastering is not
+	 * enabled, enable it.
+	 */
+	if (second_configured) {
+		reg = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+		if ((reg & PCI_COMMAND_MASTER_ENABLE) == 0)
+			pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+			reg | PCI_COMMAND_MASTER_ENABLE);
+	}
+
 	if (!pmf_device_register(self, ppb_suspend, ppb_resume))
 		aprint_error_dev(self, "couldn't establish power handler\n");
 



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

2019-01-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 31 06:43:48 UTC 2019

Modified Files:
src/sys/dev/mii [netbsd-8]: inbmphyreg.h
src/sys/dev/pci [netbsd-8]: if_wm.c if_wmreg.h if_wmvar.h

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

sys/dev/pci/if_wm.c 1.603-1.605,1.607-1.611,
1.613,1.615,1.618-1.620
via patch
sys/dev/pci/if_wmreg.h  1.110-1.111
sys/dev/pci/if_wmvar.h  1.40-1.42
sys/dev/mii/inbmphyreg.h1.13-1.15

- Add some code for suspend/resume:
  - Rename wm_smbustopci() to wm_init_phy_workarounds_pchlan(). It will
also called when resume.
  - Call wm_phy_resetisblocked() after PHY reset in
wm_init_phy_workarounds_pchlan() to wait for the PHY to quiesce to
an accessible state.
  - Add new wm_resume_workarounds_pchlan() function and use it in
wm_resume(). This workaround is only for PCH2 and newer.
  - Don't call wm_disable_aspm() neither in wm_attach() nor in
wm_resume() but in wm_reset().
  - Do some initialization in wm_resume() when IFF_UP is NOT set.
  - Don't continue when it failed to acquire semaphore in
wm_ulp_disable().
- Print CLSEM workaround bit correctly.
- Fix availability detection of WoL on some chips.
- Print the WUS (WakeUp Status) register bits when resume.
- Don't setup WoL on non-WoL capable port.
- Setup PHY wakeup feature on PCH and newer. Tested on Thinkpad X220.
- Remove an extra register read in
  wm_kmrn_lock_loss_workaround_ich8lan().
- Don't leave the MDICNFG register modified when the Power Management
  capability offset can't get.
- Reduce indent level of wm_linkintr_gmii(). No functional change.
- 80003's SERDES is not the same as 82575's but the same as legacy
  devices. Use the old methods on 80003.
- Use __nothing for null DPRINTF().
- Rename functions. Add comment.


To generate a diff of this commit:
cvs rdiff -u -r1.9.8.3 -r1.9.8.4 src/sys/dev/mii/inbmphyreg.h
cvs rdiff -u -r1.508.4.28 -r1.508.4.29 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.98.6.6 -r1.98.6.7 src/sys/dev/pci/if_wmreg.h
cvs rdiff -u -r1.33.6.3 -r1.33.6.4 src/sys/dev/pci/if_wmvar.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/inbmphyreg.h
diff -u src/sys/dev/mii/inbmphyreg.h:1.9.8.3 src/sys/dev/mii/inbmphyreg.h:1.9.8.4
--- src/sys/dev/mii/inbmphyreg.h:1.9.8.3	Tue Dec  4 11:21:32 2018
+++ src/sys/dev/mii/inbmphyreg.h	Thu Jan 31 06:43:48 2019
@@ -1,6 +1,6 @@
-/*	$NetBSD: inbmphyreg.h,v 1.9.8.3 2018/12/04 11:21:32 martin Exp $	*/
+/*	$NetBSD: inbmphyreg.h,v 1.9.8.4 2019/01/31 06:43:48 martin Exp $	*/
 /***
-Copyright (c) 2001-2005, Intel Corporation 
+Copyright (c) 2001-2015, Intel Corporation 
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without 
@@ -39,12 +39,16 @@ POSSIBILITY OF SUCH DAMAGE.
 #define	_DEV_MII_INBMPHYREG_H_
 
 /* Bits...
- * 15-5: page
- * 4-0: register offset
+ * 31-16: register offset (high)
+ * 15-5:  page
+ * 4-0:   register offset (low)
  */
-#define BME1000_PAGE_SHIFT5
+#define BME1000_PAGE_SHIFT	5
+#define BM_PHY_UPPER_SHIFT	21
 #define BME1000_REG(page, reg)\
-(((page) << BME1000_PAGE_SHIFT) | ((reg) & MII_ADDRMASK))
+(((reg) & MII_ADDRMASK) | 			\
+	(((page) & 0x) << BME1000_PAGE_SHIFT) |	\
+	(((reg) & ~MII_ADDRMASK) << (BM_PHY_UPPER_SHIFT - BME1000_PAGE_SHIFT)))
 
 #define BME1000_MAX_MULTI_PAGE_REG 0xf   /* Registers equal on all pages */
 
@@ -52,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
 	((uint16_t)(((offset) >> BME1000_PAGE_SHIFT) & 0x))
 #define	BM_PHY_REG_NUM(offset)\
 	((uint16_t)((offset) & MII_ADDRMASK)		\
-	| (((offset) >> (21 - BME1000_PAGE_SHIFT)) & ~MII_ADDRMASK))
+	| (((offset) >> (BM_PHY_UPPER_SHIFT - BME1000_PAGE_SHIFT)) & ~MII_ADDRMASK))
 
 /* BME1000 Specific Registers */
 #define BME1000_PHY_SPEC_CTRL	BME1000_REG(0, 16) /* PHY Specific Control */
@@ -126,6 +130,20 @@ POSSIBILITY OF SUCH DAMAGE.
 #define	IGP3_KMRN_DIAG		BME1000_REG(770, 19)
 #define	IGP3_KMRN_DIAG_PCS_LOCK_LOSS	(1 << 1)
 
+#define	I217_LPI_GPIO_CTRL	BME1000_REG(772, 18)
+#define	I217_LPI_GPIO_CTRL_AUTO_EN_LPI	__BIT(11)
+
+#define	I82579_LPI_CTRL		BME1000_REG(772, 20)
+#define	I82579_LPI_CTRL_ENABLE	__BITS(14, 13)
+#define	I82579_LPI_CTRL_EN_100	__BIT(13)
+#define	I82579_LPI_CTRL_EN_1000	__BIT(14)
+
+#define	I217_MEMPWR		BME1000_REG(772, 26)
+#define	I217_MEMPWR_DISABLE_SMB_RELEASE		0x0010
+
+#define	I217_CFGREG		BME1000_REG(772, 29)
+#define I217_CGFREG_ENABLE_MTA_RESET	0x0002
+
 #define HV_MUX_DATA_CTRL	BME1000_REG(776, 16)
 #define HV_MUX_DATA_CTRL_FORCE_SPEED	(1 << 2)
 #define HV_MUX_DATA_CTRL_GEN_TO_MAC	(1 << 10)
@@ -142,6 +160,16 @@ 

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

2019-01-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Jan 31 06:02:50 UTC 2019

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

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

sys/dev/pci/pci.c: revision 1.154

  Clearing PCI_PMCSR_PME_STS(W1C) bit is required to stop asserting PME#.

This change would prevent unexpected rebooting from shutdown -p or
unexpected resuming from suspend.


To generate a diff of this commit:
cvs rdiff -u -r1.152.6.1 -r1.152.6.2 src/sys/dev/pci/pci.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.c
diff -u src/sys/dev/pci/pci.c:1.152.6.1 src/sys/dev/pci/pci.c:1.152.6.2
--- src/sys/dev/pci/pci.c:1.152.6.1	Fri Dec  7 13:27:19 2018
+++ src/sys/dev/pci/pci.c	Thu Jan 31 06:02:50 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci.c,v 1.152.6.1 2018/12/07 13:27:19 martin Exp $	*/
+/*	$NetBSD: pci.c,v 1.152.6.2 2019/01/31 06:02:50 martin Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.152.6.1 2018/12/07 13:27:19 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.152.6.2 2019/01/31 06:02:50 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1221,16 +1221,36 @@ pci_child_suspend(device_t dv, const pmf
 	return true;
 }
 
+static void
+pci_pme_check_and_clear(device_t dv, pci_chipset_tag_t pc, pcitag_t tag,
+int off)
+{
+	pcireg_t pmcsr;
+
+	pmcsr = pci_conf_read(pc, tag, off + PCI_PMCSR);
+
+	if (pmcsr & PCI_PMCSR_PME_STS) {
+		/* Clear W1C bit */
+		pmcsr |= PCI_PMCSR_PME_STS;
+		pci_conf_write(pc, tag, off + PCI_PMCSR, pmcsr);
+		aprint_verbose_dev(dv, "Clear PME# now\n");
+	}
+}
+
 static bool
 pci_child_resume(device_t dv, const pmf_qual_t *qual)
 {
 	struct pci_child_power *priv = device_pmf_bus_private(dv);
 
-	if (priv->p_has_pm &&
-	pci_set_powerstate_int(priv->p_pc, priv->p_tag,
-	PCI_PMCSR_STATE_D0, priv->p_pm_offset, priv->p_pm_cap)) {
-		aprint_error_dev(dv, "unsupported state, continuing.\n");
-		return false;
+	if (priv->p_has_pm) {
+		if (pci_set_powerstate_int(priv->p_pc, priv->p_tag,
+		PCI_PMCSR_STATE_D0, priv->p_pm_offset, priv->p_pm_cap)) {
+			aprint_error_dev(dv,
+			"unsupported state, continuing.\n");
+			return false;
+		}
+		pci_pme_check_and_clear(dv, priv->p_pc, priv->p_tag,
+		priv->p_pm_offset);
 	}
 
 	pci_conf_restore(priv->p_pc, priv->p_tag, >p_pciconf);
@@ -1286,6 +1306,7 @@ pci_child_register(device_t child)
 		priv->p_has_pm = true;
 		priv->p_pm_offset = off;
 		priv->p_pm_cap = reg;
+		pci_pme_check_and_clear(child, priv->p_pc, priv->p_tag, off);
 	} else {
 		priv->p_has_pm = false;
 		priv->p_pm_offset = -1;



  1   2   3   4   >