On 3/28/2025 1:41 PM, Philippe Mathieu-Daudé wrote:
On 28/3/25 20:06, Farhan Ali wrote:
Use the QEMU PCI MMIO functions to read/write
to NVMe registers, rather than directly accessing
them.

Signed-off-by: Farhan Ali <al...@linux.ibm.com>
---
  block/nvme.c | 37 +++++++++++++++++++++----------------
  1 file changed, 21 insertions(+), 16 deletions(-)


@@ -805,16 +807,17 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
      bs->bl.request_alignment = s->page_size;
      timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000);
  -    ver = le32_to_cpu(regs->vs);
+    ver = qemu_pci_mmio_read_32(&regs->vs);
      trace_nvme_controller_spec_version(extract32(ver, 16, 16),
                                         extract32(ver, 8, 8),
                                         extract32(ver, 0, 8));
        /* Reset device to get a clean state. */
-    regs->cc = cpu_to_le32(le32_to_cpu(regs->cc) & 0xFE);
+    cc = qemu_pci_mmio_read_32(&regs->cc);
+    qemu_pci_mmio_write_32(&regs->cc, (cc & 0xFE));

Extra parenthesis not needed, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <phi...@linaro.org>

Sure, will fix. Thanks for reviewing!



Reply via email to