CVS commit: src/sys/dev/pci

2022-08-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Aug  9 12:42:05 UTC 2022

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

Log Message:
virtio(4): Move comment for virtio_vq_intr.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/dev/pci/virtio.c:1.56
--- src/sys/dev/pci/virtio.c:1.55	Sat Jun 18 22:11:01 2022
+++ src/sys/dev/pci/virtio.c	Tue Aug  9 12:42:05 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.55 2022/06/18 22:11:01 andvar Exp $	*/
+/*	$NetBSD: virtio.c,v 1.56 2022/08/09 12:42:05 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.55 2022/06/18 22:11:01 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.56 2022/08/09 12:42:05 riastradh Exp $");
 
 #include 
 #include 
@@ -465,13 +465,6 @@ vq_sync_indirect(struct virtio_softc *sc
 			ops);
 }
 
-/*
- * Can be used as sc_intrhand.
- */
-/*
- * Scan vq, bus_dmamap_sync for the vqs (not for the payload),
- * and calls (*vq_done)() if some entries are consumed.
- */
 bool
 virtio_vq_is_enqueued(struct virtio_softc *sc, struct virtqueue *vq)
 {
@@ -486,6 +479,12 @@ virtio_vq_is_enqueued(struct virtio_soft
 	return (vq->vq_used_idx != virtio_rw16(sc, vq->vq_used->idx)) ? 1 : 0;
 }
 
+/*
+ * Scan vq, bus_dmamap_sync for the vqs (not for the payload),
+ * and calls (*vq_done)() if some entries are consumed.
+ *
+ * Can be used as sc_intrhand.
+ */
 int
 virtio_vq_intr(struct virtio_softc *sc)
 {



CVS commit: src/sys/dev/pci

2022-08-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Aug  9 12:42:05 UTC 2022

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

Log Message:
virtio(4): Move comment for virtio_vq_intr.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 08:55:43 UTC 2022

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

Log Message:
To avoid releasing mutex temporally, use new wm_set_mdio_slow_mode_hv_locked().


To generate a diff of this commit:
cvs rdiff -u -r1.756 -r1.757 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.756 src/sys/dev/pci/if_wm.c:1.757
--- src/sys/dev/pci/if_wm.c:1.756	Mon Aug  8 08:52:36 2022
+++ src/sys/dev/pci/if_wm.c	Mon Aug  8 08:55:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.756 2022/08/08 08:52:36 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.757 2022/08/08 08:55:42 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.756 2022/08/08 08:52:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.757 2022/08/08 08:55:42 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -1119,6 +1119,7 @@ static int	wm_k1_gig_workaround_hv(struc
 static int	wm_k1_workaround_lv(struct wm_softc *);
 static int	wm_link_stall_workaround_hv(struct wm_softc *);
 static int	wm_set_mdio_slow_mode_hv(struct wm_softc *);
+static int	wm_set_mdio_slow_mode_hv_locked(struct wm_softc *);
 static void	wm_configure_k1_ich8lan(struct wm_softc *, int);
 static void	wm_reset_init_script_82575(struct wm_softc *);
 static void	wm_reset_mdicnfg_82580(struct wm_softc *);
@@ -17136,13 +17137,32 @@ static int
 wm_set_mdio_slow_mode_hv(struct wm_softc *sc)
 {
 	int rv;
+
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
+		device_printf(sc->sc_dev, "%s: failed to get semaphore\n",
+		__func__);
+		return rv;
+	}
+
+	rv = wm_set_mdio_slow_mode_hv_locked(sc);
+
+	sc->phy.release(sc);
+
+	return rv;
+}
+
+static int
+wm_set_mdio_slow_mode_hv_locked(struct wm_softc *sc)
+{
+	int rv;
 	uint16_t reg;
 
-	rv = wm_gmii_hv_readreg(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, );
+	rv = wm_gmii_hv_readreg_locked(sc->sc_dev, 1, HV_KMRN_MODE_CTRL, );
 	if (rv != 0)
 		return rv;
 
-	return wm_gmii_hv_writereg(sc->sc_dev, 1, HV_KMRN_MODE_CTRL,
+	return wm_gmii_hv_writereg_locked(sc->sc_dev, 1, HV_KMRN_MODE_CTRL,
 	reg | HV_KMRN_MDIO_SLOW);
 }
 
@@ -17290,11 +17310,11 @@ wm_phy_is_accessible_pchlan(struct wm_so
 	 */
 	rv = 0;
 	if (sc->sc_type < WM_T_PCH_LPT) {
-		sc->phy.release(sc);
-		wm_set_mdio_slow_mode_hv(sc);
-		rv = wm_gmii_hv_readreg(sc->sc_dev, 2, MII_PHYIDR1, );
-		rv |= wm_gmii_hv_readreg(sc->sc_dev, 2, MII_PHYIDR2, );
-		sc->phy.acquire(sc);
+		wm_set_mdio_slow_mode_hv_locked(sc);
+		rv = wm_gmii_hv_readreg_locked(sc->sc_dev, 2, MII_PHYIDR1,
+		);
+		rv |= wm_gmii_hv_readreg_locked(sc->sc_dev, 2, MII_PHYIDR2,
+		);
 	}
 	if ((rv != 0) || MII_INVALIDID(id1) || MII_INVALIDID(id2)) {
 		device_printf(sc->sc_dev, "XXX return with false\n");



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 08:55:43 UTC 2022

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

Log Message:
To avoid releasing mutex temporally, use new wm_set_mdio_slow_mode_hv_locked().


To generate a diff of this commit:
cvs rdiff -u -r1.756 -r1.757 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.



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 08:52:37 UTC 2022

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

Log Message:
Consistency use -1 instead of 1 for some error code. Advised by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.755 -r1.756 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.755 src/sys/dev/pci/if_wm.c:1.756
--- src/sys/dev/pci/if_wm.c:1.755	Mon Aug  8 07:49:18 2022
+++ src/sys/dev/pci/if_wm.c	Mon Aug  8 08:52:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.755 2022/08/08 07:49:18 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.756 2022/08/08 08:52:36 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.755 2022/08/08 07:49:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.756 2022/08/08 08:52:36 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -14567,7 +14567,7 @@ wm_nvm_validate_checksum(struct wm_softc
 
 	for (i = 0; i < NVM_SIZE; i++) {
 		if (wm_nvm_read(sc, i, 1, _data))
-			return 1;
+			return -1;
 		checksum += eeprom_data;
 	}
 
@@ -14917,7 +14917,7 @@ retry:
 			goto retry;
 		}
 		aprint_error_dev(sc->sc_dev, "could not acquire SWSM SMBI\n");
-		return 1;
+		return -1;
 	}
 
 	/* Get the FW semaphore. */
@@ -14940,7 +14940,7 @@ retry:
 		"could not acquire SWSM SWESMBI\n");
 		/* Release semaphores */
 		wm_put_swsm_semaphore(sc);
-		return 1;
+		return -1;
 	}
 	return 0;
 }
@@ -14987,7 +14987,7 @@ wm_get_swfw_semaphore(struct wm_softc *s
 			aprint_error_dev(sc->sc_dev,
 			"%s: failed to get semaphore\n",
 			__func__);
-			return 1;
+			return -1;
 		}
 		swfw_sync = CSR_READ(sc, WMREG_SW_FW_SYNC);
 		if ((swfw_sync & (swmask | fwmask)) == 0) {
@@ -15003,7 +15003,7 @@ wm_get_swfw_semaphore(struct wm_softc *s
 	device_printf(sc->sc_dev,
 	"failed to get swfw semaphore mask 0x%x swfw 0x%x\n",
 	mask, swfw_sync);
-	return 1;
+	return -1;
 }
 
 static void
@@ -15151,7 +15151,7 @@ wm_get_swfwhw_semaphore(struct wm_softc 
 	device_printf(sc->sc_dev,
 	"failed to get swfwhw semaphore ext_ctrl 0x%x\n", ext_ctrl);
 	mutex_exit(sc->sc_ich_phymtx); /* Use PHY mtx for both PHY and NVM */
-	return 1;
+	return -1;
 }
 
 static void
@@ -15208,7 +15208,7 @@ wm_get_swflag_ich8lan(struct wm_softc *s
 
 out:
 	mutex_exit(sc->sc_ich_phymtx);
-	return 1;
+	return -1;
 }
 
 static void



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 08:52:37 UTC 2022

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

Log Message:
Consistency use -1 instead of 1 for some error code. Advised by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.755 -r1.756 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.



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 07:49:18 UTC 2022

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

Log Message:
Pass an error code correctly if phy.acquire() failed.

This is not a real bug because the return value is not used.


To generate a diff of this commit:
cvs rdiff -u -r1.754 -r1.755 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.



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 07:49:18 UTC 2022

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

Log Message:
Pass an error code correctly if phy.acquire() failed.

This is not a real bug because the return value is not used.


To generate a diff of this commit:
cvs rdiff -u -r1.754 -r1.755 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.754 src/sys/dev/pci/if_wm.c:1.755
--- src/sys/dev/pci/if_wm.c:1.754	Mon Aug  8 07:44:40 2022
+++ src/sys/dev/pci/if_wm.c	Mon Aug  8 07:49:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.754 2022/08/08 07:44:40 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.755 2022/08/08 07:49:18 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.754 2022/08/08 07:44:40 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.755 2022/08/08 07:49:18 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -16399,9 +16399,10 @@ wm_set_eee_pchlan(struct wm_softc *sc)
 		return 0;
 	}
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return 0;
+		return rv;
 	}
 
 	rv = sc->phy.readreg_locked(dev, 1, I82579_LPI_CTRL, _ctrl);



CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 07:44:40 UTC 2022

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

Log Message:
Pass an error code to the upper layer instead of -1. Advised by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.753 -r1.754 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.753 src/sys/dev/pci/if_wm.c:1.754
--- src/sys/dev/pci/if_wm.c:1.753	Mon Aug  8 05:45:29 2022
+++ src/sys/dev/pci/if_wm.c	Mon Aug  8 07:44:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.753 2022/08/08 05:45:29 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.754 2022/08/08 07:44:40 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.753 2022/08/08 05:45:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.754 2022/08/08 07:44:40 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4745,7 +4745,7 @@ wm_write_smbus_addr(struct wm_softc *sc)
 
 	rv = wm_gmii_hv_readreg_locked(sc->sc_dev, 2, HV_SMB_ADDR, _data);
 	if (rv != 0)
-		return -1;
+		return rv;
 
 	phy_data &= ~HV_SMB_ADDR_ADDR;
 	phy_data |= __SHIFTOUT(strap, STRAP_SMBUSADDR);
@@ -11627,9 +11627,10 @@ wm_gmii_i82544_readreg(device_t dev, int
 	struct wm_softc *sc = device_private(dev);
 	int rv;
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc); 
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	rv = wm_gmii_i82544_readreg_locked(dev, phy, reg, val);
@@ -11678,9 +11679,10 @@ wm_gmii_i82544_writereg(device_t dev, in
 	struct wm_softc *sc = device_private(dev);
 	int rv;
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	rv = wm_gmii_i82544_writereg_locked(dev, phy, reg & MII_ADDRMASK, val);
@@ -11730,14 +11732,15 @@ wm_gmii_i80003_readreg(device_t dev, int
 	struct wm_softc *sc = device_private(dev);
 	int page_select;
 	uint16_t temp, temp2;
-	int rv = 0;
+	int rv;
 
 	if (phy != 1) /* Only one PHY on kumeran bus */
 		return -1;
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	if ((reg & MII_ADDRMASK) < GG82563_MIN_ALT_REG)
@@ -11793,9 +11796,10 @@ wm_gmii_i80003_writereg(device_t dev, in
 	if (phy != 1) /* Only one PHY on kumeran bus */
 		return -1;
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc); 
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	if ((reg & MII_ADDRMASK) < GG82563_MIN_ALT_REG)
@@ -11848,9 +11852,10 @@ wm_gmii_bm_readreg(device_t dev, int phy
 	uint16_t page = reg >> BME1000_PAGE_SHIFT;
 	int rv;
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	if ((sc->sc_type != WM_T_82574) && (sc->sc_type != WM_T_82583))
@@ -11895,9 +11900,10 @@ wm_gmii_bm_writereg(device_t dev, int ph
 	uint16_t page = reg >> BME1000_PAGE_SHIFT;
 	int rv;
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	if ((sc->sc_type != WM_T_82574) && (sc->sc_type != WM_T_82583))
@@ -12113,9 +12119,11 @@ wm_gmii_hv_readreg(device_t dev, int phy
 
 	DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n",
 		device_xname(dev), __func__));
-	if (sc->phy.acquire(sc)) {
+
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	rv = wm_gmii_hv_readreg_locked(dev, phy, reg, val);
@@ -12178,9 +12186,10 @@ wm_gmii_hv_writereg(device_t dev, int ph
 	DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n",
 		device_xname(dev), __func__));
 
-	if (sc->phy.acquire(sc)) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 	rv = wm_gmii_hv_writereg_locked(dev, phy, reg, val);
@@ -12261,9 +12270,10 @@ wm_gmii_82580_readreg(device_t dev, int 
 	struct wm_softc *sc = device_private(dev);
 	int rv;
 
-	if (sc->phy.acquire(sc) != 0) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get semaphore\n", __func__);
-		return -1;
+		return rv;
 	}
 
 #ifdef DIAGNOSTIC
@@ -12292,9 +12302,10 @@ wm_gmii_82580_writereg(device_t dev, int
 	struct wm_softc *sc = device_private(dev);
 	int rv;
 
-	if (sc->phy.acquire(sc) != 0) {
+	rv = sc->phy.acquire(sc);
+	if (rv != 0) {
 		device_printf(dev, "%s: failed to get 

CVS commit: src/sys/dev/pci

2022-08-08 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 07:44:40 UTC 2022

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

Log Message:
Pass an error code to the upper layer instead of -1. Advised by knakahara.


To generate a diff of this commit:
cvs rdiff -u -r1.753 -r1.754 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.



CVS commit: src/sys/dev/pci

2022-08-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 05:45:29 UTC 2022

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

Log Message:
Modify debug messages so that we can determine where it happened.


To generate a diff of this commit:
cvs rdiff -u -r1.752 -r1.753 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.752 src/sys/dev/pci/if_wm.c:1.753
--- src/sys/dev/pci/if_wm.c:1.752	Fri Aug  5 05:50:54 2022
+++ src/sys/dev/pci/if_wm.c	Mon Aug  8 05:45:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.752 2022/08/05 05:50:54 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.753 2022/08/08 05:45:29 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.752 2022/08/05 05:50:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.753 2022/08/08 05:45:29 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -15558,7 +15558,7 @@ wm_init_phy_workarounds_pchlan(struct wm
 break;
 
 		if (wm_phy_resetisblocked(sc) == true) {
-			device_printf(sc->sc_dev, "XXX reset is blocked(3)\n");
+			device_printf(sc->sc_dev, "XXX reset is blocked(2)\n");
 			break;
 		}
 
@@ -15591,7 +15591,7 @@ wm_init_phy_workarounds_pchlan(struct wm
 	if (rv == 0) {
 		/* Check to see if able to reset PHY.  Print error if not */
 		if (wm_phy_resetisblocked(sc)) {
-			device_printf(sc->sc_dev, "XXX reset is blocked(4)\n");
+			device_printf(sc->sc_dev, "XXX reset is blocked(3)\n");
 			goto out;
 		}
 



CVS commit: src/sys/dev/pci

2022-08-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Aug  8 05:45:29 UTC 2022

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

Log Message:
Modify debug messages so that we can determine where it happened.


To generate a diff of this commit:
cvs rdiff -u -r1.752 -r1.753 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.



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:37:48 UTC 2022

Modified Files:
src/sys/dev/pci: if_bge.c if_bgevar.h

Log Message:
Provide and use (when appropriate) a bge_free_jumbo_mem.


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/if_bgevar.h

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



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:37:48 UTC 2022

Modified Files:
src/sys/dev/pci: if_bge.c if_bgevar.h

Log Message:
Provide and use (when appropriate) a bge_free_jumbo_mem.


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/sys/dev/pci/if_bge.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/if_bgevar.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.372 src/sys/dev/pci/if_bge.c:1.373
--- src/sys/dev/pci/if_bge.c:1.372	Sun Aug  7 08:26:18 2022
+++ src/sys/dev/pci/if_bge.c	Sun Aug  7 08:37:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.372 2022/08/07 08:26:18 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.373 2022/08/07 08:37:48 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.372 2022/08/07 08:26:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.373 2022/08/07 08:37:48 skrll Exp $");
 
 #include 
 #include 
@@ -223,9 +223,7 @@ static void bge_setmulti(struct bge_soft
 
 static void bge_handle_events(struct bge_softc *);
 static int bge_alloc_jumbo_mem(struct bge_softc *);
-#if 0 /* XXX */
 static void bge_free_jumbo_mem(struct bge_softc *);
-#endif
 static void *bge_jalloc(struct bge_softc *);
 static void bge_jfree(struct mbuf *, void *, size_t, void *);
 static int bge_newbuf_std(struct bge_softc *, int, struct mbuf *,
@@ -1313,7 +1311,6 @@ static int
 bge_alloc_jumbo_mem(struct bge_softc *sc)
 {
 	char *ptr, *kva;
-	bus_dma_segment_t	seg;
 	int		i, rseg, state, error;
 	struct bge_jpool_entry	 *entry;
 
@@ -1321,13 +1318,14 @@ bge_alloc_jumbo_mem(struct bge_softc *sc
 
 	/* Grab a big chunk o' storage. */
 	if (bus_dmamem_alloc(sc->bge_dmatag, BGE_JMEM, PAGE_SIZE, 0,
-	, 1, , BUS_DMA_NOWAIT)) {
+	>bge_cdata.bge_rx_jumbo_seg, 1, , BUS_DMA_NOWAIT)) {
 		aprint_error_dev(sc->bge_dev, "can't alloc rx buffers\n");
 		return ENOBUFS;
 	}
 
 	state = 1;
-	if (bus_dmamem_map(sc->bge_dmatag, , rseg, BGE_JMEM, (void **),
+	if (bus_dmamem_map(sc->bge_dmatag, >bge_cdata.bge_rx_jumbo_seg,
+	rseg, BGE_JMEM, (void **),
 	BUS_DMA_NOWAIT)) {
 		aprint_error_dev(sc->bge_dev,
 		"can't map DMA buffers (%d bytes)\n", (int)BGE_JMEM);
@@ -1386,7 +1384,8 @@ out:
 			bus_dmamem_unmap(sc->bge_dmatag, kva, BGE_JMEM);
 			/* FALLTHROUGH */
 		case 1:
-			bus_dmamem_free(sc->bge_dmatag, , rseg);
+			bus_dmamem_free(sc->bge_dmatag,
+			>bge_cdata.bge_rx_jumbo_seg, rseg);
 			break;
 		default:
 			break;
@@ -1396,6 +1395,26 @@ out:
 	return error;
 }
 
+static void
+bge_free_jumbo_mem(struct bge_softc *sc)
+{
+	struct bge_jpool_entry *entry, *tmp;
+
+	KASSERT(SLIST_EMPTY(>bge_jinuse_listhead));
+
+	SLIST_FOREACH_SAFE(entry, >bge_jfree_listhead, jpool_entries, tmp) {
+		kmem_free(entry, sizeof(*entry));
+	}
+
+	bus_dmamap_unload(sc->bge_dmatag, sc->bge_cdata.bge_rx_jumbo_map);
+
+	bus_dmamap_destroy(sc->bge_dmatag, sc->bge_cdata.bge_rx_jumbo_map);
+
+	bus_dmamem_unmap(sc->bge_dmatag, sc->bge_cdata.bge_jumbo_buf, BGE_JMEM);
+
+	bus_dmamem_free(sc->bge_dmatag, >bge_cdata.bge_rx_jumbo_seg, 1);
+}
+
 /*
  * Allocate a jumbo buffer.
  */
@@ -4071,6 +4090,9 @@ bge_release_resources(struct bge_softc *
 		sc->bge_intrhand = NULL;
 	}
 
+	if (sc->bge_cdata.bge_jumbo_buf != NULL)
+		bge_free_jumbo_mem(sc);
+
 	if (sc->bge_dmatag != NULL) {
 		bus_dmamap_unload(sc->bge_dmatag, sc->bge_ring_map);
 		bus_dmamap_destroy(sc->bge_dmatag, sc->bge_ring_map);

Index: src/sys/dev/pci/if_bgevar.h
diff -u src/sys/dev/pci/if_bgevar.h:1.30 src/sys/dev/pci/if_bgevar.h:1.31
--- src/sys/dev/pci/if_bgevar.h:1.30	Mon Jul 25 08:29:14 2022
+++ src/sys/dev/pci/if_bgevar.h	Sun Aug  7 08:37:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgevar.h,v 1.30 2022/07/25 08:29:14 skrll Exp $	*/
+/*	$NetBSD: if_bgevar.h,v 1.31 2022/08/07 08:37:48 skrll Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -218,6 +218,7 @@ struct bge_chain_data {
 	struct mbuf		*bge_rx_jumbo_chain[BGE_JUMBO_RX_RING_CNT];
 	bus_dmamap_t		bge_rx_std_map[BGE_STD_RX_RING_CNT];
 	bus_dmamap_t		bge_rx_jumbo_map;
+	bus_dma_segment_t	bge_rx_jumbo_seg;
 	/* Stick the jumbo mem management stuff here too. */
 	void *			bge_jslots[BGE_JSLOTS];
 	void *			bge_jumbo_buf;



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:26:19 UTC 2022

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

Log Message:
Misc tidyup. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 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.



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:26:19 UTC 2022

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

Log Message:
Misc tidyup. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 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.371 src/sys/dev/pci/if_bge.c:1.372
--- src/sys/dev/pci/if_bge.c:1.371	Sun Aug  7 08:24:23 2022
+++ src/sys/dev/pci/if_bge.c	Sun Aug  7 08:26:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.371 2022/08/07 08:24:23 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.372 2022/08/07 08:26:18 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.371 2022/08/07 08:24:23 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.372 2022/08/07 08:26:18 skrll Exp $");
 
 #include 
 #include 
@@ -5603,10 +5603,10 @@ bge_init(struct ifnet *ifp)
 	 * entry of the ring.
 	 */
 	if (sc->bge_chipid == BGE_CHIPID_BCM5705_A0) {
-		uint32_t		v, i;
+		u_int i;
 		for (i = 0; i < 10; i++) {
 			DELAY(20);
-			v = bge_readmem_ind(sc, BGE_STD_RX_RINGS + 8);
+			uint32_t v = bge_readmem_ind(sc, BGE_STD_RX_RINGS + 8);
 			if (v == (MCLBYTES - ETHER_ALIGN))
 break;
 		}



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:24:24 UTC 2022

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

Log Message:
Unwrap a long line and remove unecessary brackets. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 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.370 src/sys/dev/pci/if_bge.c:1.371
--- src/sys/dev/pci/if_bge.c:1.370	Sun Aug  7 08:19:38 2022
+++ src/sys/dev/pci/if_bge.c	Sun Aug  7 08:24:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.370 2022/08/07 08:19:38 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.371 2022/08/07 08:24:23 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.370 2022/08/07 08:19:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.371 2022/08/07 08:24:23 skrll Exp $");
 
 #include 
 #include 
@@ -1424,17 +1424,15 @@ bge_jfree(struct mbuf *m, void *buf, siz
 {
 	struct bge_jpool_entry *entry;
 	struct bge_softc * const sc = arg;
-	int i, s;
+	int s;
 
 	if (sc == NULL)
 		panic("bge_jfree: can't find softc pointer!");
 
 	/* calculate the slot this buffer belongs to */
+	int i = ((char *)buf - (char *)sc->bge_cdata.bge_jumbo_buf) / BGE_JLEN;
 
-	i = ((char *)buf
-	 - (char *)sc->bge_cdata.bge_jumbo_buf) / BGE_JLEN;
-
-	if ((i < 0) || (i >= BGE_JSLOTS))
+	if (i < 0 || i >= BGE_JSLOTS)
 		panic("bge_jfree: asked to free buffer that we don't manage!");
 
 	s = splvm();



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:24:24 UTC 2022

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

Log Message:
Unwrap a long line and remove unecessary brackets. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.370 -r1.371 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.



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:19:39 UTC 2022

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

Log Message:
Fix the KNF. oops.


To generate a diff of this commit:
cvs rdiff -u -r1.369 -r1.370 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.369 src/sys/dev/pci/if_bge.c:1.370
--- src/sys/dev/pci/if_bge.c:1.369	Sun Aug  7 08:12:47 2022
+++ src/sys/dev/pci/if_bge.c	Sun Aug  7 08:19:38 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.369 2022/08/07 08:12:47 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.370 2022/08/07 08:19:38 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,10 +79,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.369 2022/08/07 08:12:47 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.370 2022/08/07 08:19:38 skrll Exp $");
 
 #include 
-#include 
+#include 
 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:19:39 UTC 2022

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

Log Message:
Fix the KNF. oops.


To generate a diff of this commit:
cvs rdiff -u -r1.369 -r1.370 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.



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:12:47 UTC 2022

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

Log Message:
whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.368 -r1.369 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.368 src/sys/dev/pci/if_bge.c:1.369
--- src/sys/dev/pci/if_bge.c:1.368	Sun Aug  7 07:48:19 2022
+++ src/sys/dev/pci/if_bge.c	Sun Aug  7 08:12:47 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.368 2022/08/07 07:48:19 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.369 2022/08/07 08:12:47 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.368 2022/08/07 07:48:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.369 2022/08/07 08:12:47 skrll Exp $");
 
 #include 
 #include 
@@ -279,7 +279,7 @@ static void bge_ape_driver_state_change(
 #define BGE_TSO_PRINTF(x)  do { if (bge_tso_debug) printf x ;} while (0)
 int	bgedebug = 0;
 int	bge_tso_debug = 0;
-void		bge_debug_info(struct bge_softc *);
+void	bge_debug_info(struct bge_softc *);
 #else
 #define DPRINTF(x)
 #define DPRINTFN(n, x)



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 08:12:47 UTC 2022

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

Log Message:
whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.368 -r1.369 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.



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 07:48:19 UTC 2022

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.367 -r1.368 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.367 src/sys/dev/pci/if_bge.c:1.368
--- src/sys/dev/pci/if_bge.c:1.367	Tue Jul 26 14:53:12 2022
+++ src/sys/dev/pci/if_bge.c	Sun Aug  7 07:48:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.367 2022/07/26 14:53:12 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.368 2022/08/07 07:48:19 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,9 +79,10 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.367 2022/07/26 14:53:12 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.368 2022/08/07 07:48:19 skrll Exp $");
 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2022-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug  7 07:48:19 UTC 2022

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.367 -r1.368 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.



CVS commit: src/sys/dev/pci

2022-08-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug  6 15:38:42 UTC 2022

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

Log Message:
sip(4): Tidy up DMA syncs.

- No membar_producer in sip_init_rxdesc -- use bus_dmamap_sync with
  BUS_DMASYNC_PREWRITE to order updates to the DMA descriptors.

- Omit needless membar_producer in sip_init_txdesc -- the hardware
  will not look at any of these descriptors until we set CMDSTS_OWN
  on the first one in the sequence, which is done later in the
  caller, sipcom_start.

- In gsip_rxintr, make sure to read cmdsts _before_ extsts, by
  separating them with BUS_DMASYNC_PREREAD.  Otherwise, the CPU might
  reorder the loads and read a stale extsts first before witnessing
  an updated cmdsts with the CMDSTS_OWN bit that transfers ownership
  of the rx packet to us.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/dev/pci/if_sip.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_sip.c
diff -u src/sys/dev/pci/if_sip.c:1.186 src/sys/dev/pci/if_sip.c:1.187
--- src/sys/dev/pci/if_sip.c:1.186	Tue May 24 20:50:19 2022
+++ src/sys/dev/pci/if_sip.c	Sat Aug  6 15:38:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_sip.c,v 1.186 2022/05/24 20:50:19 andvar Exp $	*/
+/*	$NetBSD: if_sip.c,v 1.187 2022/08/06 15:38:42 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.186 2022/05/24 20:50:19 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sip.c,v 1.187 2022/08/06 15:38:42 riastradh Exp $");
 
 #include 
 #include 
@@ -569,7 +569,6 @@ sip_init_txdesc(struct sip_softc *sc, in
 		sipd->sipd_words[sc->sc_bufptr_idx] = htole32(bufptr);
 	}
 	sipd->sipd_words[sc->sc_extsts_idx] = 0;
-	membar_producer();
 	sipd->sipd_words[sc->sc_cmdsts_idx] = htole32(cmdsts);
 	/* sip_cdtxsync() will be done later. */
 }
@@ -596,7 +595,7 @@ sip_init_rxdesc(struct sip_softc *sc, in
 		htole32(rxs->rxs_dmamap->dm_segs[0].ds_addr);
 	}
 	sipd->sipd_words[sc->sc_extsts_idx] = 0;
-	membar_producer();
+	sip_cdrxsync(sc, x, BUS_DMASYNC_PREWRITE);
 	sipd->sipd_words[sc->sc_cmdsts_idx] =
 	htole32(CMDSTS_INTR | (sc->sc_parm->p_rxbuf_len &
 				   sc->sc_bits.b_cmdsts_size_mask));
@@ -2126,9 +2125,6 @@ gsip_rxintr(struct sip_softc *sc)
 
 		cmdsts =
 		le32toh(sc->sc_rxdescs[i].sipd_words[sc->sc_cmdsts_idx]);
-		extsts =
-		le32toh(sc->sc_rxdescs[i].sipd_words[sc->sc_extsts_idx]);
-		len = CMDSTS_SIZE(sc, cmdsts);
 
 		/*
 		 * NOTE: OWN is set if owned by _consumer_.  We're the
@@ -2142,6 +2138,12 @@ gsip_rxintr(struct sip_softc *sc)
 			break;
 		}
 
+		sip_cdrxsync(sc, i, BUS_DMASYNC_POSTREAD);
+
+		extsts =
+		le32toh(sc->sc_rxdescs[i].sipd_words[sc->sc_extsts_idx]);
+		len = CMDSTS_SIZE(sc, cmdsts);
+
 		if (__predict_false(sc->sc_rxdiscard)) {
 			sip_init_rxdesc(sc, i);
 			if ((cmdsts & CMDSTS_MORE) == 0) {



CVS commit: src/sys/dev/pci

2022-08-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug  6 15:38:42 UTC 2022

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

Log Message:
sip(4): Tidy up DMA syncs.

- No membar_producer in sip_init_rxdesc -- use bus_dmamap_sync with
  BUS_DMASYNC_PREWRITE to order updates to the DMA descriptors.

- Omit needless membar_producer in sip_init_txdesc -- the hardware
  will not look at any of these descriptors until we set CMDSTS_OWN
  on the first one in the sequence, which is done later in the
  caller, sipcom_start.

- In gsip_rxintr, make sure to read cmdsts _before_ extsts, by
  separating them with BUS_DMASYNC_PREREAD.  Otherwise, the CPU might
  reorder the loads and read a stale extsts first before witnessing
  an updated cmdsts with the CMDSTS_OWN bit that transfers ownership
  of the rx packet to us.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/dev/pci/if_sip.c

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



CVS commit: src/sys/dev/pci

2022-08-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  5 05:50:54 UTC 2022

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

Log Message:
Sprinkle const on splfoo call results.


To generate a diff of this commit:
cvs rdiff -u -r1.751 -r1.752 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.



CVS commit: src/sys/dev/pci

2022-08-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Aug  5 05:50:54 UTC 2022

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

Log Message:
Sprinkle const on splfoo call results.


To generate a diff of this commit:
cvs rdiff -u -r1.751 -r1.752 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.751 src/sys/dev/pci/if_wm.c:1.752
--- src/sys/dev/pci/if_wm.c:1.751	Wed Aug  3 05:29:04 2022
+++ src/sys/dev/pci/if_wm.c	Fri Aug  5 05:50:54 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.751 2022/08/03 05:29:04 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.752 2022/08/05 05:50:54 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.751 2022/08/03 05:29:04 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.752 2022/08/05 05:50:54 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3967,7 +3967,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 	struct ifreq *ifr = (struct ifreq *)data;
 	struct ifaddr *ifa = (struct ifaddr *)data;
 	struct sockaddr_dl *sdl;
-	int s, error;
+	int error;
 
 	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
@@ -3981,7 +3981,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 	}
 
 #ifndef WM_MPSAFE
-	s = splnet();
+	const int s = splnet();
 #endif
 	switch (cmd) {
 	case SIOCSIFMEDIA:
@@ -4034,7 +4034,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 			}
 		}
 #ifdef WM_MPSAFE
-		s = splnet();
+		const int s = splnet();
 #endif
 		/* It may call wm_start, so unlock here */
 		error = ether_ioctl(ifp, cmd, data);



CVS commit: src/sys/dev/pci

2022-08-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Aug  4 21:11:52 UTC 2022

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

Log Message:
s/bufferred/buffered/ in memory description.L:


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/pci/if_bnx.c

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



CVS commit: src/sys/dev/pci

2022-08-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Aug  4 21:11:52 UTC 2022

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

Log Message:
s/bufferred/buffered/ in memory description.L:


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/dev/pci/if_bnx.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_bnx.c
diff -u src/sys/dev/pci/if_bnx.c:1.110 src/sys/dev/pci/if_bnx.c:1.111
--- src/sys/dev/pci/if_bnx.c:1.110	Sun Dec  5 02:52:17 2021
+++ src/sys/dev/pci/if_bnx.c	Thu Aug  4 21:11:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bnx.c,v 1.110 2021/12/05 02:52:17 msaitoh Exp $	*/
+/*	$NetBSD: if_bnx.c,v 1.111 2022/08/04 21:11:52 andvar Exp $	*/
 /*	$OpenBSD: if_bnx.c,v 1.101 2013/03/28 17:21:44 brad Exp $	*/
 
 /*-
@@ -35,7 +35,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.110 2021/12/05 02:52:17 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.111 2022/08/04 21:11:52 andvar Exp $");
 
 /*
  * The following controllers are supported by this driver:
@@ -216,12 +216,12 @@ static struct flash_spec flash_table[] =
 	{0x1902, 0x5b808201, 0x000500db, 0x03840253, 0xaf020406,
 	 NONBUFFERED_FLAGS, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
 	 ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*2,
-	 "Entry 0101: ST M45PE10 (128kB non-bufferred)"},
+	 "Entry 0101: ST M45PE10 (128kB non-buffered)"},
 	/* Entry 0110: ST M45PE20 (non-buffered flash)*/
 	{0x1501, 0x57808201, 0x000500db, 0x03840253, 0xaf020406,
 	 NONBUFFERED_FLAGS, ST_MICRO_FLASH_PAGE_BITS, ST_MICRO_FLASH_PAGE_SIZE,
 	 ST_MICRO_FLASH_BYTE_ADDR_MASK, ST_MICRO_FLASH_BASE_TOTAL_SIZE*4,
-	 "Entry 0110: ST M45PE20 (256kB non-bufferred)"},
+	 "Entry 0110: ST M45PE20 (256kB non-buffered)"},
 	/* Saifun SA25F005 (non-buffered flash) */
 	/* strap, cfg1, & write1 need updates */
 	{0x1d03, 0x5f808201, 0x00050081, 0x03840253, 0xaf020406,



Re: CVS commit: src/sys/dev/pci

2022-08-03 Thread Nick Hudson




On 03/08/2022 07:26, Kengo NAKAHARA wrote:

Hi,

On 2022/08/03 14:23, Nick Hudson wrote:

Module Name:    src
Committed By:    skrll
Date:    Wed Aug  3 05:23:30 UTC 2022

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

Log Message:
Add some KASSERTs around the locking protocol.

Discussed with msaitoh@, knakahara@ and riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.749 -r1.750 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.


Will you add "KASSERT(IFNET_LOCKED(ifp))" to all ethernet device driver
init routine?  If not, why the code is added wm(4) only?


Good questions.

While I don't see the problem with documenting the locking protocol this
way and flushing out bugs with the KASSERTs I don't proposed to
(personally) add them to every driver at this time.

My motivation here is is that I'm making bge(4) MP safe and using wm(4)
as a reference. It's even mentioned as a reference for the if_percpuq
framework.

https://nxr.netbsd.org/xref/src/sys/net/if.c#814

Perhaps as a driver is made MP safe it can also have similar KASSERTs added?

Nick



Re: CVS commit: src/sys/dev/pci

2022-08-03 Thread Kengo NAKAHARA

Hi,

On 2022/08/03 14:23, Nick Hudson wrote:

Module Name:src
Committed By:   skrll
Date:   Wed Aug  3 05:23:30 UTC 2022

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

Log Message:
Add some KASSERTs around the locking protocol.

Discussed with msaitoh@, knakahara@ and riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.749 -r1.750 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.


Will you add "KASSERT(IFNET_LOCKED(ifp))" to all ethernet device driver
init routine?  If not, why the code is added wm(4) only?


Thanks,

--
//
Internet Initiative Japan Inc.

Device Engineering Section,
Product Division,
Technology Unit

Kengo NAKAHARA 




CVS commit: src/sys/dev/pci

2022-08-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug  3 05:29:04 UTC 2022

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

Log Message:
Add a KASSERT for the locking protocol in wm_ioctl.

Read the interface up/down status from sc_if_flags (under WM_CORE_LOCK)
when deciding if the multicast filter needs to be updated.

Discussed with msaitoh@, knakahara@ and riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.750 -r1.751 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.750 src/sys/dev/pci/if_wm.c:1.751
--- src/sys/dev/pci/if_wm.c:1.750	Wed Aug  3 05:23:30 2022
+++ src/sys/dev/pci/if_wm.c	Wed Aug  3 05:29:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.750 2022/08/03 05:23:30 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.751 2022/08/03 05:29:04 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.750 2022/08/03 05:23:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.751 2022/08/03 05:29:04 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3972,6 +3972,14 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
+	switch (cmd) {
+	case SIOCADDMULTI:
+	case SIOCDELMULTI:
+		break;
+	default:
+		KASSERT(IFNET_LOCKED(ifp));
+	}
+
 #ifndef WM_MPSAFE
 	s = splnet();
 #endif
@@ -4040,15 +4048,15 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, 
 
 		if (cmd == SIOCSIFCAP)
 			error = if_init(ifp);
-		else if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI)
-			;
-		else if (ifp->if_flags & IFF_RUNNING) {
-			/*
-			 * Multicast list has changed; set the hardware filter
-			 * accordingly.
-			 */
+		else if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) {
 			WM_CORE_LOCK(sc);
-			wm_set_filter(sc);
+			if (sc->sc_if_flags & IFF_RUNNING) {
+/*
+ * Multicast list has changed; set the hardware filter
+ * accordingly.
+ */
+wm_set_filter(sc);
+			}
 			WM_CORE_UNLOCK(sc);
 		}
 		break;



CVS commit: src/sys/dev/pci

2022-08-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug  3 05:29:04 UTC 2022

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

Log Message:
Add a KASSERT for the locking protocol in wm_ioctl.

Read the interface up/down status from sc_if_flags (under WM_CORE_LOCK)
when deciding if the multicast filter needs to be updated.

Discussed with msaitoh@, knakahara@ and riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.750 -r1.751 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.



CVS commit: src/sys/dev/pci

2022-08-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug  3 05:23:30 UTC 2022

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

Log Message:
Add some KASSERTs around the locking protocol.

Discussed with msaitoh@, knakahara@ and riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.749 -r1.750 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.749 src/sys/dev/pci/if_wm.c:1.750
--- src/sys/dev/pci/if_wm.c:1.749	Fri Jul 29 15:30:42 2022
+++ src/sys/dev/pci/if_wm.c	Wed Aug  3 05:23:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.749 2022/07/29 15:30:42 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.750 2022/08/03 05:23:30 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.749 2022/07/29 15:30:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.750 2022/08/03 05:23:30 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3872,6 +3872,7 @@ wm_ifflags_cb(struct ethercom *ec)
 	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
 
+	KASSERT(IFNET_LOCKED(ifp));
 	WM_CORE_LOCK(sc);
 
 	/*
@@ -6470,6 +6471,8 @@ wm_init(struct ifnet *ifp)
 	struct wm_softc *sc = ifp->if_softc;
 	int ret;
 
+	KASSERT(IFNET_LOCKED(ifp));
+
 	WM_CORE_LOCK(sc);
 	ret = wm_init_locked(ifp);
 	WM_CORE_UNLOCK(sc);
@@ -6487,6 +6490,7 @@ wm_init_locked(struct ifnet *ifp)
 
 	DPRINTF(sc, WM_DEBUG_INIT, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
+	KASSERT(IFNET_LOCKED(ifp));
 	KASSERT(WM_CORE_LOCKED(sc));
 
 	/*
@@ -7042,7 +7046,9 @@ wm_init_locked(struct ifnet *ifp)
 	/* Start the one second link check clock. */
 	callout_schedule(>sc_tick_ch, hz);
 
-	/* ...all done! */
+	/*
+	 * ...all done! (IFNET_LOCKED asserted above.)
+	 */
 	ifp->if_flags |= IFF_RUNNING;
 
  out:
@@ -11299,7 +11305,10 @@ wm_gmii_mediachange(struct ifnet *ifp)
 
 	DPRINTF(sc, WM_DEBUG_GMII, ("%s: %s called\n",
 		device_xname(sc->sc_dev), __func__));
-	if ((ifp->if_flags & IFF_UP) == 0)
+
+	KASSERT(WM_CORE_LOCKED(sc));
+
+	if ((sc->sc_if_flags & IFF_UP) == 0)
 		return 0;
 
 	/* XXX Not for I354? FreeBSD's e1000_82575.c doesn't include it */
@@ -11372,6 +11381,8 @@ wm_gmii_mediastatus(struct ifnet *ifp, s
 {
 	struct wm_softc *sc = ifp->if_softc;
 
+	KASSERT(WM_CORE_LOCKED(sc));
+
 	ether_mediastatus(ifp, ifmr);
 	ifmr->ifm_active = (ifmr->ifm_active & ~IFM_ETH_FMASK)
 	| sc->sc_flowflags;



CVS commit: src/sys/dev/pci

2022-08-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Aug  3 05:23:30 UTC 2022

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

Log Message:
Add some KASSERTs around the locking protocol.

Discussed with msaitoh@, knakahara@ and riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.749 -r1.750 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.



CVS commit: src/sys/dev/pci/cxgb

2022-07-29 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jul 29 20:55:41 UTC 2022

Modified Files:
src/sys/dev/pci/cxgb: cxgb_common.h

Log Message:
s/collissions/collisions/


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/cxgb/cxgb_common.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/cxgb/cxgb_common.h
diff -u src/sys/dev/pci/cxgb/cxgb_common.h:1.3 src/sys/dev/pci/cxgb/cxgb_common.h:1.4
--- src/sys/dev/pci/cxgb/cxgb_common.h:1.3	Thu Apr 19 21:50:09 2018
+++ src/sys/dev/pci/cxgb/cxgb_common.h	Fri Jul 29 20:55:41 2022
@@ -189,7 +189,7 @@ struct mac_stats {
 u64 tx_deferred;  /* frames with deferred transmissions */
 u64 tx_late_collisions;   /* # of late collisions */
 u64 tx_total_collisions;  /* # of total collisions */
-u64 tx_excess_collisions; /* frame errors from excessive collissions */
+u64 tx_excess_collisions; /* frame errors from excessive collisions */
 u64 tx_underrun;  /* # of Tx FIFO underruns */
 u64 tx_len_errs;  /* # of Tx length errors */
 u64 tx_mac_internal_errs; /* # of internal MAC errors on Tx */



CVS commit: src/sys/dev/pci/cxgb

2022-07-29 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jul 29 20:55:41 UTC 2022

Modified Files:
src/sys/dev/pci/cxgb: cxgb_common.h

Log Message:
s/collissions/collisions/


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/cxgb/cxgb_common.h

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



CVS commit: src/sys/dev/pci

2022-07-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 29 15:30:42 UTC 2022

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

Log Message:
Improve a couple of comments


To generate a diff of this commit:
cvs rdiff -u -r1.748 -r1.749 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.748 src/sys/dev/pci/if_wm.c:1.749
--- src/sys/dev/pci/if_wm.c:1.748	Fri Jul 29 15:29:07 2022
+++ src/sys/dev/pci/if_wm.c	Fri Jul 29 15:30:42 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.748 2022/07/29 15:29:07 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.749 2022/07/29 15:30:42 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.748 2022/07/29 15:29:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.749 2022/07/29 15:30:42 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3510,7 +3510,7 @@ wm_detach(device_t self, int flags __unu
 	}
 	pci_intr_release(sc->sc_pc, sc->sc_intrs, sc->sc_nintrs);
 
-	/* wm_stop() ensure workqueue is stopped. */
+	/* wm_stop() ensured that the workqueue is stopped. */
 	workqueue_destroy(sc->sc_queue_wq);
 
 	for (i = 0; i < sc->sc_nqueues; i++)
@@ -7072,7 +7072,7 @@ wm_stop(struct ifnet *ifp, int disable)
 	WM_CORE_UNLOCK(sc);
 
 	/*
-	 * After wm_set_stopping_flags(), it is guaranteed
+	 * After wm_set_stopping_flags(), it is guaranteed that
 	 * wm_handle_queue_work() does not call workqueue_enqueue().
 	 * However, workqueue_wait() cannot call in wm_stop_locked()
 	 * because it can sleep...



CVS commit: src/sys/dev/pci

2022-07-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 29 15:30:42 UTC 2022

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

Log Message:
Improve a couple of comments


To generate a diff of this commit:
cvs rdiff -u -r1.748 -r1.749 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.



CVS commit: src/sys/dev/pci

2022-07-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 29 15:29:07 UTC 2022

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.747 -r1.748 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.747 src/sys/dev/pci/if_wm.c:1.748
--- src/sys/dev/pci/if_wm.c:1.747	Thu Jul 28 09:22:25 2022
+++ src/sys/dev/pci/if_wm.c	Fri Jul 29 15:29:07 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.747 2022/07/28 09:22:25 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.748 2022/07/29 15:29:07 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.747 2022/07/28 09:22:25 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.748 2022/07/29 15:29:07 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -664,7 +664,7 @@ struct wm_softc {
 	struct evcnt sc_ev_o2bspc;	/* OS2BMC pkts transmitted by host */
 	struct evcnt sc_ev_b2ospc;	/* BMC2OS pkts sent by BMC */
 	struct evcnt sc_ev_o2bgptc;	/* OS2BMC pkts received by BMC */
-	
+
 #endif /* WM_EVENT_COUNTERS */
 
 	struct sysctllog *sc_sysctllog;



CVS commit: src/sys/dev/pci

2022-07-29 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 29 15:29:07 UTC 2022

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.747 -r1.748 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.



CVS commit: src/sys/dev/pci

2022-07-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 28 09:22:25 UTC 2022

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

Log Message:
KNF the KNF


To generate a diff of this commit:
cvs rdiff -u -r1.746 -r1.747 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.746 src/sys/dev/pci/if_wm.c:1.747
--- src/sys/dev/pci/if_wm.c:1.746	Fri Jul 22 05:23:50 2022
+++ src/sys/dev/pci/if_wm.c	Thu Jul 28 09:22:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.746 2022/07/22 05:23:50 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.747 2022/07/28 09:22:25 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.746 2022/07/22 05:23:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.747 2022/07/28 09:22:25 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -98,8 +98,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2022-07-28 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 28 09:22:25 UTC 2022

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

Log Message:
KNF the KNF


To generate a diff of this commit:
cvs rdiff -u -r1.746 -r1.747 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.



Re: CVS commit: src/sys/dev/pci

2022-07-27 Thread Masanobu SAITOH
Hi.

On 2022/07/22 23:22, Hisashi T Fujinaka wrote:
> On Fri, 22 Jul 2022, SAITOH Masanobu wrote:
> 
>> Module Name:    src
>> Committed By:    msaitoh
>> Date:    Fri Jul 22 05:23:50 UTC 2022
>>
>> Modified Files:
>> src/sys/dev/pci: if_wm.c if_wmreg.h
>>
>> Log Message:
>> Add more statistics countes.
>>
>> - Add many statics counters that the chip has.
> 
> Shouldn't you say which "the chip" you're talking about since wm seems
> to handle so many?

The current implementation is based on the FreeBSD and Linux.
All counters I added to NetBSD are also counted on both FreeBSD
and Linux. There are some difference between those two.
I also noticed that some code are doubtful and wrote them the
different way. To make the implementation perfect, I have to
read (almost) all datasheets and test on some chips. It's not
good to write only based on the datasheets. One of the reason is
that, for example, a register is not listed in the statistics
counters' table but the detail of the register is described later
in the chapter. It's not clear whether the register is exist
or not. The current implementation may not count some useful
counters.

The current implementation is not the final form but it's worth
to have. I could have written the details of the current
implementation when I committed, but I didn't really feel the
need to write the details of the implementation in its half-way
state. My apologies.

 Thanks.

> I suppose this isn't git so you can't fix this easily.
> 
>> - Attach event counters only if available.
>>
>>
>> To generate a diff of this commit:
>> cvs rdiff -u -r1.745 -r1.746 src/sys/dev/pci/if_wm.c
>> cvs rdiff -u -r1.126 -r1.127 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.
>>
>>
> 

-- 
---
SAITOH Masanobu (msai...@execsw.org
 msai...@netbsd.org)


CVS commit: src/sys/dev/pci

2022-07-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 26 14:53:12 UTC 2022

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.366 -r1.367 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.366 src/sys/dev/pci/if_bge.c:1.367
--- src/sys/dev/pci/if_bge.c:1.366	Fri Jul 22 06:31:08 2022
+++ src/sys/dev/pci/if_bge.c	Tue Jul 26 14:53:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.366 2022/07/22 06:31:08 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.367 2022/07/26 14:53:12 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,7 +79,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.366 2022/07/22 06:31:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.367 2022/07/26 14:53:12 skrll Exp $");
 
 #include 
 
@@ -1286,7 +1286,7 @@ bge_update_all_threshes(int lvl)
 	int s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		if (strncmp(ifp->if_xname, namebuf, namelen) != 0)
-		  continue;
+			continue;
 		/* We got a match: update if doing auto-threshold-tuning */
 		if (bge_auto_thresh)
 			bge_set_thresh(ifp, lvl);
@@ -1320,7 +1320,7 @@ bge_alloc_jumbo_mem(struct bge_softc *sc
 
 	/* Grab a big chunk o' storage. */
 	if (bus_dmamem_alloc(sc->bge_dmatag, BGE_JMEM, PAGE_SIZE, 0,
-	 , 1, , BUS_DMA_NOWAIT)) {
+	, 1, , BUS_DMA_NOWAIT)) {
 		aprint_error_dev(sc->bge_dev, "can't alloc rx buffers\n");
 		return ENOBUFS;
 	}
@@ -3542,7 +3542,7 @@ bge_attach(device_t parent, device_t sel
 	 * First check if firmware knows we do not have SEEPROM.
 	 */
 	if (prop_dictionary_get_bool(device_properties(self),
-	 "without-seeprom", _seeprom) && no_seeprom)
+	"without-seeprom", _seeprom) && no_seeprom)
 		sc->bge_flags |= BGEF_NO_EEPROM;
 
 	else if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906)
@@ -4450,7 +4450,7 @@ bge_rxeof(struct bge_softc *sc)
 continue;
 			}
 			if (bge_newbuf_jumbo(sc, sc->bge_jumbo,
-	 NULL)== ENOBUFS) {
+	 NULL) == ENOBUFS) {
 if_statinc(ifp, if_ierrors);
 bge_newbuf_jumbo(sc, sc->bge_jumbo, m);
 continue;
@@ -4926,7 +4926,7 @@ bge_cksum_pad(struct mbuf *pkt)
 		 * (thus perhaps avoiding the bcm5700 dma-min bug).
 		 */
 		for (last = pkt; last->m_next != NULL; last = last->m_next) {
-		   continue; /* do nothing */
+			continue; /* do nothing */
 		}
 
 		/* `last' now points to last in chain. */
@@ -4990,8 +4990,8 @@ bge_compact_dma_runt(struct mbuf *pkt)
 			m = prev;
 			continue;
 		} else if (m->m_next != NULL &&
-			 M_TRAILINGSPACE(m) >= shortfall &&
-			 m->m_next->m_len >= (8 + shortfall)) {
+			M_TRAILINGSPACE(m) >= shortfall &&
+			m->m_next->m_len >= (8 + shortfall)) {
 		/* m is writable and have enough data in next, pull up. */
 
 			memcpy(m->m_data + m->m_len, m->m_next->m_data,
@@ -5183,7 +5183,7 @@ doit:
 			aprint_error_dev(sc->bge_dev,
 			"TSO: hard case m0->m_len == %d < ip/tcp hlen %zd,"
 			"not handled yet\n",
-			 m0->m_len, hlen+ sizeof(struct tcphdr));
+			m0->m_len, hlen+ sizeof(struct tcphdr));
 #ifdef NOTYET
 			/*
 			 * XXX jonat...@netbsd.org: untested.



CVS commit: src/sys/dev/pci

2022-07-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 26 14:53:12 UTC 2022

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

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.366 -r1.367 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.



CVS commit: src/sys/dev/pci

2022-07-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 25 08:29:14 UTC 2022

Modified Files:
src/sys/dev/pci: if_bgevar.h

Log Message:
Some more BITS(3)


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/if_bgevar.h

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



CVS commit: src/sys/dev/pci

2022-07-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 25 08:29:14 UTC 2022

Modified Files:
src/sys/dev/pci: if_bgevar.h

Log Message:
Some more BITS(3)


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/if_bgevar.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_bgevar.h
diff -u src/sys/dev/pci/if_bgevar.h:1.29 src/sys/dev/pci/if_bgevar.h:1.30
--- src/sys/dev/pci/if_bgevar.h:1.29	Mon Jul 25 08:19:50 2022
+++ src/sys/dev/pci/if_bgevar.h	Mon Jul 25 08:29:14 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgevar.h,v 1.29 2022/07/25 08:19:50 skrll Exp $	*/
+/*	$NetBSD: if_bgevar.h,v 1.30 2022/07/25 08:29:14 skrll Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -314,9 +314,9 @@ struct bge_softc {
 	uint32_t		bge_tx_max_coal_bds;
 	uint32_t		bge_tx_buf_ratio;
 	uint32_t		bge_sts;
-#define BGE_STS_LINK		0x0001	/* MAC link status */
-#define BGE_STS_LINK_EVT	0x0002	/* pending link event */
-#define BGE_STS_AUTOPOLL	0x0004	/* PHY auto-polling  */
+#define BGE_STS_LINK		__BIT(0)	/* MAC link status */
+#define BGE_STS_LINK_EVT	__BIT(1)	/* pending link event */
+#define BGE_STS_AUTOPOLL	__BIT(2)	/* PHY auto-polling  */
 #define BGE_STS_BIT(sc, x)	((sc)->bge_sts & (x))
 #define BGE_STS_SETBIT(sc, x)	((sc)->bge_sts |= (x))
 #define BGE_STS_CLRBIT(sc, x)	((sc)->bge_sts &= ~(x))



CVS commit: src/sys/dev/pci

2022-07-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 25 08:19:50 UTC 2022

Modified Files:
src/sys/dev/pci: if_bgevar.h

Log Message:
G/C the unused bge_rx_mini_chain member from bge_chain_data. It was removed
from the FreeBSD driver in 2003.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_bgevar.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_bgevar.h
diff -u src/sys/dev/pci/if_bgevar.h:1.28 src/sys/dev/pci/if_bgevar.h:1.29
--- src/sys/dev/pci/if_bgevar.h:1.28	Sat Jul  2 07:22:41 2022
+++ src/sys/dev/pci/if_bgevar.h	Mon Jul 25 08:19:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bgevar.h,v 1.28 2022/07/02 07:22:41 skrll Exp $	*/
+/*	$NetBSD: if_bgevar.h,v 1.29 2022/07/25 08:19:50 skrll Exp $	*/
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -216,7 +216,6 @@ struct bge_chain_data {
 	struct mbuf		*bge_tx_chain[BGE_TX_RING_CNT];
 	struct mbuf		*bge_rx_std_chain[BGE_STD_RX_RING_CNT];
 	struct mbuf		*bge_rx_jumbo_chain[BGE_JUMBO_RX_RING_CNT];
-	struct mbuf		*bge_rx_mini_chain[BGE_MINI_RX_RING_CNT];
 	bus_dmamap_t		bge_rx_std_map[BGE_STD_RX_RING_CNT];
 	bus_dmamap_t		bge_rx_jumbo_map;
 	/* Stick the jumbo mem management stuff here too. */



CVS commit: src/sys/dev/pci

2022-07-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jul 25 08:19:50 UTC 2022

Modified Files:
src/sys/dev/pci: if_bgevar.h

Log Message:
G/C the unused bge_rx_mini_chain member from bge_chain_data. It was removed
from the FreeBSD driver in 2003.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/if_bgevar.h

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



Re: CVS commit: src/sys/dev/pci

2022-07-22 Thread Hisashi T Fujinaka

On Fri, 22 Jul 2022, SAITOH Masanobu wrote:


Module Name:src
Committed By:   msaitoh
Date:   Fri Jul 22 05:23:50 UTC 2022

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
Add more statistics countes.

- Add many statics counters that the chip has.


Shouldn't you say which "the chip" you're talking about since wm seems
to handle so many?

I suppose this isn't git so you can't fix this easily.


- Attach event counters only if available.


To generate a diff of this commit:
cvs rdiff -u -r1.745 -r1.746 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.126 -r1.127 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.




--
Hisashi T Fujinaka - ht...@twofifty.com
BSEE + BSChem + BAEnglish + MSCS + $2.50 = coffee


CVS commit: src/sys/dev/pci

2022-07-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 22 06:31:08 UTC 2022

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

Log Message:
malloc -> kmem.


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.366 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.365 src/sys/dev/pci/if_bge.c:1.366
--- src/sys/dev/pci/if_bge.c:1.365	Sun Jul  3 13:29:28 2022
+++ src/sys/dev/pci/if_bge.c	Fri Jul 22 06:31:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bge.c,v 1.365 2022/07/03 13:29:28 skrll Exp $	*/
+/*	$NetBSD: if_bge.c,v 1.366 2022/07/22 06:31:08 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001 Wind River Systems
@@ -79,14 +79,14 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.365 2022/07/03 13:29:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.366 2022/07/22 06:31:08 skrll Exp $");
 
 #include 
 
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -1365,7 +1365,7 @@ bge_alloc_jumbo_mem(struct bge_softc *sc
 	for (i = 0; i < BGE_JSLOTS; i++) {
 		sc->bge_cdata.bge_jslots[i] = ptr;
 		ptr += BGE_JLEN;
-		entry = malloc(sizeof(*entry), M_DEVBUF, M_WAITOK);
+		entry = kmem_alloc(sizeof(*entry), KM_SLEEP);
 		entry->slot = i;
 		SLIST_INSERT_HEAD(>bge_jfree_listhead,
  entry, jpool_entries);
@@ -1702,7 +1702,7 @@ bge_free_tx_ring(struct bge_softc *sc, b
 bus_dmamap_destroy(sc->bge_dmatag32,
 dma->dmamap32);
 			}
-			free(dma, M_DEVBUF);
+			kmem_free(dma, sizeof(*dma));
 		}
 		SLIST_INIT(>txdma_list);
 	}
@@ -1769,7 +1769,7 @@ bge_init_tx_ring(struct bge_softc *sc)
 panic("dmamap32 NULL in bge_init_tx_ring");
 		} else
 			dmamap32 = dmamap;
-		dma = malloc(sizeof(*dma), M_DEVBUF, M_NOWAIT);
+		dma = kmem_alloc(sizeof(*dma), KM_NOSLEEP);
 		if (dma == NULL) {
 			aprint_error_dev(sc->bge_dev,
 			"can't alloc txdmamap_pool_entry\n");



CVS commit: src/sys/dev/pci

2022-07-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Jul 22 06:31:08 UTC 2022

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

Log Message:
malloc -> kmem.


To generate a diff of this commit:
cvs rdiff -u -r1.365 -r1.366 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.



CVS commit: src/sys/dev/pci

2022-07-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jul 22 05:23:50 UTC 2022

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
Add more statistics countes.

 - Add many statics counters that the chip has.
 - Attach event counters only if available.


To generate a diff of this commit:
cvs rdiff -u -r1.745 -r1.746 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.126 -r1.127 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.745 src/sys/dev/pci/if_wm.c:1.746
--- src/sys/dev/pci/if_wm.c:1.745	Tue Jul 19 08:22:34 2022
+++ src/sys/dev/pci/if_wm.c	Fri Jul 22 05:23:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.745 2022/07/19 08:22:34 riastradh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.746 2022/07/22 05:23:50 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.745 2022/07/19 08:22:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.746 2022/07/22 05:23:50 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -595,12 +595,76 @@ struct wm_softc {
 	/* Event counters. */
 	struct evcnt sc_ev_linkintr;	/* Link interrupts */
 
-	/* WM_T_82542_2_1 only */
+	/* >= WM_T_82542_2_1 */
 	struct evcnt sc_ev_tx_xoff;	/* Tx PAUSE(!0) frames */
 	struct evcnt sc_ev_tx_xon;	/* Tx PAUSE(0) frames */
 	struct evcnt sc_ev_rx_xoff;	/* Rx PAUSE(!0) frames */
 	struct evcnt sc_ev_rx_xon;	/* Rx PAUSE(0) frames */
 	struct evcnt sc_ev_rx_macctl;	/* Rx Unsupported */
+
+	struct evcnt sc_ev_crcerrs;	/* CRC Error */
+	struct evcnt sc_ev_algnerrc;	/* Alignment Error */
+	struct evcnt sc_ev_symerrc;	/* Symbol Error */
+	struct evcnt sc_ev_rxerrc;	/* Receive Error */
+	struct evcnt sc_ev_mpc;		/* Missed Packets */
+	struct evcnt sc_ev_colc;	/* Collision */
+	struct evcnt sc_ev_sec;		/* Sequence Error */
+	struct evcnt sc_ev_cexterr;	/* Carrier Extension Error */
+	struct evcnt sc_ev_rlec;	/* Receive Length Error */
+	struct evcnt sc_ev_scc;		/* Single Collision */
+	struct evcnt sc_ev_ecol;	/* Excessive Collision */
+	struct evcnt sc_ev_mcc;		/* Multiple Collision */
+	struct evcnt sc_ev_latecol;	/* Late Collision */
+	struct evcnt sc_ev_dc;		/* Defer */
+	struct evcnt sc_ev_gprc;	/* Good Packets Rx */
+	struct evcnt sc_ev_bprc;	/* Broadcast Packets Rx */
+	struct evcnt sc_ev_mprc;	/* Multicast Packets Rx */
+	struct evcnt sc_ev_gptc;	/* Good Packets Tx */
+	struct evcnt sc_ev_gorc;	/* Good Octets Rx */
+	struct evcnt sc_ev_gotc;	/* Good Octets Tx */
+	struct evcnt sc_ev_rnbc;	/* Rx No Buffers */
+	struct evcnt sc_ev_ruc;		/* Rx Undersize */
+	struct evcnt sc_ev_rfc;		/* Rx Fragment */
+	struct evcnt sc_ev_roc;		/* Rx Oversize */
+	struct evcnt sc_ev_rjc;		/* Rx Jabber */
+	struct evcnt sc_ev_tor;		/* Total Octets Rx */
+	struct evcnt sc_ev_tot;		/* Total Octets Tx */
+	struct evcnt sc_ev_tpr;		/* Total Packets Rx */
+	struct evcnt sc_ev_tpt;		/* Total Packets Tx */
+	struct evcnt sc_ev_mptc;	/* Multicast Packets Tx */
+	struct evcnt sc_ev_bptc;	/* Broadcast Packets Tx Count */
+	struct evcnt sc_ev_prc64;	/* Packets Rx (64 bytes) */
+	struct evcnt sc_ev_prc127;	/* Packets Rx (65-127 bytes) */
+	struct evcnt sc_ev_prc255;	/* Packets Rx (128-255 bytes) */
+	struct evcnt sc_ev_prc511;	/* Packets Rx (255-511 bytes) */
+	struct evcnt sc_ev_prc1023;	/* Packets Rx (512-1023 bytes) */
+	struct evcnt sc_ev_prc1522;	/* Packets Rx (1024-1522 bytes) */
+	struct evcnt sc_ev_ptc64;	/* Packets Tx (64 bytes) */
+	struct evcnt sc_ev_ptc127;	/* Packets Tx (65-127 bytes) */
+	struct evcnt sc_ev_ptc255;	/* Packets Tx (128-255 bytes) */
+	struct evcnt sc_ev_ptc511;	/* Packets Tx (256-511 bytes) */
+	struct evcnt sc_ev_ptc1023;	/* Packets Tx (512-1023 bytes) */
+	struct evcnt sc_ev_ptc1522;	/* Packets Tx (1024-1522 Bytes) */
+	struct evcnt sc_ev_iac;		/* Interrupt Assertion */
+	struct evcnt sc_ev_icrxptc;	/* Intr. Cause Rx Pkt Timer Expire */
+	struct evcnt sc_ev_icrxatc;	/* Intr. Cause Rx Abs Timer Expire */
+	struct evcnt sc_ev_ictxptc;	/* Intr. Cause Tx Pkt Timer Expire */
+	struct evcnt sc_ev_ictxact;	/* Intr. Cause Tx Abs Timer Expire */
+	struct evcnt sc_ev_ictxqec;	/* Intr. Cause Tx Queue Empty */
+	struct evcnt sc_ev_ictxqmtc;	/* Intr. Cause Tx Queue Min Thresh */
+	struct evcnt sc_ev_icrxdmtc;	/* Intr. Cause Rx Desc Min Thresh */
+	struct evcnt sc_ev_icrxoc;	/* Intr. Cause Receiver Overrun */
+	struct evcnt sc_ev_tncrs;	/* Tx-No CRS */
+	struct evcnt sc_ev_tsctc;	/* TCP Segmentation Context Tx */
+	struct evcnt sc_ev_tsctfc;	/* TCP Segmentation Context Tx Fail */
+	struct evcnt sc_ev_mgtprc;	/* Management Packets RX */
+	struct evcnt sc_ev_mgtpdc;	/* Management Packets Dropped */
+	struct evcnt sc_ev_mgtptc;	/* Management Packets TX */
+	struct evcnt sc_ev_b2ogprc;	/* BMC2OS pkts received by host */
+	struct evcnt sc_ev_o2bspc;	

CVS commit: src/sys/dev/pci

2022-07-21 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Fri Jul 22 05:23:50 UTC 2022

Modified Files:
src/sys/dev/pci: if_wm.c if_wmreg.h

Log Message:
Add more statistics countes.

 - Add many statics counters that the chip has.
 - Attach event counters only if available.


To generate a diff of this commit:
cvs rdiff -u -r1.745 -r1.746 src/sys/dev/pci/if_wm.c
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/pci/if_wmreg.h

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



CVS commit: src/sys/dev/pci

2022-07-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 20 06:43:37 UTC 2022

Modified Files:
src/sys/dev/pci: if_wmreg.h

Log Message:
Modify comment. Use __BIT() a little. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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_wmreg.h
diff -u src/sys/dev/pci/if_wmreg.h:1.125 src/sys/dev/pci/if_wmreg.h:1.126
--- src/sys/dev/pci/if_wmreg.h:1.125	Wed Dec 22 07:28:34 2021
+++ src/sys/dev/pci/if_wmreg.h	Wed Jul 20 06:43:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wmreg.h,v 1.125 2021/12/22 07:28:34 skrll Exp $	*/
+/*	$NetBSD: if_wmreg.h,v 1.126 2022/07/20 06:43:37 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -1145,9 +1145,9 @@ struct livengood_tcpip_ctxdesc {
 #define	WMREG_CRCERRS	0x4000	/* CRC Error Count */
 #define	WMREG_ALGNERRC	0x4004	/* Alignment Error Count */
 #define	WMREG_SYMERRC	0x4008	/* Symbol Error Count */
-#define	WMREG_RXERRC	0x400c	/* receive error Count - R/clr */
+#define	WMREG_RXERRC	0x400c	/* Receive error Count - R/clr */
 #define	WMREG_MPC	0x4010	/* Missed Packets Count - R/clr */
-#define	WMREG_COLC	0x4028	/* collision Count - R/clr */
+#define	WMREG_COLC	0x4028	/* Collision Count - R/clr */
 #define	WMREG_SEC	0x4038	/* Sequence Error Count */
 #define	WMREG_CEXTERR	0x403c	/* Carrier Extension Error Count */
 #define	WMREG_RLEC	0x4040	/* Receive Length Error Count */
@@ -1302,15 +1302,15 @@ struct livengood_tcpip_ctxdesc {
 #define	RSSRK_NUM_REGS		10
 
 #define	WMREG_MANC	0x5820	/* Management Control */
-#define	MANC_SMBUS_EN		0x0001
-#define	MANC_ASF_EN		0x0002
-#define	MANC_ARP_EN		0x2000
-#define	MANC_RECV_TCO_RESET	0x0001
-#define	MANC_RECV_TCO_EN	0x0002
-#define	MANC_BLK_PHY_RST_ON_IDE	0x0004
-#define	MANC_RECV_ALL		0x0008
-#define	MANC_EN_MAC_ADDR_FILTER	0x0010
-#define	MANC_EN_MNG2HOST	0x0020
+#define	MANC_SMBUS_EN		__BIT(0)
+#define	MANC_ASF_EN		__BIT(1)
+#define	MANC_ARP_EN		__BIT(13)
+#define	MANC_RECV_TCO_RESET	__BIT(16)
+#define	MANC_RECV_TCO_EN	__BIT(17)
+#define	MANC_BLK_PHY_RST_ON_IDE	__BIT(18)
+#define	MANC_RECV_ALL		__BIT(19)
+#define	MANC_EN_MAC_ADDR_FILTER	__BIT(20)
+#define	MANC_EN_MNG2HOST	__BIT(21)
 
 #define	WMREG_MANC2H	0x5860	/* Management Control To Host - RW */
 #define	MANC2H_PORT_623		(1 << 5)



CVS commit: src/sys/dev/pci

2022-07-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul 20 06:43:37 UTC 2022

Modified Files:
src/sys/dev/pci: if_wmreg.h

Log Message:
Modify comment. Use __BIT() a little. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/dev/pci/if_wmreg.h

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



CVS commit: src/sys/dev/pci

2022-07-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 19 08:22:34 UTC 2022

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

Log Message:
wm(4): Use CSR_WRITE_FLUSH, not bus_space_barrier.

The bus space is mapped non-prefetchable and non-cacheable, so there
is no need for bus_space_barrier and it might not even have any
effect -- bus_space_read/write are totally ordered for non-
prefetchable, non-cacheable mappings anyway.  Presumably the intent
here was to wait for acknowledgment of the write from the device --
which bus_space_barrier does not guarantee, and which I expect
requires a read transaction as CSR_WRITE_FLUSH performs.

ok msaitoh@, knakahara@


To generate a diff of this commit:
cvs rdiff -u -r1.744 -r1.745 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.744 src/sys/dev/pci/if_wm.c:1.745
--- src/sys/dev/pci/if_wm.c:1.744	Tue Jul 19 08:21:02 2022
+++ src/sys/dev/pci/if_wm.c	Tue Jul 19 08:22:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.744 2022/07/19 08:21:02 riastradh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.745 2022/07/19 08:22:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.744 2022/07/19 08:21:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.745 2022/07/19 08:22:34 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4923,8 +4923,7 @@ wm_flush_desc_rings(struct wm_softc *sc)
 
 	txq->txq_next = WM_NEXTTX(txq, txq->txq_next);
 	CSR_WRITE(sc, WMREG_TDT(0), txq->txq_next);
-	bus_space_barrier(sc->sc_st, sc->sc_sh, 0, 0,
-	BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
+	CSR_WRITE_FLUSH(sc);
 	delay(250);
 
 	preg = pci_conf_read(sc->sc_pc, sc->sc_pcitag, WM_PCI_DESCRING_STATUS);



CVS commit: src/sys/dev/pci

2022-07-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 19 08:22:34 UTC 2022

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

Log Message:
wm(4): Use CSR_WRITE_FLUSH, not bus_space_barrier.

The bus space is mapped non-prefetchable and non-cacheable, so there
is no need for bus_space_barrier and it might not even have any
effect -- bus_space_read/write are totally ordered for non-
prefetchable, non-cacheable mappings anyway.  Presumably the intent
here was to wait for acknowledgment of the write from the device --
which bus_space_barrier does not guarantee, and which I expect
requires a read transaction as CSR_WRITE_FLUSH performs.

ok msaitoh@, knakahara@


To generate a diff of this commit:
cvs rdiff -u -r1.744 -r1.745 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.



CVS commit: src/sys/dev/pci

2022-07-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 19 08:21:02 UTC 2022

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

Log Message:
wm(4): Use bus_dmamap_sync, not bus_space_barrier, for tx desc.

The newly written tx descriptor needs to be visible to the device
before the TDT register is set.  There's no bus space mappings that
need any barriers, though -- nothing mapped prefetchable or cacheable
here.  So bus_dmamap_sync (via wm_cdtxsync) is necessary, not
bus_space_barrier.  By accident, bus_space_barrier implies the same
barrier instructions as bus_dmamap_sync on some architectures, but it
wouldn't work at all if we were bouncing.

ok msaitoh@, knakahara@


To generate a diff of this commit:
cvs rdiff -u -r1.743 -r1.744 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.743 src/sys/dev/pci/if_wm.c:1.744
--- src/sys/dev/pci/if_wm.c:1.743	Tue Jul 19 06:50:34 2022
+++ src/sys/dev/pci/if_wm.c	Tue Jul 19 08:21:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.743 2022/07/19 06:50:34 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.744 2022/07/19 08:21:02 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.743 2022/07/19 06:50:34 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.744 2022/07/19 08:21:02 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4918,8 +4918,8 @@ wm_flush_desc_rings(struct wm_softc *sc)
 	txd->wtx_fields.wtxu_options = 0;
 	txd->wtx_fields.wtxu_vlan = 0;
 
-	bus_space_barrier(sc->sc_st, sc->sc_sh, 0, 0,
-	BUS_SPACE_BARRIER_WRITE);
+	wm_cdtxsync(txq, 0, WM_NTXDESC(txq),
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	txq->txq_next = WM_NEXTTX(txq, txq->txq_next);
 	CSR_WRITE(sc, WMREG_TDT(0), txq->txq_next);



CVS commit: src/sys/dev/pci

2022-07-19 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul 19 08:21:02 UTC 2022

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

Log Message:
wm(4): Use bus_dmamap_sync, not bus_space_barrier, for tx desc.

The newly written tx descriptor needs to be visible to the device
before the TDT register is set.  There's no bus space mappings that
need any barriers, though -- nothing mapped prefetchable or cacheable
here.  So bus_dmamap_sync (via wm_cdtxsync) is necessary, not
bus_space_barrier.  By accident, bus_space_barrier implies the same
barrier instructions as bus_dmamap_sync on some architectures, but it
wouldn't work at all if we were bouncing.

ok msaitoh@, knakahara@


To generate a diff of this commit:
cvs rdiff -u -r1.743 -r1.744 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.



CVS commit: src/sys/dev/pci

2022-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 19 06:50:34 UTC 2022

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.742 -r1.743 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.742 src/sys/dev/pci/if_wm.c:1.743
--- src/sys/dev/pci/if_wm.c:1.742	Tue Jul 19 06:47:34 2022
+++ src/sys/dev/pci/if_wm.c	Tue Jul 19 06:50:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.742 2022/07/19 06:47:34 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.743 2022/07/19 06:50:34 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.742 2022/07/19 06:47:34 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.743 2022/07/19 06:50:34 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -90,25 +90,25 @@ __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.
 #endif
 
 #include 
-#include 
+
+#include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
 #include 
-#include 
-#include 
+#include 
 #include 
-#include 
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
 #include 
-#include 
-
-#include 
 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2022-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 19 06:50:34 UTC 2022

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

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.742 -r1.743 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.



CVS commit: src/sys/dev/pci

2022-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 19 06:47:34 UTC 2022

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

Log Message:
Don't need sys/malloc.h so remove the #include


To generate a diff of this commit:
cvs rdiff -u -r1.741 -r1.742 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.



CVS commit: src/sys/dev/pci

2022-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 19 06:47:34 UTC 2022

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

Log Message:
Don't need sys/malloc.h so remove the #include


To generate a diff of this commit:
cvs rdiff -u -r1.741 -r1.742 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.741 src/sys/dev/pci/if_wm.c:1.742
--- src/sys/dev/pci/if_wm.c:1.741	Tue Jul 19 06:46:29 2022
+++ src/sys/dev/pci/if_wm.c	Tue Jul 19 06:47:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.741 2022/07/19 06:46:29 skrll Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.742 2022/07/19 06:47:34 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.741 2022/07/19 06:46:29 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.742 2022/07/19 06:47:34 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -93,7 +93,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/dev/pci

2022-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 19 06:46:29 UTC 2022

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

Log Message:
Turn a locking botch (shouldn't drop lock on error) into a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.740 -r1.741 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.



CVS commit: src/sys/dev/pci

2022-07-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 19 06:46:29 UTC 2022

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

Log Message:
Turn a locking botch (shouldn't drop lock on error) into a KASSERT


To generate a diff of this commit:
cvs rdiff -u -r1.740 -r1.741 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.740 src/sys/dev/pci/if_wm.c:1.741
--- src/sys/dev/pci/if_wm.c:1.740	Mon Jul 11 06:16:23 2022
+++ src/sys/dev/pci/if_wm.c	Tue Jul 19 06:46:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.740 2022/07/11 06:16:23 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.741 2022/07/19 06:46:29 skrll Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.740 2022/07/11 06:16:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.741 2022/07/19 06:46:29 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -8927,11 +8927,7 @@ wm_deferred_start_locked(struct wm_txque
 	int qid = wmq->wmq_id;
 
 	KASSERT(mutex_owned(txq->txq_lock));
-
-	if (txq->txq_stopping) {
-		mutex_exit(txq->txq_lock);
-		return;
-	}
+	KASSERT(!txq->txq_stopping);
 
 	if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
 		/* XXX need for ALTQ or one CPU system */



CVS commit: src/sys/dev/pci

2022-07-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul 17 10:10:45 UTC 2022

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

Log Message:
agp(4): Use bus_space_barrier, not membar_producer.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/dev/pci/agp_i810.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/agp_i810.c
diff -u src/sys/dev/pci/agp_i810.c:1.124 src/sys/dev/pci/agp_i810.c:1.125
--- src/sys/dev/pci/agp_i810.c:1.124	Sun Nov 10 21:16:36 2019
+++ src/sys/dev/pci/agp_i810.c	Sun Jul 17 10:10:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: agp_i810.c,v 1.124 2019/11/10 21:16:36 chs Exp $	*/
+/*	$NetBSD: agp_i810.c,v 1.125 2022/07/17 10:10:45 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2000 Doug Rabson
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.124 2019/11/10 21:16:36 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: agp_i810.c,v 1.125 2022/07/17 10:10:45 riastradh Exp $");
 
 #include 
 #include 
@@ -173,7 +173,8 @@ agp_i810_post_gtt_entry(struct agp_i810_
 	 * read, because I don't have enough time or hardware to
 	 * conduct conclusive tests.
 	 */
-	membar_producer();
+	bus_space_barrier(isc->gtt_bst, isc->gtt_bsh, 0, isc->gtt_size,
+	BUS_SPACE_BARRIER_WRITE);
 	(void)bus_space_read_4(isc->gtt_bst, isc->gtt_bsh,
 	4*(off >> AGP_PAGE_SHIFT));
 }



CVS commit: src/sys/dev/pci

2022-07-17 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jul 17 10:10:45 UTC 2022

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

Log Message:
agp(4): Use bus_space_barrier, not membar_producer.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/dev/pci/agp_i810.c

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



CVS commit: src/sys/dev/pci

2022-07-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 16 07:23:51 UTC 2022

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

Log Message:
Enable Aero.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 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.25 src/sys/dev/pci/mfii.c:1.26
--- src/sys/dev/pci/mfii.c:1.25	Sat Jul 16 07:13:03 2022
+++ src/sys/dev/pci/mfii.c	Sat Jul 16 07:23:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.25 2022/07/16 07:13:03 msaitoh Exp $ */
+/* $NetBSD: mfii.c,v 1.26 2022/07/16 07:23:51 msaitoh Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.25 2022/07/16 07:13:03 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.26 2022/07/16 07:23:51 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -608,7 +608,6 @@ static const struct mfii_iop mfii_iop_35
 	0
 };
 
-#if 0
 static const struct mfii_iop mfii_iop_aero = {
 	MFII_BAR_35,
 	MFII_IOP_NUM_SGE_LOC_35,
@@ -619,7 +618,6 @@ static const struct mfii_iop mfii_iop_ae
 	MFII_SGE_END_OF_LIST,
 	MFII_IOP_QUIRK_REGREAD | MFII_IOP_HAS_32BITDESC_BIT
 };
-#endif
 
 struct mfii_device {
 	pcireg_t		mpd_vendor;
@@ -663,7 +661,6 @@ static const struct mfii_device mfii_dev
 	/* Harpoon */
 	{ PCI_VENDOR_SYMBIOS,	PCI_PRODUCT_SYMBIOS_MEGARAID_3508,
 	_iop_35 },
-#if 0
 	/* Aero */
 	{ PCI_VENDOR_SYMBIOS,	PCI_PRODUCT_SYMBIOS_MEGARAID_39XX_2,
 	_iop_aero },
@@ -673,7 +670,6 @@ static const struct mfii_device mfii_dev
 	_iop_aero },
 	{ PCI_VENDOR_SYMBIOS,	PCI_PRODUCT_SYMBIOS_MEGARAID_38XX_3,
 	_iop_aero }
-#endif
 };
 
 static const struct mfii_iop *mfii_find_iop(struct pci_attach_args *);



CVS commit: src/sys/dev/pci

2022-07-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 16 07:23:51 UTC 2022

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

Log Message:
Enable Aero.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 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.



CVS commit: src/sys/dev/pci

2022-07-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 16 07:13:03 UTC 2022

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

Log Message:
 It seems that a logical volume number and the target ID is different
on newer systems. It's observed on an Aero. Add sc->sc_ld[X].ld_target_id
to keep the target ID and use it for scsipi layer. Now sdX is attached
on Aero system. Tested by Mark Davies.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.



CVS commit: src/sys/dev/pci

2022-07-16 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul 16 07:13:03 UTC 2022

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

Log Message:
 It seems that a logical volume number and the target ID is different
on newer systems. It's observed on an Aero. Add sc->sc_ld[X].ld_target_id
to keep the target ID and use it for scsipi layer. Now sdX is attached
on Aero system. Tested by Mark Davies.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/sys/dev/pci/mfii.c:1.25
--- src/sys/dev/pci/mfii.c:1.24	Sat Jul 16 06:52:41 2022
+++ src/sys/dev/pci/mfii.c	Sat Jul 16 07:13:03 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.24 2022/07/16 06:52:41 msaitoh Exp $ */
+/* $NetBSD: mfii.c,v 1.25 2022/07/16 07:13:03 msaitoh Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.24 2022/07/16 06:52:41 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.25 2022/07/16 07:13:03 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -355,6 +355,7 @@ struct mfii_softc {
 	struct {
 		bool		ld_present;
 		char		ld_dev[16];	/* device name sd? */
+		int		ld_target_id;
 	}			sc_ld[MFII_MAX_LD_EXT];
 	int			sc_target_lds[MFII_MAX_LD_EXT];
 	bool			sc_max256vd;
@@ -942,6 +943,7 @@ mfii_attach(device_t parent, device_t se
 	for (i = 0; i < sc->sc_ld_list.mll_no_ld; i++) {
 		int target = sc->sc_ld_list.mll_list[i].mll_ld.mld_target;
 		sc->sc_target_lds[target] = i;
+		sc->sc_ld[i].ld_target_id = target;
 	}
 
 	/* enable interrupts */
@@ -1452,6 +1454,7 @@ mfii_aen_ld_update(struct mfii_softc *sc
 		DNPRINTF(MFII_D_MISC, "%s: target %d: state %d\n",
 		DEVNAME(sc), target, sc->sc_ld_list.mll_list[i].mll_state);
 		newlds[target] = i;
+		sc->sc_ld[i].ld_target_id = target;
 	}
 
 	for (i = 0; i < MFII_MAX_LD_EXT; i++) {
@@ -2339,9 +2342,10 @@ mfii_scsi_cmd_io(struct mfii_softc *sc, 
 	struct scsipi_periph *periph = xs->xs_periph;
 	struct mpii_msg_scsi_io *io = ccb->ccb_request;
 	struct mfii_raid_context *ctx = (struct mfii_raid_context *)(io + 1);
-	int segs;
+	int segs, target;
 
-	io->dev_handle = htole16(periph->periph_target);
+	target = sc->sc_ld[periph->periph_target].ld_target_id;
+	io->dev_handle = htole16(target);
 	io->function = MFII_FUNCTION_LDIO_REQUEST;
 	io->sense_buffer_low_address = htole32(ccb->ccb_sense_dva);
 	io->sgl_flags = htole16(0x02); /* XXX */
@@ -2368,7 +2372,7 @@ mfii_scsi_cmd_io(struct mfii_softc *sc, 
 	ctx->type_nseg = sc->sc_iop->ldio_ctx_type_nseg;
 	ctx->timeout_value = htole16(0x14); /* XXX */
 	ctx->reg_lock_flags = htole16(sc->sc_iop->ldio_ctx_reg_lock_flags);
-	ctx->virtual_disk_target_id = htole16(periph->periph_target);
+	ctx->virtual_disk_target_id = htole16(target);
 
 	if (mfii_load_ccb(sc, ccb, ctx + 1,
 	ISSET(xs->xs_control, XS_CTL_NOSLEEP)) != 0)
@@ -2399,8 +2403,10 @@ mfii_scsi_cmd_cdb(struct mfii_softc *sc,
 	struct scsipi_periph *periph = xs->xs_periph;
 	struct mpii_msg_scsi_io *io = ccb->ccb_request;
 	struct mfii_raid_context *ctx = (struct mfii_raid_context *)(io + 1);
+	int target;
 
-	io->dev_handle = htole16(periph->periph_target);
+	target = sc->sc_ld[periph->periph_target].ld_target_id;
+	io->dev_handle = htole16(target);
 	io->function = MFII_FUNCTION_LDIO_REQUEST;
 	io->sense_buffer_low_address = htole32(ccb->ccb_sense_dva);
 	io->sgl_flags = htole16(0x02); /* XXX */
@@ -2425,7 +2431,7 @@ mfii_scsi_cmd_cdb(struct mfii_softc *sc,
 	}
 	memcpy(io->cdb, xs->cmd, xs->cmdlen);
 
-	ctx->virtual_disk_target_id = htole16(periph->periph_target);
+	ctx->virtual_disk_target_id = htole16(target);
 
 	if (mfii_load_ccb(sc, ccb, ctx + 1,
 	ISSET(xs->xs_control, XS_CTL_NOSLEEP)) != 0)



CVS commit: src/sys/dev/pci

2022-07-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul 11 06:16:23 UTC 2022

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

Log Message:
KNF. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.739 -r1.740 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.739 src/sys/dev/pci/if_wm.c:1.740
--- src/sys/dev/pci/if_wm.c:1.739	Mon Jul 11 06:15:27 2022
+++ src/sys/dev/pci/if_wm.c	Mon Jul 11 06:16:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.739 2022/07/11 06:15:27 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.740 2022/07/11 06:16:23 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.739 2022/07/11 06:15:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.740 2022/07/11 06:16:23 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -321,7 +321,7 @@ struct wm_softc;
 #endif
 
 #ifdef WM_EVENT_COUNTERS
-#define WM_Q_EVCNT_DEFINE(qname, evname)\
+#define WM_Q_EVCNT_DEFINE(qname, evname) \
 	char qname##_##evname##_evcnt_name[sizeof("qname##XX##evname")]; \
 	struct evcnt qname##_ev_##evname
 
@@ -2049,8 +2049,8 @@ wm_attach(device_t parent, device_t self
 aprint_error_dev(sc->sc_dev,
 "WARNING: I/O BAR at zero.\n");
 			} else if (pci_mapreg_map(pa, i, PCI_MAPREG_TYPE_IO,
-	0, >sc_iot, >sc_ioh,
-	NULL, >sc_ios) == 0) {
+			0, >sc_iot, >sc_ioh, NULL, >sc_ios)
+			== 0) {
 sc->sc_flags |= WM_F_IOH_VALID;
 			} else
 aprint_error_dev(sc->sc_dev,
@@ -3114,13 +3114,11 @@ alloc_retry:
 	 * If we're a i82544 or greater (except i82547), we can do
 	 * TCP segmentation offload.
 	 */
-	if (sc->sc_type >= WM_T_82544 && sc->sc_type != WM_T_82547) {
+	if (sc->sc_type >= WM_T_82544 && sc->sc_type != WM_T_82547)
 		ifp->if_capabilities |= IFCAP_TSOv4;
-	}
 
-	if (sc->sc_type >= WM_T_82571) {
+	if (sc->sc_type >= WM_T_82571)
 		ifp->if_capabilities |= IFCAP_TSOv6;
-	}
 
 	sc->sc_tx_process_limit = WM_TX_PROCESS_LIMIT_DEFAULT;
 	sc->sc_tx_intr_process_limit = WM_TX_INTR_PROCESS_LIMIT_DEFAULT;
@@ -7245,8 +7243,10 @@ wm_alloc_txrx_queues(struct wm_softc *sc
 
 		for (j = 0; j < WM_NTXSEGS; j++) {
 			snprintf(txq->txq_txseg_evcnt_names[j],
-			sizeof(txq->txq_txseg_evcnt_names[j]), "txq%02dtxseg%d", i, j);
-			evcnt_attach_dynamic(>txq_ev_txseg[j], EVCNT_TYPE_MISC,
+			sizeof(txq->txq_txseg_evcnt_names[j]),
+			"txq%02dtxseg%d", i, j);
+			evcnt_attach_dynamic(>txq_ev_txseg[j],
+			EVCNT_TYPE_MISC,
 			NULL, xname, txq->txq_txseg_evcnt_names[j]);
 		}
 
@@ -7531,10 +7531,15 @@ wm_init_rx_regs(struct wm_softc *sc, str
 
 		if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
 			if (MCLBYTES & ((1 << SRRCTL_BSIZEPKT_SHIFT) - 1))
-panic("%s: MCLBYTES %d unsupported for 82575 or higher\n", __func__, MCLBYTES);
+panic("%s: MCLBYTES %d unsupported for 82575 "
+"or higher\n", __func__, MCLBYTES);
 
-			/* Currently, support SRRCTL_DESCTYPE_ADV_ONEBUF only. */
-			CSR_WRITE(sc, WMREG_SRRCTL(qid), SRRCTL_DESCTYPE_ADV_ONEBUF
+			/*
+			 * Currently, support SRRCTL_DESCTYPE_ADV_ONEBUF
+			 * only.
+			 */
+			CSR_WRITE(sc, WMREG_SRRCTL(qid),
+			SRRCTL_DESCTYPE_ADV_ONEBUF
 			| (MCLBYTES >> SRRCTL_BSIZEPKT_SHIFT));
 			CSR_WRITE(sc, WMREG_RXDCTL(qid), RXDCTL_QUEUE_ENABLE
 			| RXDCTL_PTHRESH(16) | RXDCTL_HTHRESH(8)
@@ -9255,15 +9260,15 @@ wm_rxdesc_ensure_checksum(struct wm_rxqu
 
 	if (!wm_rxdesc_is_set_status(sc, status, WRX_ST_IXSM, 0, 0)) {
 		if (wm_rxdesc_is_set_status(sc, status,
-			WRX_ST_IPCS, EXTRXC_STATUS_IPCS, NQRXC_STATUS_IPCS)) {
+		WRX_ST_IPCS, EXTRXC_STATUS_IPCS, NQRXC_STATUS_IPCS)) {
 			WM_Q_EVCNT_INCR(rxq, ipsum);
 			m->m_pkthdr.csum_flags |= M_CSUM_IPv4;
 			if (wm_rxdesc_is_set_error(sc, errors,
-WRX_ER_IPE, EXTRXC_ERROR_IPE, NQRXC_ERROR_IPE))
+			WRX_ER_IPE, EXTRXC_ERROR_IPE, NQRXC_ERROR_IPE))
 m->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD;
 		}
 		if (wm_rxdesc_is_set_status(sc, status,
-			WRX_ST_TCPCS, EXTRXC_STATUS_TCPCS, NQRXC_STATUS_L4I)) {
+		WRX_ST_TCPCS, EXTRXC_STATUS_TCPCS, NQRXC_STATUS_L4I)) {
 			/*
 			 * Note: we don't know if this was TCP or UDP,
 			 * so we just set both bits, and expect the
@@ -9318,9 +9323,8 @@ wm_rxeof(struct wm_rxqueue *rxq, u_int l
 		uint8_t rsstype = wm_rxdesc_get_rsstype(rxq, i);
 #endif
 
-		if (!wm_rxdesc_dd(rxq, i, status)) {
+		if (!wm_rxdesc_dd(rxq, i, status))
 			break;
-		}
 
 		if (limit-- == 0) {
 			more = true;
@@ -9523,10 +9527,9 @@ wm_linkintr_gmii(struct wm_softc *sc, ui
 	if ((sc->sc_type == WM_T_ICH8) && (link == false))
 		wm_gig_downshift_workaround_ich8lan(sc);
 
-	if ((sc->sc_type == WM_T_ICH8)
-	&& (sc->sc_phytype == WMPHY_IGP_3)) {
+	if ((sc->sc_type == WM_T_ICH8) && (sc->sc_phytype == WMPHY_IGP_3))
 		

CVS commit: src/sys/dev/pci

2022-07-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul 11 06:16:23 UTC 2022

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

Log Message:
KNF. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.739 -r1.740 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.



CVS commit: src/sys/dev/pci

2022-07-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul 11 06:15:27 UTC 2022

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

Log Message:
Consistently use semicolon. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.738 -r1.739 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.



CVS commit: src/sys/dev/pci

2022-07-11 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Jul 11 06:15:27 UTC 2022

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

Log Message:
Consistently use semicolon. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.738 -r1.739 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.738 src/sys/dev/pci/if_wm.c:1.739
--- src/sys/dev/pci/if_wm.c:1.738	Wed Jul  6 06:33:49 2022
+++ src/sys/dev/pci/if_wm.c	Mon Jul 11 06:15:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.738 2022/07/06 06:33:49 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.739 2022/07/11 06:15:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.738 2022/07/06 06:33:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.739 2022/07/11 06:15:27 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -323,7 +323,7 @@ struct wm_softc;
 #ifdef WM_EVENT_COUNTERS
 #define WM_Q_EVCNT_DEFINE(qname, evname)\
 	char qname##_##evname##_evcnt_name[sizeof("qname##XX##evname")]; \
-	struct evcnt qname##_ev_##evname;
+	struct evcnt qname##_ev_##evname
 
 #define WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, evtype)	\
 	do {\
@@ -342,7 +342,7 @@ struct wm_softc;
 	WM_Q_EVCNT_ATTACH(qname, evname, q, qnum, xname, EVCNT_TYPE_INTR)
 
 #define WM_Q_EVCNT_DETACH(qname, evname, q, qnum)	\
-	evcnt_detach(&(q)->qname##_ev_##evname);
+	evcnt_detach(&(q)->qname##_ev_##evname)
 #endif /* WM_EVENT_COUNTERS */
 
 struct wm_txqueue {
@@ -409,27 +409,27 @@ struct wm_txqueue {
 	uint32_t txq_bytes;		/* for AIM */
 #ifdef WM_EVENT_COUNTERS
 	/* TX event counters */
-	WM_Q_EVCNT_DEFINE(txq, txsstall)/* Stalled due to no txs */
-	WM_Q_EVCNT_DEFINE(txq, txdstall)/* Stalled due to no txd */
-	WM_Q_EVCNT_DEFINE(txq, fifo_stall)  /* FIFO stalls (82547) */
-	WM_Q_EVCNT_DEFINE(txq, txdw)	/* Tx descriptor interrupts */
-	WM_Q_EVCNT_DEFINE(txq, txqe)	/* Tx queue empty interrupts */
+	WM_Q_EVCNT_DEFINE(txq, txsstall);   /* Stalled due to no txs */
+	WM_Q_EVCNT_DEFINE(txq, txdstall);   /* Stalled due to no txd */
+	WM_Q_EVCNT_DEFINE(txq, fifo_stall); /* FIFO stalls (82547) */
+	WM_Q_EVCNT_DEFINE(txq, txdw);	/* Tx descriptor interrupts */
+	WM_Q_EVCNT_DEFINE(txq, txqe);	/* Tx queue empty interrupts */
 	/* XXX not used? */
 
-	WM_Q_EVCNT_DEFINE(txq, ipsum)	/* IP checksums comp. */
-	WM_Q_EVCNT_DEFINE(txq, tusum)	/* TCP/UDP cksums comp. */
-	WM_Q_EVCNT_DEFINE(txq, tusum6)	/* TCP/UDP v6 cksums comp. */
-	WM_Q_EVCNT_DEFINE(txq, tso)	/* TCP seg offload (IPv4) */
-	WM_Q_EVCNT_DEFINE(txq, tso6)	/* TCP seg offload (IPv6) */
-	WM_Q_EVCNT_DEFINE(txq, tsopain)	/* Painful header manip. for TSO */
-	WM_Q_EVCNT_DEFINE(txq, pcqdrop)	/* Pkt dropped in pcq */
-	WM_Q_EVCNT_DEFINE(txq, descdrop)/* Pkt dropped in MAC desc ring */
+	WM_Q_EVCNT_DEFINE(txq, ipsum);	/* IP checksums comp. */
+	WM_Q_EVCNT_DEFINE(txq, tusum);	/* TCP/UDP cksums comp. */
+	WM_Q_EVCNT_DEFINE(txq, tusum6);	/* TCP/UDP v6 cksums comp. */
+	WM_Q_EVCNT_DEFINE(txq, tso);	/* TCP seg offload (IPv4) */
+	WM_Q_EVCNT_DEFINE(txq, tso6);	/* TCP seg offload (IPv6) */
+	WM_Q_EVCNT_DEFINE(txq, tsopain);/* Painful header manip. for TSO */
+	WM_Q_EVCNT_DEFINE(txq, pcqdrop);/* Pkt dropped in pcq */
+	WM_Q_EVCNT_DEFINE(txq, descdrop);   /* Pkt dropped in MAC desc ring */
 	/* other than toomanyseg */
 
-	WM_Q_EVCNT_DEFINE(txq, toomanyseg)  /* Pkt dropped(toomany DMA segs) */
-	WM_Q_EVCNT_DEFINE(txq, defrag)	/* m_defrag() */
-	WM_Q_EVCNT_DEFINE(txq, underrun)/* Tx underrun */
-	WM_Q_EVCNT_DEFINE(txq, skipcontext) /* Tx skip wrong cksum context */
+	WM_Q_EVCNT_DEFINE(txq, toomanyseg); /* Pkt dropped(toomany DMA segs) */
+	WM_Q_EVCNT_DEFINE(txq, defrag);	/* m_defrag() */
+	WM_Q_EVCNT_DEFINE(txq, underrun);   /* Tx underrun */
+	WM_Q_EVCNT_DEFINE(txq, skipcontext); /* Tx skip wrong cksum context */
 
 	char txq_txseg_evcnt_names[WM_NTXSEGS][sizeof("txqXXtxsegXXX")];
 	struct evcnt txq_ev_txseg[WM_NTXSEGS]; /* Tx packets w/ N segments */
@@ -471,11 +471,11 @@ struct wm_rxqueue {
 	uint32_t rxq_bytes;		/* for AIM */
 #ifdef WM_EVENT_COUNTERS
 	/* RX event counters */
-	WM_Q_EVCNT_DEFINE(rxq, intr)	/* Interrupts */
-	WM_Q_EVCNT_DEFINE(rxq, defer)	/* Rx deferred processing */
+	WM_Q_EVCNT_DEFINE(rxq, intr);	/* Interrupts */
+	WM_Q_EVCNT_DEFINE(rxq, defer);	/* Rx deferred processing */
 
-	WM_Q_EVCNT_DEFINE(rxq, ipsum)	/* IP checksums checked */
-	WM_Q_EVCNT_DEFINE(rxq, tusum)	/* TCP/UDP cksums checked */
+	WM_Q_EVCNT_DEFINE(rxq, ipsum);	/* IP checksums checked */
+	WM_Q_EVCNT_DEFINE(rxq, tusum);	/* TCP/UDP cksums checked */
 #endif
 };
 



CVS commit: src/sys/dev/pci

2022-07-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul  9 11:41:56 UTC 2022

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

Log Message:
Use bus_space_write_8() if available.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.21 src/sys/dev/pci/mfii.c:1.22
--- src/sys/dev/pci/mfii.c:1.21	Sat Jul  9 11:41:18 2022
+++ src/sys/dev/pci/mfii.c	Sat Jul  9 11:41:56 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.21 2022/07/09 11:41:18 msaitoh Exp $ */
+/* $NetBSD: mfii.c,v 1.22 2022/07/09 11:41:56 msaitoh Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.21 2022/07/09 11:41:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.22 2022/07/09 11:41:56 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -1862,18 +1862,18 @@ mfii_load_mfa(struct mfii_softc *sc, str
 static void
 mfii_start(struct mfii_softc *sc, struct mfii_ccb *ccb)
 {
-#if defined(__LP64__) && 0
-	u_long *r = (u_long *)>ccb_req;
-#else
 	uint32_t *r = (uint32_t *)>ccb_req;
+#if defined(__LP64__)
+	uint64_t buf;
 #endif
 
 	bus_dmamap_sync(sc->sc_dmat, MFII_DMA_MAP(sc->sc_requests),
 	ccb->ccb_request_offset, MFII_REQUEST_SIZE,
 	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
-#if defined(__LP64__) && 0
-	bus_space_write_8(sc->sc_iot, sc->sc_ioh, MFI_IQPL, *r);
+#if defined(__LP64__)
+	buf = ((uint64_t)r[1] << 32) | r[0];
+	bus_space_write_8(sc->sc_iot, sc->sc_ioh, MFI_IQPL, buf);
 #else
 	mutex_enter(>sc_post_mtx);
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MFI_IQPL, r[0]);



CVS commit: src/sys/dev/pci

2022-07-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul  9 11:41:56 UTC 2022

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

Log Message:
Use bus_space_write_8() if available.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.



CVS commit: src/sys/dev/pci

2022-07-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul  9 11:41:18 UTC 2022

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

Log Message:
Modify strange bus_space_barrier().


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.20 src/sys/dev/pci/mfii.c:1.21
--- src/sys/dev/pci/mfii.c:1.20	Wed Jun 29 13:03:20 2022
+++ src/sys/dev/pci/mfii.c	Sat Jul  9 11:41:18 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: mfii.c,v 1.20 2022/06/29 13:03:20 msaitoh Exp $ */
+/* $NetBSD: mfii.c,v 1.21 2022/07/09 11:41:18 msaitoh Exp $ */
 /* $OpenBSD: mfii.c,v 1.58 2018/08/14 05:22:21 jmatthew Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.20 2022/06/29 13:03:20 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfii.c,v 1.21 2022/07/09 11:41:18 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -1877,12 +1877,9 @@ mfii_start(struct mfii_softc *sc, struct
 #else
 	mutex_enter(>sc_post_mtx);
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MFI_IQPL, r[0]);
-	bus_space_barrier(sc->sc_iot, sc->sc_ioh,
-	MFI_IQPL, 8, BUS_SPACE_BARRIER_WRITE);
-
 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MFI_IQPH, r[1]);
 	bus_space_barrier(sc->sc_iot, sc->sc_ioh,
-	MFI_IQPH, 8, BUS_SPACE_BARRIER_WRITE);
+	MFI_IQPL, 8, BUS_SPACE_BARRIER_WRITE);
 	mutex_exit(>sc_post_mtx);
 #endif
 }



CVS commit: src/sys/dev/pci

2022-07-09 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Sat Jul  9 11:41:18 UTC 2022

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

Log Message:
Modify strange bus_space_barrier().


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.



CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jul  9 01:24:32 UTC 2022

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

Log Message:
Remove redundant ``devsw_ok = false;''

Thanks mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/nvme_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/nvme_pci.c
diff -u src/sys/dev/pci/nvme_pci.c:1.35 src/sys/dev/pci/nvme_pci.c:1.36
--- src/sys/dev/pci/nvme_pci.c:1.35	Fri Jul  8 17:32:19 2022
+++ src/sys/dev/pci/nvme_pci.c	Sat Jul  9 01:24:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme_pci.c,v 1.35 2022/07/08 17:32:19 pgoyette Exp $	*/
+/*	$NetBSD: nvme_pci.c,v 1.36 2022/07/09 01:24:32 pgoyette Exp $	*/
 /*	$OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.35 2022/07/08 17:32:19 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.36 2022/07/09 01:24:32 pgoyette Exp $");
 
 #include 
 #include 
@@ -506,7 +506,7 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 		error = devsw_attach(nvme_cd.cd_name, NULL, ,
 		_cdevsw, );
 		if (error) {
-			devsw_ok = false;
+			/*XXXPRG devsw_ok = false;*/
 			aprint_error("%s: unable to register devsw, err %d\n",
 			nvme_cd.cd_name, error);
 			/* do not abort, just /dev/nvme* will not work */



CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jul  9 01:24:32 UTC 2022

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

Log Message:
Remove redundant ``devsw_ok = false;''

Thanks mrg@


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pci/nvme_pci.c

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



re: CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette

On Sat, 9 Jul 2022, matthew green wrote:


"Paul Goyette" writes:

Module Name:src
Committed By:   pgoyette
Date:   Fri Jul  8 17:32:19 UTC 2022

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

Log Message:
devsw_ok needs to survive across invocations of nvme_modcmd() so
allocate it statically.

Should address remaining issues with kern/56914


   if (error) {
+   devsw_ok = false;


shouldn't devsw_ok be "false" here already?  seems more like
something to ASSERT() than assign.


Yeah, this is likely unnecessary now.  It got there during a
debug iteration.

I will remove.


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+


re: CVS commit: src/sys/dev/pci

2022-07-08 Thread matthew green
"Paul Goyette" writes:
> Module Name:  src
> Committed By: pgoyette
> Date: Fri Jul  8 17:32:19 UTC 2022
>
> Modified Files:
>   src/sys/dev/pci: nvme_pci.c
>
> Log Message:
> devsw_ok needs to survive across invocations of nvme_modcmd() so
> allocate it statically.
>
> Should address remaining issues with kern/56914

if (error) {
+   devsw_ok = false;


shouldn't devsw_ok be "false" here already?  seems more like
something to ASSERT() than assign.


.mrg.


CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jul  8 17:32:19 UTC 2022

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

Log Message:
devsw_ok needs to survive across invocations of nvme_modcmd() so
allocate it statically.

Should address remaining issues with kern/56914


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/nvme_pci.c

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



CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jul  8 17:32:19 UTC 2022

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

Log Message:
devsw_ok needs to survive across invocations of nvme_modcmd() so
allocate it statically.

Should address remaining issues with kern/56914


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/pci/nvme_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/nvme_pci.c
diff -u src/sys/dev/pci/nvme_pci.c:1.34 src/sys/dev/pci/nvme_pci.c:1.35
--- src/sys/dev/pci/nvme_pci.c:1.34	Fri Jul  8 16:10:34 2022
+++ src/sys/dev/pci/nvme_pci.c	Fri Jul  8 17:32:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme_pci.c,v 1.34 2022/07/08 16:10:34 pgoyette Exp $	*/
+/*	$NetBSD: nvme_pci.c,v 1.35 2022/07/08 17:32:19 pgoyette Exp $	*/
 /*	$OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.34 2022/07/08 16:10:34 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.35 2022/07/08 17:32:19 pgoyette Exp $");
 
 #include 
 #include 
@@ -495,7 +495,7 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 #ifdef _MODULE
 	devmajor_t cmajor, bmajor;
 	extern const struct cdevsw nvme_cdevsw;
-	bool devsw_ok = false;
+	static bool devsw_ok;
 #endif
 	int error = 0;
 
@@ -506,6 +506,7 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 		error = devsw_attach(nvme_cd.cd_name, NULL, ,
 		_cdevsw, );
 		if (error) {
+			devsw_ok = false;
 			aprint_error("%s: unable to register devsw, err %d\n",
 			nvme_cd.cd_name, error);
 			/* do not abort, just /dev/nvme* will not work */
@@ -516,16 +517,20 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 		error = config_init_component(cfdriver_ioconf_nvme_pci,
 		cfattach_ioconf_nvme_pci, cfdata_ioconf_nvme_pci);
 		if (error) {
-			if (devsw_ok)
+			if (devsw_ok) {
 devsw_detach(NULL, _cdevsw);
+devsw_ok = false;
+			}
 			break;
 		}
 		break;
 	case MODULE_CMD_FINI:
 		error = config_fini_component(cfdriver_ioconf_nvme_pci,
 		cfattach_ioconf_nvme_pci, cfdata_ioconf_nvme_pci);
-		if (devsw_ok)
+		if (devsw_ok) {
 			devsw_detach(NULL, _cdevsw);
+			devsw_ok = false;
+		}
 		break;
 	default:
 		break;



CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jul  8 16:10:34 UTC 2022

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

Log Message:
Initialize cmajor & bmajor so the devsw_attach() has a chance of
succeeding.

Record the success of devsw_attach(), and do not try later to
devsw_detach() unless the attach succeeded.

Partial fix for kern/56914


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/nvme_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/nvme_pci.c
diff -u src/sys/dev/pci/nvme_pci.c:1.33 src/sys/dev/pci/nvme_pci.c:1.34
--- src/sys/dev/pci/nvme_pci.c:1.33	Thu Jul  7 23:54:17 2022
+++ src/sys/dev/pci/nvme_pci.c	Fri Jul  8 16:10:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme_pci.c,v 1.33 2022/07/07 23:54:17 pgoyette Exp $	*/
+/*	$NetBSD: nvme_pci.c,v 1.34 2022/07/08 16:10:34 pgoyette Exp $	*/
 /*	$OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.33 2022/07/07 23:54:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.34 2022/07/08 16:10:34 pgoyette Exp $");
 
 #include 
 #include 
@@ -495,12 +495,14 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 #ifdef _MODULE
 	devmajor_t cmajor, bmajor;
 	extern const struct cdevsw nvme_cdevsw;
+	bool devsw_ok = false;
 #endif
 	int error = 0;
 
 #ifdef _MODULE
 	switch (cmd) {
 	case MODULE_CMD_INIT:
+		bmajor = cmajor = NODEVMAJOR;
 		error = devsw_attach(nvme_cd.cd_name, NULL, ,
 		_cdevsw, );
 		if (error) {
@@ -508,18 +510,22 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 			nvme_cd.cd_name, error);
 			/* do not abort, just /dev/nvme* will not work */
 		}
+		else
+			devsw_ok = true;
+
 		error = config_init_component(cfdriver_ioconf_nvme_pci,
 		cfattach_ioconf_nvme_pci, cfdata_ioconf_nvme_pci);
 		if (error) {
-			devsw_detach(NULL, _cdevsw);
+			if (devsw_ok)
+devsw_detach(NULL, _cdevsw);
 			break;
 		}
-		bmajor = cmajor = NODEVMAJOR;
 		break;
 	case MODULE_CMD_FINI:
 		error = config_fini_component(cfdriver_ioconf_nvme_pci,
 		cfattach_ioconf_nvme_pci, cfdata_ioconf_nvme_pci);
-		devsw_detach(NULL, _cdevsw);
+		if (devsw_ok)
+			devsw_detach(NULL, _cdevsw);
 		break;
 	default:
 		break;



CVS commit: src/sys/dev/pci

2022-07-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Jul  8 16:10:34 UTC 2022

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

Log Message:
Initialize cmajor & bmajor so the devsw_attach() has a chance of
succeeding.

Record the success of devsw_attach(), and do not try later to
devsw_detach() unless the attach succeeded.

Partial fix for kern/56914


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/pci/nvme_pci.c

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



CVS commit: src/sys/dev/pci

2022-07-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jul  7 23:54:17 UTC 2022

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

Log Message:
Add errno tto message when fail to attach the devsw


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/nvme_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/nvme_pci.c
diff -u src/sys/dev/pci/nvme_pci.c:1.32 src/sys/dev/pci/nvme_pci.c:1.33
--- src/sys/dev/pci/nvme_pci.c:1.32	Thu Mar 31 19:30:16 2022
+++ src/sys/dev/pci/nvme_pci.c	Thu Jul  7 23:54:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme_pci.c,v 1.32 2022/03/31 19:30:16 pgoyette Exp $	*/
+/*	$NetBSD: nvme_pci.c,v 1.33 2022/07/07 23:54:17 pgoyette Exp $	*/
 /*	$OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.32 2022/03/31 19:30:16 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.33 2022/07/07 23:54:17 pgoyette Exp $");
 
 #include 
 #include 
@@ -504,8 +504,8 @@ nvme_modcmd(modcmd_t cmd, void *opaque)
 		error = devsw_attach(nvme_cd.cd_name, NULL, ,
 		_cdevsw, );
 		if (error) {
-			aprint_error("%s: unable to register devsw\n",
-			nvme_cd.cd_name);
+			aprint_error("%s: unable to register devsw, err %d\n",
+			nvme_cd.cd_name, error);
 			/* do not abort, just /dev/nvme* will not work */
 		}
 		error = config_init_component(cfdriver_ioconf_nvme_pci,



CVS commit: src/sys/dev/pci

2022-07-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jul  7 23:54:17 UTC 2022

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

Log Message:
Add errno tto message when fail to attach the devsw


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/dev/pci/nvme_pci.c

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



CVS commit: src/sys/dev/pci

2022-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  7 06:11:19 UTC 2022

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

Log Message:
Trailing whitespace


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

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

Modified files:

Index: src/sys/dev/pci/if_mcx.c
diff -u src/sys/dev/pci/if_mcx.c:1.23 src/sys/dev/pci/if_mcx.c:1.24
--- src/sys/dev/pci/if_mcx.c:1.23	Fri Nov  5 23:39:47 2021
+++ src/sys/dev/pci/if_mcx.c	Thu Jul  7 06:11:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mcx.c,v 1.23 2021/11/05 23:39:47 andvar Exp $ */
+/*	$NetBSD: if_mcx.c,v 1.24 2022/07/07 06:11:19 skrll Exp $ */
 /*	$OpenBSD: if_mcx.c,v 1.101 2021/06/02 19:16:11 patrick Exp $ */
 
 /*
@@ -23,7 +23,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_mcx.c,v 1.23 2021/11/05 23:39:47 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mcx.c,v 1.24 2022/07/07 06:11:19 skrll Exp $");
 
 #include 
 #include 
@@ -4052,7 +4052,7 @@ mcx_hca_max_caps(struct mcx_softc *sc)
 	 */
 	sc->sc_bf_size = (1 << hca->log_bf_reg_size) / 2;
 	sc->sc_max_rqt_size = (1 << hca->log_max_rqt_size);
-	
+
 	if (hca->local_ca_ack_delay & MCX_CAP_DEVICE_MCAM_REG)
 		sc->sc_mcam_reg = 1;
 
@@ -8803,7 +8803,7 @@ mcx_kstat_queue_read(struct kstat *ks)
 	int error = 0;
 
 	KERNEL_LOCK();
-	
+
 	if (mcx_query_rq(sc, >q_rx, ) != 0) {
 		error = EIO;
 		goto out;



CVS commit: src/sys/dev/pci

2022-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  7 06:11:19 UTC 2022

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

Log Message:
Trailing whitespace


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

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



CVS commit: src/sys/dev/pci

2022-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  7 06:11:08 UTC 2022

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/if_rge.c

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



CVS commit: src/sys/dev/pci

2022-07-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul  7 06:11:08 UTC 2022

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

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/pci/if_rge.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_rge.c
diff -u src/sys/dev/pci/if_rge.c:1.22 src/sys/dev/pci/if_rge.c:1.23
--- src/sys/dev/pci/if_rge.c:1.22	Mon Oct 11 15:11:49 2021
+++ src/sys/dev/pci/if_rge.c	Thu Jul  7 06:11:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_rge.c,v 1.22 2021/10/11 15:11:49 msaitoh Exp $	*/
+/*	$NetBSD: if_rge.c,v 1.23 2022/07/07 06:11:08 skrll Exp $	*/
 /*	$OpenBSD: if_rge.c,v 1.9 2020/12/12 11:48:53 jan Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.22 2021/10/11 15:11:49 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rge.c,v 1.23 2022/07/07 06:11:08 skrll Exp $");
 
 #include 
 
@@ -841,7 +841,7 @@ rge_stop(struct ifnet *ifp, int disable)
 
 	if (disable) {
 		callout_halt(>sc_timeout, NULL);
-	} else 
+	} else
 		callout_stop(>sc_timeout);
 
 	ifp->if_timer = 0;
@@ -1771,11 +1771,11 @@ rge_phy_config_mac_cfg4(struct rge_softc
 	uint16_t val;
 	int i;
 	static const uint16_t mac_cfg4_b87c_value[] =
-	{ 0x8013, 0x0700, 0x8fb9, 0x2801, 0x8fba, 0x0100, 0x8fbc, 0x1900, 
-	  0x8fbe, 0xe100, 0x8fc0, 0x0800, 0x8fc2, 0xe500, 0x8fc4, 0x0f00, 
-	  0x8fc6, 0xf100, 0x8fc8, 0x0400, 0x8fca, 0xf300, 0x8fcc, 0xfd00, 
-	  0x8fce, 0xff00, 0x8fd0, 0xfb00, 0x8fd2, 0x0100, 0x8fd4, 0xf400, 
-	  0x8fd6, 0xff00, 0x8fd8, 0xf600, 0x813d, 0x390e, 0x814f, 0x790e, 
+	{ 0x8013, 0x0700, 0x8fb9, 0x2801, 0x8fba, 0x0100, 0x8fbc, 0x1900,
+	  0x8fbe, 0xe100, 0x8fc0, 0x0800, 0x8fc2, 0xe500, 0x8fc4, 0x0f00,
+	  0x8fc6, 0xf100, 0x8fc8, 0x0400, 0x8fca, 0xf300, 0x8fcc, 0xfd00,
+	  0x8fce, 0xff00, 0x8fd0, 0xfb00, 0x8fd2, 0x0100, 0x8fd4, 0xf400,
+	  0x8fd6, 0xff00, 0x8fd8, 0xf600, 0x813d, 0x390e, 0x814f, 0x790e,
 	  0x80b0, 0x0f31 };
 
 	for (i = 0; i < nitems(rtl8125_mac_cfg4_ephy); i++)
@@ -1924,8 +1924,8 @@ rge_phy_config_mac_cfg4(struct rge_softc
 	val = rge_read_phy_ocp(sc, 0xa438) & ~0xff00;
 	rge_write_phy_ocp(sc, 0xa438, val | 0xc000);
 	rge_patch_phy_mcu(sc, 1);
-	RGE_PHY_CLRBIT(sc, 0xb896, 0x0001); 
-	RGE_PHY_CLRBIT(sc, 0xb892, 0xff00); 
+	RGE_PHY_CLRBIT(sc, 0xb896, 0x0001);
+	RGE_PHY_CLRBIT(sc, 0xb892, 0xff00);
 	rge_write_phy_ocp(sc, 0xb88e, 0xc23e);
 	rge_write_phy_ocp(sc, 0xb890, 0x);
 	rge_write_phy_ocp(sc, 0xb88e, 0xc240);
@@ -1940,10 +1940,10 @@ rge_phy_config_mac_cfg4(struct rge_softc
 	rge_write_phy_ocp(sc, 0xb890, 0x1012);
 	rge_write_phy_ocp(sc, 0xb88e, 0xc24a);
 	rge_write_phy_ocp(sc, 0xb890, 0x1416);
-	RGE_PHY_SETBIT(sc, 0xb896, 0x0001); 
+	RGE_PHY_SETBIT(sc, 0xb896, 0x0001);
 	rge_patch_phy_mcu(sc, 0);
-	RGE_PHY_SETBIT(sc, 0xa86a, 0x0001); 
-	RGE_PHY_SETBIT(sc, 0xa6f0, 0x0001); 
+	RGE_PHY_SETBIT(sc, 0xa86a, 0x0001);
+	RGE_PHY_SETBIT(sc, 0xa6f0, 0x0001);
 	rge_write_phy_ocp(sc, 0xbfa0, 0xd70d);
 	rge_write_phy_ocp(sc, 0xbfa2, 0x4100);
 	rge_write_phy_ocp(sc, 0xbfa4, 0xe868);
@@ -1951,7 +1951,7 @@ rge_phy_config_mac_cfg4(struct rge_softc
 	rge_write_phy_ocp(sc, 0xb54c, 0x3c18);
 	RGE_PHY_CLRBIT(sc, 0xbfa4, 0x0020);
 	rge_write_phy_ocp(sc, 0xa436, 0x817d);
-	RGE_PHY_SETBIT(sc, 0xa438, 0x1000); 
+	RGE_PHY_SETBIT(sc, 0xa438, 0x1000);
 }
 
 void



CVS commit: src/sys/dev/pci

2022-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul  6 06:33:49 UTC 2022

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

Log Message:
Call txeof first, then rxeof for the consistency.

 There are three functions where the txeof and rxeof are called. The MSI-X
interrupt function and the workqueue function call rxeof first, then rxeof.
For legacy interrupt. rxeof is called first. Modify it to match with other
two.


To generate a diff of this commit:
cvs rdiff -u -r1.737 -r1.738 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.737 src/sys/dev/pci/if_wm.c:1.738
--- src/sys/dev/pci/if_wm.c:1.737	Wed Jul  6 05:49:46 2022
+++ src/sys/dev/pci/if_wm.c	Wed Jul  6 06:33:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.737 2022/07/06 05:49:46 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.738 2022/07/06 06:33:49 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.737 2022/07/06 05:49:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.738 2022/07/06 06:33:49 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9946,6 +9946,29 @@ wm_intr_legacy(void *arg)
 	if (rndval == 0)
 		rndval = icr;
 
+	mutex_enter(txq->txq_lock);
+
+	if (txq->txq_stopping) {
+		mutex_exit(txq->txq_lock);
+		return 1;
+	}
+
+#if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS)
+	if (icr & ICR_TXDW) {
+		DPRINTF(sc, WM_DEBUG_TX,
+		("%s: TX: got TXDW interrupt\n",
+			device_xname(sc->sc_dev)));
+		WM_Q_EVCNT_INCR(txq, txdw);
+	}
+#endif
+	if (txlimit > 0) {
+		more |= wm_txeof(txq, txlimit);
+		if (!IF_IS_EMPTY(>if_snd))
+			more = true;
+	} else
+		more = true;
+	mutex_exit(txq->txq_lock);
+
 	mutex_enter(rxq->rxq_lock);
 
 	if (rxq->rxq_stopping) {
@@ -9974,28 +9997,6 @@ wm_intr_legacy(void *arg)
 
 	mutex_exit(rxq->rxq_lock);
 
-	mutex_enter(txq->txq_lock);
-
-	if (txq->txq_stopping) {
-		mutex_exit(txq->txq_lock);
-		return 1;
-	}
-
-#if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS)
-	if (icr & ICR_TXDW) {
-		DPRINTF(sc, WM_DEBUG_TX,
-		("%s: TX: got TXDW interrupt\n",
-			device_xname(sc->sc_dev)));
-		WM_Q_EVCNT_INCR(txq, txdw);
-	}
-#endif
-	if (txlimit > 0) {
-		more |= wm_txeof(txq, txlimit);
-		if (!IF_IS_EMPTY(>if_snd))
-			more = true;
-	} else
-		more = true;
-	mutex_exit(txq->txq_lock);
 	WM_CORE_LOCK(sc);
 
 	if (sc->sc_core_stopping) {



CVS commit: src/sys/dev/pci

2022-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul  6 06:33:49 UTC 2022

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

Log Message:
Call txeof first, then rxeof for the consistency.

 There are three functions where the txeof and rxeof are called. The MSI-X
interrupt function and the workqueue function call rxeof first, then rxeof.
For legacy interrupt. rxeof is called first. Modify it to match with other
two.


To generate a diff of this commit:
cvs rdiff -u -r1.737 -r1.738 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.



CVS commit: src/sys/dev/pci

2022-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul  6 06:32:50 UTC 2022

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

Log Message:
Call txeof first, then rxeof for the consistency.

 There are three functions where the txeof and rxeof are called. The MSI-X
interrupt function and the workqueue function call rxeof first, then rxeof.
For legacy interrupt. rxeof is called first. Modify it to match with other
two.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/if_vmx.c

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

Modified files:

Index: src/sys/dev/pci/if_vmx.c
diff -u src/sys/dev/pci/if_vmx.c:1.8 src/sys/dev/pci/if_vmx.c:1.9
--- src/sys/dev/pci/if_vmx.c:1.8	Tue May 24 02:22:47 2022
+++ src/sys/dev/pci/if_vmx.c	Wed Jul  6 06:32:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vmx.c,v 1.8 2022/05/24 02:22:47 msaitoh Exp $	*/
+/*	$NetBSD: if_vmx.c,v 1.9 2022/07/06 06:32:50 msaitoh Exp $	*/
 /*	$OpenBSD: if_vmx.c,v 1.16 2014/01/22 06:04:17 brad Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.8 2022/05/24 02:22:47 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vmx.c,v 1.9 2022/07/06 06:32:50 msaitoh Exp $");
 
 #include 
 #include 
@@ -2522,14 +2522,14 @@ vmxnet3_legacy_intr(void *xsc)
 	if (sc->vmx_ds->event != 0)
 		vmxnet3_evintr(sc);
 
-	VMXNET3_RXQ_LOCK(rxq);
-	rxmore = vmxnet3_rxq_eof(rxq, rxlimit);
-	VMXNET3_RXQ_UNLOCK(rxq);
-
 	VMXNET3_TXQ_LOCK(txq);
 	txmore = vmxnet3_txq_eof(txq, txlimit);
 	VMXNET3_TXQ_UNLOCK(txq);
 
+	VMXNET3_RXQ_LOCK(rxq);
+	rxmore = vmxnet3_rxq_eof(rxq, rxlimit);
+	VMXNET3_RXQ_UNLOCK(rxq);
+
 	if (txmore || rxmore)
 		vmxnet3_sched_handle_queue(sc, vmxq);
 	else {



CVS commit: src/sys/dev/pci

2022-07-06 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Jul  6 06:32:50 UTC 2022

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

Log Message:
Call txeof first, then rxeof for the consistency.

 There are three functions where the txeof and rxeof are called. The MSI-X
interrupt function and the workqueue function call rxeof first, then rxeof.
For legacy interrupt. rxeof is called first. Modify it to match with other
two.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/if_vmx.c

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



<    4   5   6   7   8   9   10   11   12   13   >