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 no...



details:   https://anonhg.NetBSD.org/src/rev/7a1c69056aa4
branches:  netbsd-8
changeset: 460965:7a1c69056aa4
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Nov 11 17:17:22 2019 +0000

description:
Pull up following revision(s) (requested by nonaka in ticket #1432):

        sys/dev/ic/nvme.c: revision 1.47

nvme(4): Use the SET_FEATURES command to get the number of allocated queues.

diffstat:

 sys/dev/ic/nvme.c |  33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diffs (99 lines):

diff -r b59e3eb2666d -r 7a1c69056aa4 sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Sun Nov 10 13:37:22 2019 +0000
+++ b/sys/dev/ic/nvme.c Mon Nov 11 17:17:22 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvme.c,v 1.30.2.6 2019/09/26 18:23:13 martin Exp $     */
+/*     $NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 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.2.6 2019/09/26 18:23:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -114,7 +114,8 @@
 static int     nvme_command_passthrough(struct nvme_softc *,
                    struct nvme_pt_command *, uint16_t, struct lwp *, bool);
 
-static int     nvme_get_number_of_queues(struct nvme_softc *, u_int *);
+static int     nvme_set_number_of_queues(struct nvme_softc *, u_int, u_int *,
+                   u_int *);
 
 #define NVME_TIMO_QOP          5       /* queue create and delete timeout */
 #define NVME_TIMO_IDENT                10      /* probe identify timeout */
@@ -337,7 +338,7 @@
        uint32_t reg;
        u_int dstrd;
        u_int mps = PAGE_SHIFT;
-       u_int ioq_allocated;
+       u_int ncq, nsq;
        uint16_t adminq_entries = nvme_adminq_size;
        uint16_t ioq_entries = nvme_ioq_size;
        int i;
@@ -411,13 +412,15 @@
 
        if (sc->sc_use_mq) {
                /* Limit the number of queues to the number allocated in HW */
-               if (nvme_get_number_of_queues(sc, &ioq_allocated) != 0) {
+               if (nvme_set_number_of_queues(sc, sc->sc_nq, &ncq, &nsq) != 0) {
                        aprint_error_dev(sc->sc_dev,
                            "unable to get number of queues\n");
                        goto disable;
                }
-               if (sc->sc_nq > ioq_allocated)
-                       sc->sc_nq = ioq_allocated;
+               if (sc->sc_nq > ncq)
+                       sc->sc_nq = ncq;
+               if (sc->sc_nq > nsq)
+                       sc->sc_nq = nsq;
        }
 
        sc->sc_q = kmem_zalloc(sizeof(*sc->sc_q) * sc->sc_nq, KM_SLEEP);
@@ -1471,20 +1474,21 @@
 }
 
 static int
-nvme_get_number_of_queues(struct nvme_softc *sc, u_int *nqap)
+nvme_set_number_of_queues(struct nvme_softc *sc, u_int nq, u_int *ncqa,
+    u_int *nsqa)
 {
        struct nvme_pt_state state;
        struct nvme_pt_command pt;
        struct nvme_ccb *ccb;
-       uint16_t ncqa, nsqa;
        int rv;
 
        ccb = nvme_ccb_get(sc->sc_admin_q, false);
        KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */
 
        memset(&pt, 0, sizeof(pt));
-       pt.cmd.opcode = NVM_ADMIN_GET_FEATURES;
-       pt.cmd.cdw10 = NVM_FEATURE_NUMBER_OF_QUEUES;
+       pt.cmd.opcode = NVM_ADMIN_SET_FEATURES;
+       htolem32(&pt.cmd.cdw10, NVM_FEATURE_NUMBER_OF_QUEUES);
+       htolem32(&pt.cmd.cdw11, ((nq - 1) << 16) | (nq - 1));
 
        memset(&state, 0, sizeof(state));
        state.pt = &pt;
@@ -1496,13 +1500,12 @@
        rv = nvme_poll(sc, sc->sc_admin_q, ccb, nvme_pt_fill, NVME_TIMO_QOP);
 
        if (rv != 0) {
-               *nqap = 0;
+               *ncqa = *nsqa = 0;
                return EIO;
        }
 
-       ncqa = pt.cpl.cdw0 >> 16;
-       nsqa = pt.cpl.cdw0 & 0xffff;
-       *nqap = MIN(ncqa, nsqa) + 1;
+       *ncqa = (pt.cpl.cdw0 >> 16) + 1;
+       *nsqa = (pt.cpl.cdw0 & 0xffff) + 1;
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index