From patchwork Fri May 6 00:08:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 12840369 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 151A3C433FE for ; Fri, 6 May 2022 00:09:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0889910FE33; Fri, 6 May 2022 00:08:56 +0000 (UTC) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2062.outbound.protection.outlook.com [40.107.236.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id C5BB610FE0F; Fri, 6 May 2022 00:08:53 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIJGH4P/HQ+5FgZT4GvfZapE13J18DlGcdAP9Ala3q6z4DdTWpQKDkOD7aLDLTwxArSOdt+cZst8TTSEOYolPw4HaxDKzMgYTNIWtQiS8Xz9TD0/Ss2oOH3CPZaDlZJiul7Q/rZPpBgzirjkIZGaxu1y6KzqgQ4MW3m9IMB0fVoTgBhiB1IafSOS4GeYnTRXzdSm8F/rGCkTaYB2FmO79fnQcLMY6PFPoUta8CnFgC1r6nBo9cu+9yi0J0oybpWbyvXZecNrd5xGLF/qmKrWPG2HX6MaYoyYEdUHTFSt7Hy8S8H6loq1r2weBYCjdetyPbY5aqnMS4bM6lgHmHBkwA== 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=1wtrIJOQpRDgxcZmQdrCfkkxhbwhBQUNhRJIwP0ntSg=; b=bbPtS3l8Ck1RondQ3YTa6GZyFc40KTXCv9FIMKl378BocCTD0t0wx0ZPxGvHlSBHmiq5UqkMMGOQ+cKJIZu5kXPhHjQh8cweN6gniGDp7lLj1QbxqEPv5G3cgaYsCAKkd53EC+P/vY+ewY6qHAHBxQcj8/R2OHUUElbeYyxuEHUqTzL95j+ASGzizeZ7UkVGV7n+HdGEcEtXk4SPFrhXg5HmpXJCHsR81TS2RHnWEwS7VqRIBq1AF1upfQRgCpWuCEy7E5nuxhL4kiCX03Ez5p2hXmBjGH0mtQLUkS/uV+OnlMlIKsivcaryIwpc+HvLEVZ0RzlSrgOl9zL9i7+ITA== 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=1wtrIJOQpRDgxcZmQdrCfkkxhbwhBQUNhRJIwP0ntSg=; b=BRLPxmfHEnKHcLnsRMgCaU/RDHbICPlHFAjLd0mKOotL3dQAXEK3DxvUvscRSJ6KIODCpanFgceHHBpWtCZQzXqKDGEpmlbWNndw+amzLqV3ZzCTZ1nK8NW2PGl9s1nA58ZyzJIf+I3xLFkIkh6l7Vc8QpHoXGqslE0dpAI21E73tSyDEPeBVZP6Lh9eaALy6eAJIL6qmxURSlA0aKjAVaTPZkiEzEiLQX5HvF7KrZ8VkJQc0j3JYYxUccERNxZF1Mij8nfP1QGuzP68ny5NFx4LvEiEJLmkzt4J/P1RKXRhEtd8u0q6pQlBcCtbT+/TZ55ivlhYym/kSy4QrYZ+Ng== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) by BYAPR12MB2934.namprd12.prod.outlook.com (2603:10b6:a03:13b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Fri, 6 May 2022 00:08:51 +0000 Received: from MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::ec2d:9167:1b47:2db2]) by MN2PR12MB4192.namprd12.prod.outlook.com ([fe80::ec2d:9167:1b47:2db2%6]) with mapi id 15.20.5206.027; Fri, 6 May 2022 00:08:51 +0000 From: Jason Gunthorpe To: Alexander Gordeev , David Airlie , Alex Williamson , Christian Borntraeger , Cornelia Huck , Jonathan Corbet , Daniel Vetter , dri-devel@lists.freedesktop.org, Harald Freudenberger , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Jani Nikula , Jason Herne , Joonas Lahtinen , kvm@vger.kernel.org, Kirti Wankhede , linux-doc@vger.kernel.org, linux-s390@vger.kernel.org, Matthew Rosato , Peter Oberparleiter , Halil Pasic , Rodrigo Vivi , Sven Schnelle , Tvrtko Ursulin , Vineeth Vijayan , Zhenyu Wang , Zhi Wang Subject: [PATCH v4 6/7] vfio: Remove dead code Date: Thu, 5 May 2022 21:08:44 -0300 Message-Id: <6-v4-8045e76bf00b+13d-vfio_mdev_no_group_jgg@nvidia.com> In-Reply-To: <0-v4-8045e76bf00b+13d-vfio_mdev_no_group_jgg@nvidia.com> References: X-ClientProxiedBy: BL0PR1501CA0036.namprd15.prod.outlook.com (2603:10b6:207:17::49) To MN2PR12MB4192.namprd12.prod.outlook.com (2603:10b6:208:1d5::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de61833c-58dd-4461-b5c9-08da2ef497e3 X-MS-TrafficTypeDiagnostic: BYAPR12MB2934:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YQe9NBAPbSC9BTiexdHW6dzTJfK6WKvYratYWGCPOiEEq2Y+JDTCZUu1J6at0EnO/p1bZ909jg7ahTvM+g6SgnWYrDn0LH5Zt2j94IWX4jkkWpWQWgdxjkrAenkTLJJoWUlXimx3LEgNQcjLVcOp+ATdQ52wsXdf/zfXCpdbHJDI/AH0+uK3cL6szHidllV1NPuuYigLRpldIN3V7N6LVv+bhKaiBdDPPo5a3w92frOfInKBUca+P6Rue5xPMA/P/XTdEzhAihJ23p8Kmt/eCg9YvQLu4ZoNKsZxt1uXZJl3yJ4Y+0U7yTrBQ719qpS+ujypmcfJCUts9Wz1/10BkMW20L0BwWLXcpnBgNUD+F9BlKfu8VBKGcelTP1s8AcZQbyV1BwP4NN2gdCJDPUiynGwLl1dD8C0WhG1u0nNyyvq7ElwNBNgoiVcB/+997/kt0sKm9llzloyr8p+CFo1qTJuxfkyZ3iJrl/JbM21UQNDqVYxftfh0MvKPmeYSNJHY3LthvT1YXIHACvMoMma2zQFrItJDo5rXJQ3BRqbSqBlxuI4yaAAU6gUYsgVCVUX7+dNGjjI8zSYY9IYZXaetneTQ5m+wEPOC1MmYjsQtlQDf1z5YpYpJKbXK7vsXVQcUd7PD4JX+zyiqQ4lEfEgn8E5BJOA8TIwz/hfxVES4aeNJSW1Pe5weE/Qn6tAnJ3QgtsFQTh6Ns/Ohp4MdEj/4w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB4192.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(5660300002)(2906002)(66946007)(66556008)(54906003)(8676002)(86362001)(110136005)(4326008)(6486002)(38100700002)(508600001)(316002)(66476007)(6666004)(6512007)(6506007)(186003)(2616005)(921005)(26005)(7416002)(8936002)(83380400001)(7406005)(36756003)(4216001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TN9n1k7Y5YMAgedRWhQbf8Vha2spycWVVuvg/Dp1WcqRpiArJPFpECnXHSYPtZHlMPzg+kNRuYuOaWOMi6M0t4HH9KpsxDu2NcZOVMnZhk66cqyNue+zF0rxcWD10Wcn+k7NOCg9D5WTrSuJHDajoLhhsx59w/kqcrBlfvnuAAiUCFAnjny3pgy0bL7GncB7TmOikhvPRIam3ek/NUkbuRQ2DzQNhFrMOnwy73P54ayiV/oZmmdjDalZnJxbkUm8TwPGrHmhdci2BvkBUF9lKaQUGrIQlLqHwnhNhdDcBXwx4Fg5kAiuKJu+s7iSZElApIH/Fd/Q6Ga8G5rEohz6h725JwcMa1DpRd4M3YP7Et3pktwuO98nROmCTY+p4hWrjleECm7MFd4iw7wTtoEAfebtg9NsbfVAN1zyQrpBcaXI1FscjgFQEzB+QBgubtHog8K575SVEq7ux/cMAL2lPUNYc7nhnOA4O5pkCgvKNaZzpmSKTf2pgLrMhBrZQzF6S6Sxl1wfL4ANLsNSiOMIjcNMCFQrHNIWjMh+wLfTuGXN1I9TUycu+lvuNnTSuwUPm0je5nFEXQFiF43CjvfcyGu6zVnzGjlCTXBmj4vYCSBHogJ97V+QPFdYV1UDR1BWTO+rNrJJRwFyMJu2r/RDfglI32T6f2u/TS1UeMaSFbvgmG1XJv7ln8BSxMe5mESLE+TuUJ9A2NMQqb46H9m0erdTtA6dsTiDRzdTOAvXv3k3bjd7t5K7PpNQST+HClH3qiN4OI2IIcbHmN1CAIGUPio195jSykzVg97G+fDE/Q75ansi9p1TFWC2GwjNPNQSuZnSmu3QGd5XceGDg/H1ehW3pwaKKoTmnCpPnfy4iXMHvy36WIWi/GQJxwZuD56JpIuJ7i3WFa3oBN+uqGG7wdoejwrgqL1wegj4tFsO5kC+wDtC0SP9kD604o2jqeoUECjdZ2DoaMd5GG4GJQ/qpVGb5fsP8NukjDs3MoeOvBIql9pU9qLWWgTNG6vfLda9ew6t6+5e1pNbYIHnoZY/q3E3W/HXj0ieIjbT1DD49jlsgnbay4U2GPjwb9KuYKTFTWoJihfg30vU0wLrgNLmmdUUjtZxhVrUbZigUM9bJsKWpCh/c6yJxCuPeMNcsX2RL9be7Kovi7XlU5a4tT4Z1e9gcC8mEKwB7rrVPLdV1ldPKmeuL/UX6tZhvFql9bDQqohj3wOslbAZomZM+cJHTE3gl1Xc/6guyfRSaMNlxfe46EqCL4QyVPydE8XqeYVbhXtOkjykMvQeAcdFlEC+/03UTqvXifrhIO60Dsv2rT+e+YcAESEW4YTBdIbqTpSSft3Z/lfmXAko3TTxkxMf4kKc0sSbaJ4V8dc3qiDhsje+/8kLxA0SyrZ6b6XWKSg1gJF89ft+/0XRPY3GIsrKUj30i5zJ4VjI66y1x+hMMhPeSJjK5+yV8+Olga/8sGg4ya08qqpFRwPnafaXCdgaf4lbRptqNBm3+dks4XMtvmw7FsC2szIoqp+SRuqTrDF8NuIrHtEfcDOfCS2mBTAfpQGw/q6H5qygXASuQkd63k2wDq4U01E+NgUXdomxvkHtgocJe99Hge6nZzw8vSKEJajN0Oy9HLB5oepPDQM5yGMOnd51GMxBr/kK2wfzOqIHoUa/bzy0bD88sJUf0378ppeqqIv6S1ggfPF3snx3oYsHpk6yCKB/fmm3YQyi7vrPFU2k7uY0c2MhiZyRBR7NqA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: de61833c-58dd-4461-b5c9-08da2ef497e3 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4192.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 May 2022 00:08:48.3714 (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: 4FgDQHxGUqPI/ygt2CgZC8bXthyuGBm7BtnxFjkJEz16uTBhwkHTBss/tfWeY+3u X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2934 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tony Krowiak , Kevin Tian , Eric Farman , "Liu, Yi L" , Christoph Hellwig Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that callers have been updated to use the vfio_device APIs the driver facing group interface is no longer used, delete it: - vfio_group_get_external_user_from_dev() - vfio_group_pin_pages() - vfio_group_unpin_pages() - vfio_group_iommu_domain() Reviewed-by: Christoph Hellwig Reviewed-by: Kevin Tian Signed-off-by: Jason Gunthorpe --- FIXME: vfio_group_put_external_user() is removable too when combined with the KVM series --- drivers/vfio/vfio.c | 151 ------------------------------------------- include/linux/vfio.h | 11 ---- 2 files changed, 162 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 85e1304099b8a5..c651c4805acd59 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1732,44 +1732,6 @@ struct vfio_group *vfio_group_get_external_user(struct file *filep) } EXPORT_SYMBOL_GPL(vfio_group_get_external_user); -/* - * External user API, exported by symbols to be linked dynamically. - * The external user passes in a device pointer - * to verify that: - * - A VFIO group is assiciated with the device; - * - IOMMU is set for the group. - * If both checks passed, vfio_group_get_external_user_from_dev() - * increments the container user counter to prevent the VFIO group - * from disposal before external user exits and returns the pointer - * to the VFIO group. - * - * When the external user finishes using the VFIO group, it calls - * vfio_group_put_external_user() to release the VFIO group and - * decrement the container user counter. - * - * @dev [in] : device - * Return error PTR or pointer to VFIO group. - */ - -struct vfio_group *vfio_group_get_external_user_from_dev(struct device *dev) -{ - struct vfio_group *group; - int ret; - - group = vfio_group_get_from_dev(dev); - if (!group) - return ERR_PTR(-ENODEV); - - ret = vfio_group_add_container_user(group); - if (ret) { - vfio_group_put(group); - return ERR_PTR(ret); - } - - return group; -} -EXPORT_SYMBOL_GPL(vfio_group_get_external_user_from_dev); - void vfio_group_put_external_user(struct vfio_group *group) { vfio_group_try_dissolve_container(group); @@ -2003,101 +1965,6 @@ int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn, } EXPORT_SYMBOL(vfio_unpin_pages); -/* - * Pin a set of guest IOVA PFNs and return their associated host PFNs for a - * VFIO group. - * - * The caller needs to call vfio_group_get_external_user() or - * vfio_group_get_external_user_from_dev() prior to calling this interface, - * so as to prevent the VFIO group from disposal in the middle of the call. - * But it can keep the reference to the VFIO group for several calls into - * this interface. - * After finishing using of the VFIO group, the caller needs to release the - * VFIO group by calling vfio_group_put_external_user(). - * - * @group [in] : VFIO group - * @user_iova_pfn [in] : array of user/guest IOVA PFNs to be pinned. - * @npage [in] : count of elements in user_iova_pfn array. - * This count should not be greater - * VFIO_PIN_PAGES_MAX_ENTRIES. - * @prot [in] : protection flags - * @phys_pfn [out] : array of host PFNs - * Return error or number of pages pinned. - */ -int vfio_group_pin_pages(struct vfio_group *group, - unsigned long *user_iova_pfn, int npage, - int prot, unsigned long *phys_pfn) -{ - struct vfio_container *container; - struct vfio_iommu_driver *driver; - int ret; - - if (!group || !user_iova_pfn || !phys_pfn || !npage) - return -EINVAL; - - if (group->dev_counter > 1) - return -EINVAL; - - if (npage > VFIO_PIN_PAGES_MAX_ENTRIES) - return -E2BIG; - - container = group->container; - driver = container->iommu_driver; - if (likely(driver && driver->ops->pin_pages)) - ret = driver->ops->pin_pages(container->iommu_data, - group->iommu_group, user_iova_pfn, - npage, prot, phys_pfn); - else - ret = -ENOTTY; - - return ret; -} -EXPORT_SYMBOL(vfio_group_pin_pages); - -/* - * Unpin a set of guest IOVA PFNs for a VFIO group. - * - * The caller needs to call vfio_group_get_external_user() or - * vfio_group_get_external_user_from_dev() prior to calling this interface, - * so as to prevent the VFIO group from disposal in the middle of the call. - * But it can keep the reference to the VFIO group for several calls into - * this interface. - * After finishing using of the VFIO group, the caller needs to release the - * VFIO group by calling vfio_group_put_external_user(). - * - * @group [in] : vfio group - * @user_iova_pfn [in] : array of user/guest IOVA PFNs to be unpinned. - * @npage [in] : count of elements in user_iova_pfn array. - * This count should not be greater than - * VFIO_PIN_PAGES_MAX_ENTRIES. - * Return error or number of pages unpinned. - */ -int vfio_group_unpin_pages(struct vfio_group *group, - unsigned long *user_iova_pfn, int npage) -{ - struct vfio_container *container; - struct vfio_iommu_driver *driver; - int ret; - - if (!group || !user_iova_pfn || !npage) - return -EINVAL; - - if (npage > VFIO_PIN_PAGES_MAX_ENTRIES) - return -E2BIG; - - container = group->container; - driver = container->iommu_driver; - if (likely(driver && driver->ops->unpin_pages)) - ret = driver->ops->unpin_pages(container->iommu_data, - user_iova_pfn, npage); - else - ret = -ENOTTY; - - return ret; -} -EXPORT_SYMBOL(vfio_group_unpin_pages); - - /* * This interface allows the CPUs to perform some sort of virtual DMA on * behalf of the device. @@ -2301,24 +2168,6 @@ int vfio_unregister_notifier(struct vfio_device *device, } EXPORT_SYMBOL(vfio_unregister_notifier); -struct iommu_domain *vfio_group_iommu_domain(struct vfio_group *group) -{ - struct vfio_container *container; - struct vfio_iommu_driver *driver; - - if (!group) - return ERR_PTR(-EINVAL); - - container = group->container; - driver = container->iommu_driver; - if (likely(driver && driver->ops->group_iommu_domain)) - return driver->ops->group_iommu_domain(container->iommu_data, - group->iommu_group); - - return ERR_PTR(-ENOTTY); -} -EXPORT_SYMBOL_GPL(vfio_group_iommu_domain); - /* * Module/class support */ diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 8a151025871776..6195edd2edcd7b 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -140,8 +140,6 @@ int vfio_mig_get_next_state(struct vfio_device *device, */ extern struct vfio_group *vfio_group_get_external_user(struct file *filep); extern void vfio_group_put_external_user(struct vfio_group *group); -extern struct vfio_group *vfio_group_get_external_user_from_dev(struct device - *dev); extern bool vfio_external_group_match_file(struct vfio_group *group, struct file *filep); extern int vfio_external_user_iommu_id(struct vfio_group *group); @@ -154,18 +152,9 @@ extern int vfio_pin_pages(struct vfio_device *device, unsigned long *user_pfn, int npage, int prot, unsigned long *phys_pfn); extern int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn, int npage); - -extern int vfio_group_pin_pages(struct vfio_group *group, - unsigned long *user_iova_pfn, int npage, - int prot, unsigned long *phys_pfn); -extern int vfio_group_unpin_pages(struct vfio_group *group, - unsigned long *user_iova_pfn, int npage); - extern int vfio_dma_rw(struct vfio_device *device, dma_addr_t user_iova, void *data, size_t len, bool write); -extern struct iommu_domain *vfio_group_iommu_domain(struct vfio_group *group); - /* each type has independent events */ enum vfio_notify_type { VFIO_IOMMU_NOTIFY = 0,