Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic PR kern/55674:
details: https://anonhg.NetBSD.org/src/rev/9f8e8173b4bb
branches: trunk
changeset: 944177:9f8e8173b4bb
user: kardel <kardel%NetBSD.org@localhost>
date: Tue Sep 22 11:53:10 2020 +0000
description:
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 26a5ed72fe40 -r 9f8e8173b4bb sys/dev/ic/ld_nvme.c
--- a/sys/dev/ic/ld_nvme.c Tue Sep 22 11:44:44 2020 +0000
+++ b/sys/dev/ic/ld_nvme.c Tue Sep 22 11:53:10 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_nvme.c,v 1.23 2019/10/01 10:59:49 mlelstv Exp $ */
+/* $NetBSD: ld_nvme.c,v 1.24 2020/09/22 11:53:10 kardel 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.23 2019/10/01 10:59:49 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.24 2020/09/22 11:53:10 kardel 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 26a5ed72fe40 -r 9f8e8173b4bb sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Tue Sep 22 11:44:44 2020 +0000
+++ b/sys/dev/ic/nvme.c Tue Sep 22 11:53:10 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme.c,v 1.49 2020/07/28 15:59:19 jdolecek Exp $ */
+/* $NetBSD: nvme.c,v 1.50 2020/09/22 11:53:10 kardel 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.49 2020/07/28 15:59:19 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.50 2020/09/22 11:53:10 kardel 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