e1000: Hold RTNL when e1000_down can be called
Subsystems (3)
RFC 1/1 e1000: Hold RTNL when e1000_down can be called
e1000_down calls netif_queue_set_napi, which assumes that RTNL is held.
There are a few paths for e1000_down to be called in e1000 where RTNL is not currently being held:
- e1000_shutdown (pci shutdown)
- e1000_suspend (power management)
- e1000_reinit_locked (via e1000_reset_task delayed work)
Hold RTNL in two places to fix this issue:
- e1000_reset_task
- __e1000_shutdown (which is called from both e1000_shutdown and
e1000_suspend).
The other paths which call e1000_down seemingly hold RTNL and are OK:
- e1000_close (ndo_stop)
- e1000_change_mtu (ndo_change_mtu)
I'm submitting this is as an RFC because:
- the e1000_reinit_locked issue appears very similar to commit 21f857f0321d ("e1000e: add rtnl_lock() to e1000_reset_task"), which fixes a similar issue in e1000e
however
- adding rtnl to e1000_reinit_locked seemingly conflicts with an earlier e1000 commit b2f963bfaeba ("e1000: fix lockdep warning in e1000_reset_task").
Hopefully Intel can weigh in and shed some light on the correct way to go.
--- drivers/net/ethernet/intel/e1000/e1000_main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/intel/e1000/e1000_main.c +4 -0
@@ -3509,7 +3509,9 @@ static void e1000_reset_task(struct work_struct *work) container_of(work, struct e1000_adapter, reset_task);e_err (drv,"Reset adapter\n" ); +rtnl_lock ();e1000_reinit_locked (adapter); +rtnl_unlock (); }/**
@@ -5074,7 +5076,9 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)usleep_range (10000 ,20000 );WARN_ON (test_bit (__E1000_RESETTING, &adapter->flags)); +rtnl_lock ();e1000_down (adapter); +rtnl_unlock (); } status =er32 (STATUS );
base-commit: d811ac148f0afd2f3f7e1cd7f54de8da973ec5e3
Signature · 1 line
2.25.1
Quoted 8 lines · Joe Damato
e1000_downcallsnetif_queue_set_napi, which assumes that RTNL is held.There are a few paths for
e1000_downto be called in e1000 where RTNL is not currently being held:
-e1000_shutdown(pci shutdown)
-e1000_suspend(power management)
-e1000_reinit_locked(viae1000_reset_taskdelayed work)
Quoted 4 lines
Hold RTNL in two places to fix this issue:
-e1000_reset_task
-__e1000_shutdown(which is called from bothe1000_shutdownande1000_suspend).
It looks like there's one other spot I missed:
e1000_io_error_detected (pci error handler) which should also hold rtnl_lock:
+ if (netif_running(netdev)) {
+ rtnl_lock();
e1000_down(adapter);+ rtnl_unlock();
+ }
I can send that update in the v2, but I'll wait to see if Intel has suggestions on the below.
Quoted 22 lines
The other paths which call
e1000_downseemingly hold RTNL and are OK:
-e1000_close(ndo_stop)
-e1000_change_mtu(ndo_change_mtu)I'm submitting this is as an RFC because:
- thee1000_reinit_lockedissue appears very similar to commit21f857f0321d("e1000e: addrtnl_lock()toe1000_reset_task"), which fixes a similar issue in e1000ehowever
- adding rtnl to
e1000_reinit_lockedseemingly conflicts with an earlier e1000 commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").Hopefully Intel can weigh in and shed some light on the correct way to go.
Fixes 8f7ff18a5ec7 ("e1000: Link NAPI instances to queues and IRQs")Reported-by Dmitry Antipov <[email protected]>Signed-off-by Joe Damato <[email protected]>
Quoted 25 lines · Joe Damato
Quoted 8 lines · Joe Damato
e1000_downcallsnetif_queue_set_napi, which assumes that RTNL is held.There are a few paths for
e1000_downto be called in e1000 where RTNL is not currently being held:
-e1000_shutdown(pci shutdown)
-e1000_suspend(power management)
-e1000_reinit_locked(viae1000_reset_taskdelayed work)Quoted 4 lines
Hold RTNL in two places to fix this issue:
-e1000_reset_task
-__e1000_shutdown(which is called from bothe1000_shutdownande1000_suspend).It looks like there's one other spot I missed:
e1000_io_error_detected(pci error handler) which should also holdrtnl_lock:drivers/net/ethernet/intel/e1000/e1000_main.c +4
-0+if (netif_running (netdev)) { +rtnl_lock ();e1000_down (adapter); +rtnl_unlock (); + }
Quoted 20 lines
I can send that update in the v2, but I'll wait to see if Intel has suggestions on the below.
Quoted 17 lines
The other paths which call
e1000_downseemingly hold RTNL and are OK:
-e1000_close(ndo_stop)
-e1000_change_mtu(ndo_change_mtu)I'm submitting this is as an RFC because:
- thee1000_reinit_lockedissue appears very similar to commit21f857f0321d("e1000e: addrtnl_lock()toe1000_reset_task"), which fixes a similar issue in e1000ehowever
- adding rtnl to
e1000_reinit_lockedseemingly conflicts with an earlier e1000 commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").Hopefully Intel can weigh in and shed some light on the correct way to go.
Regarding the above locations where rtnl_lock may need to be held, comparing to other intel drivers:
- e1000_reset_task: it appears that igc, igb, and e100e all hold rtnl_lock in their reset_task functions, so I think adding an rtnl_lock / rtnl_unlock to e1000_reset_task should be OK, despite the existence of commit b2f963bfaeba ("e1000: fix lockdep warning in e1000_reset_task").
- e1000_io_error_detected:
- e1000e temporarily obtains and drops rtnl in e1000e_pm_freeze
- ixgbe holds rtnl in the same path (toward the bottom of ixgbe_io_error_detected)
- igb does NOT hold rtnl in this path (as far as I can tell)
- it was suggested in another thread to hold rtnl in this path for igc [1].
Given that it will be added to igc and is held in this same path in e1000e and ixgbe, I think it is safe to add it for e1000, as well.
- e1000_shutdown:
- igb holds rtnl in the same path,
- e1000e temporarily holds it in this path (via
e1000e_pm_freeze)
- ixgbe holds rtnl in the same path
So based on the recommendation for igc [1], and the precedent set in the other Intel drivers in most cases (except igb and the io_error path), I think adding rtnl to all 3 locations described above is correct.
Please let me know if you all agree. Thanks for reviewing this.
Quoted 73 lines · Joe Damato
Quoted 25 lines · Joe Damato
Quoted 8 lines · Joe Damato
e1000_downcallsnetif_queue_set_napi, which assumes that RTNL is held.There are a few paths for
e1000_downto be called in e1000 where RTNL is not currently being held:
-e1000_shutdown(pci shutdown)
-e1000_suspend(power management)
-e1000_reinit_locked(viae1000_reset_taskdelayed work)Quoted 4 lines
Hold RTNL in two places to fix this issue:
-e1000_reset_task
-__e1000_shutdown(which is called from bothe1000_shutdownande1000_suspend).It looks like there's one other spot I missed:
e1000_io_error_detected(pci error handler) which should also holdrtnl_lock:drivers/net/ethernet/intel/e1000/e1000_main.c +4
-0+if (netif_running (netdev)) { +rtnl_lock ();e1000_down (adapter); +rtnl_unlock (); + }Quoted 20 lines
I can send that update in the v2, but I'll wait to see if Intel has suggestions on the below.
Quoted 17 lines
The other paths which call
e1000_downseemingly hold RTNL and are OK:
-e1000_close(ndo_stop)
-e1000_change_mtu(ndo_change_mtu)I'm submitting this is as an RFC because:
- thee1000_reinit_lockedissue appears very similar to commit21f857f0321d("e1000e: addrtnl_lock()toe1000_reset_task"), which fixes a similar issue in e1000ehowever
- adding rtnl to
e1000_reinit_lockedseemingly conflicts with an earlier e1000 commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").Hopefully Intel can weigh in and shed some light on the correct way to go.
Regarding the above locations where
rtnl_lockmay need to be held, comparing to other intel drivers:-
e1000_reset_task: it appears that igc, igb, and e100e all holdrtnl_lockin theirreset_taskfunctions, so I think adding anrtnl_lock/rtnl_unlocktoe1000_reset_taskshould be OK, despite the existence of commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").-
e1000_io_error_detected:
- e1000e temporarily obtains and drops rtnl ine1000e_pm_freeze
- ixgbe holds rtnl in the same path (toward the bottom ofixgbe_io_error_detected)
- igb does NOT hold rtnl in this path (as far as I can tell)
- it was suggested in another thread to hold rtnl in this path for igc [1].Given that it will be added to igc and is held in this same path in e1000e and ixgbe, I think it is safe to add it for e1000, as well.
-
e1000_shutdown:
- igb holds rtnl in the same path,
- e1000e temporarily holds it in this path (viae1000e_pm_freeze)
Quoted 10 lines
- ixgbe holds rtnl in the same path
So based on the recommendation for igc [1], and the precedent set in the other Intel drivers in most cases (except igb and the
io_errorpath), I think adding rtnl to all 3 locations described above is correct.Please let me know if you all agree. Thanks for reviewing this.
[1]:
https://lore.kernel.org/netdev/[email protected]/
I agree with this assessment.
Quoted 83 lines · Jacob Keller
Quoted 80 lines · Joe Damato
Quoted 25 lines · Joe Damato
Quoted 8 lines · Joe Damato
e1000_downcallsnetif_queue_set_napi, which assumes that RTNL is held.There are a few paths for
e1000_downto be called in e1000 where RTNL is not currently being held:
-e1000_shutdown(pci shutdown)
-e1000_suspend(power management)
-e1000_reinit_locked(viae1000_reset_taskdelayed work)Quoted 4 lines
Hold RTNL in two places to fix this issue:
-e1000_reset_task
-__e1000_shutdown(which is called from bothe1000_shutdownande1000_suspend).It looks like there's one other spot I missed:
e1000_io_error_detected(pci error handler) which should also holdrtnl_lock:drivers/net/ethernet/intel/e1000/e1000_main.c +4
-0+if (netif_running (netdev)) { +rtnl_lock ();e1000_down (adapter); +rtnl_unlock (); + }Quoted 20 lines
I can send that update in the v2, but I'll wait to see if Intel has suggestions on the below.
Quoted 17 lines
The other paths which call
e1000_downseemingly hold RTNL and are OK:
-e1000_close(ndo_stop)
-e1000_change_mtu(ndo_change_mtu)I'm submitting this is as an RFC because:
- thee1000_reinit_lockedissue appears very similar to commit21f857f0321d("e1000e: addrtnl_lock()toe1000_reset_task"), which fixes a similar issue in e1000ehowever
- adding rtnl to
e1000_reinit_lockedseemingly conflicts with an earlier e1000 commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").Hopefully Intel can weigh in and shed some light on the correct way to go.
Regarding the above locations where
rtnl_lockmay need to be held, comparing to other intel drivers:-
e1000_reset_task: it appears that igc, igb, and e100e all holdrtnl_lockin theirreset_taskfunctions, so I think adding anrtnl_lock/rtnl_unlocktoe1000_reset_taskshould be OK, despite the existence of commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").-
e1000_io_error_detected:
- e1000e temporarily obtains and drops rtnl ine1000e_pm_freeze
- ixgbe holds rtnl in the same path (toward the bottom ofixgbe_io_error_detected)
- igb does NOT hold rtnl in this path (as far as I can tell)
- it was suggested in another thread to hold rtnl in this path for igc [1].Given that it will be added to igc and is held in this same path in e1000e and ixgbe, I think it is safe to add it for e1000, as well.
-
e1000_shutdown:
- igb holds rtnl in the same path,
- e1000e temporarily holds it in this path (viae1000e_pm_freeze)- ixgbe holds rtnl in the same path
So based on the recommendation for igc [1], and the precedent set in the other Intel drivers in most cases (except igb and the
io_errorpath), I think adding rtnl to all 3 locations described above is correct.
Quoted 7 lines
Quoted 3 lines
Please let me know if you all agree. Thanks for reviewing this.
[1]:
https://lore.kernel.org/netdev/[email protected]/I agree with this assessment.
Thanks for taking a look. I will send an official iwl-net PATCH with these changes once the 24 hour timer has expired.
Quoted 25 lines · Joe Damato
Quoted 8 lines · Joe Damato
e1000_downcallsnetif_queue_set_napi, which assumes that RTNL is held.There are a few paths for
e1000_downto be called in e1000 where RTNL is not currently being held:
-e1000_shutdown(pci shutdown)
-e1000_suspend(power management)
-e1000_reinit_locked(viae1000_reset_taskdelayed work)Quoted 4 lines
Hold RTNL in two places to fix this issue:
-e1000_reset_task
-__e1000_shutdown(which is called from bothe1000_shutdownande1000_suspend).It looks like there's one other spot I missed:
e1000_io_error_detected(pci error handler) which should also holdrtnl_lock:drivers/net/ethernet/intel/e1000/e1000_main.c +4
-0+if (netif_running (netdev)) { +rtnl_lock ();e1000_down (adapter); +rtnl_unlock (); + }
Quoted 21 lines
I can send that update in the v2, but I'll wait to see if Intel has suggestions on the below.
Quoted 18 lines
The other paths which call
e1000_downseemingly hold RTNL and are OK:
-e1000_close(ndo_stop)
-e1000_change_mtu(ndo_change_mtu)I'm submitting this is as an RFC because:
- thee1000_reinit_lockedissue appears very similar to commit21f857f0321d("e1000e: addrtnl_lock()toe1000_reset_task"), which fixes a similar issue in e1000ehowever
- adding rtnl to
e1000_reinit_lockedseemingly conflicts with an earlier e1000 commitb2f963bfaeba("e1000: fix lockdep warning ine1000_reset_task").Hopefully Intel can weigh in and shed some light on the correct way to go.
From my review, I think we need the RTNL lock around this function. The deadlocks mentions in the fix lockdep patch appear to be due to having an *extra* lock which could then cause issues.
Quoted 4 lines
Quoted 4 lines
Fixes 8f7ff18a5ec7 ("e1000: Link NAPI instances to queues and IRQs")Reported-by Dmitry Antipov <[email protected]>Signed-off-by Joe Damato <[email protected]>