diff --git a/drivers/video/rockchip/mpp/mpp_common.c b/drivers/video/rockchip/mpp/mpp_common.c index 8552eebc5b28..49785e3e2f96 100644 --- a/drivers/video/rockchip/mpp/mpp_common.c +++ b/drivers/video/rockchip/mpp/mpp_common.c @@ -320,6 +320,8 @@ static int mpp_dev_abort(struct mpp_dev *mpp) static int mpp_task_run(struct mpp_dev *mpp, struct mpp_task *task) { + int ret; + mpp_debug_enter(); /* @@ -327,6 +329,16 @@ static int mpp_task_run(struct mpp_dev *mpp, * working in current hardware */ mpp_set_grf(mpp->grf_info); + /* + * for iommu share hardware, should attach to ensure + * working in current device + */ + ret = mpp_iommu_attach(mpp->iommu_info); + if (ret) { + dev_err(mpp->dev, "mpp_iommu_attach failed\n"); + return -ENODATA; + } + mpp_power_on(mpp); mpp_time_record(task); mpp_debug(DEBUG_TASK_INFO, "pid %d, start hw %s\n", diff --git a/drivers/video/rockchip/mpp/mpp_iommu.c b/drivers/video/rockchip/mpp/mpp_iommu.c index 05c860031aac..401133d936bd 100644 --- a/drivers/video/rockchip/mpp/mpp_iommu.c +++ b/drivers/video/rockchip/mpp/mpp_iommu.c @@ -213,16 +213,8 @@ struct mpp_dma_buffer *mpp_dma_import_fd(struct mpp_iommu_info *iommu_info, ret = PTR_ERR(sgt); goto fail_map; } - - ret = mpp_iommu_attach(iommu_info); - if (ret) { - dev_err(session->dev, "mpp_iommu_attach failed\n"); - goto fail_attachment; - } - buffer->iova = sg_dma_address(sgt->sgl); buffer->size = sg_dma_len(sgt->sgl); - buffer->attach = attach; buffer->sgt = sgt; buffer->session = session; @@ -239,8 +231,6 @@ struct mpp_dma_buffer *mpp_dma_import_fd(struct mpp_iommu_info *iommu_info, return buffer; -fail_attachment: - dma_buf_unmap_attachment(buffer->attach, sgt, buffer->dir); fail_map: dma_buf_detach(buffer->dmabuf, attach); fail_attach: