[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250113100300.174382-1-wangyufeng@kylinos.cn>
Date: Mon, 13 Jan 2025 18:03:00 +0800
From: Yufeng Wang <wangyufeng@...inos.cn>
To: "Michael S . Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
Yufeng Wang <wangyufeng@...inos.cn>,
Eugenio Pérez <eperezma@...hat.com>,
virtualization@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH v2] tools/virtio: Add DMA_MAPPING_ERROR and sg_dma_len api define for virtio test
when we build tools/virtio, meet below error information.
cc -g -O2 -Werror -Wno-maybe-uninitialized -Wall -I. -I../include/
-I ../../usr/include/ -Wno-pointer-sign -fno-strict-overflow
-fno-strict-aliasing -fno-common -MMD
-U_FORTIFY_SOURCE -include ../../include/linux/kconfig.h
-mfunction-return=thunk
-fcf-protection=none -mindirect-branch-register -pthread
-c -o virtio_ring.o ../../drivers/virtio/virtio_ring.c
../../drivers/virtio/virtio_ring.c: in function 'vring_need_unmap_buffer':
../../drivers/virtio/virtio_ring.c:294:54: error:'DMA_MAPPING_ERROR'Undeclared (first use within this function)
294 | return vring->use_dma_api && (extra->addr != DMA_MAPPING_ERROR);
| ^~~~~~~~~~~~~~~~~
../../drivers/virtio/virtio_ring.c:294:54: Note: Each undeclared identifier is only reported once within the function it appears in
../../drivers/virtio/virtio_ring.c: in function 'vring_map_one_sg':
../../drivers/virtio/virtio_ring.c:369:24: error:Implicit declaration function'sg_dma_len' [-Wimplicit-function-declaration]
369 | *len = sg_dma_len(sg);
| ^~~~~~~~~~
../../drivers/virtio/virtio_ring.c: in function'virtqueue_add_desc_split':
../../drivers/virtio/virtio_ring.c:518:37: error:'DMA_MAPPING_ERROR'Undeclared (first use within this function)
518 | extra[i].addr = premapped ? DMA_MAPPING_ERROR : addr;
| ^~~~~~~~~~~~~~~~~
../../drivers/virtio/virtio_ring.c: in function'virtqueue_add_indirect_packed':
../../drivers/virtio/virtio_ring.c:1370:61: error: 'DMA_MAPPING_ERROR'Undeclared (first use within this function)
1370 | extra[i].addr = premapped ? DMA_MAPPING_ERROR : addr;
| ^~~~~~~~~~~~~~~~~
../../drivers/virtio/virtio_ring.c: in function'virtqueue_add_packed':
../../drivers/virtio/virtio_ring.c:1535:41: error:'DMA_MAPPING_ERROR'Undeclared (first use within this function)
1535 | DMA_MAPPING_ERROR : addr;
| ^~~~~~~~~~~~~~~~~
Fixes: <c7e1b422afac>("virtio_ring: perform premapped operations based on per-buffer")
also add DMA_MAPPING_ERROR define for virtio test.
Signed-off-by: Yufeng Wang <wangyufeng@...inos.cn>
---
v2: fix more build error in the same commit
<c7e1b422afac>("virtio_ring: perform premapped operations based on per-buffer")
---
tools/virtio/linux/dma-mapping.h | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/virtio/linux/dma-mapping.h b/tools/virtio/linux/dma-mapping.h
index 822ecaa8e4df..095958461788 100644
--- a/tools/virtio/linux/dma-mapping.h
+++ b/tools/virtio/linux/dma-mapping.h
@@ -31,6 +31,7 @@ enum dma_data_direction {
#define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0)
#define sg_dma_address(sg) (0)
+#define sg_dma_len(sg) (0)
#define dma_need_sync(v, a) (0)
#define dma_unmap_single_attrs(d, a, s, r, t) do { \
(void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \
@@ -43,4 +44,16 @@ enum dma_data_direction {
} while (0)
#define dma_max_mapping_size(...) SIZE_MAX
+/*
+ * A dma_addr_t can hold any valid DMA or bus address for the platform. It can
+ * be given to a device to use as a DMA source or target. It is specific to a
+ * given device and there may be a translation between the CPU physical address
+ * space and the bus address space.
+ *
+ * DMA_MAPPING_ERROR is the magic error code if a mapping failed. It should not
+ * be used directly in drivers, but checked for using dma_mapping_error()
+ * instead.
+ */
+#define DMA_MAPPING_ERROR (~(dma_addr_t)0)
+
#endif
--
2.34.1
Powered by blists - more mailing lists