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 ka...
details: https://anonhg.NetBSD.org/src/rev/9dde4551f4d6
branches: netbsd-8
changeset: 939417:9dde4551f4d6
user: martin <martin%NetBSD.org@localhost>
date: Sun Sep 27 10:33:45 2020 +0000
description:
Pull up following revision(s) (requested by kardel in ticket #1610):
sys/dev/ic/ld_nvme.c: revision 1.24 (patch)
sys/dev/ic/nvme.c: revision 1.50 (patch)
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 | 49 +++++++++++++++++++++++++++++++++++++++----------
2 files changed, 43 insertions(+), 32 deletions(-)
diffs (136 lines):
diff -r ddc444ff02e5 -r 9dde4551f4d6 sys/dev/ic/ld_nvme.c
--- a/sys/dev/ic/ld_nvme.c Wed Sep 23 14:32:46 2020 +0000
+++ b/sys/dev/ic/ld_nvme.c Sun Sep 27 10:33:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_nvme.c,v 1.16.2.4 2019/10/28 18:27:47 martin Exp $ */
+/* $NetBSD: ld_nvme.c,v 1.16.2.5 2020/09/27 10:33:45 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.16.2.4 2019/10/28 18:27:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16.2.5 2020/09/27 10:33:45 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 LBA data sizes allowed here */
ld->sc_secsize = 1 << f->lbads;
ld->sc_secperunit = ns->ident->nsze;
diff -r ddc444ff02e5 -r 9dde4551f4d6 sys/dev/ic/nvme.c
--- a/sys/dev/ic/nvme.c Wed Sep 23 14:32:46 2020 +0000
+++ b/sys/dev/ic/nvme.c Sun Sep 27 10:33:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvme.c,v 1.30.2.7 2019/11/11 17:17:22 martin Exp $ */
+/* $NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 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.7 2019/11/11 17:17:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.30.2.8 2020/09/27 10:33:45 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -469,23 +469,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;
- memset(&naa, 0, sizeof(naa));
- naa.naa_nsid = i + 1;
- naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
- naa.naa_maxphys = sc->sc_mdts;
- sc->sc_namespaces[i].dev = config_found(sc->sc_dev, &naa,
- nvme_print);
+ }
+
+ 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;
+ naa.naa_qentries = (ioq_entries - 1) * sc->sc_nq;
+ naa.naa_maxphys = sc->sc_mdts;
+ sc->sc_namespaces[i - 1].dev = config_found(sc->sc_dev, &naa,
+ nvme_print);
}
return 0;
}
Home |
Main Index |
Thread Index |
Old Index