The virtio-pmem request object stores wait queues, flags, and list
pointers next to buffers mapped for virtqueue DMA. The response buffer is
mapped DMA_FROM_DEVICE, so non-coherent DMA invalidation must not share a
cache line with CPU-owned fields.

Keep the request buffer outside the DMA-from-device group and wrap only
the response buffer with __dma_from_device_group_begin/end.

Signed-off-by: Li Chen <[email protected]>
---
Changes in v6:
- New patch.

 drivers/nvdimm/virtio_pmem.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/virtio_pmem.h b/drivers/nvdimm/virtio_pmem.h
index 1017e498c9b4c..23bff40249c1b 100644
--- a/drivers/nvdimm/virtio_pmem.h
+++ b/drivers/nvdimm/virtio_pmem.h
@@ -10,6 +10,7 @@
 #ifndef _LINUX_VIRTIO_PMEM_H
 #define _LINUX_VIRTIO_PMEM_H
 
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <uapi/linux/virtio_pmem.h>
 #include <linux/kref.h>
@@ -19,8 +20,6 @@
 
 struct virtio_pmem_request {
        struct kref kref;
-       struct virtio_pmem_req req;
-       struct virtio_pmem_resp resp;
 
        /* Wait queue to process deferred work after ack from host */
        wait_queue_head_t host_acked;
@@ -30,6 +29,11 @@ struct virtio_pmem_request {
        wait_queue_head_t wq_buf;
        bool wq_buf_avail;
        struct list_head list;
+
+       struct virtio_pmem_req req;
+       __dma_from_device_group_begin(resp);
+       struct virtio_pmem_resp resp;
+       __dma_from_device_group_end(resp);
 };
 
 struct virtio_pmem {
-- 
2.52.0

Reply via email to