From: Michael Guralnik <michaelgur@nvidia.com>
To: <jgg@nvidia.com>
Cc: <linux-rdma@vger.kernel.org>, <leonro@nvidia.com>,
<mbloch@nvidia.com>, <cmeiohas@nvidia.com>, <msanalla@nvidia.com>,
Michael Guralnik <michaelgur@nvidia.com>
Subject: [PATCH rdma-next 4/7] RDMA/device: Clear netdev mapping in ib_device_get_netdev on unregistration
Date: Wed, 21 Aug 2024 08:10:14 +0300 [thread overview]
Message-ID: <20240821051017.7730-5-michaelgur@nvidia.com> (raw)
In-Reply-To: <20240821051017.7730-1-michaelgur@nvidia.com>
From: Maher Sanalla <msanalla@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, revise ib_device_get_netdev to assign NULL to netdev when the netdev
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.
Fixes: c2261dd76b54 ("RDMA/device: Add ib_device_set_netdev() as an alternative to get_netdev"
Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
---
drivers/infiniband/core/device.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 0290aca18d26..583047457de2 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2257,6 +2257,7 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
* propagation of an unregistering netdev.
*/
if (res && res->reg_state != NETREG_REGISTERED) {
+ ib_device_set_netdev(ib_dev, NULL, port);
dev_put(res);
return NULL;
}
--
2.17.2
next prev parent reply other threads:[~2024-08-21 5:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 5:10 [PATCH rdma-next 0/7] Support RDMA events monitoring through Michael Guralnik
2024-08-21 5:10 ` [PATCH rdma-next 1/7] RDMA/mlx5: Check RoCE LAG status before getting netdev Michael Guralnik
2024-08-21 5:10 ` [PATCH rdma-next 2/7] RDMA/mlx5: Obtain upper net device only when needed Michael Guralnik
2024-08-21 5:10 ` [PATCH rdma-next 3/7] RDMA/mlx5: Initialize phys_port_cnt earlier in RDMA device creation Michael Guralnik
2024-08-21 5:10 ` Michael Guralnik [this message]
2024-08-21 5:10 ` [PATCH rdma-next 5/7] RDMA/mlx5: Use IB set_netdev and get_netdev functions Michael Guralnik
2024-08-21 5:10 ` [PATCH rdma-next 6/7] RDMA/nldev: Add support for RDMA monitoring Michael Guralnik
2024-08-21 19:18 ` kernel test robot
2024-08-21 20:30 ` kernel test robot
2024-08-21 5:10 ` [PATCH rdma-next 7/7] RDMA/nldev: Expose whether RDMA monitoring is supported Michael Guralnik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240821051017.7730-5-michaelgur@nvidia.com \
--to=michaelgur@nvidia.com \
--cc=cmeiohas@nvidia.com \
--cc=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=msanalla@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.