summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlaus Jensen2020-12-09 13:10:45 +0100
committerKlaus Jensen2021-02-08 21:15:53 +0100
commit165f134f3d8f62cb74ab2f53e3b72158be0cfb31 (patch)
tree3e712c4c7d65978e29638bdd1839e79c454b64ca
parenthw/block/nvme: conditionally enable DULBE for zoned namespaces (diff)
downloadqemu-165f134f3d8f62cb74ab2f53e3b72158be0cfb31.tar.gz
qemu-165f134f3d8f62cb74ab2f53e3b72158be0cfb31.tar.xz
qemu-165f134f3d8f62cb74ab2f53e3b72158be0cfb31.zip
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 <k.jensen@samsung.com> Reviewed-by: Keith Busch <kbusch@kernel.org> Tested-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> Reviewed-by: Dmitry Fomichev <dmitry.fomichev@wdc.com>
-rw-r--r--hw/block/nvme.c12
1 files 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);