nvme-pci: clear shadow doorbell memory on resets
authorKeith Busch <kbusch@kernel.org>
Thu, 14 Oct 2021 16:45:42 +0000 (09:45 -0700)
committerChristoph Hellwig <hch@lst.de>
Wed, 20 Oct 2021 17:23:29 +0000 (19:23 +0200)
The host memory doorbell and event buffers need to be initialized on
each reset so the driver doesn't observe stale values from the previous
instantiation.

Signed-off-by: Keith Busch <kbusch@kernel.org>
Tested-by: John Levon <john.levon@nutanix.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/pci.c

index ed684874842ff0da4e0aa942a403918de0b69a81..6e05cfb4879fb7fd00cf7b4f90a9ba82e75d7905 100644 (file)
@@ -245,8 +245,15 @@ static int nvme_dbbuf_dma_alloc(struct nvme_dev *dev)
 {
        unsigned int mem_size = nvme_dbbuf_size(dev);
 
-       if (dev->dbbuf_dbs)
+       if (dev->dbbuf_dbs) {
+               /*
+                * Clear the dbbuf memory so the driver doesn't observe stale
+                * values from the previous instantiation.
+                */
+               memset(dev->dbbuf_dbs, 0, mem_size);
+               memset(dev->dbbuf_eis, 0, mem_size);
                return 0;
+       }
 
        dev->dbbuf_dbs = dma_alloc_coherent(dev->dev, mem_size,
                                            &dev->dbbuf_dbs_dma_addr,