Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1246532imj; Sun, 17 Feb 2019 01:13:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IZLsm22D8Rh/Tk37NlZZ2W9OHj8GbUvJQoyc7vLLKlLf+cUh8c04Npfqn7xAMkGgZCxXxhV X-Received: by 2002:a63:8341:: with SMTP id h62mr17569417pge.254.1550394834087; Sun, 17 Feb 2019 01:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550394834; cv=none; d=google.com; s=arc-20160816; b=iS1cJqYYWdedHy45SY3wbxR16MGPw5kWo6wCGKs/ATk7uSI2VIFnKjJ0eyLKZ7hCNV lUsV5WzbpT762VTM8OoqVd1xqGrgoAabni+tQfFRJJuuKPIqFuX9eCHCy3aLp9OIvHqv hweEc/SqJvgU3y+vKDTxUtuUE2HcGERRZ6G7v+P1a8K6fQKpwrK8X4nKcKpxc5aRNUKt 7yIPfoLim5yo235pkZ5m246/XCZRZBvEAekqn+SXO8IiWTPf1dyRPPfkNQN3OfNDoOIl Cdg47PE7Dk+2VkVTiwNWPrEHsJ9plJlr/iGCx0boB3O957IhDS+4c0HYMuoy7krDikDq nFjQ== 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=vlarbUDX9wMFKLoqOrIsLrVgyFxrmW/GVlMuYc8lENs=; b=Pv48kR/FKs97MLuSjyLYDxKm2NRdSq5/O0TuVYBJvsAel6gjV+MNBFmZh5fz0g6hLu YXeoNhiIDlrJdIyxc3IPU4AKjDKAWDQvW4S3m5HaloLEhE9z5qPYmLWpgvKqbsvH2LN2 dRe4eKlc9/YkSuWUWtSo2Ni7oyUgL2SekIULwsETEDorI4/viI3ptQXeE8Fsc26P6GT2 DVM1gG3EdUxsEOCHwhhHxmU72nLlLweigqe4+f7aPaQteQnW5kq/uTH2+jopUEI843GH 9a24k5ifw0xN/MTODxXodWagmBuEnf6fJ2fcn6i1FiHam0A+SZDXD2FSoioGfw7wueg8 Zunw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 90si4323488pfs.173.2019.02.17.01.13.38; Sun, 17 Feb 2019 01:13:54 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727347AbfBQJHx (ORCPT + 99 others); Sun, 17 Feb 2019 04:07:53 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:43370 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727136AbfBQJHx (ORCPT ); Sun, 17 Feb 2019 04:07:53 -0500 X-UUID: 992f40b48bd74862a61eb496c5489ed8-20190217 X-UUID: 992f40b48bd74862a61eb496c5489ed8-20190217 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 991814477; Sun, 17 Feb 2019 17:07:48 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 17 Feb 2019 17:07:47 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sun, 17 Feb 2019 17:07:46 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Evan Green , Tomasz Figa , Will Deacon , , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke Subject: [PATCH v6 08/22] iommu/mediatek: Add larb-id remapped support Date: Sun, 17 Feb 2019 17:04:46 +0800 Message-ID: <1550394300-17420-9-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550394300-17420-1-git-send-email-yong.wu@mediatek.com> References: <1550394300-17420-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 --- 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 685f5d5..3bf7b76 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -220,6 +220,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( @@ -740,12 +742,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 b8749ac..eec19a6 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -47,6 +47,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