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 ka...
details: https://anonhg.NetBSD.org/src/rev/33f2237090d0
branches: netbsd-9
changeset: 939415:33f2237090d0
user: martin <martin%NetBSD.org@localhost>
date: Sun Sep 27 10:30:16 2020 +0000
description:
Pull up following revision(s) (requested by kardel in ticket #1094):
sys/dev/ic/ld_nvme.c: revision 1.24
sys/dev/ic/nvme.c: revision 1.50
PR kern/55674:
move name space availability check from ld_nvme.c:ld_nvme_attach()
to nvme.c:nvme_rescan().
this avoids allocation of ld(4) instances for every possible
name space, even if it is not usable. it also reduces the device
node flood generated from that strategy.
diffstat:
sys/dev/ic/ld_nvme.c | 26 ++++----------------------
sys/dev/ic/nvme.c | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 39 insertions(+), 28 deletions(-)
diffs (132 lines):
diff -r 266a973f7e59 -r 33f2237090d0 sys/dev/ic/ld_nvme.c
--- a/sys/dev/ic/ld_nvme.c Wed Sep 23 08:48:07 2020 +0000
+++ b/sys/dev/ic/ld_nvme.c Sun Sep 27 10:30:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $ */
+/* $NetBSD: ld_nvme.c,v 1.22.2.2 2020/09/27 10:30:16 martin Exp $ */
/*-
* Copyright (C) 2016 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.1 2019/10/28 18:30:43 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.22.2.2 2020/09/27 10:30:16 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -86,7 +86,6 @@
struct nvme_attach_args *naa = aux;
struct nvme_namespace *ns;
struct nvm_namespace_format *f;
- int error;
ld->sc_dv = self;
sc->sc_nvme = nsc;
@@ -95,28 +94,11 @@
aprint_naive("\n");
aprint_normal("\n");
- error = nvme_ns_identify(sc->sc_nvme, sc->sc_nsid);
- if (error) {
- aprint_error_dev(self, "couldn't identify namespace\n");
- return;
- }
-
ns = nvme_ns_get(sc->sc_nvme, sc->sc_nsid);
KASSERT(ns);
+
f = &ns->ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
-
- /*
- * NVME1.0e 6.11 Identify command
- *
- * LBADS values smaller than 9 are not supported, a value
- * of zero means that the format is not used.
- */
- if (f->lbads < 9) {
- if (f->lbads > 0)
- aprint_error_dev(self,
- "unsupported logical data size %u\n", f->lbads);
- return;
- }
+ KASSERT(f->lbads >= 9); /* only valid LBS data sizes allowed here */
ld->sc_secsize = 1 << f->lbads;
ld->sc_secperunit = ns->ident->nsze;
diff -r 266a973f7e59 -r 33f2237090d0 sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Wed Sep 23 08:48:07 2020 +0000
+++ b/sys/dev/ic/nvme.c Sun Sep 27 10:30:16 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme.c,v 1.44.2.3 2019/11/11 17:15:42 martin Exp $ */
+/* $NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 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.3 2019/11/11 17:15:42 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.44.2.4 2020/09/27 10:30:16 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -471,23 +471,52 @@
{
struct nvme_softc *sc = device_private(self);
struct nvme_attach_args naa;
+ struct nvm_namespace_format *f;
+ struct nvme_namespace *ns;
uint64_t cap;
int ioq_entries = nvme_ioq_size;
int i;
+ int error;
cap = nvme_read8(sc, NVME_CAP);
if (ioq_entries > NVME_CAP_MQES(cap))
ioq_entries = NVME_CAP_MQES(cap);
- for (i = 0; i < sc->sc_nn; i++) {
- if (sc->sc_namespaces[i].dev)
+ for (i = 1; i <= sc->sc_nn; i++) {
+ if (sc->sc_namespaces[i - 1].dev)
+ continue;
+
+ /* identify to check for availability */
+ error = nvme_ns_identify(sc, i);
+ if (error) {
+ aprint_error_dev(self, "couldn't identify namespace #%d\n", i);
continue;
+ }
+
+ ns = nvme_ns_get(sc, i);
+ KASSERT(ns);
+
+ f = &ns->ident->lbaf[NVME_ID_NS_FLBAS(ns->ident->flbas)];
+
+ /*
+ * NVME1.0e 6.11 Identify command
+ *
+ * LBADS values smaller than 9 are not supported, a value
+ * of zero means that the format is not used.
+ */
+ if (f->lbads < 9) {
+ if (f->lbads > 0)
+ aprint_error_dev(self,
+ "unsupported logical data size %u\n", f->lbads);
+ continue;
+ }
+
memset(&naa, 0, sizeof(naa));
- naa.naa_nsid = i + 1;
+ naa.naa_nsid = i;
naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
naa.naa_maxphys = sc->sc_mdts;
naa.naa_typename = sc->sc_modelname;
- sc->sc_namespaces[i].dev = config_found(sc->sc_dev, &naa,
+ sc->sc_namespaces[i - 1].dev = config_found(sc->sc_dev, &naa,
nvme_print);
}
return 0;
Home |
Main Index |
Thread Index |
Old Index