]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RDMA/core: Add device ufile cleanup operation
authorPatrisious Haddad <phaddad@nvidia.com>
Thu, 31 Oct 2024 11:22:51 +0000 (13:22 +0200)
committerLeon Romanovsky <leon@kernel.org>
Mon, 4 Nov 2024 11:57:21 +0000 (06:57 -0500)
Add a driver operation to allow preemptive cleanup of ufile HW resources
before the standard ufile cleanup flow begins. Thus, expediting the
final cleanup phase which leads to fast teardown overall.

This allows the use of driver specific clean up procedures to make the
cleanup process more efficient.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Link: https://patch.msgid.link/cabe00d75132b5732cb515944e3c500a01fb0b4a.1730373303.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/core/device.c
drivers/infiniband/core/rdma_core.c
include/rdma/ib_verbs.h

index e029401b56805fcd8166ec82db22b0d5b5c77328..de4ffc9eb37de43db85d23996a44d8686b97d32f 100644 (file)
@@ -2759,6 +2759,7 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops)
        SET_DEVICE_OP(dev_ops, resize_cq);
        SET_DEVICE_OP(dev_ops, set_vf_guid);
        SET_DEVICE_OP(dev_ops, set_vf_link_state);
+       SET_DEVICE_OP(dev_ops, ufile_hw_cleanup);
 
        SET_OBJ_SIZE(dev_ops, ib_ah);
        SET_OBJ_SIZE(dev_ops, ib_counters);
index 29b1ab1d5f9338cbacb11ce843b7bcc343c63e77..02ef09e77bf80173cb29ad349e05a71c0876a1cb 100644 (file)
@@ -880,9 +880,14 @@ static void ufile_destroy_ucontext(struct ib_uverbs_file *ufile,
 static int __uverbs_cleanup_ufile(struct ib_uverbs_file *ufile,
                                  enum rdma_remove_reason reason)
 {
+       struct uverbs_attr_bundle attrs = { .ufile = ufile };
+       struct ib_ucontext *ucontext = ufile->ucontext;
+       struct ib_device *ib_dev = ucontext->device;
        struct ib_uobject *obj, *next_obj;
        int ret = -EINVAL;
-       struct uverbs_attr_bundle attrs = { .ufile = ufile };
+
+       if (ib_dev->ops.ufile_hw_cleanup)
+               ib_dev->ops.ufile_hw_cleanup(ufile);
 
        /*
         * This shouldn't run while executing other commands on this
index 67551133b5228eb2d773862ddad91719b685b7f9..3417636da960226c989864c677224a015c053539 100644 (file)
@@ -2675,6 +2675,12 @@ struct ib_device_ops {
         */
        void (*del_sub_dev)(struct ib_device *sub_dev);
 
+       /**
+        * ufile_cleanup - Attempt to cleanup ubojects HW resources inside
+        * the ufile.
+        */
+       void (*ufile_hw_cleanup)(struct ib_uverbs_file *ufile);
+
        DECLARE_RDMA_OBJ_SIZE(ib_ah);
        DECLARE_RDMA_OBJ_SIZE(ib_counters);
        DECLARE_RDMA_OBJ_SIZE(ib_cq);