From patchwork Sat Dec 8 08:39:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WW9uZyBXdSAo5ZC05YuHKQ==?= X-Patchwork-Id: 10719299 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D2E713BB for ; Sat, 8 Dec 2018 09:31:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB612CA20 for ; Sat, 8 Dec 2018 09:31:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E6962CA49; Sat, 8 Dec 2018 09:31:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E593D2CA20 for ; Sat, 8 Dec 2018 09:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=y7iNVUb4Q45mjl3vNrZBNrJrqehAJn7rtmLlB5iZF/o=; b=QIAjwLgyX4oZVz yPC9LLMMGRDON6SwoRtLJgYk+D4U/B5W2aYVk/1+ypkKKtxMK8wUjSGzY2EgYonaC0DX22MpRIZx/ EO6FwQ2arlCmEMrUBgZ2/LX4N72PpSDEq1LtIV2DM+fqdPbAjkkS4Ti9Fc7RTwaUqB54y0uLZqHzP HGn0HkWQszBevnXFw6ialPPMHlOr17rE/jZuyWlxJbCCD7iQRz2VTN2ImI1BG0Qww1vOjp8S5RU+2 5LgZnbw6Yw/AJzH3FA7ChuElUuSih+7eqyi+yTNhWc6dPRI/zNpI/7j+lUnRcSm8sQt/LTlZqom62 rv7fum42N8ikjQ6EBFmQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVYxK-0006fq-09; Sat, 08 Dec 2018 09:31:26 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVYxI-0006fH-D9; Sat, 08 Dec 2018 09:31:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JdJYMQvBYcP0jIX9pst1R17vavCNBrg+Xjro+izm+4Q=; b=MgRGV6NsEQR+LuZu3OSqjA1nu DCrF78gJoqGU/n2+jaZ6MXDRxjzBtUjTaINo8CkrYC4GET5wJLnli0MxabGE6/Fxnnr0A7xNQ+8Nx Kl/IvjVGer1fa0LytCC5p3i9OMUsLbF65NzsKN77ewioVIwm8ZH539Nx8mNcgWUjwwgoGOSQm+n3z 9IVkEoOrPLXsXzLpleBWdQ8DkqBCGdtj6Kw9dbh4h30+9iKK/u5ToSzlI/F7pa+yiW1wC0sIsdT+A THCu0TjpMptb6LRr8L4qSe3eV4piin1tKhYD+4kXLdW9wKRUDaNTKAVwZ/VbkCj8VW4bO2UrGkXI0 Hsu4v5eOg==; Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVYBq-0001e6-2N; Sat, 08 Dec 2018 08:42:23 +0000 X-UUID: f8599a6e82e34e979c77c4f29482cf2d-20181208 X-UUID: f8599a6e82e34e979c77c4f29482cf2d-20181208 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 641199871; Sat, 08 Dec 2018 16:42:04 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 8 Dec 2018 16:42:03 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sat, 8 Dec 2018 16:42:02 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring Subject: [PATCH v4 08/18] iommu/mediatek: Add larb-id remapped support Date: Sat, 8 Dec 2018 16:39:21 +0800 Message-ID: <1544258371-4600-9-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1544258371-4600-1-git-send-email-yong.wu@mediatek.com> References: <1544258371-4600-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: B2849508C9D441139B34C01F7A651BA1F57369EF02D4B450316A8F5D7F1946582000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181208_034222_331050_28E799BB X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: youlin.pei@mediatek.com, devicetree@vger.kernel.org, Nicolas Boichat , arnd@arndb.de, srv_heupstream@mediatek.com, Will Deacon , linux-kernel@vger.kernel.org, Tomasz Figa , iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, yong.wu@mediatek.com, Arvind Yadav , yingjoe.chen@mediatek.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. This also is a preparing patch for mt8183. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 3 +++ drivers/iommu/mtk_iommu.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index eda062a..8ab3b69 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -220,6 +220,9 @@ 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); + if (data->plat_data->larbid_remap_enable) + fault_larb = data->plat_data->larbid_remapped[fault_larb]; + if (report_iommu_fault(&dom->domain, data->dev, fault_iova, write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) { dev_err_ratelimited( diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h index b8749ac..3877050 100644 --- a/drivers/iommu/mtk_iommu.h +++ b/drivers/iommu/mtk_iommu.h @@ -47,6 +47,10 @@ struct mtk_iommu_plat_data { /* HW will use the EMI clock if there isn't the "bclk". */ bool has_bclk; + + /* The larb-id may be remapped in the smi-common. */ + bool larbid_remap_enable; + unsigned int larbid_remapped[MTK_LARB_NR_MAX]; }; struct mtk_iommu_domain;