From patchwork Tue Jul 18 19:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13318544 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 559ADEB64DA for ; Wed, 19 Jul 2023 08:18:05 +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=oJh36wRfk1IZJ2DQXgDGsJS4v7ACeBr7J0khN8qXtt8=; b=IllBFrVzfgXvAz gaFYRrDUjBoeOWwbRjDk91mI4GRFn+55SKXj4rUCPvV5u7DOIyxYdv3HnFgIlZFyLQS0u3F/sei1v VHhKKFzqurNCkUC+ehV+78UuYdpviUVwA33C1J0TpKoIENKhPvYE8p+yWgaXJGUqldtQXuAAbS9it eGxX7idGfc46oSc7BfNjV6oDPe7GW8IBk8Bibfv/XUjdheN/28ZQ5en+ypY69gJ8xkJHxZvs+YEdX N2yXH1kSizhPsbL0Sy9mem/a+UYTm4L/5o9EDaNarSnjbchTi0W1++X6RXy3lQU5odnbPngF0doVN tGilW1GinjFNM6zO//Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM2Ne-006He2-00; Wed, 19 Jul 2023 08:17:54 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM2Nd-006Hdj-0d; Wed, 19 Jul 2023 08:17:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=hvwdiC6E5CEiy25PSFgk7REzIIrBWJs/ybCCiwdcjMs=; b=UV6MEQq2SMTFteMPEvlgp/zlCh oTuUWkszFd29jZYww4kJXgMWE7kh1FdnLQjyVI+YP7DHCnHGiTq9NRTe+AJZ4g7RGUZPzMiZorSbV 8fpqvBYrW7F1hHV6jwBKwG9aCAu4Axr6439bTb/jr/ZE/05Xw5PJOf8Mlqz7bXqi3dfmWY7eSW2hy J/+ud3CBWC03SCScmvaHvtKOHOGR+6LPUHpyLNk0G2fAt16I0vFDkMloxc+gywCWwuuhitu8qIJ9R ZZPehhN6qQeokmBaJVA+tCa2GsJdDzgZRrulAaLWDN7rdQuBHPHVBFZ2vkxQMaDATXZ5cjxstCv5V faKifQkw==; Received: from mail-mw2nam10on2061e.outbound.protection.outlook.com ([2a01:111:f400:7e89::61e] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLq2h-00BvjX-1n; Tue, 18 Jul 2023 19:07:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i29eL/tZdPg1vVMF5gZf+BjRfFnIXh14DseczAaURECLy10corm7/5oXKXT0+t7SXjPUc00AlFJ0STwGo187HsuxXLNgXRHt1atDPanAaXJ5Z79nteUycXIHeZ0lyyzZAFmnPbuGcrXEvBMewzueGoTuk6LdaOnnswV33H1PNuJ1YsZao80uztj2qRaskRSVNcsXJ36/dchh30E8sucnEG7jN9H9qOVMJngzvasmUB5Bb1JOpipD0Nob3OCPFP47G3xGqbhED77IoJKEN2B9FZ+UfBdKzNy2yFCcaHHIUfniBt1aKml5e+E2imxpnrC7F5dFZ+OFvtXwRRAO4ub6zg== 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=hvwdiC6E5CEiy25PSFgk7REzIIrBWJs/ybCCiwdcjMs=; b=iUsXfKZ4aQoD9Ayh82Ix5re1gReinVIjthI/0FuJxmHDCcGufXAu7suYdbMpVvfSzvdRerA6XaxN3XbdQgWM4Vsi2eQhFNyDCqJoBVGA6Sr0yk58jn0jhOmCeWf94sllECIQK2qQVyhi2x936a38Z7Txjjaue0nwHTrYcy8mwTcbz2gcsTJzRMKdCg8EivTq/5j02EJdX9LuCFuzSKlJwU39VIPxinuTZDt6oUEhO7TwNe6rOgIM3fRslGjifOsfQ182wo0RW/ryXKLQ8k39n/xN+nRIRy3CISzswJy1XfqYLZR+UszqK3Rx0qbfm+LCtYJH3aZsU6nHM3YTF6sjpg== 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=hvwdiC6E5CEiy25PSFgk7REzIIrBWJs/ybCCiwdcjMs=; b=gMHMbfMbWIQafZQIpEklpBBJ5yFUyCGeuhJf5nuEg4Otm/BmZO1mDUpz2wP5/iRfAOoIcPNBoeKXcrRt2S04CreWxddUgDGskzDsukBtMEXL1XUCBH2/26bovdufutC2yhyIE9mFBkh9dp3DEJWq9pM4K3kox5yv0TKZFw+lJpY0eyXI35g6Fa9OtmZIeUwYBnMMnlSnhaWzd6BCyEh76M2/+HvC43SSEvz9fpEz8rqtDgGCPMWTGaTuY9RboqAB5teAoFWJhRNd1FXuh0EuzjMYm9ik8CR6B5Qpy6CWS4rovi0XHtgAIWJM/vlBsk9hOATxLiXfcFsHTUfdbX5QYw== 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 LV3PR12MB9329.namprd12.prod.outlook.com (2603:10b6:408:21c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Tue, 18 Jul 2023 19:06:02 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::5111:16e8:5afe:1da1]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::5111:16e8:5afe:1da1%6]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 19:06:02 +0000 From: Jason Gunthorpe To: Baolin Wang , Lu Baolu , David Woodhouse , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Joerg Roedel , linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Orson Zhai , Robin Murphy , Samuel Holland , Chen-Yu Tsai , Will Deacon , Chunyan Zhang Cc: Alex Williamson Subject: [PATCH 05/10] iommu/sprd: Convert to generic_single_device_group() Date: Tue, 18 Jul 2023 16:05:53 -0300 Message-ID: <5-v1-3c8177327a47+256-iommu_group_locking_jgg@nvidia.com> In-Reply-To: <0-v1-3c8177327a47+256-iommu_group_locking_jgg@nvidia.com> References: X-ClientProxiedBy: CH0PR03CA0098.namprd03.prod.outlook.com (2603:10b6:610:cd::13) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|LV3PR12MB9329:EE_ X-MS-Office365-Filtering-Correlation-Id: 66291ebd-c23e-4706-1845-08db87c20741 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nGqKpBzPonSXjnixyKZOAlmwq9swWBnZqZbLdCR2x2I7fkaRd8r+HF/59Uppo4Rc8sxb6NnsB+5RhtA5YSnCBzWGEOAIxeaUeKvNwtlt5PD+dxC6tsC8GppBHCtxCso/WJ6DJq6aJpyRivwZsHBJqpr6VlqfdcVhsVu4JEVU8+Ur6J2eJSTJfQ4yiXb+b8tJ+JEO1BySt8xxZQYiyrhE752CcaTv1yrm8RzgQ1ia8+V4mB1UEg/EJbkDmrNhnd8CSjFNZ5fJucGrmo/Zp3pBAcFiWqhErHjDA5sg4zfjUGRUhDv2A56QljN4igrDKoQWKgnQnP2HlBuQmvklvHQt/We/bokM3uETDKYJ0uzQY2LduP0GhG1s8jUqXadRg/4WnKGOhSaPIVBZy+6LleEc38WjcI0ObFIziBGYUqaLgsdidFLOvvh0kfBZwUPxIA7KgIV8KeLDDD3SrWwp+DdIv54r0fLb174Nb6encIR/g2hZ/LSgtsE9iKebz0f3fEYgZc7V5VvR4NOnoYx6XTI6iwuGyONHH34qgM7mOOT5lPDie9z0aU8uH8kQKWRKNviuq3BSy3TUVlFiR8SkgMC7tYkEUOxecLe/vkqTAjK9HUeAuo5TJfZxchU82vYOMbqajDrklWRLim4NST4HoTkeNg== 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)(39860400002)(346002)(376002)(396003)(136003)(366004)(451199021)(2906002)(110136005)(6512007)(38100700002)(921005)(2616005)(83380400001)(186003)(6506007)(26005)(5660300002)(86362001)(36756003)(8676002)(7416002)(4326008)(478600001)(6666004)(6486002)(316002)(66946007)(8936002)(66476007)(41300700001)(66556008)(4216001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FAiSilI2AEX1WM/+id/sdhA7Sabg2oFT7Rz8jcvV6tlet+s1695z79Zb8SdOkcEjO8nb0La5LWSqQS7HXqB3MJ6m0vTc7Qp/A2089BuFMAhMiRfJ5/5d9NVzIAU28R+eGsHc7dATe4yfLlDN8eYv2cqyxoC/DkME2NLtYtBEGeClvGGCeGyfRtI7QXyy5PGwq3eyKORR2JVi+ZxsJXz0spKJuQXO3diKFuPZgngbdogm+zePSvRywSowbqNJN0vTobPJDhV+C67krlmv5XAW2U/5QcwtcrnBrHMDec2B8Ji2vwlyu86dW1AQCldVCjNX+XYIk5/wC5lH1CrIrabH8vaxm3X8wa1nl1iKFpV40hGrtxBGPK7YjXvTuWjqf+NXLJsKUEJ+Q8m2Y6r2bcTtzqpUjihdTrbhSTyGJkQ9a+IlDgexwsH+GWmMZujW6i8bWpx2FFb5XIDzhcvP9B/ONBxMU8YTJbWjEjLOgS2naqKzbcULq39YE39ZTuf+qdaF8wXllRoRoVp9WsqKXmQrp+9XUdTlYM0CJtquKHxcZptTyiE1/SSeeIliCpS/3bLgsxvuq2uLq+JpB3VWicoy/6bViiSHr0McGMBwLFn9ZKY9i/7Kgg4tBF5mt7hF1AywWrHRACppg4Eif1RsCmqIoNLSRkAkfGlxv3/y7M9kKcECTlAK1f0UlxQdu6o8uIvceQWeCEgKjEdoILSorRv3/r3bM3vFUrVjqlFdrb+pTICkziD48cj3Iht+Rk4ZRgJa0hW3xr7z0tJ+DqXWX0A4V/Ve77vnL2lE73gbL71+EBPgDP74z32V5EtY+l088oNhqLbpAQ+zxeWdjWmhYizZ/WogpRxmsdvY0rBxaY+K/WONE7LbJFCOE886QPkzGPq2nzsm1e+Y57DZ8zSpqhrR7c+QR3LgpOtqliDrE78TOaUsgm/X09auXPZay7cseaR6GlUM92rt/GV2VT0tChAnOLOaGpT8f+W16KT81w37UywvYFiZC+2Q7hiHMwVcD9gxm5wd4rQcxi5CId60jxYpRndSVkHqKkBDelmFEk9gWKy6w5FklhEdY5i9pCtSolqvOWvKq3Hwzr+fLfHTBMZicjcbn6bDCzpDT7PJngwcBR+9u+1zr/Uum46ixLOaB1d6xbweBPb5/aGboh0Raka+4rr7oYgznpvgOiqHvDQ6KlWX7e2ivnx/q3vqMEjqN1qOFPsesJIKt1SAmctzeKgp9kTFPrdVTGVDw0lA3LkvWRcCG5VyCCH/0hX+2gwqaH675i+c+GZgTc1XJULSM9HpN2W1Lzlo8HffGrmJ4qM7j78fBW7eGhkmYQD/ayBGg09hcJyCyJ+NP9vx70UtqGGNIsnuR4fgNCISZNOOJ6H3u9T/cI+YuA28h4MpmxP2D33zxvolLQfcoi3kKA0TSlxhX83hYuuBpEy+n8tVf1KWF333+clYksfcc8QxUQnf/i+0AtPLcegfoGQ3TB8VjU1VFmL1K5nsJq9kzsN8BqjMNZM9YnG3s4TxeYOu3PTj6RycDLw16Nur4RpxMF9H+iC8MJUu+TJ4It8wXxCdWUODzTq6lgv5PUI2zFOgwA/pBWtR X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66291ebd-c23e-4706-1845-08db87c20741 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 19:06:01.9531 (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: f1fLm+e+dNOUIVGtjFXvVl4SwvvGDDoGqezA6eaUbD9qMzaHOqW/dCHX/Rcdd6dF X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9329 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230718_200730_357896_13B241B9 X-CRM114-Status: GOOD ( 13.62 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Use the new helper. Signed-off-by: Jason Gunthorpe --- drivers/iommu/sprd-iommu.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index 39e34fdeccda78..9fc98fd144e445 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -69,7 +69,6 @@ struct sprd_iommu_device { void __iomem *base; struct device *dev; struct iommu_device iommu; - struct iommu_group *group; struct clk *eb; }; @@ -397,13 +396,6 @@ static struct iommu_device *sprd_iommu_probe_device(struct device *dev) return &sdev->iommu; } -static struct iommu_group *sprd_iommu_device_group(struct device *dev) -{ - struct sprd_iommu_device *sdev = dev_iommu_priv_get(dev); - - return iommu_group_ref_get(sdev->group); -} - static int sprd_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) { struct platform_device *pdev; @@ -421,7 +413,7 @@ static int sprd_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) static const struct iommu_ops sprd_iommu_ops = { .domain_alloc = sprd_iommu_domain_alloc, .probe_device = sprd_iommu_probe_device, - .device_group = sprd_iommu_device_group, + .device_group = generic_single_device_group, .of_xlate = sprd_iommu_of_xlate, .pgsize_bitmap = SPRD_IOMMU_PAGE_SIZE, .owner = THIS_MODULE, @@ -494,16 +486,9 @@ static int sprd_iommu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sdev); sdev->dev = dev; - /* All the client devices are in the same iommu-group */ - sdev->group = iommu_group_alloc(); - if (IS_ERR(sdev->group)) { - ret = PTR_ERR(sdev->group); - goto free_page; - } - ret = iommu_device_sysfs_add(&sdev->iommu, dev, NULL, dev_name(dev)); if (ret) - goto put_group; + goto free_page; ret = iommu_device_register(&sdev->iommu, &sprd_iommu_ops, dev); if (ret) @@ -528,8 +513,6 @@ static int sprd_iommu_probe(struct platform_device *pdev) iommu_device_unregister(&sdev->iommu); remove_sysfs: iommu_device_sysfs_remove(&sdev->iommu); -put_group: - iommu_group_put(sdev->group); free_page: dma_free_coherent(sdev->dev, SPRD_IOMMU_PAGE_SIZE, sdev->prot_page_va, sdev->prot_page_pa); return ret; @@ -541,9 +524,6 @@ static void sprd_iommu_remove(struct platform_device *pdev) dma_free_coherent(sdev->dev, SPRD_IOMMU_PAGE_SIZE, sdev->prot_page_va, sdev->prot_page_pa); - iommu_group_put(sdev->group); - sdev->group = NULL; - platform_set_drvdata(pdev, NULL); iommu_device_sysfs_remove(&sdev->iommu); iommu_device_unregister(&sdev->iommu);