From patchwork Tue Apr 11 09:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 81846 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2449459vqo; Tue, 11 Apr 2023 02:52:58 -0700 (PDT) X-Google-Smtp-Source: AKy350ZKSr9ZgRMXORronqC1bJcmMSM2g0GJUT9XX8d/rMuW7xVrJtclySaJjbooARPMIgrfGFa6 X-Received: by 2002:a17:906:f9c2:b0:921:7e42:2777 with SMTP id lj2-20020a170906f9c200b009217e422777mr10228359ejb.69.1681206778378; Tue, 11 Apr 2023 02:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681206778; cv=none; d=google.com; s=arc-20160816; b=m7Ffyn+kjugZfCP7EKhOJdvho+jk8zlszlGeST9tcnJq+2nuGtoF0JTwda+PbI0WTM f2uwf7bSw7UKPh1fCRHuyZR+mTURXJIjYiTD8iVWrEdrGF/4e6/UXb5jYpmXks3+Y5Qu i9xNmnj/jzzdDuPz0DqyUqPbCrh4SuWPsE0Uh16HNDlv9QF7Wk3MsWBQ6i1LJRQrQ1GC 7t89NScMfRHeKqJ4X02+1XnxIn9SqxxFEuCyDSqD4CJsw1KwuZKmhmlMgpjIRFEm7xwj 68us5qg+NW90H6ST/qkO30kHlfMz0ES9i2J74z9i2h81WVgOkxaJVufrGJAeSnFA+Odm XiJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Gbacnh4qt5DCcPUzPDRzUSmOnmUijCnl8GTEcmOfwW0=; b=G2NuT/zl9YCCFyokF9LBnxODHxRFubXrz7oh5Q2kuG+Xbnd4Hyt7dDs2MeJ5qNBaRw sWepZb4FclSnfdUo2JO6GN4fmTmgPFi/TX+DYDCNZ0uxd/Gofo3O+u5n0OSAEG9GOXbJ CmrVV68xNo85Y51rXnqo8FwdwWMkMq0QdhmT0TQ38dOivHikUqZAU1RsXMB/47Apx1vQ XgiCNmdSsjbvtoPioxtBOA9x+3KrDZRkhmMLWWe6KvDCp/knDroCCoKIF1ts/MR3uMGZ Ahb4o2WnVJAN9VntYhVVMq5h7/B8EZRWu2mWFqtj8AvoadzHttmDdmiTMAlEMtS69j10 7Oig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=rcJg4iun; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gl8-20020a170906e0c800b0094a619e8109si2415915ejb.1011.2023.04.11.02.52.34; Tue, 11 Apr 2023 02:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=rcJg4iun; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbjDKJdu (ORCPT + 99 others); Tue, 11 Apr 2023 05:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjDKJdj (ORCPT ); Tue, 11 Apr 2023 05:33:39 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E018A2D60; Tue, 11 Apr 2023 02:33:16 -0700 (PDT) X-UUID: e047fd80d84b11edb6b9f13eb10bd0fe-20230411 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Gbacnh4qt5DCcPUzPDRzUSmOnmUijCnl8GTEcmOfwW0=; b=rcJg4iunB9vIHcEoLDrWjjQdQQjdQhWTy/XhiGP0/CNg8XdgLxLDyETHMeocQM5ZP+GcrZggnCnpB8klafS/DYcacURog+oszdi507H6Lxa1VLSQ6ott1B58AXlSJpfFVWhj5DKdE8LIm2wxiC89uUHmfPLhuzh43E7EJW3UXfY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:a07a08fe-86b0-4ef2-bc62-233ae6b33d12,IP:0,U RL:0,TC:0,Content:-20,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-20 X-CID-META: VersionHash:120426c,CLOUDID:3c79f3a0-8fcb-430b-954a-ba3f00fa94a5,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:1,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: e047fd80d84b11edb6b9f13eb10bd0fe-20230411 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 717596227; Tue, 11 Apr 2023 17:33:11 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 11 Apr 2023 17:33:10 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 11 Apr 2023 17:33:09 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Mauro Carvalho Chehab , Rob Herring CC: Will Deacon , Robin Murphy , Krzysztof Kozlowski , Hans Verkuil , , , , , , , , AngeloGioacchino Del Regno , , , , Yunfei Dong , kyrie wu , , , , Yong Wu Subject: [PATCH v7 06/14] iommu/mediatek: mt8195: Add iova_region_larb_msk Date: Tue, 11 Apr 2023 17:31:36 +0800 Message-ID: <20230411093144.2690-7-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411093144.2690-1-yong.wu@mediatek.com> References: <20230411093144.2690-1-yong.wu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762873078458407908?= X-GMAIL-MSGID: =?utf-8?q?1762873078458407908?= Add iova_region_larb_msk for mt8195. We separate the 16GB iova regions by each device's larbid/portid. Refer to include/dt-bindings/memory/mt8195-memory-port.h Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 672059f9e0b7..bb3734378934 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1579,6 +1579,21 @@ static const struct mtk_iommu_plat_data mt8195_data_infra = { .iova_region_nr = ARRAY_SIZE(single_domain), }; +static const unsigned int mt8195_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = { + [0] = {~0, ~0, ~0, ~0}, /* Region0: all ports for larb0/1/2/3 */ + [1] = {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, ~0, ~0, ~0, ~0, ~0, /* Region1: larb19/20/21/22/23/24 */ + ~0}, + [2] = {0, 0, 0, 0, ~0, ~0, ~0, ~0, /* Region2: the other larbs. */ + ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, + ~0, ~0, 0, 0, 0, 0, 0, 0, + 0, ~0, ~0, ~0, ~0}, + [3] = {0}, + [4] = {[18] = BIT(0) | BIT(1)}, /* Only larb18 port0/1 */ + [5] = {[18] = BIT(2) | BIT(3)}, /* Only larb18 port2/3 */ +}; + static const struct mtk_iommu_plat_data mt8195_data_vdo = { .m4u_plat = M4U_MT8195, .flags = HAS_BCLK | HAS_SUB_COMM_2BITS | OUT_ORDER_WR_EN | @@ -1589,6 +1604,7 @@ static const struct mtk_iommu_plat_data mt8195_data_vdo = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8195_larb_region_msk, .larbid_remap = {{2, 0}, {21}, {24}, {7}, {19}, {9, 10, 11}, {13, 17, 15/* 17b */, 25}, {5}}, }; @@ -1603,6 +1619,7 @@ static const struct mtk_iommu_plat_data mt8195_data_vpp = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8195_larb_region_msk, .larbid_remap = {{1}, {3}, {22, MTK_INVALID_LARBID, MTK_INVALID_LARBID, MTK_INVALID_LARBID, 23}, {8}, {20}, {12},