LF-12399: swiotlb-xen: solve domu can not play video

VPU driver use "dma_map_resource" to transmit bus address to dma
address when both enable/disable IOMMU.

But in xen, if one device did not enable IOMMU,
The dma_map_ops of one device is "xen_swiotlb_dma_ops".
However the 'map_resource' callback is not achieved.
so this function returned value is 0xffffffff.

Add 'map_resource' and 'unmap_resource' for xen.
Use dma_direct_map_resource to achieve.

Signed-off-by: TaoJiang <tao.jiang_2@nxp.com>
Reviewed-by: MingQian <ming.qian@nxp.com>
This commit is contained in:
TaoJiang 2024-06-27 14:38:20 +05:30
parent ea76cda7ba
commit 0d983dd54b

View File

@ -372,6 +372,23 @@ xen_swiotlb_sync_sg_for_device(struct device *dev, struct scatterlist *sgl,
}
}
/*swiotlb means disable IOMMU*/
static dma_addr_t xen_swiotlb_dma_map_resource(struct device *dev, phys_addr_t phys_addr,
size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
dma_addr_t addr = DMA_MAPPING_ERROR;
addr = dma_direct_map_resource(dev, phys_addr, size, dir, attrs);
return addr;
}
static void xen_swiotlb_dma_unmap_resource(struct device *dev, dma_addr_t addr, size_t size,
enum dma_data_direction dir, unsigned long attrs)
{
/*do nothing*/
}
/*
* Return whether the given device DMA address mask can be supported
* properly. For example, if your device can only drive the low 24-bits
@ -406,4 +423,6 @@ const struct dma_map_ops xen_swiotlb_dma_ops = {
.alloc_pages = dma_common_alloc_pages,
.free_pages = dma_common_free_pages,
.max_mapping_size = swiotlb_max_mapping_size,
.map_resource = xen_swiotlb_dma_map_resource,
.unmap_resource = xen_swiotlb_dma_unmap_resource,
};