From patchwork Tue Mar 7 08:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 65319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2308158wrd; Tue, 7 Mar 2023 00:16:17 -0800 (PST) X-Google-Smtp-Source: AK7set+eB9Vx30fyuDovGo+v50j820Xf6BmtvzOsoOWMfV1ra6SU/pDzyhqcrcnIoNIi5UJ+uJ39 X-Received: by 2002:a17:902:e812:b0:19c:da7f:a237 with SMTP id u18-20020a170902e81200b0019cda7fa237mr17202655plg.5.1678176977651; Tue, 07 Mar 2023 00:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678176977; cv=none; d=google.com; s=arc-20160816; b=TFT/ut7vmDWU9SOQluM82UUwsE6ciMgU/OcKRUPkS5r+e5v712ZVl0z+68KrvmrE3M JdxIwhOPGGzuG2Xg/WXMnfGV18tEpbmHabKSTMQ62eI4+kBoybin9TzPznIkFodSKmwd B+HWNYEzfyQoGeBqyQMNLxI6+JDfQNAoOcFoDeoO48yzK+5obdUpiCtaduVMb3ymicWm Ajv9lcdotKIWXqCUldzd9G+Pn24LGACBl2EPt/evVpUVthO/mDxy5Mh0PH0BOAeW8//h gnSMKRB2LfP5MEyittnYKpNgLX/hY+AVSw+FFZcaLRUoB192ASSuTeyF0Y+LjluGthzj 8h/A== 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=Xcl0geET81WYNBRHKToCqUUKoHCvhorE98xJYXCbui4=; b=yRt3qk3HXNJxLzLuvt+DGXURNDEMcwvHyVuH5AelHrnSwcbfmWLBNvxLkfTuO37brK KyJ/E4vjkMkom4PfMjaPq8TlJsh3ksFwVDr6zPjWtFaiuZgk+JE1vmZYzsmT/Zr8V9h+ F2WTSGS5NYE1NQ9Pa5cKzFk96lnyVy5J3uS//6kRZveCxuy+DfnASrUZywujN/JVQtS8 7I5Pa/jkgsRDkLAHAMTVI3GzLxtWIF8tgnBLkSC/1hxVogWnArS60cvzQiK1JVd5WWiY N5wbHFsg+U9Jt0HqWI9ImxdOwBGHfeTEWXw0/NNYAWOu2OFx1OBgG3kg8wCMK179feOQ LEFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=e7f+gbNQ; 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 kc13-20020a17090333cd00b0019894a59be0si7531737plb.566.2023.03.07.00.16.02; Tue, 07 Mar 2023 00:16:17 -0800 (PST) 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=e7f+gbNQ; 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 S229699AbjCGIIb (ORCPT + 99 others); Tue, 7 Mar 2023 03:08:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjCGIIZ (ORCPT ); Tue, 7 Mar 2023 03:08:25 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83CB226B2; Tue, 7 Mar 2023 00:07:52 -0800 (PST) X-UUID: 2400960cbcbf11ed945fc101203acc17-20230307 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=Xcl0geET81WYNBRHKToCqUUKoHCvhorE98xJYXCbui4=; b=e7f+gbNQJEVMn52asKShIb4jvRrjO2mZpnHHYUVeFnk2JHfjv1FTc1M3nvNZSNxqvVMXvjz3CtRgdqk9lXwh2vgFwiSOuyVhfnXAa2QLdkpnJuW1pTOqgDyju1DTpREwsUZrHg7cankd0H3rU5JOTdO97wq41mWg3GNy6QRfA/4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:075c8cbe-3d27-40a9-87d4-d7320c5ef510,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:25b5999,CLOUDID:34d69327-564d-42d9-9875-7c868ee415ec,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-UUID: 2400960cbcbf11ed945fc101203acc17-20230307 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 704658285; Tue, 07 Mar 2023 16:07:44 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 7 Mar 2023 16:07:42 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 7 Mar 2023 16:07:42 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , Rob Herring , Matthias Brugger CC: Robin Murphy , Krzysztof Kozlowski , Yong Wu , AngeloGioacchino Del Regno , , , , , , , , , , Subject: [PATCH v8 7/7] iommu/mediatek: mt8188: Add iova_region_larb_msk Date: Tue, 7 Mar 2023 16:05:55 +0800 Message-ID: <20230307080555.14399-8-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230307080555.14399-1-yong.wu@mediatek.com> References: <20230307080555.14399-1-yong.wu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham 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?1759696102475096628?= X-GMAIL-MSGID: =?utf-8?q?1759696102475096628?= Add iova_region_larb_msk for mt8188. We separate the 16GB iova regions by each device's larbid/portid. Refer to include/dt-bindings/memory/mediatek,mt8188-memory-port.h Note: larb19(21) as commented in that h above, it means larb19 while its SW index is 21. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index c56f0f121be8..9ccdcf1aba2d 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1603,6 +1603,20 @@ static const struct mtk_iommu_plat_data mt8188_data_infra = { .iova_region_nr = ARRAY_SIZE(single_domain), }; +static const u32 mt8188_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(21)/21(22)/23 */ + [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}, + [3] = {0}, + [4] = {[24] = BIT(0) | BIT(1)}, /* Only larb27(24) port0/1 */ + [5] = {[24] = BIT(2) | BIT(3)}, /* Only larb27(24) port2/3 */ +}; + static const struct mtk_iommu_plat_data mt8188_data_vdo = { .m4u_plat = M4U_MT8188, .flags = HAS_BCLK | HAS_SUB_COMM_3BITS | OUT_ORDER_WR_EN | @@ -1614,6 +1628,7 @@ static const struct mtk_iommu_plat_data mt8188_data_vdo = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8188_larb_region_msk, .larbid_remap = {{2}, {0}, {21}, {0}, {19}, {9, 10, 11 /* 11a */, 25 /* 11c */}, {13, 0, 29 /* 16b */, 30 /* 17b */, 0}, {5}}, @@ -1630,6 +1645,7 @@ static const struct mtk_iommu_plat_data mt8188_data_vpp = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8188_larb_region_msk, .larbid_remap = {{1}, {3}, {23}, {7}, {MTK_INVALID_LARBID}, {12, 15, 24 /* 11b */}, {14, MTK_INVALID_LARBID, 16 /* 16a */, 17 /* 17a */, MTK_INVALID_LARBID,