From patchwork Mon Apr 17 07:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 84044 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1956669vqo; Mon, 17 Apr 2023 01:10:13 -0700 (PDT) X-Google-Smtp-Source: AKy350bVHSzNN5MfeT/wVC9gocr3e6T3hnLblkHUHHdWyGoZWWzkw3bhSNlZUsqwEb6tbG0u0Adc X-Received: by 2002:a17:90b:2305:b0:242:c4a8:c574 with SMTP id mt5-20020a17090b230500b00242c4a8c574mr14270240pjb.5.1681719012988; Mon, 17 Apr 2023 01:10:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719012; cv=none; d=google.com; s=arc-20160816; b=klUujFsV4JeAaZb9FH2mh4c7imWzhL5/APRiQuaqCxHH218cYPT5gEP8ay8f+Q50h1 kDH2o+JyZrNk0SDvu4kM/b8zoIQnV4qqfDCHEvP+5IzJpKYBwMNGEY0+TuaRoacU2K/H jSTVvnv83jhArw21CoDNeCOhsgThtZyt/Ha6hceiZ2Pag+te0HKp8jBI+XFSn+KsOAic nnYZFVUaTo2jotwjM2DcNgMFSzDQLa1ktbfJPhjA6fSRGOC6zrUwAoQVespQs4EtG8Uc qesoNpUUfQo7YqsVZ602WYefAjFWez9xO3jR2YtHm8b2nunwhm/8gRoHBw5wyKu+ZXx4 VXfw== 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=DQv2qOPx5dYPZdNgHn6YjWMVC72EGZL4V7OLMRx5WoA=; b=KR5JNbTw5jw0Ef9CAj22WXSx7tl9Q3IQMxfhnRwH0JjbXSY3DE6F9vhkTplbJTZQQa YvCJPp5mhl1z96Sb5PQQUor+upH6ej22tddS9CzA9gVD27oVF1/p7YITB2yqjuwqr8ew tVM9HLefblP4/iSWWZ8fn3yZ+HI1s8m0C9K1EWb3XhiL5HuFadLVqeu3ecSBVNRqjIXR mmEQesN6iRbL+W+7I8hYT8h5ZPi6Kd8wTqN9+Zm7ZpHinZDAoHjR45BD8a6rVVqT4JOZ 4kO0YyK0ld3NLQALaui4VPKRfjdfvWq9r19OwzLXBOLeKmcJ5Q8kik+KVXC/Ky/PFqD3 dCVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=l0yYBaQk; 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 d7-20020a170902cec700b001a52db202c7si2097735plg.382.2023.04.17.01.10.01; Mon, 17 Apr 2023 01:10:12 -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=l0yYBaQk; 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 S231215AbjDQHjP (ORCPT + 99 others); Mon, 17 Apr 2023 03:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbjDQHix (ORCPT ); Mon, 17 Apr 2023 03:38:53 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F1A558A; Mon, 17 Apr 2023 00:38:06 -0700 (PDT) X-UUID: b9db8a30dcf211edb6b9f13eb10bd0fe-20230417 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=DQv2qOPx5dYPZdNgHn6YjWMVC72EGZL4V7OLMRx5WoA=; b=l0yYBaQkBpdjhIZhwTXm1UfCbO80DkHRKg+oPYZF7/Iszmfx4U0t/YxIJEBKdICqIjo4JVHtbnijGPwUDS/2ygr6fPU6YxgW5V57+MXX3BF7Q1FbpwtUe0m/qBcA1QP/ZnLQ20VNQgcqSF/99W5V+O19jPBV1PGjnCjwhgt2mXE=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:328d42d7-baf5-4b12-8e9b-6949e008d987,IP:0,U RL:0,TC:0,Content:-20,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:75 X-CID-INFO: VERSION:1.1.22,REQID:328d42d7-baf5-4b12-8e9b-6949e008d987,IP:0,URL :0,TC:0,Content:-20,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:75 X-CID-META: VersionHash:120426c,CLOUDID:404133eb-db6f-41fe-8b83-13fe7ed1ef52,B ulkID:230417153738YML1T4G9,BulkQuantity:0,Recheck:0,SF:17|19|48|38|29|28,T C:nil,Content:1,EDM:-3,IP:nil,URL: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: b9db8a30dcf211edb6b9f13eb10bd0fe-20230417 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1793255066; Mon, 17 Apr 2023 15:37:37 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 17 Apr 2023 15:37:36 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 17 Apr 2023 15:37:35 +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 v10 6/7] iommu/mediatek: mt8188: Add iova_region_larb_msk Date: Mon, 17 Apr 2023 15:36:05 +0800 Message-ID: <20230417073606.25729-7-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417073606.25729-1-yong.wu@mediatek.com> References: <20230417073606.25729-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,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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?1763410195806678177?= X-GMAIL-MSGID: =?utf-8?q?1763410195806678177?= 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 As commented in the code, larb19(21) means it's 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 fa46c4309f35..876624f807d6 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1599,6 +1599,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 | @@ -1610,6 +1624,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}}, @@ -1626,6 +1641,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,