diff mbox series

[rdma-core] verbs: If the uverbs module is not loaded allow get_devices to retry init

Message ID 20180920163456.GA4120@ziepe.ca (mailing list archive)
State Not Applicable
Headers show
Series [rdma-core] verbs: If the uverbs module is not loaded allow get_devices to retry init | expand

Commit Message

Jason Gunthorpe Sept. 20, 2018, 4:34 p.m. UTC
Currently if uverbs is not loaded libibverbs latches into a permanent
disabled state on the first try to ibv_get_device_list. This is not
compatible with hot-plug which could insert the uverbs module at any
later point. Recheck for uverbs presence until we get a successful init
or a hard failure during init.

Cc: stable@linux-rdma.org
Fixes: c632072027a8 ("verbs: Refresh cahced ibv_device list")
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
---
 libibverbs/device.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Sept. 25, 2018, 5:57 p.m. UTC | #1
On Thu, Sep 20, 2018 at 10:34:56AM -0600, Jason Gunthorpe wrote:
> Currently if uverbs is not loaded libibverbs latches into a permanent
> disabled state on the first try to ibv_get_device_list. This is not
> compatible with hot-plug which could insert the uverbs module at any
> later point. Recheck for uverbs presence until we get a successful init
> or a hard failure during init.
>
> Cc: stable@linux-rdma.org
> Fixes: c632072027a8 ("verbs: Refresh cahced ibv_device list")
> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
> ---
>  libibverbs/device.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Nicolas Morey-Chaisemartin Oct. 5, 2018, 9:21 a.m. UTC | #2
Applied to stable 15-20 branches

On 09/25/2018 07:57 PM, Leon Romanovsky wrote:
> On Thu, Sep 20, 2018 at 10:34:56AM -0600, Jason Gunthorpe wrote:
>> Currently if uverbs is not loaded libibverbs latches into a permanent
>> disabled state on the first try to ibv_get_device_list. This is not
>> compatible with hot-plug which could insert the uverbs module at any
>> later point. Recheck for uverbs presence until we get a successful init
>> or a hard failure during init.
>>
>> Cc: stable@linux-rdma.org
>> Fixes: c632072027a8 ("verbs: Refresh cahced ibv_device list")
>> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
>> ---
>>  libibverbs/device.c | 17 ++++++++++++++++-
>>  1 file changed, 16 insertions(+), 1 deletion(-)
>>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
diff mbox series

Patch

diff --git a/libibverbs/device.c b/libibverbs/device.c
index 448795a993af21..3900afd3f90bd3 100644
--- a/libibverbs/device.c
+++ b/libibverbs/device.c
@@ -64,7 +64,22 @@  LATEST_SYMVER_FUNC(ibv_get_device_list, 1_1, "IBVERBS_1.1",
 
 	pthread_mutex_lock(&dev_list_lock);
 	if (!initialized) {
-		int ret = ibverbs_init();
+		char value[8];
+		int ret;
+
+		/*
+		 * The uverbs module is not loaded, this is a ENOSYS return
+		 * but it is not a hard failure, we can try again to see if it
+		 * has become loaded since.
+		 */
+		if (ibv_read_sysfs_file(ibv_get_sysfs_path(),
+					"class/infiniband_verbs/abi_version",
+					value, sizeof(value)) < 0) {
+			errno = -ENOSYS;
+			goto out;
+		}
+
+		ret = ibverbs_init();
 		initialized = (ret < 0) ? ret : 1;
 	}