Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp11460461imu; Mon, 31 Dec 2018 23:21:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Kd/+63oTgZq0+hOiouhQso0/psH15UJI9gG/SObeZKB95gbFjLtLdN+optyOUb7mZRF16 X-Received: by 2002:a17:902:22f:: with SMTP id 44mr39470707plc.137.1546327291526; Mon, 31 Dec 2018 23:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546327291; cv=none; d=google.com; s=arc-20160816; b=v3ALtWhZiB1Fy617fVJNIPJyfeT27rmNWwCIQ3cBQGST2gxYxf3ExIP8xexMqO60f0 TC1m6pdRKBo/qaf28nIj4O0d72SFCF1mXLNN3v1Zsqeyq7uve83pFKxkaVzCM3Osw7gi EEuFhCA9SNKitbBu+9rTJE4rxIr+cukXs8uoNoqWhGDis1HZrVVV7ItW906Hlhj1vZ6N Bg0/igIalSArvLwpjSyew0G4bE0qZxhXxglaRkNu5HoZEogExpjP45fNTPNQAFpg+txk xH8sxzxGy0bqvZyinyUIfZkyaZ/gX1wiYxSzzIgxzMhmhkkYMStpsUahuqFoxYsMKoht JoQg== 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=UauPOuSDgTMWZGL5jEMBfxx1hbWVMW9bZpLqwy9owMU=; b=GN5bjGGTjbNmEG7E1gBG3EOs9IRjMzZSunQz+KEVCcZWEWuDEBhXMPwjC8wLiGZFbx HgxhBdUBl5bIjVsYZVA5XxzkR6XmQjFST+PoOOcIXRYKk1eBJMsBr3pZSywnUpBiyThv kveQn9HvI26+rWKY8VRMQnGewsaBv79lF1BAtr7aDOnxJLxrhK+4OF5Q43mbz1h4E2qf oUAi9zEVNggSYP+LDiUh1yk438VWkYGSQbUPwVlyHn17HkXtbVgoXjHb6EQA9petLntz YtqCTNmgCP052ncRHaC9Zxvy9fhAx9XxiREF3Gv5ZYciGk93QVR0oQ5UFR0cP78CYEkc gk7A== 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 q17si50057696pfc.198.2018.12.31.23.20.47; Mon, 31 Dec 2018 23:21:31 -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 S1728295AbfAAD6R (ORCPT + 99 others); Mon, 31 Dec 2018 22:58:17 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:49307 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728271AbfAAD6R (ORCPT ); Mon, 31 Dec 2018 22:58:17 -0500 X-UUID: e94fc75190ce40469e42893c8c692e46-20190101 X-UUID: e94fc75190ce40469e42893c8c692e46-20190101 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1739954521; Tue, 01 Jan 2019 11:58:11 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 1 Jan 2019 11:57:54 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 1 Jan 2019 11:57:53 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring CC: Tomasz Figa , Will Deacon , , , , , , , , , , , Nicolas Boichat Subject: [PATCH v5 08/20] iommu/mediatek: Add larb-id remapped support Date: Tue, 1 Jan 2019 11:55:40 +0800 Message-ID: <1546314952-15990-9-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1546314952-15990-1-git-send-email-yong.wu@mediatek.com> References: <1546314952-15990-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 07AC4DA7F558F0F3BE563D10B010F08727169C392AFD9085EB238D0836A730872000:8 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 --- 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 847082c..eca1536 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( @@ -742,12 +744,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