From patchwork Mon Jul 31 17:50:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13335343 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 0927DC001DE for ; Mon, 31 Jul 2023 17:51:08 +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=WHj+Aw/GG/hBkWLqw03iEnSRz/Vl862y2mcKl9LAu9M=; b=bjfFKrFFE0UsZI Pn2k+U1DNMRxje+u7PCpHY+GlcNd222NKHz76Xu89D9NGQwa70Jd4ZxCxM07ravbIlNq4JAjGq0wg 5+lCKEC/gZRoysZpDzeAQIqp2pU5H8HK3FxTWiH39+0ldbc2GVs5I2eSYuastFVa0gaDnus4dG4V4 n/ScHZIymN9eLUtyOvFutTVqHC+1zhyhu+h/uqFi6qI17NGZ5MG2WFNoo8qIHIiEXF4gUmtpoHP90 Cq99sBQuH9dA68R0g8aEpyCv85jVkfpiyEcoTuNGBlVoPtHEUJyuSLgJvOozrAUO2hUZEEUEE8oX2 runMe+eORgYuHj+HJ7vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQX2t-00Gttk-1s; Mon, 31 Jul 2023 17:51:03 +0000 Received: from mail-bn8nam12on20618.outbound.protection.outlook.com ([2a01:111:f400:fe5b::618] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qQX2f-00GtYt-0X; Mon, 31 Jul 2023 17:50:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L7bqMvQBrw1sRVSzRHcXZLmi6ykBUgBKcTffvrH8lMLVi33brrvoEePnQfAzS8smDO3L5nbnG1kT4zobYiDAXSsnMoc03ZyedRgC3qG3XjRUrTcGl+Q9476F4jPlwm0yFR5P6Q36jdX5VWx0ZtApaPPohwxqrb76CwI0KTQlhjp9W3Wg8t/S+yuzgZlyfWh4pQFVAiI04XaROMT5w57+lcrlBzolqJ8k5nl176SNYEShulQPSmKUx6EcKVvAq3p2t+JnwxGoZUVtDwMpDmhT8+SUsA3lZ9RGPaPWdEW8mB8CFIAKZPMUEMwCDUe4ggiWyduk4o4LW702RGh/GEODpw== 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=SrLde/OIC0cgtPmLWXIJF5U19mbUA+17Secmw/4gCag=; b=ZIdXmDWgOW3unTdZQskpf+n0HmxnhCRKld9eygCnCT4GL5PPIrR620WezWe1L7OOhXexbnWGIw/aBcb8Z+wXR06fs4VPIQYot7TvK4lLIv8gxID+HIbHpelVIH6Gxkfkl1sfO9faaNl7gVEmbEj0wEnfKGoP3TuFroB1wx+1C4jQWtiYqEQv38pVAVunA5CADa+EvSTZ7Tz//Xo//6LwH7oyJOGgxaq6XlP2uFOL5d9RQ+7DF+pc/tmsLiNp4n9BdnfrAMLS8PFRonw9i3MaedvFcE6ZweAIhizlee32LKOhRgf+pA8ylskC4Lw6yBp10FsjMW4KttCR4cG/abikdg== 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=SrLde/OIC0cgtPmLWXIJF5U19mbUA+17Secmw/4gCag=; b=RAZXl1rJWXqSWA76F2G0W08Si7S3Dtr682bNiZ7+GmN+Dl0YggG1c7AwCcYd+7QzZ36sUpiCY4U0x0h3xQL/E+l4SCiCYCJlKEHBnRX+3W/L55mZguvjZ2KFZMrsZd+Q1Q7oyGNEdLmXL/pa8GbA7YZld2hyiwYvgxofyZ9ZTBIp0MwSBnHguXDVPJvIKpd2+bNAQSzsZhPDVan+31V/34b7KuOlLGHKmUUpMkWdlp0l7wwf/KlXvVkNCAz46gcIxPKliplWm8OU6wDb58AOP41DjyGXHWFrObXGmElpIL06nhjdNBVs05ho6Ew4Y9n91ytB1Gc4QMf4ea1RCqfefg== 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 SJ0PR12MB6992.namprd12.prod.outlook.com (2603:10b6:a03:483::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.43; Mon, 31 Jul 2023 17:50:37 +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.6631.043; Mon, 31 Jul 2023 17:50:37 +0000 From: Jason Gunthorpe To: Baolin Wang , 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 , Lu Baolu Subject: [PATCH v2 04/10] iommu/sun50i: Convert to generic_single_device_group() Date: Mon, 31 Jul 2023 14:50:27 -0300 Message-ID: <4-v2-b0417f84403e+11f-iommu_group_locking_jgg@nvidia.com> In-Reply-To: <0-v2-b0417f84403e+11f-iommu_group_locking_jgg@nvidia.com> References: X-ClientProxiedBy: YT4PR01CA0003.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:d1::7) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6992:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a5083ec-369c-4ea3-092c-08db91eea486 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: efqiC01FRoHj0Ym9PZZrklkAgy2MXMyDI22K2Tc8Jy3BHQxKq+Jn6gvxGwEk84TJ9/Xykc3PIMu6J8plMfWH9nOzhF1RLAPScs/CgVYX8CUkabpFLm28nQsxhNhrwab0tww3SDRVFDsuvDNZNA97wDsZ04f1r9m4be5HeoXntfeFdlWUWa7kw+ZhgR897CDm+FASwYVpRzntRo5ndTn4JRtwkxvKUAjEVyW0fZUpmGNzhhc68BCaxx/oSQYSb97Gs5iBHxE3LNmXteOAYLmkvbDsXBgqQ89yhskdCvRh7TueNbOvhWtfPSB8+a27sSZs9EyPtZYTwWUvR4gFKXdok1/41gS3aW7VcShKV+FnmT2WeTouZ4SOcoRlR+CQsSQK93na4Y2wKgyVXESsEE67Ukn4QjLT92RODRuVLBvpAaT/v/2P8MpJ/b+jHsVYRDLeKRGe6cknbINo3grWHrnCuuJns/sqE+D1NxGCozocIvJBPnIKtQdEdk4SEwC/1sT8Y3ygIwK3CEhnMIzSRIihDjk0N9cfj9ZjnjUaMiFhdjDEMRWhxVe6xMf8EfMVf8K4iq5RtpFv5+h5nv6+T6Msw8b/XONkTubaxku6tqtZCB1rH8vmCxVYnSORFigBVHiI0ekqAKDetd412hBM0qEtJw== 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)(366004)(376002)(136003)(396003)(451199021)(6512007)(6486002)(36756003)(2616005)(6506007)(26005)(83380400001)(186003)(66946007)(66556008)(7416002)(54906003)(41300700001)(921005)(110136005)(38100700002)(66476007)(86362001)(316002)(5660300002)(4326008)(8676002)(8936002)(2906002)(6666004)(478600001)(4216001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DWht0jx4cMbK+WRz6P++YXkShMxZvvIAmrF92yZYGdMpsUBHYZhYh35m2bCHAJxocmYofPlMUfyPToThAYPl3sYSCPqlxAd749tkM/7Mo4NYjExZU3/V+XfRi9FeZLKVFwG4AG7qgyby8IqGtuDqbj7LUllOEYkhO6gUgwGo3AjYgnAqrHHGy8Rv2e+TY0DYdI5wCBZb8cMqqx3oQM4Bem3904fXAXOIZWrbn321HCZs50KklRDPer81u3dVqNDtMCrMvdPkoTkuqRgbjfRE5dn/hgcAbihSYjfp+iwX2wertG+gBGe/v+sBU97fnJTTs64+E3kZ8pYaSumIdHt5r9pgkyvfBHRECBlAKL2HMzqwK8dRcT1IhbduLYBI5fdjaDNOKRKuFd1Iir5O/UTHYVPUTy081Vo8LINv9H+Xaz8Nu83ZMU3Psl7hRww+REbGgFLyAdTdWULwQ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AVJZuu3dwXNbgS3Hc2xUKm3PngNe1Tll/rT4uMAk0zIC+3cuDq061ZWzu1 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a5083ec-369c-4ea3-092c-08db91eea486 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2023 17:50:35.3520 (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: TLWppAQV/Eja5IzsaE5x//+vv1sYX6+UusDItUUoVIRGqpTkxbxD50cU97c+Qe1L X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6992 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230731_105049_205099_AF258D4D X-CRM114-Status: GOOD ( 13.46 ) 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/sun50i-iommu.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 74c5cb93e90027..b8df655185ab2a 100644 --- a/drivers/iommu/sun50i-iommu.c +++ b/drivers/iommu/sun50i-iommu.c @@ -107,7 +107,6 @@ struct sun50i_iommu { struct clk *clk; struct iommu_domain *domain; - struct iommu_group *group; struct kmem_cache *pt_pool; }; @@ -808,13 +807,6 @@ static struct iommu_device *sun50i_iommu_probe_device(struct device *dev) return &iommu->iommu; } -static struct iommu_group *sun50i_iommu_device_group(struct device *dev) -{ - struct sun50i_iommu *iommu = sun50i_iommu_from_dev(dev); - - return iommu_group_ref_get(iommu->group); -} - static int sun50i_iommu_of_xlate(struct device *dev, struct of_phandle_args *args) { @@ -828,7 +820,7 @@ static int sun50i_iommu_of_xlate(struct device *dev, static const struct iommu_ops sun50i_iommu_ops = { .pgsize_bitmap = SZ_4K, - .device_group = sun50i_iommu_device_group, + .device_group = generic_single_device_group, .domain_alloc = sun50i_iommu_domain_alloc, .of_xlate = sun50i_iommu_of_xlate, .probe_device = sun50i_iommu_probe_device, @@ -995,42 +987,36 @@ static int sun50i_iommu_probe(struct platform_device *pdev) if (!iommu->pt_pool) return -ENOMEM; - iommu->group = iommu_group_alloc(); - if (IS_ERR(iommu->group)) { - ret = PTR_ERR(iommu->group); - goto err_free_cache; - } - iommu->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(iommu->base)) { ret = PTR_ERR(iommu->base); - goto err_free_group; + goto err_free_cache; } irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = irq; - goto err_free_group; + goto err_free_cache; } iommu->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(iommu->clk)) { dev_err(&pdev->dev, "Couldn't get our clock.\n"); ret = PTR_ERR(iommu->clk); - goto err_free_group; + goto err_free_cache; } iommu->reset = devm_reset_control_get(&pdev->dev, NULL); if (IS_ERR(iommu->reset)) { dev_err(&pdev->dev, "Couldn't get our reset line.\n"); ret = PTR_ERR(iommu->reset); - goto err_free_group; + goto err_free_cache; } ret = iommu_device_sysfs_add(&iommu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev)); if (ret) - goto err_free_group; + goto err_free_cache; ret = iommu_device_register(&iommu->iommu, &sun50i_iommu_ops, &pdev->dev); if (ret) @@ -1049,9 +1035,6 @@ static int sun50i_iommu_probe(struct platform_device *pdev) err_remove_sysfs: iommu_device_sysfs_remove(&iommu->iommu); -err_free_group: - iommu_group_put(iommu->group); - err_free_cache: kmem_cache_destroy(iommu->pt_pool);