Skip to contentSkip to conversation

DMA-API: Introduce dma_(un)map_peer_resource

PATCH Konrad Wilk 2 participants 2 messages Aug 18, 2015 – Aug 19, 2015 PCI

lore
Share & tools
lore
#0 lore raw
Quoted 20 lines
(quoted diff) +2 -0
+#ifdef CONFIG_HAS_DMA_P2P
+static inline dma_peer_addr_t dma_map_peer_resource_attrs(struct

device *dev,

(quoted diff) +15 -0
+							  struct device *peer,
+							  struct resource *res,
+							  size_t offset,
+							  size_t size,
+							  enum dma_data_direction dir,
+							  struct dma_attrs *attrs)
+{
+	struct dma_map_ops *ops = get_dma_ops(dev);
+	dma_peer_addr_t addr;
+
+	BUG_ON(!valid_dma_direction(dir));
+	BUG_ON(ops->map_peer_resource == NULL);
+	addr = ops->map_peer_resource(dev, peer, res, offset, size, dir,
+				      attrs);
+	debug_dma_map_peer_resource(dev, peer, res, offset, size, dir,

addr);

Review

Quoted 3 lines
(quoted diff) +3 -0
+
+	return addr;
+

With those 'BUG_ON' you need to make sure that every dma_map_ops has this implemented. That means the calgary_dma_ops, gart_dma_ops, swiotlb_dma_ops, and xen_swiotlb_dma_ops MUST have something implemented.

Please keep in mind that on one can do 'iommu=soft swiotbl=force' on the command line which will force the IOMMUs to be ignored and only the SWIOTLB code will be used.

#1 lore raw
Quoted 27 lines
Quoted 19 lines
(quoted diff) +2 -0
+#ifdef CONFIG_HAS_DMA_P2P
+static inline dma_peer_addr_t dma_map_peer_resource_attrs(struct

device *dev,

(quoted diff) +15 -0
+							  struct device *peer,
+							  struct resource *res,
+							  size_t offset,
+							  size_t size,
+							  enum dma_data_direction dir,
+							  struct dma_attrs *attrs)
+{
+	struct dma_map_ops *ops = get_dma_ops(dev);
+	dma_peer_addr_t addr;
+
+	BUG_ON(!valid_dma_direction(dir));
+	BUG_ON(ops->map_peer_resource == NULL);
+	addr = ops->map_peer_resource(dev, peer, res, offset, size, dir,
+				      attrs);
+	debug_dma_map_peer_resource(dev, peer, res, offset, size, dir,

addr);

Review

Quoted 3 lines
(quoted diff) +3 -0
+
+	return addr;
+

With those 'BUG_ON' you need to make sure that every dma_map_ops has this implemented. That means the calgary_dma_ops, gart_dma_ops, swiotlb_dma_ops, and xen_swiotlb_dma_ops MUST have something implemented.

Quoted 3 lines

Please keep in mind that on one can do 'iommu=soft swiotbl=force' on the command line which will force the IOMMUs to be ignored and only the SWIOTLB code will be used.

Thanks for the feedback, Konrad. I will add implementations for those dma_map_ops in v6.

Will

--
nvpublic