From patchwork Tue Aug 22 16:16:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13361125 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 6D56DEE4993 for ; Tue, 22 Aug 2023 16:16:27 +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=vYMPnNW10YH+6gkSqHqJtWvk2TOgcZ9lqLeFS2rmYJU=; b=ZOH+Wpo8TTZInM LXZLV2+RboSm+99KDiFp+Ff3ILbonsyk0XQwubL29ydOQt126LkqBv/w1WKLumdfbGCUCMzq9OlO2 wmzMxQxiF+q8wFBg6oI/kI9W55DDnqROmIbXolenT/OAnJy1yrly9Pql3opNhUKf5+S1G8hbgCjpc 1aYhpo8+oCOe4LlfoAiRPa7rfVOCGeAUZ2PbUjloaJqi4GJyQDu/nxB2YiNMeGX0CChBuHofa/fGe GnCZZqftjOw9HiAVs1hkBAkEJ7ws8cSkm45yKaDoQBHK8JPcIGR+Wu3lchwFbbPJTP5WAZRJXdDmL y+bd+n9WSkDTJ9XybE0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qYU3A-00GRz3-2a; Tue, 22 Aug 2023 16:16:12 +0000 Received: from mail-bn8nam11on20600.outbound.protection.outlook.com ([2a01:111:f400:7eae::600] helo=NAM11-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qYU36-00GRva-2g; Tue, 22 Aug 2023 16:16:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hOlOodWOp+2rRQJ4PIDbu5XqiHFWxZ9DIixWhFLQ3Ri8EDjvd1k7yppjJyyQl6JDCWbtZTtULN7Dz4AamdMYqmvMh7dwcCGKwx5n4zHnVHcCaS+FxwT0nrPOxRl6PtrWbGrK58fBarOmLFJwA2wxoEsGtCgiNj8FAasmIZ6dpyFt+JS2cd4g+7dSfRfS0Iwm6WZt3/uOddz9tr45HD4HKPzhKeOxZlZNrB6+0ryrQYSCobnjqk/ZqxqKDrvW4cxuQw9z0LuK1MuKhvNc0F5wtXgbFi7mE9fOLkXJuR9hU9Qi5xux9ashiYflRSB4VqYgZhoS+3Pusb9eWCjfGjsC6Q== 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=nZbD14POHu2WrHgEO8Jvpv+BAByIdXDcXCIfoGvu5FQ=; b=HmK6KZYtrgxkEHjrGyBI/bB1G7d5b9qiKsvvKxZGzkADO/cICE07srIM+pZBv1jtqZEl/xWQwLlTRpfZaGAdAerwruiBhMZP8paX9eLt4hfRc+NUvK11wITprn5ImPDix6qK61tYyH3Zf5mgbHm3A9O3+Eu7+c0jmLEpJ9XrcBAfcqwKlE4a1Iw7xOh07A2S6yHZpsxGlOeWJ438eQqlloHQn8y2DRH6T6/SIRUvh77TkuOVt9ItRsfFpo24CuxHdJ1ciWnDQKE4staUYl5zCVV1waNCmz4UR6c0/g27N8QTy06AnsW1Exx737qjDexwNeyucBmUb38cd0NBC9Xt7g== 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=nZbD14POHu2WrHgEO8Jvpv+BAByIdXDcXCIfoGvu5FQ=; b=QWq7+l5rTrZ/08Qm0aeM+wytJ+yFy6cqZdBgWb9O6FQ1yte1TFl35yxE8blKRlqUYinlNUGrh1+YOA4MwDQYzWI2BkVCSj0zSsd7SjkJvduXwn28im4NKoVr+BEhZgcl5DlISz+MWidT/hA3r7Vzz0A5za47t27cGdSr3E0GOMQRs1QHgvQaVDPPOrwR2r0Ln6MtoGs6sBlfbCsX3r1irDUnpCK+6uiqX6XBYenzC/mC3KtO6a+pPZmibN8WTRSBws3dx2iP+MNmRbRQDjRkim56W4KZcIf8B9GdvDbgqnOMI+0rZB+t+uU8zBKzAbHk6EOIJ4WAdRUZXGHmaoC2iA== 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 DS0PR12MB6655.namprd12.prod.outlook.com (2603:10b6:8:d0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Tue, 22 Aug 2023 16:16:03 +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:03 +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 7/7] iommu/omap: Convert to generic_single_device_group() Date: Tue, 22 Aug 2023 13:16:02 -0300 Message-ID: <7-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: CH2PR19CA0019.namprd19.prod.outlook.com (2603:10b6:610:4d::29) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DS0PR12MB6655:EE_ X-MS-Office365-Filtering-Correlation-Id: 4815ff2b-eaba-4d59-f3d1-08dba32b14dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nFzrUNvYQNaBDsIhFlqWw/E/6QqZBkSzTjdCYnZ8zU1kAkUJIq7ezUDPLoW218yHNf6/nCZFUREgjyRBb9XtrSGL5TEF+K56q/VeRXNQ3UUS2CcXouZty4yQXt/nRKikID+pe/B4FqgImRq7BAEZzr1YFTawh9Lgc9pwywRVvLHn8AxLb7/elmwq++W+OejZ9vvVcjs+y94Fk0TeuDk8SwThmtisYo7ZB7ohiCofodOCxjbB3y9bd66LBZPAWLB5FApjDIBuUzNmkMI8NpAtnuznOre2Ira3cdKQRINowVh7LDT2ZWO9PQXebKAFzLX5ItB1Uq37yy7S3TMCt8tNgGdyJA505wuoh82lxNgEMhNc4nfbNWgq0oa1XelKmVcjvhDvLniUJHUXinUeuOxJ4WMunNEVYQ2E3oYp0pmSUZNHM46gzVYpiPBsG6yBWXC38TCxsjAm86wVT4jyd/lAqNQ885eRGtwQSV6nyh6LNR7DkEMzaYnvbAeulQpU4siQLM+mOrIyyg7IUz8OAO78p4+ta/xFYK8vUvxWA8nesJSzCe2XztHLaIhGzo0+OvXUfMkJz5iiBkgMc8rBP3fT+J6sHKVaTtdxJPQHLAH2kTl43St304U/DuJN4xUfKHMGEbWvFtKU68uAXn4VCzy7pQ== 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)(376002)(346002)(39860400002)(366004)(396003)(136003)(1800799009)(451199024)(186009)(4326008)(8676002)(8936002)(316002)(478600001)(66556008)(110136005)(66476007)(54906003)(66946007)(41300700001)(6506007)(6486002)(6512007)(921005)(38100700002)(7416002)(36756003)(26005)(5660300002)(2906002)(2616005)(83380400001)(86362001)(4216001)(41533002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +xlOYImExYhkKku7dpnoSzA/8TMt9COPEFbW9rZoDFJuPdLAwS3tYk8amDpic8vS5JhC3wiFuIGNSea4YvkE/mUbBEWVqHdtAAmu2fWbnOK67STWANXXPxVD6nve0a6JjnAP3XubbhkcZrj32DZeL2kq4/IAyj75hLUgUBu2Tc1h1AwCv6kusB03PYD8gB1hjRJDkiRVBq/NdNdwc20tWv2Z2jISG9HkbOO9/4d1pgiZ2fjf+s7u7s3wp6jIIWs98csDVzq0rVVQLv6M3L5JkGSYxFs3mGlapgCYZJDvdX5GQOMVztGpz9l559BqRFLnm1MGbRACNhOjZrMPqei8Nqk+HxC8JGS4nfUhH9yCRAB2bFcvD+KnpbWDr/3o49NFjCAlP3X3uMkOka2Z4rkeijtnaDjP8V0MGb7+th/yhAJjtKMpzkEFXScfBffs9yrK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Cg/J+jhnHl6Xw8oiFAucRGqW34n5JGRFQihFSL6KShQ8FXj0BF4yKbD9sv668+emmBrGquFIj2zG X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4815ff2b-eaba-4d59-f3d1-08dba32b14dd 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.4479 (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: +5d6Fe30Ozr5panqyr8TMCaaea6x9eagcANb5Swr8ARYouf5duafLpwANRINcDXq X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6655 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230822_091608_873455_1D5AF1CD X-CRM114-Status: GOOD ( 14.15 ) 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. For some reason omap will probe its driver even if it doesn't load an iommu driver. Keep this working by keeping a bool to track if the iommu driver was started. Signed-off-by: Jason Gunthorpe --- drivers/iommu/omap-iommu.c | 30 ++++-------------------------- drivers/iommu/omap-iommu.h | 2 +- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 537e402f9bba97..97c45f50bf4332 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1225,18 +1225,15 @@ static int omap_iommu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, obj); if (omap_iommu_can_register(pdev)) { - obj->group = iommu_group_alloc(); - if (IS_ERR(obj->group)) - return PTR_ERR(obj->group); - err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL, obj->name); if (err) - goto out_group; + return err; err = iommu_device_register(&obj->iommu, &omap_iommu_ops, &pdev->dev); if (err) goto out_sysfs; + obj->has_iommu_driver = true; } pm_runtime_enable(obj->dev); @@ -1252,8 +1249,6 @@ static int omap_iommu_probe(struct platform_device *pdev) out_sysfs: iommu_device_sysfs_remove(&obj->iommu); -out_group: - iommu_group_put(obj->group); return err; } @@ -1261,10 +1256,7 @@ static void omap_iommu_remove(struct platform_device *pdev) { struct omap_iommu *obj = platform_get_drvdata(pdev); - if (obj->group) { - iommu_group_put(obj->group); - obj->group = NULL; - + if (obj->has_iommu_driver) { iommu_device_sysfs_remove(&obj->iommu); iommu_device_unregister(&obj->iommu); } @@ -1717,25 +1709,11 @@ static void omap_iommu_release_device(struct device *dev) } -static struct iommu_group *omap_iommu_device_group(struct device *dev) -{ - struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev); - struct iommu_group *group = ERR_PTR(-EINVAL); - - if (!arch_data) - return ERR_PTR(-ENODEV); - - if (arch_data->iommu_dev) - group = iommu_group_ref_get(arch_data->iommu_dev->group); - - return group; -} - static const struct iommu_ops omap_iommu_ops = { .domain_alloc = omap_iommu_domain_alloc, .probe_device = omap_iommu_probe_device, .release_device = omap_iommu_release_device, - .device_group = omap_iommu_device_group, + .device_group = generic_single_device_group, .set_platform_dma_ops = omap_iommu_set_platform_dma, .pgsize_bitmap = OMAP_IOMMU_PGSIZES, .default_domain_ops = &(const struct iommu_domain_ops) { diff --git a/drivers/iommu/omap-iommu.h b/drivers/iommu/omap-iommu.h index 18ee713ede784d..27697109ec79a5 100644 --- a/drivers/iommu/omap-iommu.h +++ b/drivers/iommu/omap-iommu.h @@ -80,7 +80,7 @@ struct omap_iommu { u32 id; struct iommu_device iommu; - struct iommu_group *group; + bool has_iommu_driver; u8 pwrst; };