From: dv Date: Sat, 13 Jul 2024 08:59:41 +0000 (+0000) Subject: Backout previous change related to not freeing memory on suspend. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0abee971b6b0b08435fe3aa5b23b37e708c5f479;p=openbsd Backout previous change related to not freeing memory on suspend. It broke resume from hibernate. :( --- diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index 300505dbb51..a37f0f74587 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -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 @@ -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