The TC_SETUP_QDISC_MQPRIO path of ice_setup_tc() takes the auxiliary
device lock to test whether the RDMA driver is bound, and ndo_setup_tc()
runs with the RTNL lock held. This closes the same cycle against the
RDMA auxiliary probe as the two preceding patches.

Use device_trylock() and report the device as busy when it fails. When
the qdisc is added, userspace gets -EBUSY and can retry. When it is
deleted, mqprio_disable_offload() ignores the return value, so the
hardware traffic classes and the channel VSIs stay in place until a
later qdisc teardown gets through, the same as the existing -EBUSY for
a bound RDMA driver. The message is a netdev_warn() because of that
second case, nothing else reports it.

Fixes: 4b31fd4d77ff ("ice: Fix RDMA VSI removal during queue rebuild")
Signed-off-by: Petr Oros <[email protected]>
---
v2:
- rebased on the new patches 1 and 2
- netdev_warn() instead of netdev_dbg(), the qdisc teardown cannot
  retry and ignores the return value

v1: https://lore.kernel.org/all/[email protected]/
---
 drivers/net/ethernet/intel/ice/ice_main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
b/drivers/net/ethernet/intel/ice/ice_main.c
index 9de375f5c4deb5..7eb653a7ebacd5 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -9451,7 +9451,12 @@ ice_setup_tc(struct net_device *netdev, enum 
tc_setup_type type,
                        mutex_lock(&pf->adev_mutex);
                        adev = cdev->adev;
                        if (adev) {
-                               device_lock(&adev->dev);
+                               if (!device_trylock(&adev->dev)) {
+                                       mutex_unlock(&pf->adev_mutex);
+                                       netdev_warn(netdev, "RDMA auxiliary 
device is busy, qdisc not changed\n");
+                                       err = -EBUSY;
+                                       goto tc_unlock;
+                               }
                                locked = true;
                                if (adev->dev.driver) {
                                        netdev_err(netdev, "Cannot change qdisc 
when RDMA is active\n");
@@ -9471,6 +9476,7 @@ ice_setup_tc(struct net_device *netdev, enum 
tc_setup_type type,
                        device_unlock(&adev->dev);
                        mutex_unlock(&pf->adev_mutex);
                }
+tc_unlock:
                mutex_unlock(&pf->tc_mutex);
                return err;
        case TC_SETUP_QDISC_ETF:
-- 
2.56.0

Reply via email to