Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3147163ybi; Mon, 10 Jun 2019 05:21:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOEfxYj2g69j4JgbG4gCLreagdkKbK6FqfFgXm0bLgaurzSMdenYlPo1tTVbY9r+/GgVhu X-Received: by 2002:a63:191b:: with SMTP id z27mr15221770pgl.327.1560169272592; Mon, 10 Jun 2019 05:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560169272; cv=none; d=google.com; s=arc-20160816; b=yEnZ6T9Cmjgjs2N46zXPKK2/XsyfFtR3NQ4Shoi4xeIibXCEjxHkSCu+qkOI625F8W u28yF+vYJKNbKPJYzc0D3DL680cYiiqxOvPAY+8nidQaYAwNqXuw8COKm/Wh6SLcpNr6 CKmlSESOthHgz0jMCSdUAxyVOcGzB0RlQE4x1tJ71UkQ3boshyehSAXVOxDmM+wlzROr b3CKrzsBuMmXn5qmoEzPn6xDJ0OHdHkzGuPgCF6yF0Ylvtjb7f4ZsV8GIIXoLw/g+dMk +6IWqAQqltQBJycawTZCCqmSTMMjRJVhaitFj9N2eYQ1+BGw/reyaED9Vy3h6bkSKRO4 4DgQ== 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=YOd8nVIKpVtvTSqi1M1Vl/MTVVefR6jTEYUvDdeROU4=; b=0IKAj8PrzGps4hb1ZEpSk5rKK7bNSBfh1u6pfvLQf4f7N9bRENHTzDyWztZ3gyWM8m Wdjh19leJ2V7sFfOspgO7kclE5qruOOpsJ8+ufc/tm5uJZVci1qJwIz7yGFuWUQGpSt4 c11U9eg7e6bxCje9WD+zikFVvH4yEPGUPua3dTjjNwVCh8ZkgU6aDxj+PxtYAzE6Gtx0 vVjjRuR55pe4yRUvrA3ko70q8DaZSOynaul6F2O4mroy3abIQfhksuQX8yKFRrQhtGQA HAiJ6kpcgsyY3xTc3by2G2sQQT8rARxf+KCEksybPvrABrMIH+6UtfBJy+0tU6/xiVl/ 2xAw== 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 v4si9033204plp.404.2019.06.10.05.20.57; Mon, 10 Jun 2019 05:21:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389737AbfFJMUK (ORCPT + 99 others); Mon, 10 Jun 2019 08:20:10 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:24507 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2388952AbfFJMUK (ORCPT ); Mon, 10 Jun 2019 08:20:10 -0400 X-UUID: 4ff2c7dd04a647038cdb442a2416699f-20190610 X-UUID: 4ff2c7dd04a647038cdb442a2416699f-20190610 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 666678171; Mon, 10 Jun 2019 20:20:01 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Jun 2019 20:20:00 +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; Mon, 10 Jun 2019 20:19:59 +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 v7 08/21] iommu/mediatek: Add larb-id remapped support Date: Mon, 10 Jun 2019 20:17:47 +0800 Message-ID: <1560169080-27134-9-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1560169080-27134-1-git-send-email-yong.wu@mediatek.com> References: <1560169080-27134-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 264dda4..ad838b9 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( @@ -744,12 +746,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 63e235e..61fd5d6 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -46,6 +46,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