diff mbox series

[v3,rdma-next,4/7] RDMA/device: Remove optimization in ib_device_get_netdev()

Message ID 20240909173025.30422-5-michaelgur@nvidia.com (mailing list archive)
State Accepted
Headers show
Series Support RDMA events monitoring through | expand

Commit Message

Michael Guralnik Sept. 9, 2024, 5:30 p.m. UTC
From: Chiara Meiohas <cmeiohas@nvidia.com>

The caller of ib_device_get_netdev() relies on its result to accurately
match a given netdev with the ib device associated netdev.

ib_device_get_netdev returns NULL when the IB device associated
netdev is unregistering, preventing the caller of matching netdevs properly.

Thus, remove this optimization and return the netdev even if
it is undergoing unregistration, allowing matching by the caller.

This change ensures proper netdev matching and reference count handling
by the caller of ib_device_get_netdev/ib_device_set_netdev API.

Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/core/device.c | 9 ---------
 1 file changed, 9 deletions(-)

Comments

Kalesh Anakkur Purayil Sept. 10, 2024, 4 a.m. UTC | #1
On Mon, Sep 9, 2024 at 11:10 PM Michael Guralnik <michaelgur@nvidia.com> wrote:
>
> From: Chiara Meiohas <cmeiohas@nvidia.com>
>
> The caller of ib_device_get_netdev() relies on its result to accurately
> match a given netdev with the ib device associated netdev.
>
> ib_device_get_netdev returns NULL when the IB device associated
> netdev is unregistering, preventing the caller of matching netdevs properly.
>
> Thus, remove this optimization and return the netdev even if
> it is undergoing unregistration, allowing matching by the caller.
>
> This change ensures proper netdev matching and reference count handling
> by the caller of ib_device_get_netdev/ib_device_set_netdev API.
>
> Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
> Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
> Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
> Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Looks good to me
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> ---
>  drivers/infiniband/core/device.c | 9 ---------
>  1 file changed, 9 deletions(-)
>
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 0290aca18d26..b1377503cb9d 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -2252,15 +2252,6 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
>                 spin_unlock(&pdata->netdev_lock);
>         }
>
> -       /*
> -        * If we are starting to unregister expedite things by preventing
> -        * propagation of an unregistering netdev.
> -        */
> -       if (res && res->reg_state != NETREG_REGISTERED) {
> -               dev_put(res);
> -               return NULL;
> -       }
> -
>         return res;
>  }
>
> --
> 2.17.2
>
>
diff mbox series

Patch

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 0290aca18d26..b1377503cb9d 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2252,15 +2252,6 @@  struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
 		spin_unlock(&pdata->netdev_lock);
 	}
 
-	/*
-	 * If we are starting to unregister expedite things by preventing
-	 * propagation of an unregistering netdev.
-	 */
-	if (res && res->reg_state != NETREG_REGISTERED) {
-		dev_put(res);
-		return NULL;
-	}
-
 	return res;
 }