git: bc1696f189b5 - stable/14 - virtio_p9fs: Check for completions after enabling interrupts

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 13 Aug 2025 12:02:02 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=bc1696f189b51bf3753ffb7097e03c9777399f84

commit bc1696f189b51bf3753ffb7097e03c9777399f84
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-10-25 17:52:22 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-08-13 11:56:14 +0000

    virtio_p9fs: Check for completions after enabling interrupts
    
    Otherwise we can end up with a lost interrupt, causing lost request
    completion wakeups and hangs in the filesystem layer.
    
    Continue processing until we enable interrupts and then observe an empty
    queue, like other virtio drivers do.
    
    Sponsored by:   Klara, Inc.
    
    (cherry picked from commit 1f6f247b3526abd4d5927684735012220aefe373)
---
 sys/dev/virtio/p9fs/virtio_p9fs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/dev/virtio/p9fs/virtio_p9fs.c b/sys/dev/virtio/p9fs/virtio_p9fs.c
index 67426a88bceb..24d4542e4e48 100644
--- a/sys/dev/virtio/p9fs/virtio_p9fs.c
+++ b/sys/dev/virtio/p9fs/virtio_p9fs.c
@@ -222,11 +222,15 @@ vt9p_intr_complete(void *xsc)
 	P9_DEBUG(TRANS, "%s: completing\n", __func__);
 
 	VT9P_LOCK(chan);
+again:
 	while ((curreq = virtqueue_dequeue(vq, NULL)) != NULL) {
 		curreq->rc->tag = curreq->tc->tag;
 		wakeup_one(curreq);
 	}
-	virtqueue_enable_intr(vq);
+	if (virtqueue_enable_intr(vq) != 0) {
+		virtqueue_disable_intr(vq);
+		goto again;
+	}
 	cv_signal(&chan->submit_cv);
 	VT9P_UNLOCK(chan);
 }