On 3/27/2025 12:26 PM, Stefan Hajnoczi wrote:
On Wed, Mar 26, 2025 at 11:10:07AM -0700, Farhan Ali wrote:
+static inline uint32_t nvme_mmio_read_32(const void *addr)
+{
+    uint32_t ret;
+
+#ifdef __s390x__
+    ret = s390x_pci_mmio_read_32(addr);
+#else
+    /* Prevent the compiler from optimizing away the load */
+    ret = *((volatile uint32_t *)addr);
+#endif
The NVMe driver should not need to worry about s390 PCI MMIO specifics.
It would be nice to add a QEMU PCI MMIO load/store API that hides this.

block/nvme.c would use the API to access MMIO registers instead of
accessing them directly. The functions could be static inline in the
header file to minimize overhead on platforms that can directly access
PCI MMIO registers.

Hi Stefan,

Thanks for reviewing. I do agree, having a generic QEMU PCI MMIO load/store API for this would be good. And we can hide architecture specifics there. I didn't add that to begin with was NVMe driver would be the only place to consume it so thought might be unnecessary. I will refactor this in v2.

Thanks

Farhan



Reply via email to