From patchwork Tue Aug 22 16:15:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13361158 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 2BA23EE4996 for ; Tue, 22 Aug 2023 16:17:42 +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=RuV6CmsEd6ADkVjd4qbqBEJFtoctaEz2V4pBb38hJx0=; b=o9C3OjifBEAIap y+LAwromYNwhs5xMMV5UAqLLSM0/OQ69dkRsr5bqi+UbAHLNhpQn5wtIm+xC1lKAmfGGBM+Co6uwG YaOFxxVFP29prZL4l+aomZarmmDmlw2rd8QIJtjD4M+ZqxU0lKWvDyZq/t7I7Gxl27ufvgjdxoic6 IJhPQDGpIqoB2NJSNHJabYdm8Pjq+xc1Nol1+ZI9W7UEyQsG/x2qMBIFYRgg0/Jd5rX1XRNPI3iOJ jSTVtcuzdztheBAmeTsUo/uZJxSenE5Xq/uf1CbKrdU3q1pOb8lWBjRbiwuGq74m+tDayzm2JnIKt ob+3PJNJ9B6ILz0CtENQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYU48-00GSn0-0v; Tue, 22 Aug 2023 16:17:12 +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 1qYU3d-00GSM8-2h; Tue, 22 Aug 2023 16:16:41 +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=fCojKI/W5M3s3vHbMVLtKa/z4qtT7egQpecWd6L2jls=; b=gZU3LEnzqH7Te26KeYFWqvs/Mm DE0vpWKn5RCtQwYFrFOIOB/rugYzcRD20q5aW2ebuadiFy4yqsVLe/qBk8SLKlZdvGx3Xh4bckYeB QinZ18IQT1m7fa85rKG2g+NFZqYvNnI/bp4IJwQHOkjaR1e2vCkuhdq5m3fNDNUGHhePGHYf8hBxu 38p2Pd2WOKk1nHnHKn7fxApjf6V13Vt8ONNLfINJExTUB5Peh0AewXM5mZC/AXdJBZHUbjKZsznCn QZEpc4EJpJ4YthuzKliNAnZoRLTO+a9jYtSS6qXTu32B1NrFof7ovFYSY5p7NaCYCk58Y6c5Pr/W2 2pJzNPSw==; Received: from mail-mw2nam12on2060d.outbound.protection.outlook.com ([2a01:111:f400:fe5a::60d] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYU3Z-002rm8-10; Tue, 22 Aug 2023 16:16:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NXAY6x0lHGpQ3qk71UWA7In7OsC1KL94YtT2dqERIC5yigFMk7Y7CfmzCmFm5u2CXKvdDC1GLX4p72AuGWn70DXquBprVVSYd0i6Rs4oxO3KglJKXVKWpfHXf1NG0T44lGMIO0T+zHAvp+RAiQ7i/HKXudISh/EH+6bloLePjQTqlMsWP5h8OoZjlmeyfV9aE6aqpfixLY6qyAz189DnLeBGgrfaoPwNi4k0+aDdmHW6cMj2p0UvfyYhwKF4hlCsHK2opnLFQaAYB4JSLSNHIlRgfBaD/QQwSIlG3nTVWje6PCLEitpruq24MWQiUs8DjL2qII/3/N4qaeR+5ZScTw== 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=fCojKI/W5M3s3vHbMVLtKa/z4qtT7egQpecWd6L2jls=; b=RmTWfZVHzA8YLabfk7ajLAIKPIs2I1H0MElEvrmJl4RKEMWaAp3TrTN6hQHyxAO7Mm67u4BTdR06EqTiiUwgCEL1jJ6Yxi0D/sp5btkDVESV86KN2EM8z6qahN93okDlLtRn5PLsRclxhc7E1oKLozzYIYncgUDamjb7TA0HbwYxoAlq8Rm3ZS3yGvw4fZKVwpBfppCsaX0YIkOKUUhLvMxu6d2KSJs7Sri1wDa07UZ2TQKp/Q7MncS0MyKzjNttbHXwyFp8HL9iQHgCLYj3BfSNeZVKNvdrqbfnvrCb/Wv1KbzRnWUMKnKBtA7eEQEqogn8wyQU5FiVq7/ThlyfOA== 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=fCojKI/W5M3s3vHbMVLtKa/z4qtT7egQpecWd6L2jls=; b=gJcJlkI1CmhWLfT7t89syWJqT2hqeNaYVyd0gvHKfjm3eIjMzCpaenbScGinWU3oZvcnV08vJqcAOqdak8WbSy6gd0a3McOYtLv+HZvenZUrQj1d2IJAgheYprspm3rtMq5q2CUInzmpg8XZDkU4R+eo+btIhkxHu8EHY5nMcPAQeAkB67YyFUQShfOu998pw6naM0XRwnPHvxbiN5SwxfrTpGBUl9o8OFWzY0N87yTgsdZ/uybQHcbalwoiGkyLwPdyeHmHGh4YLbsap6txEJ6l86VJsr2SZRzmYW2R4JRpJ45yZwzbtddixLVOjEV4eRsZljzHDbH7ZzAyR3BwjA== 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 PH7PR12MB5831.namprd12.prod.outlook.com (2603:10b6:510:1d6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.20; Tue, 22 Aug 2023 16:16:04 +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.6699.020; Tue, 22 Aug 2023 16:16:04 +0000 From: Jason Gunthorpe To: Baolin Wang , 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: Lu Baolu , Kevin Tian , Marek Szyprowski Subject: [PATCH 4/7] iommu/sprd: Convert to generic_single_device_group() Date: Tue, 22 Aug 2023 13:15:59 -0300 Message-ID: <4-v1-c869a95191f2+5e8-iommu_single_grp_jgg@nvidia.com> In-Reply-To: <0-v1-c869a95191f2+5e8-iommu_single_grp_jgg@nvidia.com> References: X-ClientProxiedBy: CH2PR19CA0024.namprd19.prod.outlook.com (2603:10b6:610:4d::34) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH7PR12MB5831:EE_ X-MS-Office365-Filtering-Correlation-Id: 029c95ca-c903-4198-0598-08dba32b14f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MEu6L+7IC1DLMGdiAeUmapuuVT7Yb6AXAyHwF4IrMHl95F4AXyRORN3nEWJus2Hzb+iVs2ew3adZUkRVMyq4lMTrlgEp41nUqz+oA00Qq+IzFj6I/xAXYGBrAkfBtnxVcRiGhn9NT/kuPM8uFx3LDtAzdyi2xnp5YyEYS+zr5GWNxpAWt+A/zxSP1wK4M2M923WSre+RBTkVk1Ky9kJoMJzx7W5gkgntaw1zP/jZa9RDgy6IjURHY/gU4XZLlg9KAQNO5yu+OKs24z/febrplSx+PRqSXJMgE9bmNlUvX78HzBPQN9mfqSYem2ZClDebGVJ5mkdWYHU1mH5Lv4dtH9/U3517kecpxWPBif0cMSxfscl4jKmrGsoFxPFXLCmEo3NpG5cegpeIqwYu5Nf4Ly2rqcA8H4XudUOKRp3fQ2anVo6yZElhl46d2MSRm4v6UN7NyVWqk9mXp6hIzLAdbtFtMxFXf4uDNNZ7fsqukjsQKG3u7gE0dxu3Z2TqbKfa3+27IjFprnFBcT38TfJmWooC3SCBzErCJS38bgh3etfTdWUuRld9Da6QV/h/DluvkKuNRjckvXmFCyZzMb8gmID8aGopZxgppShh3qBO5Q8pivy32EyFnAWCWZVGCc8HVBOaCWp+WuOVLV1qm+jyVA== 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:(13230031)(366004)(451199024)(1800799009)(186009)(2906002)(7416002)(38100700002)(6506007)(6486002)(83380400001)(5660300002)(26005)(86362001)(8676002)(2616005)(8936002)(4326008)(66946007)(6512007)(54906003)(66556008)(66476007)(110136005)(498600001)(921005)(6666004)(36756003)(4216001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IzkrZ2XqVKvD5x3MkLFvik7uZ8Yy1ub7PWDNDaufdT1cLe8zrSP+qnWt1FN9v/TuwpQA+00msWDLbPFco8mym8WXgtlf3LAqlgoOgMpMS5jAU4U+EddKcoKr4ZYvrz5v+6MJUXuNhatAyedcxBgmZ8kl4Bi+VKqOxePzJGNmA8jq9MLhb9y8GXCt3reIrec6MpifPjQGY0QncBfTKEkJtiFqZWO+bUcVGrqpqcVlo/JXlWq/odeDC+sR2wH5Xz1ymR1b/wJneu0VR0X4EL4dbNk9yi3iXCPsS4cFvNO/aJL4aO6MAGU9w0Q9ABNNtHIpLTfJLMsCHxsYyz374NGLdWRiVuE6vVmCTzvp44RHIHLQivYj0sU9jkgUFDbOJVpSypTTU2ampsoPeAAQzCaerZ2A8cuyyTTIkTqUQAlDj9MljiDQOmEyd4GJclLflZx2MXwHubj5V59erJ9w9EEi8SK6BTXN4bRkDjtmjjYvhqVxe+mqa09jHBzVB2aqI9fYe9v3zwoquW1LqNCPay6CSrgOW9EMf9sMKeVNv+uoBKTdLSQGG49Cbh/ALNovxlchVCpnrTe8bmVKY8WPs5QBeJSGI/Kngf7N5u9XIyBI0SqfagKMepXNSN5t4IP8kDvDEoA7Y6Kfm5OdVcx7QrTbZe5LOyaQ+MYqCuhmAkqOUSVp+g1Tp93ygJDBv8q2F1rJ5iWb3lMuxUsXkEuZrw2W7d4zpDxx+79bl+BLf2VLuKzs8J6BwsB+4agZRA7jjMp3LNUcwrvtNefXqNZhqjzxAxFBIgkWTS5uY58jNYwwHf8zdcYFrGmF0A/XdCoW5Kx1oU6MBhVmeqf5q3Q12eoaE1k73An419mhpSqjEmKIIBSpnhReIBDmt/xBMMQT5uYJp6tC3QMTzX1tX7CTXqxae/WK6fIpOI7Spb20bJHaqbzrS2coUY5XVKdVOsfIkBnUJcFfkHDojVK5vSBg5rtJsAXDCeKB4RnvkQHUBhoIiXUgHYaHu0JrAkwJ7p7krKQOtUTLjR2rjyoex4Dy5ZGC1LAa7u7ZIkf1sOn0fUT26VU+tGEupvKrlMVzjNWBkildsFRI8QZTT0MUl0I0JF2jNhzhbsKoF4fQxAQXJ6MVgYYkZWSBt33270erzLFnyeiOLk+W73vwMD9fDLqOglgSWFN45whOcXTSG20/eMm0o70L2GkTCuWcKbHVtNryaLBgKhKxI7O7kBIKVCRMfVFXajQ0NxSETHwyr1lbv3owPqdUgkxmvthiHP4cxwGO/W7B2+Y9HXr+OZNxNS70VzHxMUxIALTBNCnAn4Fum6gfpWYctGT60WVk42pXrbQMpoXrxjG+7GrHZDe8OJNLivj6TsKVec1+KcCzaCWuSxQtaZxBXY6gubPsumWgdjmjjmjSbV+vyGV1WBKD1JSvuJ1fXwdG01cKtH+42lXRhI5jlAtXBbZR6yq4Udgtug35CBkOJhu+drZEJtzoh1YiO1I8yu30p6PiXaI0ySK8WALHevKyhm7MfMIy+fAuNnqGdNJhMItmB5wEhb04yPPpVJltp6uWTu/oLbkcZYwysMlOQWc8BY5bPnlcCkHd1fUi2DNe X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 029c95ca-c903-4198-0598-08dba32b14f1 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2023 16:16:03.5739 (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: igYYTj+D1uAd61rPRjJyjCJibVmC7e2iwo6Q2cbhytH1FKe4USytkbhFHfd6Xgfi X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5831 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230822_171637_463347_34CB490D X-CRM114-Status: GOOD ( 13.16 ) 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 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 2fa9afebd4f5f0..1ca22368649884 100644 --- a/drivers/iommu/sprd-iommu.c +++ b/drivers/iommu/sprd-iommu.c @@ -70,7 +70,6 @@ struct sprd_iommu_device { void __iomem *base; struct device *dev; struct iommu_device iommu; - struct iommu_group *group; struct clk *eb; }; @@ -399,13 +398,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; @@ -423,7 +415,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, @@ -496,16 +488,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) @@ -530,8 +515,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; @@ -543,9 +526,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);