Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/dev/ic Pull up following revision(s) (requested by no...
details: https://anonhg.NetBSD.org/src/rev/c41c927afb71
branches: netbsd-9
changeset: 1001107:c41c927afb71
user: martin <martin%NetBSD.org@localhost>
date: Mon Nov 11 17:15:42 2019 +0000
description:
Pull up following revision(s) (requested by nonaka in ticket #415):
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 73893078c11e -r c41c927afb71 sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Mon Nov 11 17:13:28 2019 +0000
+++ b/sys/dev/ic/nvme.c Mon Nov 11 17:15:42 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme.c,v 1.44.2.2 2019/09/26 19:13:14 martin Exp $ */
+/* $NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 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.44.2.2 2019/09/26 19:13:14 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -116,7 +116,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 */
@@ -339,7 +340,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;
@@ -413,13 +414,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);
@@ -1579,20 +1582,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;
@@ -1604,13 +1608,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