Message ID | 7-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com |
---|---|
State | Superseded |
Headers | show
Return-Path: <linux-arm-msm-owner@vger.kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2A53C87FDE for <linux-arm-msm@archiver.kernel.org>; Fri, 9 Jun 2023 19:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231560AbjFIT4c (ORCPT <rfc822;linux-arm-msm@archiver.kernel.org>); Fri, 9 Jun 2023 15:56:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232116AbjFIT43 (ORCPT <rfc822;linux-arm-msm@vger.kernel.org>); Fri, 9 Jun 2023 15:56:29 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2071.outbound.protection.outlook.com [40.107.244.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26399E4A; Fri, 9 Jun 2023 12:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ONnco2GF8WhzqRHjgt9JCr6mJOw6MxU9QvhK17Qg37xr3MTAY2ARpvNFdpuiIM7cUidq00keu5gOnWEn84EHKw6GoMu0TjDoWoK+Gsy6yIUjNG+n5l1ATMzcOVQ35WB9JBCowaveiadNWBbpn2bEJsZIOE/g2aSuU/7+Avv7oEFO+G2i8fekomzQEJZDb3x8uUY0y063SYRfvNi1p6xLp1v+a13+kPK0vnpIFs9K53KUmfsL7rnLAnTh/R+7FZ0HnlUFmAsCvwh294E9cd/KDwOZ/eTILSKIralo7S35Gmx/3fQAVAuXfwf2MKgHhQAkThboX/EcFYgyYc5aR5A46Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oc9+cmsyQ7ClyqBWCUJKmesYXwKbwskFnJn3iebEKMo=; b=kgmaQd0AoUYyReaqMuVXh3RtbfANb+apS8fmMMzeH6ZcYBLNzTQtcaLBRYezchy/CGfKDK0HDNRn9uvnF+W8J2QuVu5e7Q9VWyeRSpWKY3jUwNLWzvb+vtwvCE/nNRyhK64ct5+FcXd8svrB0V9nxc+a/X/2mnU/mZSeZNcPxB7fIgtzjBwVSW4cXf+MFGWgBbebzbRwuaVe6vLYUsoIP6if7lYfkbJJdBykcRLO4Ohr/JgOSepCT8dPre8a2hKyZkv92vL9Hu+RqM1jmrUJRKlLjB1R4/69rhKkF6k8odUuzcKqK6b+XY9S9vt7HVykLYKS8uhya4LwtwqAMDm3Bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oc9+cmsyQ7ClyqBWCUJKmesYXwKbwskFnJn3iebEKMo=; b=A6of4EQYw97VfRbv2z3Le0aECz9dEaiU47foB5hd4aJOsrlTDr8JWnElJLDsDbsZHH4XqAm/9DDtOwWHlMjyKQ6tp6nS6ka1zZpelbRgQ2HNTNF6WVYOfIr9xqwifaiMK6xNWPkO12bIlUoPaiDbusuduSXBKUOTuEqZLf42466NQKOWu9NT5azw1nnSm63BnOaoLy0RD59GXdl0U9wEGRRi306plYyhdjIOJKeLY+pFZGwDejNoDwwMeCMSQkwSNkNkS4HPNq7EbhnLyVX0Cauc1CsxCFrZUzMI3JmrMDFMVKABh8WRZEO4j4G1gZFkswURv0IWwaDlEKv+nWVllA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by DM4PR12MB5264.namprd12.prod.outlook.com (2603:10b6:5:39c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 19:56:21 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 19:56:21 +0000 From: Jason Gunthorpe <jgg@nvidia.com> To: Andy Gross <agross@kernel.org>, Alim Akhtar <alim.akhtar@samsung.com>, Bjorn Andersson <andersson@kernel.org>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Baolin Wang <baolin.wang@linux.alibaba.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Gerald Schaefer <gerald.schaefer@linux.ibm.com>, Heiko Stuebner <heiko@sntech.de>, iommu@lists.linux.dev, Jernej Skrabec <jernej.skrabec@gmail.com>, Jonathan Hunter <jonathanh@nvidia.com>, Joerg Roedel <joro@8bytes.org>, Kevin Tian <kevin.tian@intel.com>, Konrad Dybcio <konrad.dybcio@linaro.org>, Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Russell King <linux@armlinux.org.uk>, linuxppc-dev@lists.ozlabs.org, Matthias Brugger <matthias.bgg@gmail.com>, Matthew Rosato <mjrosato@linux.ibm.com>, Michael Ellerman <mpe@ellerman.id.au>, Nicholas Piggin <npiggin@gmail.com>, Orson Zhai <orsonzhai@gmail.com>, Rob Clark <robdclark@gmail.com>, Robin Murphy <robin.murphy@arm.com>, Samuel Holland <samuel@sholland.org>, Thierry Reding <thierry.reding@gmail.com>, Krishna Reddy <vdumpa@nvidia.com>, Chen-Yu Tsai <wens@csie.org>, Will Deacon <will@kernel.org>, Yong Wu <yong.wu@mediatek.com>, Chunyan Zhang <zhang.lyra@gmail.com> Cc: Lu Baolu <baolu.lu@linux.intel.com>, Dmitry Osipenko <digetx@gmail.com>, Marek Szyprowski <m.szyprowski@samsung.com>, Nicolin Chen <nicolinc@nvidia.com>, Niklas Schnelle <schnelle@linux.ibm.com>, Steven Price <steven.price@arm.com>, Thierry Reding <treding@nvidia.com> Subject: [PATCH v3 07/25] iommu/mtk_iommu_v1: Implement an IDENTITY domain Date: Fri, 9 Jun 2023 16:55:55 -0300 Message-Id: <7-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY3PR05CA0051.namprd05.prod.outlook.com (2603:10b6:a03:39b::26) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5264:EE_ X-MS-Office365-Filtering-Correlation-Id: 7856a976-9cca-4824-e529-08db692397eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YKexdcYZjJdWXnlzmcT+KeLI0vO5uvOI77vGkZuPhzHhtPn+xRmmCgjMNDnonDo5LHUYE+RnrkIxBa8+ThyincXbLwBFFrrh6Jd+iWVIAJzk/P2+UD6TqEKxfb1qi//v2nz3FxLtgzTi+HnrrI5bxMG5CRpdKKSGOBG9ISaZn/a4OqActydHtbrrdRae+AQajP1TxCziDjehXFM6AmE1VZMNFaiWorEa5ZuLkZF2mN5+yOPQdkn+rKj8WPBNXXP5pMgaGk/YP9qCMiM+6Ewmt8QA2UQzxzeJdoIDeO5/DaUZyYRgT0hFqMMU8BpwtqqMQgE5IxNlrRI4gkepxs6qUryHZB3o0TCJtgcV/OcZmgIagRpjzBgQMsk1ti7QIrI084aSpBonWtShnxDaz2Jcfvkw5aEeRE2JL/48moe5Hai8iR4/aYWppFehyyA5tqjMHZVZuLO6DiZfUaJxxC1oc1A6yC0ZdlNGr6kYmsd7vLWLPbhcsgzZUHtonaUoiq8+kpD3AdI2zu1fi98R5SdHV5nhH4GCi4wlltlWDnz2Z9z5ydrjpE7OvsFb6L0chpYSwZfdTAyyA1Oe5AzBOa4aY00EerE/JOo5OEaF59BaoH2pL9sRhuyfL6vLf1U1GZct X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(366004)(136003)(376002)(396003)(451199021)(2906002)(83380400001)(36756003)(26005)(6512007)(6506007)(478600001)(54906003)(110136005)(107886003)(6486002)(6666004)(8936002)(7416002)(7406005)(5660300002)(2616005)(41300700001)(66946007)(66556008)(4326008)(66476007)(8676002)(186003)(316002)(38100700002)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mugXLiFcQTl5IT2CoKPn8SmoCPQfeYUSdWYNvjwmqyEItiOnWQBf3Qv1c47Hi+dx7SY0sGQ9dD3w+Sl2QjjOACJqByHNXLtYw6C+H75Cxl2FP8GboERYGnr9jxjgSkJdUYWK0Rayj8CFsCS2+Bwz5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WP0fLSd8tC2vB2DnVNfHDWzANDzV0U0mAN5d4YGS8NCGbZeiila0oKSXqA7P9wytZdXbbiHmhZttSzRSEHXrgMxyK7bi/fDENoyxxV0rs3yPkMgL+cdGKftTNPbxZOVIutGgh1ge8unYpoL48J6d010O7UnwHwsYqyBzBarp5SdC7lr4KOtgYy8uwOV2W9qciBjacYz8fbMaOFwIaCvL/qRW6lHlExM7SxHfJKhmTGsYbVpnaVDM2L2Rg7kdLWXX4qVhq4yJM6NVldbWiADiWjbBJtlKs8jAOJ5n1F1vT64ySQzDopHNuAZF3KOei3IXIebttkybQGuEcXtrpFM2lKT9g8+HXWNZu3acB+picetfQnp X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7856a976-9cca-4824-e529-08db692397eb X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 19:56:19.8465 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 34Vg+yhZaOkC51JWqFMk/o03N9htSqYZ08AqdguWagkA8fZ5Bd9kMYcPvDL3atzY X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5264 Precedence: bulk List-ID: <linux-arm-msm.vger.kernel.org> X-Mailing-List: linux-arm-msm@vger.kernel.org |
Series |
iommu: Make default_domain's mandatory
|
expand
|
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c index 8a0a5e5d049f4a..cc3e7d53d33ad9 100644 --- a/drivers/iommu/mtk_iommu_v1.c +++ b/drivers/iommu/mtk_iommu_v1.c @@ -319,11 +319,27 @@ static int mtk_iommu_v1_attach_device(struct iommu_domain *domain, struct device return 0; } -static void mtk_iommu_v1_set_platform_dma(struct device *dev) +static int mtk_iommu_v1_identity_attach(struct iommu_domain *identity_domain, + struct device *dev) { struct mtk_iommu_v1_data *data = dev_iommu_priv_get(dev); mtk_iommu_v1_config(data, dev, false); + return 0; +} + +static struct iommu_domain_ops mtk_iommu_v1_identity_ops = { + .attach_dev = mtk_iommu_v1_identity_attach, +}; + +static struct iommu_domain mtk_iommu_v1_identity_domain = { + .type = IOMMU_DOMAIN_IDENTITY, + .ops = &mtk_iommu_v1_identity_ops, +}; + +static void mtk_iommu_v1_set_platform_dma(struct device *dev) +{ + mtk_iommu_v1_identity_attach(&mtk_iommu_v1_identity_domain, dev); } static int mtk_iommu_v1_map(struct iommu_domain *domain, unsigned long iova, @@ -443,7 +459,7 @@ static int mtk_iommu_v1_create_mapping(struct device *dev, struct of_phandle_arg static int mtk_iommu_v1_def_domain_type(struct device *dev) { - return IOMMU_DOMAIN_UNMANAGED; + return IOMMU_DOMAIN_IDENTITY; } static struct iommu_device *mtk_iommu_v1_probe_device(struct device *dev) @@ -578,6 +594,7 @@ static int mtk_iommu_v1_hw_init(const struct mtk_iommu_v1_data *data) } static const struct iommu_ops mtk_iommu_v1_ops = { + .identity_domain = &mtk_iommu_v1_identity_domain, .domain_alloc = mtk_iommu_v1_domain_alloc, .probe_device = mtk_iommu_v1_probe_device, .probe_finalize = mtk_iommu_v1_probe_finalize,
What mtk does during mtk_iommu_v1_set_platform_dma() is actually putting the iommu into identity mode. Make this available as a proper IDENTITY domain. The mtk_iommu_v1_def_domain_type() from commit 8bbe13f52cb7 ("iommu/mediatek-v1: Add def_domain_type") explains this was needed to allow probe_finalize() to be called, but now the IDENTITY domain will do the same job so change the returned def_domain_type. mkt_v1 is the only driver that returns IOMMU_DOMAIN_UNMANAGED from def_domain_type(). This allows the next patch to enforce an IDENTITY domain policy for this driver. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> --- drivers/iommu/mtk_iommu_v1.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)