From patchwork Thu Feb 16 05:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 57878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp131955wrn; Wed, 15 Feb 2023 22:08:48 -0800 (PST) X-Google-Smtp-Source: AK7set99K4wonuj38a59J33CzI0bHgLtJ6EYUB8T4U4zcOOr+9uNpmlnGPd3jeG0poYpJ0M2oggg X-Received: by 2002:a17:907:8a26:b0:8af:3b75:18c0 with SMTP id sc38-20020a1709078a2600b008af3b7518c0mr7754206ejc.12.1676527728384; Wed, 15 Feb 2023 22:08:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676527728; cv=none; d=google.com; s=arc-20160816; b=yHnkYZY/blmMd9DUoSvyA3HCKaWABzRAiHtgRZNeO5kcV1e1GY8r4SPkVeBJmI+U4A tI7bsggLR22GHi7MsXdbjsAncOZxK8xGQzg2f2XPTLrDB8qGR1oMGIFCXqZT9D7DI/Ux /Usgt9G+KYXns/X/yv6vOmldj6Oil+FQ4ebMiftxbtpOgqIorIjUbCYAA/MJtv+WQRlJ nnheLMGw6+APbfVzremh6Bi/YYwBvFMhygC/D0iFCcefHpXRIV9AuV0ZxYpGQk2TOeuK PIR8eyPbgUryRb5wj/blDCsbbo1O5T51DsMzijXE6Gku59m4oqgZ2yQjz4Pba/0u3HJT 9gYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LrqqZVczADf4UXxLULFwBwcdFJyfPBBKUZSijRZtoyk=; b=BxkVycMqJRbeQ48x5sN5IjsDDGjybtoY0SrPjTDpMNANGYe6JmAqHUN7gy4hTGJaxg AxhSMxJx75ME7mTuVPFNg71b1k6IZ6rCTogYVC7f9lD//NQTYQZaGf0ErOqEQ9YRiD8/ JrdAm+l/tKdrE5L6yAeLbRodrgJe0PDKE3I8nWEv5zloCNa8lhGeb1QGx10dyAI6ozaJ aLSGgX65AF5tzj9+3cnOijODwwJfbXIMpvHWYrBoq5qzSkJQS8qpEZ8rGvKiwfbwUrdI nBcxLTFjxKPxnWgQV8kUCfbbqHSbe4PRO9tOoNG/S9PZuv4uaI9FMo7Kxnb5nmYyQh9b znCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=MlDTKuG4; 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 wg15-20020a1709078f0f00b008b13ba8e468si761164ejc.827.2023.02.15.22.08.24; Wed, 15 Feb 2023 22:08:48 -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=MlDTKuG4; 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 S229711AbjBPFf2 (ORCPT + 99 others); Thu, 16 Feb 2023 00:35:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbjBPFf0 (ORCPT ); Thu, 16 Feb 2023 00:35:26 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F2D46096; Wed, 15 Feb 2023 21:35:08 -0800 (PST) X-UUID: a7bdfaecadbb11eda06fc9ecc4dadd91-20230216 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=LrqqZVczADf4UXxLULFwBwcdFJyfPBBKUZSijRZtoyk=; b=MlDTKuG4oQCkSsOoRT0CHi9Ya+0DK1C+NdyNaSqkmALKlIuapMvZdJZlyv8fW9VVhh/fak5nJ5oy0GZCbpFZfrr0FbDM+qVdsv3WxqUyxuRqQ9LCJ1fu6e8nQFhiyqdBvREZBILsJy4Jq9e2mK6Hqlj+wkzQ2IJ1u3PJF4fqLvM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:62d7e7ef-4aa7-4802-bb0b-5254b9a0c8e7,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:885ddb2,CLOUDID:02059cb0-beed-4dfc-bd9c-e1b22fa6ccc4,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: a7bdfaecadbb11eda06fc9ecc4dadd91-20230216 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1678086085; Thu, 16 Feb 2023 13:35:00 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 16 Feb 2023 13:35:00 +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.792.15 via Frontend Transport; Thu, 16 Feb 2023 13:34:59 +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 v7 6/6] iommu/mediatek: mt8188: Add iova_region_larb_msk Date: Thu, 16 Feb 2023 13:33:22 +0800 Message-ID: <20230216053322.11596-7-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230216053322.11596-1-yong.wu@mediatek.com> References: <20230216053322.11596-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 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?1757966739206257549?= X-GMAIL-MSGID: =?utf-8?q?1757966739206257549?= 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 --- 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 a3012fdc8f61..7dc7cd510a8b 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1595,6 +1595,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 | @@ -1606,6 +1620,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}}, @@ -1622,6 +1637,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,