From patchwork Fri Mar 17 08:55:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 6802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp228868wrt; Fri, 17 Mar 2023 02:08:51 -0700 (PDT) X-Google-Smtp-Source: AK7set9DYd1TaPZX1Xaiqxg9HL0VoAXpNws4oxlBx6OumCgoFeNJemCWFKs6tzSDN/Voj54KwjAR X-Received: by 2002:a17:90b:46d7:b0:236:1ec1:6d30 with SMTP id jx23-20020a17090b46d700b002361ec16d30mr5808883pjb.3.1679044131443; Fri, 17 Mar 2023 02:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679044131; cv=none; d=google.com; s=arc-20160816; b=rkwcmXgJaXGmnPmSk4mTT419DbipVdAF/Oq8/fg8I1DUuqGZPvqMh+tSN1jY3+TBqK OWr4267mI3eTFwK2J8e2IEWcb7DUiV9VuVWMjoNyGZkmNAEuE8gSKyhoWlIg6Pn2JAef WlJrs1u71GyuqeLa23yO0zkOg4/SOiMaYjM6KHFHe+XESBL7HZihf9jYOuNYZsDL0QbS uSkMKpiHk6t+PspYc5EavQYKXD2uOUijFtaprIZbn53VIO+J5S4qgTgpD3SaA2wg5Qth QL931a/6hmpmlIzqlFRuPzUjq2SIuO9N/ohj97RLyp0uiBUa2EwD3pdK2Z/bji0DRqUz 7zmw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HK6jXpbP8L8/LEWjHAidc1nyc9oWHOpCfxw/41IYs64=; b=C91mCpaHYCxMLFkMa+af/SuDphdYLW7YzGaQo+gGYJUUNgJQPYZcmHA1qsgbLxOWm9 Cx4K2kRVRl2rfOHn/H5wFqpJDnLH1sIrQk90yI7//I/5Dtzv81+oWv9rzTsjxXFqJNKp SEqD7/7r9YtS+S6ZWx+mbDKnlOKKnOkOcovhFj4uNg+aSPdgQfEXfzpNMjrMUF25v/MD RZ+dBastcUAhnbyxWasutkyv5S4s0OGyhrdoJ1iQOuCxfJ1Cci7V3aDYwIftFWYWZDTZ pzZzvbYGsGbTzD1APVAUvR7v7Ig+daqBlfA/+Pcc6RddqJEnrvD26JiiUcwfv6ceINkg E/zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=QkQbVtPi; 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 mu9-20020a17090b388900b0023404175e3csi8185680pjb.178.2023.03.17.02.08.36; Fri, 17 Mar 2023 02:08:51 -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=QkQbVtPi; 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 S231213AbjCQI4b (ORCPT + 99 others); Fri, 17 Mar 2023 04:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbjCQI42 (ORCPT ); Fri, 17 Mar 2023 04:56:28 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136F96A9E4; Fri, 17 Mar 2023 01:55:54 -0700 (PDT) X-UUID: 83704abcc4a111ed91027fb02e0f1d65-20230317 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:Message-ID:Date:Subject:CC:To:From; bh=HK6jXpbP8L8/LEWjHAidc1nyc9oWHOpCfxw/41IYs64=; b=QkQbVtPinI/H0TkZKgTMpubRkBO0ctMLWVVU66yRKHGfWwDcwzQwjmYqYuucr2cGchOdYdxFWp5Os7j5MD2yFECyHFPkI0xFMbC/fQzPcLOhYF/cUD50HBMbmXC8QJYyfBMYDfU8LdVkKYaKIdKhNs8WN6NmXnp+dtnhCv8xVy4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.21,REQID:5dcd4cfc-5702-451d-a1de-fc61f9b613df,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:83295aa,CLOUDID:1d381cf6-ddba-41c3-91d9-10eeade8eac7,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:1,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: 83704abcc4a111ed91027fb02e0f1d65-20230317 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1163237211; Fri, 17 Mar 2023 16:55:49 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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; Fri, 17 Mar 2023 16:55:48 +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; Fri, 17 Mar 2023 16:55:47 +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 v9 0/7] MT8188 IOMMU SUPPORT Date: Fri, 17 Mar 2023 16:55:34 +0800 Message-ID: <20230317085541.20447-1-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 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?1760605379286157410?= X-GMAIL-MSGID: =?utf-8?q?1760605379286157410?= MT8188 have 3 IOMMU HWs. 2 IOMMU HW is for multimedia, and 1 IOMMU HW is for infra-master, like PCIe. About the 2 MM IOMMU HW, the connection could be something like this: IOMMU(VDO) IOMMU(VPP) | | SMI_COMMON(VDO) SMI_COMMON(VPP) --------------- ---------------- | | ... | | ... larb0 larb2 ... larb1 larb3 ... INFRA IOMMU does not have SMI, the master connects to IOMMU directly. Although multiple banks supported in MT8188, we only use one of them, which means PCIe is put in bank0 of INFRA IOMMU. So we have two pgtable for MT8188, specifically, these two MM IOMMU HW share a pgtable while INFRA IOMMU HW use a independent pgtable. Another change is that we add some SMC command for INFRA master to enable/disable INFRA IOMMU in ATF considering security concerns. We also adjust the flow of mtk_iommu_config to reduce indention. change since v9: - Move the patch about setting set_dma_mask out from this patchset. - Add a MAINTAINER patch since the header file was added a prefix "mediatek," change since v8: https://lore.kernel.org/linux-mediatek/20230307080555.14399-1-yong.wu@mediatek.com/ - Base on v6.3-rc1 and mtk-iommu-dma-range-v5: https://lore.kernel.org/linux-mediatek/20230307023507.13306-1-yong.wu@mediatek.com/ - Add a new patch set_dma_mask about since mt8188 support the PA of pgtable 35bits. changes since v7: https://lore.kernel.org/linux-mediatek/20230216053322.11596-1-yong.wu@mediatek.com/ - Base on mtk-iommu-dma-range-v4: https://lore.kernel.org/linux-mediatek/20230215062544.8677-1-yong.wu@mediatek.com/ - Add a new patch for two IOMMU share pagetable issue. - Add a new patch for adding iova_region_larb_msk for mt8188. - Add the comment in the dt-binding header file about larb index. This is for readable when updating the iova_region_larb_msk. Since there is something wrong for chengci's mail account when sending to devicetree mail list, we don't know why. I help send this patchset. https://lore.kernel.org/linux-mediatek/5a916595-12ee-92e6-d380-84146dd75218@linaro.org/ changes since v6: https://lore.kernel.org/linux-mediatek/20221223101439.494-1-chengci.xu@mediatek.com/ - base on tag: next-20221220. - update commit message of patch[2/4]. changes since v5: - base on tag: next-20221205. - add flag PGTABLE_PA_35_EN for all IOMMU in MT8188. - modify the type of "portid_msk" from "u32" to "unsigned long". changes since v4: - base on tag: next-20221018. - add patch[2/4] to reduce indention by adjust mtk_iommu_config flow. changes since v3: - base on tag: next-20220916. - use license "GPL-2.0-only OR BSD-2-Clause" in bingings head file. - drop redundant "portid" assignment when configure infra master. - reduce indentation by using "else if" when config infra master. - update probe flow about "pericfg" for CFG_IFA_MASTER_IN_ATF. - drop unused "pericfg_comp_str" in mt8188_data_infra. - drop words like "This commit/patch". changes since v2: - base on tag: next-20220831. - rename "mt8188-memory-port.h" to "mediatek,mt8188-memory-port.h". - use dual-license in "mediatek,mt8188-memory-port.h" - remove unnecessary "()" when define SMI_LARB_ID changes since v1: - base on tag: next-20220803. - adds MT8188 IOMMU support. Chengci.Xu (5): dt-bindings: mediatek: mt8188: Add binding for MM & INFRA IOMMU iommu/mediatek: Fix two IOMMU share pagetable issue iommu/mediatek: Adjust mtk_iommu_config flow iommu/mediatek: Add enable IOMMU SMC command for INFRA masters iommu/mediatek: Add MT8188 IOMMU Support Yong Wu (2): iommu/mediatek: mt8188: Add iova_region_larb_msk MAINTAINERS: iommu/mediatek: Update the header file name .../bindings/iommu/mediatek,iommu.yaml | 12 +- MAINTAINERS | 2 +- drivers/iommu/mtk_iommu.c | 151 ++++-- .../memory/mediatek,mt8188-memory-port.h | 489 ++++++++++++++++++ include/soc/mediatek/smi.h | 1 + 5 files changed, 622 insertions(+), 33 deletions(-) create mode 100644 include/dt-bindings/memory/mediatek,mt8188-memory-port.h