All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iwl-net v3 0/4] ice: fix RTNL vs auxiliary device lock inversion
@ 2026-11-13 16:14 Petr Oros
  2026-11-13 16:14 ` [PATCH iwl-net v3 1/4] ice: check the auxiliary device pointer under adev_mutex Petr Oros
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Petr Oros @ 2026-11-13 16:14 UTC (permalink / raw)
  To: intel-wired-lan
  Cc: Petr Oros, Tony Nguyen, Przemek Kitszel, Jacob Keller,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Sebastian Andrzej Siewior, Clark Williams,
	Steven Rostedt, Dave Ertman, Mateusz Palczewski, Leon Romanovsky,
	Rafal Rogalski, Shiraz Saleem, Aleksandr Loktionov

ice takes the auxiliary device lock of its RDMA auxiliary device from
three places that run with the RTNL lock held. The RDMA auxiliary probe
takes the two in the opposite order, because __driver_attach() holds the
auxiliary device lock across ib_register_device(), which needs the RTNL
lock. The result is a hard deadlock of everything that needs the RTNL
lock, so the boot never completes:

  systemd-udevd   state:D
    really_probe                  <- holds device_lock(&adev->dev)
    icrdma_probe
    irdma_ib_register_device
    ib_register_device
    setup_device
    irdma_roce_port_immutable
    ib_query_port
    irdma_query_port
    ib_get_eth_speed              <- blocks on rtnl_lock()

  lldpad          state:D
    rtnetlink_rcv_msg             <- holds rtnl_lock()
    dcb_doit
    dcbnl_ieee_set
    ice_dcbnl_setets
    ice_pf_dcb_cfg
    ice_send_event_to_aux         <- blocks on device_lock(&adev->dev)

Lockdep cannot flag it, because device_initialize() marks dev->mutex
with lockdep_set_novalidate_class(). A PREEMPT_RT kernel with
CONFIG_DEBUG_RT_MUTEXES reports "rtmutex deadlock detected" instead.

The probe side cannot be changed, so the three ice callers use
device_trylock() and refuse the operation with -EBUSY when the driver
core holds the lock. Patch 1 fixes a separate race on the same sites,
the auxiliary device pointer was tested before pf->adev_mutex was taken.
Patch 2 keeps the locks across the whole DCB reconfiguration so that
BEFORE_TC_CHANGE and AFTER_TC_CHANGE are either both delivered or the
request is refused before anything changes, and re-arms the service
task events. Patches 3 and 4 turn the remaining two locks into trylocks.

The series is based on the dev-queue branch of net-queue, which carries
Przemek's "ice: fix DCB lock ordering" [1]. That series takes the RTNL
lock before pf->tc_mutex and then drops the mutex, so the lock order
patch of v2 is gone and ndo_setup_tc() has no mutex to release on the
new error path.

[1]
https://lore.kernel.org/all/20261102105346.30739-1-przemyslaw.kitszel@intel.com/

The proper fix is provider-owned registration as in i40e and mlx5, which
makes the inversion impossible by construction. That is a net-next change
across ice, irdma and iidc_rdma.h, this series is the backportable part.

Tested on an E810-XXV with two PFs, irdma bound to both auxiliary
devices, on net tip commit 191aa41548b2d2 ("MAINTAINERS: add Bobby
Eshleman as vsock reviewer") with and without this series. A reproducer
binds the irdma auxiliary driver while driving one of the three RTNL
held callers into the probe window:

                        without the series   with the series
  ethtool set_channels  deadlock 10/10       0/10, window entered 300x
  ndo_setup_tc mqprio   deadlock             0/10, window entered 50x
  dcbnl ets set         deadlock             0/10, window entered 30x

A window entry is a contended device_trylock(), so each one used to
close the cycle. 25 reboots on the patched kernel were clean.

Changes since v2:
- rebased on "ice: fix DCB lock ordering", patch 2 of v2 dropped
- patch 2 runs the fallback for non-contiguous traffic classes in place
  of the transaction instead of after it, the deferred one let the RDMA
  driver resume on traffic classes the PF VSI did not have
- Reviewed-by from Aleksandr on patches 1 and 3

Link to v2:
https://lore.kernel.org/all/20261023070258.730168-1-poros@redhat.com/
Link to v1:
https://lore.kernel.org/all/20261019065301.3983537-1-poros@redhat.com/

Petr Oros (4):
  ice: check the auxiliary device pointer under adev_mutex
  ice: avoid RTNL deadlock when notifying the RDMA auxiliary driver
  ice: do not block on the aux device lock in ethtool set_channels
  ice: do not block on the aux device lock in ndo_setup_tc

 drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 47 ++++++++++++++++---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 26 +++++++----
 drivers/net/ethernet/intel/ice/ice_idc.c     | 48 ++++++++++++++++----
 drivers/net/ethernet/intel/ice/ice_idc_int.h |  2 +
 drivers/net/ethernet/intel/ice/ice_main.c    | 40 +++++++++++-----
 5 files changed, 126 insertions(+), 37 deletions(-)


base-commit: 1fcc5adeeda91622627c5c238985b60421ee9e70
-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-13 16:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 16:14 [PATCH iwl-net v3 0/4] ice: fix RTNL vs auxiliary device lock inversion Petr Oros
2026-11-13 16:14 ` [PATCH iwl-net v3 1/4] ice: check the auxiliary device pointer under adev_mutex Petr Oros
2026-11-13 16:14 ` [PATCH iwl-net v3 2/4] ice: avoid RTNL deadlock when notifying the RDMA auxiliary driver Petr Oros
2026-11-13 16:46   ` sashiko-bot
2026-11-13 16:14 ` [PATCH iwl-net v3 3/4] ice: do not block on the aux device lock in ethtool set_channels Petr Oros
2026-11-13 16:14 ` [PATCH iwl-net v3 4/4] ice: do not block on the aux device lock in ndo_setup_tc Petr Oros
2026-11-13 16:31   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.