Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1448854ybl; Fri, 23 Aug 2019 20:44:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqa+N3Y33vn5IeJ2tcDB9HPtArm3pdwNJ6U+XKuduWnj/wGylwU+MkQa+ynDkSTQbDtOE0 X-Received: by 2002:a62:f24b:: with SMTP id y11mr9031987pfl.0.1566618288043; Fri, 23 Aug 2019 20:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566618288; cv=none; d=google.com; s=arc-20160816; b=jum1q4/qfJdl68Wo+OD35pZytf9v7/gLAsFWUzq87oaIwZMNd7QOc1lvq94gA6Bl6y 2C0uGy0T0YGEQRaR10DdRDZwahDKjyiMfWF+v+Xh7nAVSFRWDT36GXJ2mVb+MMdYuwoz gyR22k3z+WNN8XOKfsfr4lzY5eRgF3foF5Ut10fhP5we2TIzXOiKCtAOtVvY85iqFP+J aQk4scj34TMSt86AcPFsvfgVGlyJTnU772QSg/qg9Zcbc8G+E9hPmwYWVjCnBDsjiHpf R2J3cQAzjtgEECoVWbWpbnAvS1d8iXZgm7y4yQQXHFO4GGhRHYShod5kuNNwTD2uRAAd onNg== 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=sa5uF8HXrue6Ipvlh7J7koH+9rGoRH01eJMPMdsFyBwcAIexfhEClDW23+OFRyNN8V UfNgri3ftnCKvVNPqGd2AKDkMYmpRmgVv3t3EWs7Rkqely1kUFxT8u6PtJOsfiTTGp60 i+37CoDV+sTlwvYE5mw7zJnOAGUi4qWlJuMk7pIxOZH8uOKRV5E9qivcHkDcPzA38xnw sYnjWZe4eXLdOpnPcJ+jwMUfSsBBTw+Jg1G3LgDCrTVQ8Dd4Cp+p1oZzhp5i9zCNE1/i FvIQLGXD3scajrx8bZgmw3Gg4nLoID/WJhESj8vXxwXVlukPJDcZhiKAVIxaxRZh+T+F d1nw== 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 b14si4368980pfp.253.2019.08.23.20.44.32; Fri, 23 Aug 2019 20:44:48 -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 S1726927AbfHXDnn (ORCPT + 99 others); Fri, 23 Aug 2019 23:43:43 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:47399 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726397AbfHXDnn (ORCPT ); Fri, 23 Aug 2019 23:43:43 -0400 X-UUID: 28af3dac038240a1924bd0ffd8bca3cd-20190824 X-UUID: 28af3dac038240a1924bd0ffd8bca3cd-20190824 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 1958240382; Sat, 24 Aug 2019 11:05:09 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 24 Aug 2019 11:05:01 +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; Sat, 24 Aug 2019 11:05:00 +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 v11 12/23] iommu/mediatek: Add larb-id remapped support Date: Sat, 24 Aug 2019 11:01:57 +0800 Message-ID: <1566615728-26388-13-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566615728-26388-1-git-send-email-yong.wu@mediatek.com> References: <1566615728-26388-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