From d6a0a91bc4b403d4d9757a0ff3be9b58247de298 Mon Sep 17 00:00:00 2001 From: Yandong Lin Date: Mon, 18 Oct 2021 17:55:01 +0800 Subject: [PATCH] video: rockchip: mpp: Fix report wrong dev when pagefault On some platforms(such as px30), vepu and vdpu shared the same mmu.So when registering the iommu handle function, there will be overwriting.Results in the reported device mismatch when page fault. Signed-off-by: Yandong Lin Change-Id: Id07c7f3088c52fcb987797c689296154c670078c --- drivers/video/rockchip/mpp/mpp_common.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/video/rockchip/mpp/mpp_common.c b/drivers/video/rockchip/mpp/mpp_common.c index 37fc4034acc1..4862d03691ed 100644 --- a/drivers/video/rockchip/mpp/mpp_common.c +++ b/drivers/video/rockchip/mpp/mpp_common.c @@ -1780,13 +1780,19 @@ static int mpp_iommu_handle(struct iommu_domain *iommu, unsigned long iova, int status, void *arg) { - struct mpp_dev *mpp = (struct mpp_dev *)arg; - struct mpp_task *task = mpp_taskqueue_get_running_task(mpp->queue); + struct mpp_taskqueue *queue = (struct mpp_taskqueue *)arg; + struct mpp_task *task = mpp_taskqueue_get_running_task(queue); + struct mpp_dev *mpp; - dev_err(mpp->dev, "fault addr 0x%08lx status %x\n", iova, status); - - if (!task) + /* + * NOTE: In link mode, this task may not be the task of the current + * hardware processing error + */ + if (!task || !task->session) return -EIO; + /* get mpp from cur task */ + mpp = task->session->mpp; + dev_err(mpp->dev, "fault addr 0x%08lx status %x\n", iova, status); mpp_task_dump_mem_region(mpp, task); mpp_task_dump_hw_reg(mpp, task); @@ -1896,7 +1902,7 @@ int mpp_dev_probe(struct mpp_dev *mpp, /* set iommu fault handler */ if (!IS_ERR(mpp->iommu_info)) iommu_set_fault_handler(mpp->iommu_info->domain, - mpp_iommu_handle, mpp); + mpp_iommu_handle, mpp->queue); /* read hardware id */ if (hw_info->reg_id >= 0) {