[PATCH v7 09/14] iommu/mediatek: Set dma_mask for the master devices

Yong Wu posted 14 patches 1 year, 7 months ago
[PATCH v7 09/14] iommu/mediatek: Set dma_mask for the master devices
Posted by Yong Wu 1 year, 7 months ago
MediaTek iommu arranges dma ranges for all the masters, this patch is to
help them set dma mask. This is to avoid each master setting their own
mask, but also to avoid a real issue, such as JPEG uses
"mediatek,mtk-jpgenc" for 2701/8183/8186/8188, then JPEG could ignore its
different dma_mask in different SoC to achieve common code.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
 drivers/iommu/mtk_iommu.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 0e104bb27010..f58b970dccf2 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -738,6 +738,14 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,
 	}
 	mutex_unlock(&data->mutex);
 
+	if (region_id > 0) {
+		ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(34));
+		if (ret) {
+			dev_err(m4udev, "Failed to set dma_mask for %s(%d).\n", dev_name(dev), ret);
+			return ret;
+		}
+	}
+
 	return mtk_iommu_config(data, dev, true, region_id);
 
 err_unlock:
-- 
2.25.1
Re: [PATCH v7 09/14] iommu/mediatek: Set dma_mask for the master devices
Posted by AngeloGioacchino Del Regno 1 year, 7 months ago
Il 11/04/23 11:31, Yong Wu ha scritto:
> MediaTek iommu arranges dma ranges for all the masters, this patch is to
> help them set dma mask. This is to avoid each master setting their own
> mask, but also to avoid a real issue, such as JPEG uses
> "mediatek,mtk-jpgenc" for 2701/8183/8186/8188, then JPEG could ignore its
> different dma_mask in different SoC to achieve common code.
> 
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>