Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Jan 2024 17:17:46 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e2b71e1490a3 - stable/14 - mpi3mr: Minor tweak to task queue pausing
Message-ID:  <202401191717.40JHHkGo097506@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by mav:

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

commit e2b71e1490a37d8e42a6e1dc408cd83296360e1f
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-11-29 01:50:57 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2024-01-19 17:16:50 +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
    
    (cherry picked from commit 272a406042608da9bc3e67e41c6b7fc31d4166b8)
---
 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 73a40b374c1a..01ecceb430d6 100644
--- a/sys/dev/mpi3mr/mpi3mr.c
+++ b/sys/dev/mpi3mr/mpi3mr.c
@@ -5861,13 +5861,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);
+	}
 }
 
 /**



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401191717.40JHHkGo097506>