Module Name:    src
Committed By:   martin
Date:           Sat Feb 22 13:06:51 UTC 2025

Modified Files:
        src/sys/dev/ic [netbsd-10]: bwi.c

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

        sys/dev/ic/bwi.c: revision 1.43

bwi: Remove a delay() loop in the PIO RX path.


To generate a diff of this commit:
cvs rdiff -u -r1.38.10.2 -r1.38.10.3 src/sys/dev/ic/bwi.c

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

Modified files:

Index: src/sys/dev/ic/bwi.c
diff -u src/sys/dev/ic/bwi.c:1.38.10.2 src/sys/dev/ic/bwi.c:1.38.10.3
--- src/sys/dev/ic/bwi.c:1.38.10.2	Sat Feb 22 12:40:40 2025
+++ src/sys/dev/ic/bwi.c	Sat Feb 22 13:06:51 2025
@@ -1,4 +1,4 @@
-/*	$NetBSD: bwi.c,v 1.38.10.2 2025/02/22 12:40:40 martin Exp $	*/
+/*	$NetBSD: bwi.c,v 1.38.10.3 2025/02/22 13:06:51 martin Exp $	*/
 /*	$OpenBSD: bwi.c,v 1.74 2008/02/25 21:13:30 mglocker Exp $	*/
 
 /*
@@ -48,7 +48,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.38.10.2 2025/02/22 12:40:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bwi.c,v 1.38.10.3 2025/02/22 13:06:51 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -9064,10 +9064,10 @@ bwi_rx_frame_pio(struct bwi_softc *sc)
 	struct ifnet *ifp = &sc->sc_if;
 	const u_int qid = 0;
 	const size_t pio_hdrlen = 20;
+	struct timeval start, diff;
 	uint32_t val;
 	uint16_t pktlen;
 	uint16_t flags2;
-	u_int n;
 
 	/* Check for frame ready bit and acknowledge it */
 	val = CSR_READ_4(sc, BWI_PIO_RXCTL(qid));
@@ -9077,17 +9077,19 @@ bwi_rx_frame_pio(struct bwi_softc *sc)
 	CSR_WRITE_4(sc, BWI_PIO_RXCTL(qid), BWI_PIO_RXCTL_FRAMERDY);
 
 	/* Wait for up to 100us for data ready */
-	for (n = 10; n > 0; n--) {
+	microuptime(&start);
+	for (;;) {
 		val = CSR_READ_4(sc, BWI_PIO_RXCTL(qid));
 		if ((val & BWI_PIO_RXCTL_DATARDY) != 0) {
 			break;
 		}
-		delay(10);
-	}
-	if (n == 0) {
-		device_printf(sc->sc_dev, "RX timeout\n");
-		if_statinc(ifp, if_ierrors);
-		goto ack;
+		microuptime(&diff);
+		timersub(&diff, &start, &diff);
+		if (diff.tv_sec != 0 || diff.tv_usec > 100) {
+			device_printf(sc->sc_dev, "RX timeout\n");
+			if_statinc(ifp, if_ierrors);
+			goto ack;
+		}
 	}
 
 	/* Read 20 bytes of the packet RX header from the FIFO... */

Reply via email to