@@ -2019,8 +2019,12 @@ static int iw_query_port(struct ib_device *device,
memset(port_attr, 0, sizeof(*port_attr));
netdev = ib_device_get_netdev(device, port_num);
+ /* Some iwarp device may be not binded to a netdev temporarily when
+ * ib_register_device called. To adapt this scenario, allowing iWarp
+ * device drivers decide the return value.
+ */
if (!netdev)
- return -ENODEV;
+ goto query_port;
port_attr->max_mtu = IB_MTU_4096;
port_attr->active_mtu = ib_mtu_int_to_enum(netdev->mtu);
@@ -2045,6 +2049,7 @@ static int iw_query_port(struct ib_device *device,
}
dev_put(netdev);
+query_port:
return device->ops.query_port(device, port_num, port_attr);
}
This change lets the iWarp device drivers decide the return value of iw_query_port when attached netdev is NULL. This allows ib_register_device calling when netdev is NULL. background info: https://lore.kernel.org/all/20220118141324.GF8034@ziepe.ca/ Signed-off-by: Cheng Xu <chengyou@linux.alibaba.com> --- drivers/infiniband/core/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)