block/nvme: introduce PMR support from NVMe 1.4 spec
PATCH v4 1/1 block/nvme: introduce PMR support from NVMe 1.4 spec
This patch introduces support for PMR that has been defined as part of NVMe 1.4 spec. User can now specify a pmrdev option that should point to HostMemoryBackend. pmrdev memory region will subsequently be exposed as PCI BAR 2 in emulated NVMe device. Guest OS can perform mmio read and writes to the PMR region that will stay persistent across system reboot.
---
v3:
- replaced qemu_msync() use with qemu_ram_writeback() to allow pmem_persist() or qemu_msync() be called depending on configuration [4] (Stefan)
- rephrased comments to improve clarity and fixed code style issues [4] (Stefan, Klaus)
v2:
- reworked PMR to use HostMemoryBackend instead of directly mapping PMR backend file into qemu [1] (Stefan)
v1:
- provided support for Bit 1 from PMRWBM register instead of Bit 0 to ensure improved performance in virtualized environment [2] (Stefan)
- added check if pmr size is power of two in size [3] (David)
- addressed cross compilation build problems reported by CI environment
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
[2]: https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4-2019.06.10-Ratified.pdf
[3]: https://lore.kernel.org/qemu-devel/[email protected]/
[4]: https://lore.kernel.org/qemu-devel/[email protected]/
---
Persistent Memory Region (PMR) is a new optional feature provided in NVMe 1.4 specification. This patch implements initial support for it in NVMe driver.
--- hw/block/Makefile.objs | 2 +- hw/block/nvme.c | 109 ++++++++++++++++++++++++++ hw/block/nvme.h | 2 + hw/block/trace-events | 4 + include/block/nvme.h | 172 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 288 insertions(+), 1 deletion(-)
hw/block/Makefile.objs +1 -1
@@ -7,12 +7,12 @@ common-obj-$(CONFIG_PFLASH_CFI02) += pflash_cfi02.o common-obj-$(CONFIG_XEN) += xen-block.o common-obj-$(CONFIG_ECC) += ecc.o common-obj-$(CONFIG_ONENAND) += onenand.o -common-obj-$(CONFIG_NVME_PCI) += nvme.o common-obj-$(CONFIG_SWIM) += swim.o common-obj-$(CONFIG_SH4) += tc58128.o obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o +obj-$(CONFIG_NVME_PCI) += nvme.o obj-y += dataplane/
hw/block/nvme.c +109 -0
161 lines not on this page · raw message
hw/block/nvme.h +2 -0
@@ -83,6 +83,8 @@ typedef struct NvmeCtrl {uint64_t timestamp_set_qemu_clock_ms;/* QEMU clock time */ char *serial; +HostMemoryBackend *pmrdev; +NvmeNamespace *namespaces;NvmeSQueue **sq;NvmeCQueue **cq;
hw/block/trace-events +4 -0
@@ -110,6 +110,10 @@ nvme_ub_mmiowr_ssreset_w1c_unsupported(void) "attempted to W1C CSTS.NSSRO but CA nvme_ub_mmiowr_ssreset_unsupported(void) "attempted NVM subsystem reset but CAP.NSSRS is zero (not supported)" nvme_ub_mmiowr_cmbloc_reserved(void) "invalid write to reserved CMBLOC when CMBSZ is zero, ignored" nvme_ub_mmiowr_cmbsz_readonly(void) "invalid write to read only CMBSZ, ignored" +nvme_ub_mmiowr_pmrcap_readonly(void) "invalid write to read only PMRCAP, ignored" +nvme_ub_mmiowr_pmrsts_readonly(void) "invalid write to read only PMRSTS, ignored" +nvme_ub_mmiowr_pmrebs_readonly(void) "invalid write to read only PMREBS, ignored" +nvme_ub_mmiowr_pmrswtp_readonly(void) "invalid write to read only PMRSWTP, ignored" nvme_ub_mmiowr_invalid(uint64_t offset, uint64_t data) "invalid MMIO write, offset=0x%"PRIx64", data=0x%"PRIx64"" nvme_ub_mmiord_misaligned32(uint64_t offset) "MMIO read not 32-bit aligned, offset=0x%"PRIx64"" nvme_ub_mmiord_toosmall(uint64_t offset) "MMIO read smaller than 32-bits, offset=0x%"PRIx64""
include/block/nvme.h +172 -0
202 lines not on this page · raw message
Signature · 1 line
2.21.1
Quoted 34 lines · Andrzej Jakowski
This patch introduces support for PMR that has been defined as part of NVMe 1.4 spec. User can now specify a pmrdev option that should point to HostMemoryBackend. pmrdev memory region will subsequently be exposed as PCI BAR 2 in emulated NVMe device. Guest OS can perform mmio read and writes to the PMR region that will stay persistent across system reboot.
Signed-off-by Andrzej Jakowski <[email protected]>Reviewed-by Klaus Jensen <[email protected]>---
v3:
- replacedqemu_msync()use withqemu_ram_writeback()to allowpmem_persist()orqemu_msync()be called depending on configuration [4] (Stefan)
- rephrased comments to improve clarity and fixed code style issues [4] (Stefan, Klaus)v2:
- reworked PMR to use HostMemoryBackend instead of directly mapping PMR backend file into qemu [1] (Stefan)v1:
- provided support for Bit 1 from PMRWBM register instead of Bit 0 to ensure improved performance in virtualized environment [2] (Stefan)- added check if pmr size is power of two in size [3] (David)
- addressed cross compilation build problems reported by CI environment
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
[2]: https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4-2019.06.10-Ratified.pdf
[3]: https://lore.kernel.org/qemu-devel/[email protected]/
[4]: https://lore.kernel.org/qemu-devel/[email protected]/
---
Persistent Memory Region (PMR) is a new optional feature provided in NVMe 1.4 specification. This patch implements initial support for it in NVMe driver.
Quoted 7 lines
--- hw/block/Makefile.objs | 2 +- hw/block/nvme.c | 109 ++++++++++++++++++++++++++ hw/block/nvme.h | 2 + hw/block/trace-events | 4 + include/block/nvme.h | 172 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 288 insertions(+), 1 deletion(-)
Excellent, thank you!
Quoted 3 lines · Stefan Hajnoczi
Excellent, thank you!
Reviewed-by Stefan Hajnoczi <[email protected]>
Awesome, thx! Not sure about process...
Is this patch now staged for inclusion in QEMU?
Quoted 7 lines · Andrzej Jakowski
Quoted 3 lines · Stefan Hajnoczi
Excellent, thank you!
Reviewed-by Stefan Hajnoczi <[email protected]>Awesome, thx! Not sure about process...
Is this patch now staged for inclusion in QEMU?
Kevin or Max would normally merge it.
A review or ack from Keith Busch would be great, too.
Stefan
Quoted 6 lines · Stefan Hajnoczi
Quoted 5 lines · Andrzej Jakowski
Quoted 3 lines · Stefan Hajnoczi
Excellent, thank you!
Reviewed-by Stefan Hajnoczi <[email protected]>
Quoted 8 lines
Quoted 2 lines
Awesome, thx! Not sure about process...
Is this patch now staged for inclusion in QEMU?Kevin or Max would normally merge it.
A review or ack from Keith Busch would be great, too.
Stefan
Yes, I reviewed this patch on this thread, and looks good to me:
https://lists.nongnu.org/archive/html/qemu-devel/2020-03/msg08816.html