From af2e22982fca34f02775433b38e83d9ff406dcb1 Mon Sep 17 00:00:00 2001 From: Aya Levin Date: Wed, 17 Jul 2024 11:22:26 +0300 Subject: [PATCH] tsbin/mlnx-sf: Wait for SF config driver to load As a part of the SF probing, the user should unbind the SF from the default config driver and bind the actual SF driver. Make the script wait 20 seconds for the config driver to load, so SF probing on startup will be more resilient. Issue: 3956110 Signed-off-by: Aya Levin --- tsbin/mlnx-sf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tsbin/mlnx-sf b/tsbin/mlnx-sf index 65af49d..d5a8f89 100755 --- a/tsbin/mlnx-sf +++ b/tsbin/mlnx-sf @@ -46,6 +46,8 @@ DEVLINK = 'devlink' SUPPORTED_ACTIONS=["create", "show", "delete"] RDMA_DEV_TIMEOUT = 120 DEVLINK_DEV_TIMEOUT = 20 +SF_CFG_DRIVER_TIMEOUT = 20 + verbose = False if os.path.exists("/usr/bin/mlxconfig"): @@ -211,6 +213,15 @@ class SF: break time.sleep(0.001) + # Wait for sf_cfg link to be created + start = time.process_time() + while True: + if time.process_time() - start > SF_CFG_DRIVER_TIMEOUT: + break + if os.path.basename(os.readlink("/sys/bus/auxiliary/devices/{}/driver".format(self.aux_dev))) == "mlx5_core.sf_cfg": + break + time.sleep(0.001) + # Unbind the SF from the default config driver and bind the actual SF driver if os.path.basename(os.readlink("/sys/bus/auxiliary/devices/{}/driver".format(self.aux_dev))) == "mlx5_core.sf_cfg": try: