The branch main has been updated by imp:

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

commit 272a406042608da9bc3e67e41c6b7fc31d4166b8
Author:     Warner Losh <i...@freebsd.org>
AuthorDate: 2023-11-29 01:50:57 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2023-11-29 01:52:28 +0000

    mpi3mr: Minor tweak to task queue pausing
    
    Use a while loop with cancel / drain to make sure that all tasks have
    completed before proceeding to reset.
    
    Suggested by:           jhb
    Sponsored by:           Netflix
---
 sys/dev/mpi3mr/mpi3mr.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr.c b/sys/dev/mpi3mr/mpi3mr.c
index 39cefd15d476..932d174a6b50 100644
--- a/sys/dev/mpi3mr/mpi3mr.c
+++ b/sys/dev/mpi3mr/mpi3mr.c
@@ -5860,13 +5860,16 @@ static int mpi3mr_issue_reset(struct mpi3mr_softc *sc, 
U16 reset_type,
 inline void mpi3mr_cleanup_event_taskq(struct mpi3mr_softc *sc)
 {
        /*
-        * Block the taskqueue before draining. This means any new tasks won't
-        * be queued to a worker thread. But it doesn't stop the current workers
-        * that are running. taskqueue_drain waits for those correctly in the
-        * case of thread backed taskqueues.
+        * Block the taskqueue before draining.  This means any new tasks won't
+        * be queued to the taskqueue worker thread.  But it doesn't stop the
+        * current workers that are running.  taskqueue_drain waits for those
+        * correctly in the case of thread backed taskqueues.  The while loop
+        * ensures that all taskqueue threads have finished their current tasks.
         */
        taskqueue_block(sc->cam_sc->ev_tq);
-       taskqueue_drain(sc->cam_sc->ev_tq, &sc->cam_sc->ev_task);
+       while (taskqueue_cancel(sc->cam_sc->ev_tq, &sc->cam_sc->ev_task, NULL) 
!= 0) {
+               taskqueue_drain(sc->cam_sc->ev_tq, &sc->cam_sc->ev_task);
+       }
 }
 
 /**

Reply via email to