Backout previous change related to not freeing memory on suspend.
authordv <dv@openbsd.org>
Sat, 13 Jul 2024 08:59:41 +0000 (08:59 +0000)
committerdv <dv@openbsd.org>
Sat, 13 Jul 2024 08:59:41 +0000 (08:59 +0000)
It broke resume from hibernate. :(

sys/dev/ic/nvme.c

index 300505d..a37f0f7 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: nvme.c,v 1.120 2024/07/12 14:53:09 dv Exp $ */
+/*     $OpenBSD: nvme.c,v 1.121 2024/07/13 08:59:41 dv Exp $ */
 
 /*
  * Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@@ -78,7 +78,7 @@ void  nvme_empty_done(struct nvme_softc *, struct nvme_ccb *,
 struct nvme_queue *
        nvme_q_alloc(struct nvme_softc *, u_int16_t, u_int, u_int);
 int    nvme_q_create(struct nvme_softc *, struct nvme_queue *);
-void   nvme_q_reset(struct nvme_softc *, struct nvme_queue *);
+int    nvme_q_reset(struct nvme_softc *, struct nvme_queue *);
 int    nvme_q_delete(struct nvme_softc *, struct nvme_queue *);
 void   nvme_q_submit(struct nvme_softc *,
            struct nvme_queue *, struct nvme_ccb *,
@@ -436,22 +436,33 @@ nvme_resume(struct nvme_softc *sc)
                return (1);
        }
 
-       nvme_q_reset(sc, sc->sc_admin_q);
+       if (nvme_q_reset(sc, sc->sc_admin_q) != 0) {
+               printf("%s: unable to reset admin queue\n", DEVNAME(sc));
+               return (1);
+       }
 
        if (nvme_enable(sc) != 0) {
                printf("%s: unable to enable controller\n", DEVNAME(sc));
                return (1);
        }
 
+       sc->sc_q = nvme_q_alloc(sc, NVME_IO_Q, 128, sc->sc_dstrd);
+       if (sc->sc_q == NULL) {
+               printf("%s: unable to allocate io q\n", DEVNAME(sc));
+               goto disable;
+       }
+
        if (nvme_q_create(sc, sc->sc_q) != 0) {
                printf("%s: unable to create io q\n", DEVNAME(sc));
-               goto disable;
+               goto free_q;
        }
 
        nvme_write4(sc, NVME_INTMC, 1);
 
        return (0);
 
+free_q:
+       nvme_q_free(sc, sc->sc_q);
 disable:
        nvme_disable(sc);
 
@@ -1346,7 +1357,7 @@ nvme_q_delete(struct nvme_softc *sc, struct nvme_queue *q)
        if (rv != 0)
                goto fail;
 
-       nvme_q_reset(sc, q);
+       nvme_q_free(sc, q);
 
 fail:
        scsi_io_put(&sc->sc_iopool, ccb);
@@ -1505,7 +1516,7 @@ free:
        return (NULL);
 }
 
-void
+int
 nvme_q_reset(struct nvme_softc *sc, struct nvme_queue *q)
 {
        memset(NVME_DMA_KVA(q->q_sq_dmamem), 0, NVME_DMA_LEN(q->q_sq_dmamem));
@@ -1517,6 +1528,8 @@ nvme_q_reset(struct nvme_softc *sc, struct nvme_queue *q)
 
        nvme_dmamem_sync(sc, q->q_sq_dmamem, BUS_DMASYNC_PREWRITE);
        nvme_dmamem_sync(sc, q->q_cq_dmamem, BUS_DMASYNC_PREREAD);
+
+       return (0);
 }
 
 void