Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/dev/ic Pull up following revision(s) (requested by jd...



details:   https://anonhg.NetBSD.org/src/rev/3e18be631cbe
branches:  netbsd-8
changeset: 851486:3e18be631cbe
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Mar 17 08:11:18 2018 +0000

description:
Pull up following revision(s) (requested by jdolecek in ticket #636):
        sys/dev/ic/nvme.c: revision 1.33
        sys/dev/ic/nvmevar.h: revision 1.14
stop using q_nccbs_avail for deciding whether there are available ccbs;
no need to maintain a counter _and_ q_ccb_list
this fixes deadlock when all ccbs happen to be taken before completion
interrupt - nvme_q_complete() increased q_nccbs_avail only after
processing all the completed commands, by then there was nothing
left to actually kick the disk queue again into action
this also fixes ccb leak on command errors e.g. with bus_dmamem_alloc()
or bus_dmamel_load() - q_nccbs_avail was never decreased on the error path
fixes PR kern/52769 by Martin Husemann, thanks to Paul Goyette
for testing

diffstat:

 sys/dev/ic/nvme.c    |  18 ++++--------------
 sys/dev/ic/nvmevar.h |   3 +--
 2 files changed, 5 insertions(+), 16 deletions(-)

diffs (70 lines):

diff -r b9788c6a0e05 -r 3e18be631cbe sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Fri Mar 16 13:19:38 2018 +0000
+++ b/sys/dev/ic/nvme.c Sat Mar 17 08:11:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvme.c,v 1.30 2017/06/01 02:45:10 chs Exp $    */
+/*     $NetBSD: nvme.c,v 1.30.2.1 2018/03/17 08:11:18 martin Exp $     */
 /*     $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.1 2018/03/17 08:11:18 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1144,12 +1144,6 @@
 
        mutex_exit(&q->q_cq_mtx);
 
-       if (rv) {
-               mutex_enter(&q->q_ccb_mtx);
-               q->q_nccbs_avail += rv;
-               mutex_exit(&q->q_ccb_mtx);
-       }
-
        return rv;
 }
 
@@ -1362,7 +1356,6 @@
        q->q_ccbs = kmem_alloc(sizeof(*ccb) * nccbs, KM_SLEEP);
 
        q->q_nccbs = nccbs;
-       q->q_nccbs_avail = nccbs;
        q->q_ccb_prpls = nvme_dmamem_alloc(sc,
            sizeof(*prpl) * sc->sc_max_sgl * nccbs);
 
@@ -1402,11 +1395,8 @@
        struct nvme_ccb *ccb = NULL;
 
        mutex_enter(&q->q_ccb_mtx);
-       if (q->q_nccbs_avail > 0) {
-               ccb = SIMPLEQ_FIRST(&q->q_ccb_list);
-               KASSERT(ccb != NULL);
-               q->q_nccbs_avail--;
-
+       ccb = SIMPLEQ_FIRST(&q->q_ccb_list);
+       if (ccb != NULL) {
                SIMPLEQ_REMOVE_HEAD(&q->q_ccb_list, ccb_entry);
 #ifdef DEBUG
                ccb->ccb_cookie = NULL;
diff -r b9788c6a0e05 -r 3e18be631cbe sys/dev/ic/nvmevar.h
--- a/sys/dev/ic/nvmevar.h      Fri Mar 16 13:19:38 2018 +0000
+++ b/sys/dev/ic/nvmevar.h      Sat Mar 17 08:11:18 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmevar.h,v 1.13 2017/04/05 20:15:49 jdolecek Exp $    */
+/*     $NetBSD: nvmevar.h,v 1.13.6.1 2018/03/17 08:11:18 martin Exp $  */
 /*     $OpenBSD: nvmevar.h,v 1.8 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -88,7 +88,6 @@
 
        kmutex_t                q_ccb_mtx;
        uint16_t                q_nccbs;        /* total number of ccbs */
-       uint16_t                q_nccbs_avail;  /* available ccbs */
        struct nvme_ccb         *q_ccbs;
        SIMPLEQ_HEAD(, nvme_ccb) q_ccb_list;
        struct nvme_dmamem      *q_ccb_prpls;



Home | Main Index | Thread Index | Old Index