From patchwork Fri Jun 16 19:02:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13283271 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 578CAEB64D7 for ; Fri, 16 Jun 2023 20:15:58 +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=WMEsOM5Sq8youn SBKsM/1WGeju0L80wFXW0wQRev97je34GthRxsDkN8BCFGpRrw1p4sI0vfbPQOh3sf3FRkStXxWU0 EsKEkMDa/hR6l0Le5UC+ynWXtjqqVXDQa1cV5vRw7NDB+zglSuoLGPJ3G9JyxfOMiq7V9MluYnyS2 n5klf2Eydi9dDBi5ra66AQ9759MhaYMvFLapL4mhcvT+J6hLQqlLtyqSfu0saC8owB7IirEw7umby JzYad84LfZD43RSvwot6tTnVX22LcX7JBORz1rJqi65Bjusa4xc+PO+ox+O+YsaTmce/B2uot/X1j HRYd35Zjmm9z4vamdHbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qAFrP-001l9k-0F; Fri, 16 Jun 2023 20:15:55 +0000 Received: from mail-bn7nam10on2062f.outbound.protection.outlook.com ([2a01:111:f400:7e8a::62f] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qAEjA-001X1S-06; Fri, 16 Jun 2023 19:03:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jOGTSeC8zYJr1DmwPNIXYySV1Av3/kUire3d9F6Qp7+fyQKcZRVWOsNbITzd7fLQuHEdnDgSU9LXxhmAP3kVLNEUbgqS5wIGpdK6Dp0h3t4iDLH8OkDT7ekMs7s1T6F7R9HuDH2CPOS0objRCoVNQcgiEt/wxIG+ITEijs82UhMV9Odcaz9ntsYLo2znFBNOda2E/o8duE2SRjAQ/TRWStqZsbT08iF8o12yKEC7hRac7Gj7MZdqP4AyUZHiEgk4aijzCESSCKP0Y/Gp9jBggLkQdMarL5fxG8/0URdzexTcK1eM4VONwh5Ay/1F2iQIf3sRqNA9wxYlSNOMYKSfhw== 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=aTGcU7Sir9Mw7scqV8HGJ2A/e7a+ilz5ehuENd4bsB6uLee+1i6juXpFpBQWSFBLDV4sVfS0BUTbIKVU15VH5hXsrTibmrZIgDWIhNqN7D59cPUDnAYQmd+O8uA1M1ftcUFF34bUb9NaoEbEJUNg8mEqUWoZeK70x2tWFUzIz8IxJzKQCpWxJx918pgZPpXiBiG4Ng6PCztxij0DcSoSdLcxcnogOr0oXL1Eib1/CWgm94smQZceO01KcoZt5o1F2yYtvi7Jd5huFYV+2C67Q+o/Ou5lONN5ZNZcTPIZx7cjWxG0g6oaxFwPzlYztZPAexUnJ7zXNpo0ENWDCDW/Mg== 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=NVxJS5IgZYCe1/L5WPip+HpLA1fY0Ki/1OENoQMg4vIhMUqAojuAjId4BG0BsIN0Ojg8Mo3JHir1X/EDvvdosVvYhXK37/uFRRVmsz+HERbaXEBkmHFLBUPevOCcDEj0HHmkXSMFdKNu+LiEJ/dUJzaAfWveyy6Ur44BOqI2iNfMOpffCB445m8AWhZrJ4KK2bwmr3WZc9Q/TqVJsjdnn8VcVnWNR0zgnoT4JLH4qs59e6KSIWQW+lzlk47+CqQhaJcXKCfkpLBAui4200A6Bw90RD/gQo2WPTfXRH0+8nigNN0ZWKgsDZ0hBVvH5nJALTbfzNdu6EY9sOPFl++N+A== 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 SJ1PR12MB6051.namprd12.prod.outlook.com (2603:10b6:a03:48a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.37; Fri, 16 Jun 2023 19:03:07 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%7]) with mapi id 15.20.6477.037; Fri, 16 Jun 2023 19:03:07 +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 v4 16/25] iommu: Remove ops->set_platform_dma_ops() Date: Fri, 16 Jun 2023 16:02:45 -0300 Message-Id: <16-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v4-874277bde66e+1a9f6-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: MN2PR20CA0059.namprd20.prod.outlook.com (2603:10b6:208:235::28) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ1PR12MB6051:EE_ X-MS-Office365-Filtering-Correlation-Id: c3dfd829-b06b-4b5f-d7a3-08db6e9c4bf7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7XIf1xelxTdYWj1/dWcgz6FKGekMpXycQgbqA/1LvgL88CRridsQMPQCHYLGqldq9jHpNM9sRkXFVlcAA4k2uz0G9ovtg49Sk+NrtWUU4POYEhUAAET57TIrmp0A0OV0U+dvTT34loAF2+xJ5LmonSYygDJEM/vkqDYVkO55nSTFciVwdZJaC54DFYzM0Wk2OLkaQUgIdsqGlx25ZeDqaXZTTG02MTd95J2iJr74+WIP/Z2Ekt8xytIs3EqedM6BmvqCO6PGTIfaNpWoiVWbXSJXAWUAhsmpO4FeU1+Mtw4PC57WcjD3oa2BNND4t8Uwh2jRPVVRMef6gKmOO4xjfM03wxvunbp498A1nZ1eveQcVmeZgCM3frSTf/ED6bqsbB+xnrH2L8D1MZ/AKqtaEhp9gRy5VBoVBNhaZ3KMoaShCJU0TK7RSgX6pW3yyy8LNSQHBEduESN/eeVYf1giIIXqU6Lr8pTv/XZ2ev4Bl5twPWan7cRDbAEJeTQpcQyabSlR/uPSHzNFoW3kLfI6Hn4/BZk9RvdvY3r66U/rsJDxihpdyoukBNYjgUIQcy52xSC9wrURwcyJCq5V238B08C93bZzsEJDzbHOiemzByY= 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)(366004)(346002)(39860400002)(136003)(376002)(451199021)(2906002)(83380400001)(2616005)(36756003)(86362001)(921005)(38100700002)(8676002)(8936002)(5660300002)(107886003)(66556008)(316002)(478600001)(66476007)(66946007)(4326008)(6666004)(6486002)(186003)(7416002)(6506007)(54906003)(7406005)(110136005)(41300700001)(26005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 984Whq2DXQLXIvf6/pyvp6EInUv/wNOQlmq6+2le9ysGYbQpMzaENGR8AKdmDbDvbuJf+vP812OfLWu3CW6Ho+z3uSu2Zdp4FXn4SIJ6MdOUVKBgsCtWyYKAuJAxGBzQ3IPaglysIl55REYURDErgT2UW/rxU8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/ReGYlzZqb7XrdvEXpa9MsuFJZv8XmLfen0NBfQ4kYXeE7yDzNfnoSrkpwLHhONyA0klFveizot6Pl0arkGIZsZqeOtN+jxLtPZezJDIcOzYLfvaSwLAwYCMTyQEqJEd1/Ht74tnJ0kJTOg+lBZpVJr0q7UFSyuF/al5Wi+RUliXvu4offMuK3AeXJsyX1Y6eMkxMPabbVxecQqs1LAutq0mcTNLk0iueXE/o+KVRLZBNkLOIIlRq+T6dmyOmrLVWPZB9haH0kYNPocezYULl5UeI+NJCpRv9JsJKzdTpL5waKEvbS3lllvVA4E1eER7o5XDZAuiwZRf+qOIy5Xk/9l5DMaPWmUveqfYCYgKdrFP8 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3dfd829-b06b-4b5f-d7a3-08db6e9c4bf7 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2023 19:02:57.3081 (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: nA8v8CV9CqPbTmeiggylA/33KWUmWZM/vyF5+NgIRDSD2H3sV0HLArq7wcLLhN2T X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6051 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230616_120320_131267_D9E250C1 X-CRM114-Status: GOOD ( 20.69 ) 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 */