Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp788685imu; Fri, 21 Dec 2018 07:23:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3MJtvdWSfyfX826EWbVlghcIG+Ant0ifUHmYIIBwW2EC4JEov3upCv76QPJIFIACI+rNA X-Received: by 2002:a62:4e16:: with SMTP id c22mr2911161pfb.167.1545405827585; Fri, 21 Dec 2018 07:23:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545405827; cv=none; d=google.com; s=arc-20160816; b=An7Ud9InnsdHdaJyN0n0riSuyZ+dXf7uy1uFxSTN0sQ5w3kahXq5We00oFOifVjSVI N2J17JQcHwdhl69bXo2FQmF3u6B6nPjIlsdpngJrRAiQraXpuwwhsxn0aI0kJ9CoHmOF ISdv08UVSgXsVcd0YJXPCrW6WUtJwLQUfAQ/ZerIbUP+s/z8RMfszkQTphPgrdMFKQHv 1mmcn8k+id7z69zcCi9AmTcyjL7PLXgPE1akOosOC5WhxcRGLFdPniowaV3fJxoUJDNU FtBtXWQjbfh8NsTjvDAU15N+RwtLy1b76643z/i6irB9Pqjcw8lIYxIwD2NYDziS2Hgb GMRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id; bh=tgcuwXVkKmg0AKenCmDtgP4JTYj8oYsk8uYP9DSxeYI=; b=PuRp0qcKxNKsqnoCML7teTu0SMYAWzHJPBnyzfAbfqSM/7f8cyzLTNz07Q+IzgO68+ RY3aNwV2x1oFSVlD4tTgkuLQ6HraFsbLSXcdxjyxNS/5KB8HVEAAz7mwpAujJENfVspH OvWznrmfxTl+44KwBK2lhGerIjQaS9H9KEEJOyne9+SDNIDkWpG8VmGkeBzG3mtg1XBh KJANCkLOne86ZklaW+945xvPWSRLtjwciQcUYnf92F/+ZbexNmbCc2LSo+c4rv3YQvjI Lf4+N8YD2sm2s1a8CJdqsh9/V9DhoBMFj8WkPwnJOtfc+EpYDSAHWWSTstiBNHx8VM00 N3tQ== 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 f10si3814826pgl.528.2018.12.21.07.23.31; Fri, 21 Dec 2018 07:23:47 -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 S1732619AbeLUIDA (ORCPT + 99 others); Fri, 21 Dec 2018 03:03:00 -0500 Received: from Mailgw01.mediatek.com ([1.203.163.78]:21192 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729898AbeLUIDA (ORCPT ); Fri, 21 Dec 2018 03:03:00 -0500 X-UUID: 9fe65b3a70c640b19bf2f0a91b128b6e-20181221 X-UUID: 9fe65b3a70c640b19bf2f0a91b128b6e-20181221 Received: from mtkcas36.mediatek.inc [(172.27.4.250)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 764756075; Fri, 21 Dec 2018 16:02:46 +0800 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 21 Dec 2018 16:02:44 +0800 Received: from [10.17.3.153] (10.17.3.153) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 21 Dec 2018 16:02:43 +0800 Message-ID: <1545379363.29587.52.camel@mhfsdcap03> Subject: Re: [PATCH v4 08/18] iommu/mediatek: Add larb-id remapped support From: Yong Wu To: Nicolas Boichat CC: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring , Tomasz Figa , Will Deacon , , , , lkml , linux-arm Mailing List , , , , , "Arvind Yadav" Date: Fri, 21 Dec 2018 16:02:43 +0800 In-Reply-To: References: <1544258371-4600-1-git-send-email-yong.wu@mediatek.com> <1544258371-4600-9-git-send-email-yong.wu@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nicolas, Thanks for the review of this patchset. On Fri, 2018-12-21 at 11:35 +0800, Nicolas Boichat wrote: > On Sat, Dec 8, 2018 at 4:42 PM Yong Wu wrote: > > > > 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]; > > Wouldn't it be a little simpler if you just had > larbid_remap[MTK_LARB_NR_MAX] (no larbid_remap_enable), and just set > it to {0, 1, 2, 3, 4, 5, 6, 7} in platforms that don't need > complicated remapping? Actually I'd like the original way(Print the larb-id from the register directly if larb-id is not remapped). But this solution is also ok for me. > > Also, unsigned char/u8 array would be enough. OK. "unsigned char" is enough. Originally I think "int" or "long" may be better to access in ARM/ARM64. > > > }; > > > > struct mtk_iommu_domain; > > -- > > 1.9.1 > >