Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp400875imu; Fri, 21 Dec 2018 00:49:03 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Ja25pZInnDDqotkYhbBp4ywcZ9YyO8MYI64yRbBNbXUWb3lpH/hQWIF0+QDalJfHvLucK X-Received: by 2002:a62:31c1:: with SMTP id x184mr1669641pfx.204.1545382143411; Fri, 21 Dec 2018 00:49:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545382143; cv=none; d=google.com; s=arc-20160816; b=aDoM+IcROXMXjDhjFBXqQbGefskxI7PYwbDtmj0Jm3eVgyUpEQn1w4kkXoVPBfWqh/ +VE5/neBh69pGmAFyx/vRD4uk66IfmqQBA5eWXWq7zKy4kMfBtfmfJqtIouBDZOgevLv hukL5SWw/Gd4/e3MZ2dODhZbxsSNuufwe/YMY2X+JFoQSI00GWLndP5d5U8Ex8SuJJRq KeR1vsucID1p7BA/mYDXOWVP4iMz0JynzQjq1EyYLdRowp8PSDwrDJoJ+7ioIh6GqAkk bBlwa4dzarOG4FKgP+rUUcmnT1aHnp900+hstJJhpS3hyahfRdKf5vXd53xw8NZ5SheF oLvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1YKu3l2W2tnjwEusBHKXK1YRzv6cTe2O21eT23+mEyU=; b=mLDvhyO1gPtxrg3igULjQWFcJf05xnYWmCggm/XhB5yehB1KmvS1NXbHrzhNHPocu7 EiePaHcaSPMTjiGnWINdCs4DwVZE7gRLXVn4t3JoXB3JYFgbi1zfcpvfaDZObtrGNg2g Le374k0nJOdZe1S8qyaG9xZMCays/VE0CNVd94csBqy/+R+CUVjtDShGm/2xjBMuLl39 tAsaijqOoSZ5omIiqTHa6G5CMNpFD4QYqmOMTWgrpQ998qlQ7fs/UNWzXTV/FGw/1d5C 74Z0bZxd/xj+GA5qJKvorT/YGfVmwcixBOCAo3S9Jgi4hwOnbiP8+VwpZVnDRTbW0fzE FW6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OYmVann3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o192si20477689pgo.129.2018.12.21.00.48.46; Fri, 21 Dec 2018 00:49:03 -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; dkim=pass header.i=@chromium.org header.s=google header.b=OYmVann3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390902AbeLUDgE (ORCPT + 99 others); Thu, 20 Dec 2018 22:36:04 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:44399 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388947AbeLUDgE (ORCPT ); Thu, 20 Dec 2018 22:36:04 -0500 Received: by mail-qt1-f194.google.com with SMTP id n32so4261277qte.11 for ; Thu, 20 Dec 2018 19:36:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1YKu3l2W2tnjwEusBHKXK1YRzv6cTe2O21eT23+mEyU=; b=OYmVann3ocxoEst0RrE5++bYdAiYd1ZyviOS/oRcs3l1x+M0+pga7amLk2552x5uXa pSvHdvGPYIJpj4XDkyUz9qmyY0tHI7Q11yC66OLNwyPfP17ZGIj/S0zJa4MFKkc1DIXY uA0B2vJx4V4oYWqBcKds2EI3AfZss7ktv1Cz4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1YKu3l2W2tnjwEusBHKXK1YRzv6cTe2O21eT23+mEyU=; b=FIM3Pwhr7gAlmh7XviVeWGUXJh29tes9eCtqQZI0lBIgp/Ce3WaUL1i4qARaEZAUCM o2jK0gFPhYydP5pKflrbHmOOoo2cX6twKeyQEI03f+nsP+9W93xjvEn7v1RZXpTydfJc Z7fKj/paM1OrCX/EO83IOBm1zZn/vyHlBbuRXSWj2oEWGJI50XUqucL4rHJ3phCn9n0c eL0E28rbX6ICtXvLSOunOzClB4uCvnYSg5BW8fRjeVFHorkLqS1UkeLsVTvFQ7n17h4u EQ+anTGbfKimT1/LMGCeWzOpNbAOZ2x0Tl+Frbj6czKOETXuxh364FwweYbKs5bHvqMp bmTQ== X-Gm-Message-State: AJcUukc4c+ImV86svQRp0887IG6iSYigR7C9Yb0i4xuJT03vdrKr19aa Dm8EFDzUcwcaAOEZpOLgFtTR7cfmRiT6FHvuhSTCJQ== X-Received: by 2002:a0c:db04:: with SMTP id d4mr824527qvk.114.1545363362797; Thu, 20 Dec 2018 19:36:02 -0800 (PST) MIME-Version: 1.0 References: <1544258371-4600-1-git-send-email-yong.wu@mediatek.com> <1544258371-4600-9-git-send-email-yong.wu@mediatek.com> In-Reply-To: <1544258371-4600-9-git-send-email-yong.wu@mediatek.com> From: Nicolas Boichat Date: Fri, 21 Dec 2018 11:35:51 +0800 Message-ID: Subject: Re: [PATCH v4 08/18] iommu/mediatek: Add larb-id remapped support To: Yong Wu Cc: Joerg Roedel , Matthias Brugger , Robin Murphy , Rob Herring , Tomasz Figa , Will Deacon , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, devicetree@vger.kernel.org, lkml , linux-arm Mailing List , iommu@lists.linux-foundation.org, arnd@arndb.de, yingjoe.chen@mediatek.com, youlin.pei@mediatek.com, Arvind Yadav Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Also, unsigned char/u8 array would be enough. > }; > > struct mtk_iommu_domain; > -- > 1.9.1 >