NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/60736 (ixl driver hang, then failure on ifconfig, if SFP module present at boot time and media connected.)



Synopsis: ixl driver hang, then failure on ifconfig, if SFP module present at boot time and media connected.

Responsible-Changed-From-To: kern-bug-people->yamaguchi
Responsible-Changed-By: riastradh%NetBSD.org@localhost
Responsible-Changed-When: Thu, 17 Sep 2026 18:29:16 +0000
Responsible-Changed-Why:
Yamaguchi-san, I see that you made several changes related to link
state handling in 2023.  Can you take a look at this?


I notice some issues in the driver's use of cv_timedwait (which is hard
to use correctly!):

1. If ixl_get_link_status fails with EBUSY in the first part, the
   second part might overwrite that error code.

2. If it wakes up part way to a timeout, it will start over
   cv_timedwait with the same timeout afresh, instead of counting down
   how much time is left when it starts over.

3. If the timeout happens at about the same time as it is woken by a
   legitimate wakeup, it might fail to notice the legitimate wakeup.

So it might be worthwhile to apply this change (untested), though I
don't think it will help to fix the issue tls@ observed:

--- if_ixl.c
+++ if_ixl.c
@@ -3651,16 +3651,23 @@
 	} else {
 		/* the previous command is not completed */
 		error = EBUSY;
+		goto out;
 	}
 
 	if (ISSET(flags, IXL_LINK_FLAG_WAITDONE)) {
-		do {
-			error = cv_timedwait(&sc->sc_atq_cv, &sc->sc_atq_lock,
-			    IXL_ATQ_EXEC_TIMEOUT);
-			if (error == EWOULDBLOCK)
+		const unsigned deadline = getticks() + IXL_ATQ_EXEC_TIMEOUT;
+
+		while (iatq->iatq_inuse ||
+		    ISSET(iaq->iaq_flags, htole16(IXL_AQ_DD))) {
+			const int left = deadline - getticks();
+
+			if (left <= 0) {
+				error = EWOULDBLOCK;
 				break;
-		} while (iatq->iatq_inuse ||
-		    ISSET(iaq->iaq_flags, htole16(IXL_AQ_DD)));
+			}
+			(void)cv_timedwait(&sc->sc_atq_cv, &sc->sc_atq_lock,
+			    left);
+		}
 	}
 
 out:






Home | Main Index | Thread Index | Old Index