Skip to content

Commit bf0ecb3

Browse files
rleonmszyprow
authored andcommitted
xen: swiotlb: Open code map_resource callback
General dma_direct_map_resource() is going to be removed in next patch, so simply open-code it in xen driver. Reviewed-by: Juergen Gross <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]> Link: https://lore.kernel.org/r/e9c66a92e818f416875441b6711963f9782dbbeb.1757423202.git.leonro@nvidia.com
1 parent 18c9cbb commit bf0ecb3

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

drivers/xen/swiotlb-xen.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,25 @@ xen_swiotlb_sync_sg_for_device(struct device *dev, struct scatterlist *sgl,
392392
}
393393
}
394394

395+
static dma_addr_t xen_swiotlb_direct_map_resource(struct device *dev,
396+
phys_addr_t paddr,
397+
size_t size,
398+
enum dma_data_direction dir,
399+
unsigned long attrs)
400+
{
401+
dma_addr_t dma_addr = paddr;
402+
403+
if (unlikely(!dma_capable(dev, dma_addr, size, false))) {
404+
dev_err_once(dev,
405+
"DMA addr %pad+%zu overflow (mask %llx, bus limit %llx).\n",
406+
&dma_addr, size, *dev->dma_mask, dev->bus_dma_limit);
407+
WARN_ON_ONCE(1);
408+
return DMA_MAPPING_ERROR;
409+
}
410+
411+
return dma_addr;
412+
}
413+
395414
/*
396415
* Return whether the given device DMA address mask can be supported
397416
* properly. For example, if your device can only drive the low 24-bits
@@ -426,5 +445,5 @@ const struct dma_map_ops xen_swiotlb_dma_ops = {
426445
.alloc_pages_op = dma_common_alloc_pages,
427446
.free_pages = dma_common_free_pages,
428447
.max_mapping_size = swiotlb_max_mapping_size,
429-
.map_resource = dma_direct_map_resource,
448+
.map_resource = xen_swiotlb_direct_map_resource,
430449
};

0 commit comments

Comments
 (0)