From 4aed134bfeaf7d85544a23f25edaee913462321e Mon Sep 17 00:00:00 2001 From: Cai YiWei Date: Thu, 14 Oct 2021 16:26:33 +0800 Subject: [PATCH] media: rockchip: isp: replace iommu detach/attach fix NULL Pointer when isp to reset [ 4486.719609] __iommu_dma_unmap+0x14/0x7c [ 4486.719968] iommu_dma_unmap_sg+0x64/0x90 [ 4486.720348] __iommu_unmap_sg_attrs+0x48/0x5c [ 4486.720745] vb2_dma_sg_dmabuf_ops_detach+0x60/0x80 [ 4486.721192] dma_buf_detach+0x88/0x9c iommu_detach_device will set domain to null, and __iommu_dma_unmap using domain but no check. Change-Id: I3c679565c6a7e67783e1750fc4d028191a9c9fcf Signed-off-by: Cai YiWei --- drivers/media/platform/rockchip/isp/hw.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rockchip/isp/hw.c b/drivers/media/platform/rockchip/isp/hw.c index 1f587f95da03..5707b29ea975 100644 --- a/drivers/media/platform/rockchip/isp/hw.c +++ b/drivers/media/platform/rockchip/isp/hw.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "common.h" #include "dev.h" @@ -523,10 +524,6 @@ static inline bool is_iommu_enable(struct device *dev) void rkisp_soft_reset(struct rkisp_hw_dev *dev, bool is_secure) { void __iomem *base = dev->base_addr; - struct iommu_domain *domain = iommu_get_domain_for_dev(dev->dev); - - if (domain) - iommu_detach_device(domain, dev->dev); if (is_secure) { /* if isp working, cru reset isn't secure. @@ -549,8 +546,11 @@ void rkisp_soft_reset(struct rkisp_hw_dev *dev, bool is_secure) writel(0xffff, base + CIF_IRCL); udelay(10); - if (domain) - iommu_attach_device(domain, dev->dev); + /* refresh iommu after reset */ + if (dev->is_mmu) { + rockchip_iommu_disable(dev->dev); + rockchip_iommu_enable(dev->dev); + } } static void isp_config_clk(struct rkisp_hw_dev *dev, int on)