From 3fc0486fdf762698abd24b8ce4f596b8b87b7707 Mon Sep 17 00:00:00 2001 From: Simon Xue Date: Tue, 6 Apr 2021 16:54:17 +0800 Subject: [PATCH] iommu/rockchip: add max segment size for device The default max segment size is 64Kb, if memory that device want to map larger than default then it will break to several times mapping which may result in non-contiguous IOVA. So set to 4Gb Change-Id: I22eb7f30a3f741689c8c32734509c34f99fd8100 Signed-off-by: Simon Xue --- drivers/iommu/rockchip-iommu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 6b9ca1f5e824..7beef892a6eb 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1107,6 +1107,14 @@ static struct iommu_device *rk_iommu_probe_device(struct device *dev) data->defer_attach = false; + /* set max segment size for dev, needed for single chunk map */ + if (!dev->dma_parms) + dev->dma_parms = kzalloc(sizeof(*dev->dma_parms), GFP_KERNEL); + if (!dev->dma_parms) + return ERR_PTR(-ENOMEM); + + dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); + return &iommu->iommu; }