From 165f134f3d8f62cb74ab2f53e3b72158be0cfb31 Mon Sep 17 00:00:00 2001 From: Klaus Jensen Date: Wed, 9 Dec 2020 13:10:45 +0100 Subject: hw/block/nvme: fix shutdown/reset logic A shutdown is only about flushing stuff. It is the host that should delete any queues, so do not perform a reset here. Also, on shutdown, make sure that the PMR is flushed if in use. Fixes: 368f4e752cf9 ("hw/block/nvme: Process controller reset and shutdown differently") Signed-off-by: Klaus Jensen Reviewed-by: Keith Busch Tested-by: Dmitry Fomichev Reviewed-by: Dmitry Fomichev --- hw/block/nvme.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index b0b7abf331..551878338e 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -3419,7 +3419,7 @@ static void nvme_process_sq(void *opaque) } } -static void nvme_clear_ctrl(NvmeCtrl *n) +static void nvme_ctrl_reset(NvmeCtrl *n) { NvmeNamespace *ns; int i; @@ -3453,11 +3453,7 @@ static void nvme_clear_ctrl(NvmeCtrl *n) n->aer_queued = 0; n->outstanding_aers = 0; n->qs_created = false; -} -static void nvme_ctrl_reset(NvmeCtrl *n) -{ - nvme_clear_ctrl(n); n->bar.cc = 0; } @@ -3466,7 +3462,9 @@ static void nvme_ctrl_shutdown(NvmeCtrl *n) NvmeNamespace *ns; int i; - nvme_clear_ctrl(n); + if (n->pmrdev) { + memory_region_msync(&n->pmrdev->mr, 0, n->pmrdev->size); + } for (i = 1; i <= n->num_namespaces; i++) { ns = nvme_ns(n, i); @@ -4318,7 +4316,7 @@ static void nvme_exit(PCIDevice *pci_dev) NvmeNamespace *ns; int i; - nvme_ctrl_shutdown(n); + nvme_ctrl_reset(n); for (i = 1; i <= n->num_namespaces; i++) { ns = nvme_ns(n, i); -- cgit v1.2.3-55-g7522