Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1084974ybl; Wed, 21 Aug 2019 09:54:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPlINdiyewHfrC//RVW8nrJ87NNB+bIsH6vDjbKRqAPbGoDvviXissCRcl4L2P44xzG23N X-Received: by 2002:aa7:934f:: with SMTP id 15mr36146785pfn.22.1566406485653; Wed, 21 Aug 2019 09:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566406485; cv=none; d=google.com; s=arc-20160816; b=ygE/xslRkFRBK+70macwMO1xYvtNXOdXoDZLn4g0tIVKoEOv6P6In1W6PzyGvXFVRE FT/EYDY3G1id7ETwSkLhmLyjxMwE02nuA1pJ1144U326Fl+DIKZ6eMjHtAj5pcSIxqFh fVoOkCaeXAn6jXExFsh7JHtG3WNAVgjZ35bG9NQqQHR371BKTaupAsPsbaTJGgbWzzPu p170Pr2+f9/RF2ZFIqq056lXZcl/Y5nHPm7rqKy9yO2X+SpgyvFj2vo7N31VUQFZ042U tvdW5zF8v+PJVP3q6TiXSI1Lo5XlgwC3wfBdukGnNzCFPdZr0M3R9MvERx7/wR782kmK p1Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ZnJao1XzxNjJe9VZoNAFJz2LDBwCW9ALu6BKyn2MTmE=; b=pWqtVONZwnSvv65C2QSNvvVyAiU9f6tIYTSEWuMYDmbf7+jOprRWo/T7hP2IiGtfAs 2GjQZkQFNilAAZQDtHsmVVtbb2LwnNNydXmmf96iR3B1lgO7oOJ2bLogxzlUBmL8MtRR qnKt02RWdJcwNllrEJx+HkfuCMXeID4rdLSPn6CDbAQnlQjHiLX8Q+wJJ9AiniF4vV/k oNI8R5az0H/3KnyqhJt9o5D1Kg8egeMgti1IZP9qOdEjBp9As8fyx6lvymh1q4y5rLgA rV7R87YCTF7eEULRlgQw7zRQ+y9LknC6eeWWH+ybU5MBJOi+Odc+75Ky6ZmRd8Kj88+Z orVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si14564036pgo.283.2019.08.21.09.54.30; Wed, 21 Aug 2019 09:54:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729195AbfHUN4L (ORCPT + 99 others); Wed, 21 Aug 2019 09:56:11 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:30686 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729178AbfHUN4K (ORCPT ); Wed, 21 Aug 2019 09:56:10 -0400 X-UUID: bf032ca8b0f3494c86c7cd8c8458a5a3-20190821 X-UUID: bf032ca8b0f3494c86c7cd8c8458a5a3-20190821 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 631189620; Wed, 21 Aug 2019 21:56:05 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Aug 2019 21:56:03 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 21 Aug 2019 21:56:01 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Will Deacon CC: Rob Herring , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke , , , Subject: [PATCH v10 12/23] iommu/mediatek: Add larb-id remapped support Date: Wed, 21 Aug 2019 21:53:15 +0800 Message-ID: <1566395606-7975-13-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> References: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The larb-id may be remapped in the smi-common, this means the larb-id reported in the mtk_iommu_isr isn't the real larb-id, Take mt8183 as a example: M4U | --------------------------------------------- | SMI common | -0-----7-----5-----6-----1-----2------3-----4- <- Id remapped | | | | | | | | larb0 larb1 IPU0 IPU1 larb4 larb5 larb6 CCU disp vdec img cam venc img cam As above, larb0 connects with the id 0 in smi-common. larb1 connects with the id 7 in smi-common. ... If the larb-id reported in the isr is 7, actually it's larb1(vdec). In order to output the right larb-id in the isr, we add a larb-id remapping relationship in this patch. If there is no this larb-id remapping in some SoCs, use the linear mapping array instead. This also is a preparing patch for mt8183. Signed-off-by: Yong Wu Reviewed-by: Nicolas Boichat Reviewed-by: Evan Green Reviewed-by: Matthias Brugger --- drivers/iommu/mtk_iommu.c | 4 ++++ drivers/iommu/mtk_iommu.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 4df3cb4..34f0203 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -236,6 +236,8 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) fault_larb = F_MMU0_INT_ID_LARB_ID(regval); fault_port = F_MMU0_INT_ID_PORT_ID(regval); + fault_larb = data->plat_data->larbid_remap[fault_larb]; + if (report_iommu_fault(&dom->domain, data->dev, fault_iova, write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) { dev_err_ratelimited( @@ -766,12 +768,14 @@ static int __maybe_unused mtk_iommu_resume(struct device *dev) .m4u_plat = M4U_MT2712, .has_4gb_mode = true, .has_bclk = true, + .larbid_remap = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, }; static const struct mtk_iommu_plat_data mt8173_data = { .m4u_plat = M4U_MT8173, .has_4gb_mode = true, .has_bclk = true, + .larbid_remap = {0, 1, 2, 3, 4, 5}, /* Linear mapping. */ }; static const struct of_device_id mtk_iommu_of_ids[] = { diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index 821172b..d1a1d88 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -38,6 +38,8 @@ struct mtk_iommu_plat_data { /* HW will use the EMI clock if there isn't the "bclk". */ bool has_bclk; + + unsigned char larbid_remap[MTK_LARB_NR_MAX]; }; struct mtk_iommu_domain; -- 1.9.1