From patchwork Fri Jun 9 19:56:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13274413 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 95670C7EE2E for ; Fri, 9 Jun 2023 19:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sD+1VRmmlqfiXvoHzLJSSVM8uL9H51j7s5H3cJTY7Bg=; b=thTpq6wUXA6HY2 +4yphrmEYmmBConxBj2hwhX37Htb4QGvgH03AtKymB1P8VKCSmKFqfSeM4JpI+mNugAQObNs3n2+X k2buNt/yCLjYvRl+ZkMgqRU/c7HIIFKe2W8jm1rOS3BCPMTUv/FDGbcZ9OSEP1Ex2OiPNr4l8b6LD qsdowniDNAojfcla6JG2J7jkYX7448lG6ei1HjjphnXT13ZEwPi6K6bgm4L/sVNPH0j7KRJ1x9KeH Bg3m7wCSaFVH8MZOVqLpmEX3dvo3nHhk4xELB1ofcw2UBRQMudSaDrBE+/sv9o2QCJsjYU/x6EA2K Rl4WcZjvE/iWFt7adbjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7iFw-00E6jT-0e; Fri, 09 Jun 2023 19:58:44 +0000 Received: from mail-dm6nam12on20611.outbound.protection.outlook.com ([2a01:111:f400:fe59::611] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7iDv-00E4TN-2W; Fri, 09 Jun 2023 19:56:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mk2JGDyVdgBusVjBD6/kSG4IY2QcIil5vpW+K5as9Z79OFwvnDKYe+OQ7kaYvZj2rlF6pz+0OjaqTRINWiZyt7v9SDfqpIyZoA0plcwRt8HnsiQESCIpbUZeiluBMbqoG5me8Vm8K506ptbYhF7tpURbNVBysKwvmVw3U6iS2wKS5h2vjspb/1fmS3oyBs/becpu4Duh14+l31udgYFHXt0pt+3dqJQgTolZtqyVGK/6GI7kCnSv8V6yKfN9zaZe8gfVh9/Dila96T55FOq7z8OMPK2o9icu6snV6jROmiGTUOy/xSEcV9MlcsiPq9LpKa4GzYSOca4lOcpMPAietQ== 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=YUJcfpNdGV7lboIiAgPA0VpwiRBsj+xi4myndKO42wo=; b=AVoeHJDxCCtA24qaMnzBRvjDUn+8L2IgNaPi42fJA+Gej02nCCVV6LVGhRtIbYe5vuBpuwJlKpguL45szZ6g1MyP812I4QITk20SMQ9NqTEv1uxaTXv/SuYwQMQNnaZdnEbhUM4SjXCERW4N6utJmuhw8ZEKga0M3cyoSLQ6XD4NJqpanysUIZzqBv4MD/Ss4Bq3OPPOdxtQU8U8gsJiRAWkJ2S1Lo4Xwwrcnfy9/HIAHEzPnNxQpvvH8WRw9QbOJd26gedJjbRAAhO2pkh20rjQoEJe5yQYpP1qndMs5gVrYLO3UbcoPFUkSzNET9Z9L6VTp1+jmG8z1ChtidemiQ== 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=YUJcfpNdGV7lboIiAgPA0VpwiRBsj+xi4myndKO42wo=; b=XH+OhXa9MpFyz7M5XcOJPPx/QHpZ2xX68AR0u7w/DFyauSp/0bgOH+eb5WMnln8vdF+rXoWzYmGCIqQvVd54z7EIU0YxMrspLD9HU4mSDsHWX/r+xlMWzWA6JqhKetILdUB9hPIAPaAh8zCWEu09aFTGUpGUuRCQsnUhhAXKq3zVRMvB7wkVovwofYWaRUoFJa8J04ujR7H6WOopQGEQVJIKc//D7Qj8xR8YutoOjaYJCPVSp8RqKKsevMkqM3ARUqOi6BdNQmDxqkQpTsd1tXGLCNuK6t46zRL0kRRq8995FGAbnFjfDbON48njH6F3Yt7YXnRsTmSvvcXxoV1P3Q== 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 MN0PR12MB5785.namprd12.prod.outlook.com (2603:10b6:208:374::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.36; Fri, 9 Jun 2023 19:56:25 +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:25 +0000 From: Jason Gunthorpe To: Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Christophe Leroy , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Kevin Tian , Konrad Dybcio , Krzysztof Kozlowski , 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 , linuxppc-dev@lists.ozlabs.org, Matthias Brugger , Matthew Rosato , Michael Ellerman , Nicholas Piggin , Orson Zhai , Rob Clark , Robin Murphy , Samuel Holland , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Dmitry Osipenko , Marek Szyprowski , Nicolin Chen , Niklas Schnelle , Steven Price , Thierry Reding Subject: [PATCH v3 16/25] iommu: Remove ops->set_platform_dma_ops() Date: Fri, 9 Jun 2023 16:56:04 -0300 Message-Id: <16-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: SJ0PR05CA0109.namprd05.prod.outlook.com (2603:10b6:a03:334::24) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|MN0PR12MB5785:EE_ X-MS-Office365-Filtering-Correlation-Id: b7016c47-b82d-4f87-47ca-08db69239988 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: amPtFXdHG8kHDNbjmB+vMrFlIZUg7BHpt0kFYxjmoV5pRrBbbT9mwSipM8koarCuY+2fOynix1kIvtZQdrAy/+sYLyx5wZckfcqaMHGR5aLnjKDSerG9h5qH1Rr/2XjMZKNap/eZm+QinTPxiHsbMIpDefVEAPEC1fXh1bCIZlsfsyE8iCDS+PvPy7Uq/NPB+/Y/G2EMsMUZdi4ePeGo9LmO8wXbqBdyTDdVWl1ezOjEvBWPep+1DySnH8kcjLbtZbaenyt/f/72gTZkqbfCGVUbJA6l5jBZpDX6w+2bAsnSX0+RDrhzxgDu0138C30GL7yHBqeOHAj6RBp9t00hZq8Ee+WmR54J6ZRxDX/dHWJ94VrslQSQ5fZfMTV/+OfbZlvTNSz0PM0x7Y2HwoubhmaKtZpJy11Kp8Jk4ExBcx9IVlS+oczIENuABeyzR8rg7VvBuD4dunDtEYNIOX1pwq4IGabN51vhmPvf5ZhNki1syEKBDYOIt2JCLpX6PaTW8fFsQTKPx1mYzY0NTN1dMyPrtpZBEPtxZYIISk3gu+BffXTotfptdKZmeVV3Z/cJ/UEDGdx7NyI6MHJ+nN2L8X/j3ujtCfiEoL+Sb54RlfI= 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)(396003)(136003)(39860400002)(346002)(366004)(376002)(451199021)(83380400001)(7416002)(7406005)(110136005)(478600001)(8676002)(8936002)(4326008)(86362001)(66476007)(66946007)(921005)(66556008)(5660300002)(38100700002)(41300700001)(316002)(6666004)(6486002)(36756003)(2906002)(54906003)(6512007)(107886003)(186003)(26005)(6506007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rAZD1v/ckDPFcJRbQ+gjf7/ixbRJq8G5pgLzirpKa+jA0ZwsRzauogPjJ5wBhBzODu+EePRskDmp4n7gU572TPgkAaNuzKibA/n40PnybqrtdJDMSQQ1xt1VUAyxLrP2oMqTO3DA6NxsNAYc1Jx7UvVoqfk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8up7yEjbpLTT/iG6J2w2rnDyDiRPNqP8S1NAqygkidSVsiGqWZsDDbnzP0sXqMOUuRx0PL5U5Egf+cRAgGZfBmQe4s7QwFn9pRWGQJ8VhCjk6tNPFSGcfKgPqsqEFArL4mqnvMCgRPNj7KbmkxqfNS/MPkotuhHOnvv+whqRNcsqUyVqXsrKzGzmZEHKfJcsJ+rOJEmOg7P4Mh7ysvSPL2B0l3qHUrvOYgrSVpk5JIcNanloFimG00yOIPzGSssW0T9+Vb/g9Pd3ydkh2zkVbzdR3qpl2vk1C07QX2rTJurPJykzGMKJqrj2Eb04qHPlhIk4aHCo40zZ0UH5hshrzOCEq9xRaLvI X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7016c47-b82d-4f87-47ca-08db69239988 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:22.5325 (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: D5/y01kQfVfThRunHJz0Xyvhc1q5m9jHe7ppZGkJ7rdU3Lzq6EwyojXKWYiKsh79 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5785 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_125639_852703_26E7DEDF X-CRM114-Status: GOOD ( 20.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org All drivers are now using IDENTITY or PLATFORM domains for what this did, we can remove it now. It is no longer possible to attach to a NULL domain. Tested-by: Heiko Stuebner Tested-by: Niklas Schnelle Tested-by: Steven Price Tested-by: Marek Szyprowski Tested-by: Nicolin Chen Signed-off-by: Jason Gunthorpe --- drivers/iommu/iommu.c | 30 +++++------------------------- include/linux/iommu.h | 4 ---- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index a3a4d004767b4d..e60640f6ccb625 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2250,21 +2250,8 @@ static int __iommu_group_set_domain_internal(struct iommu_group *group, if (group->domain == new_domain) return 0; - /* - * New drivers should support default domains, so set_platform_dma() - * op will never be called. Otherwise the NULL domain represents some - * platform specific behavior. - */ - if (!new_domain) { - for_each_group_device(group, gdev) { - const struct iommu_ops *ops = dev_iommu_ops(gdev->dev); - - if (!WARN_ON(!ops->set_platform_dma_ops)) - ops->set_platform_dma_ops(gdev->dev); - } - group->domain = NULL; - return 0; - } + if (WARN_ON(!new_domain)) + return -EINVAL; /* * Changing the domain is done by calling attach_dev() on the new @@ -2300,19 +2287,15 @@ static int __iommu_group_set_domain_internal(struct iommu_group *group, */ last_gdev = gdev; for_each_group_device(group, gdev) { - const struct iommu_ops *ops = dev_iommu_ops(gdev->dev); - /* - * If set_platform_dma_ops is not present a NULL domain can - * happen only for first probe, in which case we leave - * group->domain as NULL and let release clean everything up. + * A NULL domain can happen only for first probe, in which case + * we leave group->domain as NULL and let release clean + * everything up. */ if (group->domain) WARN_ON(__iommu_device_set_domain( group, gdev->dev, group->domain, IOMMU_SET_DOMAIN_MUST_SUCCEED)); - else if (ops->set_platform_dma_ops) - ops->set_platform_dma_ops(gdev->dev); if (gdev == last_gdev) break; } @@ -2926,9 +2909,6 @@ static int iommu_setup_default_domain(struct iommu_group *group, /* * There are still some drivers which don't support default domains, so * we ignore the failure and leave group->default_domain NULL. - * - * We assume that the iommu driver starts up the device in - * 'set_platform_dma_ops' mode if it does not support default domains. */ dom = iommu_group_alloc_default_domain(group, req_type); if (!dom) { diff --git a/include/linux/iommu.h b/include/linux/iommu.h index ef0a0000f09326..49331573f1d1f5 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -237,9 +237,6 @@ struct iommu_iotlb_gather { * @release_device: Remove device from iommu driver handling * @probe_finalize: Do final setup work after the device is added to an IOMMU * group and attached to the groups domain - * @set_platform_dma_ops: Returning control back to the platform DMA ops. This op - * is to support old IOMMU drivers, new drivers should use - * default domains, and the common IOMMU DMA ops. * @device_group: find iommu group for a particular device * @get_resv_regions: Request list of reserved regions for a device * @of_xlate: add OF master IDs to iommu grouping @@ -271,7 +268,6 @@ struct iommu_ops { struct iommu_device *(*probe_device)(struct device *dev); void (*release_device)(struct device *dev); void (*probe_finalize)(struct device *dev); - void (*set_platform_dma_ops)(struct device *dev); struct iommu_group *(*device_group)(struct device *dev); /* Request/Free a list of reserved regions for a device */