]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ice: avoid bonding causing auxiliary plug/unplug under RTNL lock
authorDave Ertman <david.m.ertman@intel.com>
Fri, 10 Mar 2023 19:48:33 +0000 (11:48 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:34:02 +0000 (13:34 +0100)
commit c50a354bc514f6bb10df0daefc9856989157e05c upstream.

RDMA is not supported in ice on a PF that has been added to a bonded
interface. To enforce this, when an interface enters a bond, we unplug
the auxiliary device that supports RDMA functionality.  This unplug
currently happens in the context of handling the netdev bonding event.
This event is sent to the ice driver under RTNL context.  This is causing
a deadlock where the RDMA driver is waiting for the RTNL lock to complete
the removal.

Defer the unplugging/re-plugging of the auxiliary device to the service
task so that it is not performed under the RTNL lock context.

Cc: stable@vger.kernel.org # 6.1.x
Reported-by: Jaroslav Pulchart <jaroslav.pulchart@gooddata.com>
Link: https://lore.kernel.org/netdev/CAK8fFZ6A_Gphw_3-QMGKEFQk=sfCw1Qmq0TVZK3rtAi7vb621A@mail.gmail.com/
Fixes: a276ea96090c ("ice: Fix race condition during interface enslave")
Fixes: 91e1f22ab3c9 ("RDMA/irdma: Report the correct link speed")
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20230310194833.3074601-1-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/ice/ice.h
drivers/net/ethernet/intel/ice/ice_main.c

index e04871379baad6167e189d3839f7a0d95ba65039..ca6b877fdde81cc7a2c10afd24a5684fd947b6ac 100644 (file)
@@ -485,6 +485,7 @@ enum ice_pf_flags {
        ICE_FLAG_VF_VLAN_PRUNING,
        ICE_FLAG_LINK_LENIENT_MODE_ENA,
        ICE_FLAG_PLUG_AUX_DEV,
+       ICE_FLAG_UNPLUG_AUX_DEV,
        ICE_FLAG_MTU_CHANGED,
        ICE_FLAG_GNSS,                  /* GNSS successfully initialized */
        ICE_PF_FLAGS_NBITS              /* must be last */
@@ -926,16 +927,11 @@ static inline void ice_set_rdma_cap(struct ice_pf *pf)
  */
 static inline void ice_clear_rdma_cap(struct ice_pf *pf)
 {
-       /* We can directly unplug aux device here only if the flag bit
-        * ICE_FLAG_PLUG_AUX_DEV is not set because ice_unplug_aux_dev()
-        * could race with ice_plug_aux_dev() called from
-        * ice_service_task(). In this case we only clear that bit now and
-        * aux device will be unplugged later once ice_plug_aux_device()
-        * called from ice_service_task() finishes (see ice_service_task()).
+       /* defer unplug to service task to avoid RTNL lock and
+        * clear PLUG bit so that pending plugs don't interfere
         */
-       if (!test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags))
-               ice_unplug_aux_dev(pf);
-
+       clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags);
+       set_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags);
        clear_bit(ICE_FLAG_RDMA_ENA, pf->flags);
 }
 #endif /* _ICE_H_ */
index 3c6bb3f9ac780ea805525ae2dfb009cb07f2c877..cfc57cfc46e4298005095a7c296b9c32cd1a752a 100644 (file)
@@ -2326,18 +2326,15 @@ static void ice_service_task(struct work_struct *work)
                }
        }
 
-       if (test_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags)) {
-               /* Plug aux device per request */
-               ice_plug_aux_dev(pf);
+       /* unplug aux dev per request, if an unplug request came in
+        * while processing a plug request, this will handle it
+        */
+       if (test_and_clear_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags))
+               ice_unplug_aux_dev(pf);
 
-               /* Mark plugging as done but check whether unplug was
-                * requested during ice_plug_aux_dev() call
-                * (e.g. from ice_clear_rdma_cap()) and if so then
-                * plug aux device.
-                */
-               if (!test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags))
-                       ice_unplug_aux_dev(pf);
-       }
+       /* Plug aux device per request */
+       if (test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags))
+               ice_plug_aux_dev(pf);
 
        if (test_and_clear_bit(ICE_FLAG_MTU_CHANGED, pf->flags)) {
                struct iidc_event *event;