| Message ID | 20261023070258.730168-5-poros@redhat.com |
|---|---|
| State | New |
| Headers | show |
| Series | ice: fix RTNL vs auxiliary device lock inversion | expand |
> -----Original Message----- > From: Petr Oros <poros@redhat.com> > Sent: Friday, October 23, 2026 9:03 AM > To: netdev@vger.kernel.org > Cc: Oros, Petr <poros@redhat.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw > <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>; > David S. Miller <davem@davemloft.net>; Eric Dumazet > <edumazet@kernel.org>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni > <pabeni@redhat.com>; Sebastian Andrzej Siewior <bigeasy@linutronix.de>; > Clark Williams <clrkwllms@kernel.org>; Steven Rostedt > <rostedt@goodmis.org>; Ertman, David M <david.m.ertman@intel.com>; > Mateusz Palczewski <mateusz.palczewski@intel.com>; Leon Romanovsky > <leon@kernel.org>; Rafal Rogalski <rafalx.rogalski@intel.com>; Shiraz > Saleem <shiraz.saleem@intel.com>; Loktionov, Aleksandr > <aleksandr.loktionov@intel.com>; intel-wired-lan@lists.osuosl.org; > linux-kernel@vger.kernel.org; linux-rt-devel@lists.linux.dev > Subject: [PATCH iwl-net v2 4/5] ice: do not block on the aux device lock > in ethtool set_channels > > ice_set_channels() takes the auxiliary device lock to test whether the > RDMA driver is bound, and ethtool ops run with the RTNL lock held. This > is the same inversion against the RDMA auxiliary probe as the one fixed > in ice_send_event_to_aux(), reached through a different caller. > > Use device_trylock() and report the device as busy when it fails. The > existing diagnostic is not reused, a contended lock does not mean the > RDMA driver is bound. It is a netdev_dbg(), the condition is transient > and userspace already learns about it from -EBUSY. > > Fixes: a6a0974aae42 ("ice: Prevent set_channel from changing queues > while RDMA active") > Signed-off-by: Petr Oros <poros@redhat.com> > --- > v2: > - rebased on the new patches 1 and 2, the trylock now sits inside the > pointer test done under adev_mutex > > v1: https://lore.kernel.org/all/20261019065301.3983537-3- > poros@redhat.com/ > --- > drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c > b/drivers/net/ethernet/intel/ice/ice_ethtool.c > index 5482a64c81c95a..dbc662d6233957 100644 > --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c > +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c > @@ -3947,7 +3947,11 @@ static int ice_set_channels(struct net_device > *dev, struct ethtool_channels *ch) > mutex_lock(&pf->adev_mutex); > adev = pf->cdev_info->adev; > if (adev) { > - device_lock(&adev->dev); > + if (!device_trylock(&adev->dev)) { > + mutex_unlock(&pf->adev_mutex); > + netdev_dbg(dev, "RDMA auxiliary device is > busy, try again\n"); > + return -EBUSY; > + } > locked = true; > if (adev->dev.driver) { > netdev_err(dev, "Cannot change channels when > RDMA is active\n"); > -- > 2.56.0 Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c index 5482a64c81c95a..dbc662d6233957 100644 --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c @@ -3947,7 +3947,11 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch) mutex_lock(&pf->adev_mutex); adev = pf->cdev_info->adev; if (adev) { - device_lock(&adev->dev); + if (!device_trylock(&adev->dev)) { + mutex_unlock(&pf->adev_mutex); + netdev_dbg(dev, "RDMA auxiliary device is busy, try again\n"); + return -EBUSY; + } locked = true; if (adev->dev.driver) { netdev_err(dev, "Cannot change channels when RDMA is active\n");
ice_set_channels() takes the auxiliary device lock to test whether the RDMA driver is bound, and ethtool ops run with the RTNL lock held. This is the same inversion against the RDMA auxiliary probe as the one fixed in ice_send_event_to_aux(), reached through a different caller. Use device_trylock() and report the device as busy when it fails. The existing diagnostic is not reused, a contended lock does not mean the RDMA driver is bound. It is a netdev_dbg(), the condition is transient and userspace already learns about it from -EBUSY. Fixes: a6a0974aae42 ("ice: Prevent set_channel from changing queues while RDMA active") Signed-off-by: Petr Oros <poros@redhat.com> --- v2: - rebased on the new patches 1 and 2, the trylock now sits inside the pointer test done under adev_mutex v1: https://lore.kernel.org/all/20261019065301.3983537-3-poros@redhat.com/ --- drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)