summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-04-12 10:20:26 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-04-12 10:20:26 +0000
commit7fbf824b2ed9b3f800b35aaaf33df9b01d535afc (patch)
tree04d9dca6590c209c706ef882720c0dca1dc006f6 /sys/dev/ic
parent00a547e7f4df40eeec1ac7a52b3b1613a8a29aba (diff)
shuffle attach so we read chip capabilities before operating on it
most importantly this gets the proper timeout for chip enables/disables.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/nvme.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c
index c46c45287ca..a04b422a6ab 100644
--- a/sys/dev/ic/nvme.c
+++ b/sys/dev/ic/nvme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nvme.c,v 1.14 2016/01/15 06:38:33 dlg Exp $ */
+/* $OpenBSD: nvme.c,v 1.15 2016/04/12 10:20:25 dlg Exp $ */
/*
* Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@@ -261,6 +261,10 @@ nvme_attach(struct nvme_softc *sc)
u_int dstrd;
u_int mps = PAGE_SHIFT;
+ mtx_init(&sc->sc_ccb_mtx, IPL_BIO);
+ SIMPLEQ_INIT(&sc->sc_ccb_list);
+ scsi_iopool_init(&sc->sc_iopool, sc, nvme_ccb_get, nvme_ccb_put);
+
reg = nvme_read4(sc, NVME_VS);
if (reg == 0xffffffff) {
printf(", invalid mapping\n");
@@ -270,11 +274,6 @@ nvme_attach(struct nvme_softc *sc)
nvme_version(sc, reg);
printf("\n");
- if (nvme_disable(sc) != 0) {
- printf("%s: unable to disable controller\n", DEVNAME(sc));
- return (1);
- }
-
cap = nvme_read8(sc, NVME_CAP);
dstrd = NVME_CAP_DSTRD(cap);
if (NVME_CAP_MPSMIN(cap) > mps)
@@ -286,9 +285,11 @@ nvme_attach(struct nvme_softc *sc)
sc->sc_mps = 1 << mps;
sc->sc_mdts = MAXPHYS;
sc->sc_max_sgl = 2;
- mtx_init(&sc->sc_ccb_mtx, IPL_BIO);
- SIMPLEQ_INIT(&sc->sc_ccb_list);
- scsi_iopool_init(&sc->sc_iopool, sc, nvme_ccb_get, nvme_ccb_put);
+
+ if (nvme_disable(sc) != 0) {
+ printf("%s: unable to disable controller\n", DEVNAME(sc));
+ return (1);
+ }
sc->sc_admin_q = nvme_q_alloc(sc, NVME_ADMIN_Q, 128, dstrd);
if (sc->sc_admin_q == NULL) {