Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci fix nvme_pci_detach() to not pci_intr_disestabli...



details:   https://anonhg.NetBSD.org/src/rev/95faed9a9fa2
branches:  trunk
changeset: 347777:95faed9a9fa2
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Sep 16 10:59:28 2016 +0000

description:
fix nvme_pci_detach() to not pci_intr_disestablish(); the interrupts
are disestablished and handler pointers are set to NULL already by
nvme_detach(), leading to panic here; this was happening when running
on system without MSI/MSI-X

change all the alloc/dealloc code for sc_ih to use psc->psc_nintrs, so
that we avoid some duplicated logic

diffstat:

 sys/dev/pci/nvme_pci.c |  22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diffs (78 lines):

diff -r 120ef6f845bb -r 95faed9a9fa2 sys/dev/pci/nvme_pci.c
--- a/sys/dev/pci/nvme_pci.c    Fri Sep 16 10:54:45 2016 +0000
+++ b/sys/dev/pci/nvme_pci.c    Fri Sep 16 10:59:28 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvme_pci.c,v 1.4 2016/07/11 06:14:51 knakahara Exp $   */
+/*     $NetBSD: nvme_pci.c,v 1.5 2016/09/16 10:59:28 jdolecek Exp $    */
 /*     $OpenBSD: nvme_pci.c,v 1.3 2016/04/14 11:18:32 dlg Exp $ */
 
 /*
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.4 2016/07/11 06:14:51 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme_pci.c,v 1.5 2016/09/16 10:59:28 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -112,7 +112,7 @@
        pcireg_t memtype;
        bus_addr_t memaddr;
        int flags, msixoff;
-       int nq, error;
+       int error;
 
        sc->sc_dev = self;
        psc->psc_pc = pa->pa_pc;
@@ -166,8 +166,7 @@
        sc->sc_intr_establish = nvme_pci_intr_establish;
        sc->sc_intr_disestablish = nvme_pci_intr_disestablish;
 
-       nq = sc->sc_nq + (sc->sc_use_mq ? 1 : 0);
-       sc->sc_ih = kmem_zalloc(sizeof(*sc->sc_ih) * nq, KM_SLEEP);
+       sc->sc_ih = kmem_zalloc(sizeof(*sc->sc_ih) * psc->psc_nintrs, KM_SLEEP);
        if (sc->sc_ih == NULL) {
                aprint_error_dev(self, "unable to allocate ih memory\n");
                goto intr_release;
@@ -185,7 +184,7 @@
        return;
 
 intr_free:
-       kmem_free(sc->sc_ih, sizeof(*sc->sc_ih) * nq);
+       kmem_free(sc->sc_ih, sizeof(*sc->sc_ih) * psc->psc_nintrs);
        sc->sc_nq = 0;
 intr_release:
        pci_intr_release(pa->pa_pc, psc->psc_intrs, psc->psc_nintrs);
@@ -200,7 +199,7 @@
 {
        struct nvme_pci_softc *psc = device_private(self);
        struct nvme_softc *sc = &psc->psc_nvme;
-       int i, nq, error;
+       int error;
 
        if (!ISSET(sc->sc_flags, NVME_F_ATTACHED))
                return 0;
@@ -209,12 +208,7 @@
        if (error)
                return error;
 
-       nq = sc->sc_nq + (sc->sc_use_mq ? 1 : 0);
-       if (!sc->sc_use_mq) {
-               for (i = 0; i < nq; i++)
-                       pci_intr_disestablish(psc->psc_pc, sc->sc_ih[i]);
-       }
-       kmem_free(sc->sc_ih, sizeof(*sc->sc_ih) * nq);
+       kmem_free(sc->sc_ih, sizeof(*sc->sc_ih) * psc->psc_nintrs);
        pci_intr_release(psc->psc_pc, psc->psc_intrs, psc->psc_nintrs);
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
        return 0;
@@ -274,7 +268,7 @@
            sizeof(intrbuf));
        if (!sc->sc_use_mq) {
                aprint_normal_dev(sc->sc_dev, "interrupting at %s\n", intrstr);
-       } else if (qid == 0) {
+       } else if (qid == NVME_ADMIN_Q) {
                aprint_normal_dev(sc->sc_dev,
                    "for admin queue interrupting at %s\n", intrstr);
        } else if (!nvme_pci_mpsafe) {



Home | Main Index | Thread Index | Old Index