public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net•de>
To: Jakub Kicinski <kuba@kernel•org>
Cc: davem@davemloft•net, netdev@vger•kernel.org, edumazet@google•com,
	pabeni@redhat•com, andrew+netdev@lunn•ch, horms@kernel•org,
	jakub@cloudflare•com, maxime.chevallier@bootlin•com,
	lee@kernel•org, linux-leds@vger•kernel.org, pavel@kernel•org,
	jv@jvosburgh•net, michael.chan@broadcom•com, jhs@mojatatu•com,
	vinicius.gomes@intel•com, idosch@nvidia•com, razor@blackwall•org,
	hare@suse•de, jhasan@marvell•com, danieller@nvidia•com
Subject: Re: [PATCH net-next v2 07/11] net: bridge: don't recurse on the port's netdev ops lock
Date: Wed, 03 Jun 2026 09:16:39 +0200	[thread overview]
Message-ID: <b9a0430bb83cc76096488ce4bf239368@tipi-net.de> (raw)
In-Reply-To: <20260603012840.2254293-8-kuba@kernel.org>

Hi Jakub

On 3.6.2026 03:28, Jakub Kicinski wrote:
> port_cost() calls __ethtool_get_link_ksettings() on the port device,
> which will soon take the port's ops lock. br_port_carrier_check()
> is reached via the NETDEV_CHANGE notifier from linkwatch, which
> already holds the port's ops lock, so the call would deadlock.
> 
> Make port_cost() expect the port's ops lock held and switch to
> netif_get_link_ksettings(). The only other caller is new_nbp(),
> make sure it takes the lock explicitly.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel•org>
> ---
>  net/bridge/br_if.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
> index d39571e13744..049d1d25bc26 100644
> --- a/net/bridge/br_if.c
> +++ b/net/bridge/br_if.c
> @@ -19,6 +19,7 @@
>  #include <linux/if_ether.h>
>  #include <linux/slab.h>
>  #include <net/dsa.h>
> +#include <net/netdev_lock.h>
>  #include <net/sock.h>
>  #include <linux/if_vlan.h>
>  #include <net/switchdev.h>
> @@ -30,13 +31,13 @@
>   * Determine initial path cost based on speed.
>   * using recommendations from 802.1d standard
>   *
> - * Since driver might sleep need to not be holding any locks.
> + * Since driver might sleep, we need to not be holding any bridge 
> spinlocks.
>   */
>  static int port_cost(struct net_device *dev)
>  {
>  	struct ethtool_link_ksettings ecmd;
> 
> -	if (!__ethtool_get_link_ksettings(dev, &ecmd)) {
> +	if (!netif_get_link_ksettings(dev, &ecmd)) {
>  		switch (ecmd.base.speed) {
>  		case SPEED_10000:
>  			return 2;
> @@ -436,7 +437,9 @@ static struct net_bridge_port *new_nbp(struct 
> net_bridge *br,
>  	p->br = br;
>  	netdev_hold(dev, &p->dev_tracker, GFP_KERNEL);
>  	p->dev = dev;
> +	netdev_lock_ops(dev);
>  	p->path_cost = port_cost(dev);
> +	netdev_unlock_ops(dev);
>  	p->priority = 0x8000 >> BR_PORT_BITS;
>  	p->port_no = index;
>  	p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD;

Reviewed-by: Nicolai Buchwitz <nb@tipi-net•de>

Thanks
Nicolai

  reply	other threads:[~2026-06-03  7:16 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03  1:28 [PATCH net-next v2 00/11] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked Jakub Kicinski
2026-06-03  1:28 ` [PATCH net-next v2 01/11] net: rename netdev_ops_assert_locked() Jakub Kicinski
2026-06-03  7:29   ` Nicolai Buchwitz
2026-06-03 11:15   ` Jakub Sitnicki
2026-06-03 17:05   ` Stanislav Fomichev
2026-06-03  1:28 ` [PATCH net-next v2 02/11] net: ethtool: cmis_cdb: hold instance lock for ops locked devices Jakub Kicinski
2026-06-03 17:06   ` Stanislav Fomichev
2026-06-03  1:28 ` [PATCH net-next v2 03/11] net: document NETDEV_CHANGENAME as ops locked Jakub Kicinski
2026-06-03 12:47   ` Jakub Sitnicki
2026-06-03 17:06   ` Stanislav Fomichev
2026-06-03  1:28 ` [PATCH net-next v2 04/11] net: ethtool: add netif_get_link_ksettings() for correct ops-locked use Jakub Kicinski
2026-06-03  6:40   ` Maxime Chevallier
2026-06-03 17:06   ` Stanislav Fomichev
2026-06-03  1:28 ` [PATCH net-next v2 05/11] net: bonding: don't recurse on the slave's netdev ops lock Jakub Kicinski
2026-06-03  7:20   ` Nicolai Buchwitz
2026-06-03  1:28 ` [PATCH net-next v2 06/11] net: team: don't recurse on the port's " Jakub Kicinski
2026-06-03  1:28 ` [PATCH net-next v2 07/11] net: bridge: " Jakub Kicinski
2026-06-03  7:16   ` Nicolai Buchwitz [this message]
2026-06-03  7:54   ` Nikolay Aleksandrov
2026-06-03 13:28   ` Ido Schimmel
2026-06-03  1:28 ` [PATCH net-next v2 08/11] net: sched: don't recurse on the netdev ops lock in qdiscs Jakub Kicinski
2026-06-04 23:38   ` Vinicius Costa Gomes
2026-06-03  1:28 ` [PATCH net-next v2 09/11] leds: trigger: netdev: don't recurse on the netdev ops lock Jakub Kicinski
2026-06-03  1:28 ` [PATCH net-next v2 10/11] scsi: fcoe: don't recurse on the netdev's " Jakub Kicinski
2026-06-03  1:28 ` [PATCH net-next v2 11/11] net: ethtool: make sure __ethtool_get_link_ksettings() is ops-locked Jakub Kicinski
2026-06-03  7:18   ` Nicolai Buchwitz
2026-06-03 17:06   ` Stanislav Fomichev
2026-06-04 21:30 ` [PATCH net-next v2 00/11] " patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9a0430bb83cc76096488ce4bf239368@tipi-net.de \
    --to=nb@tipi-net$(echo .)de \
    --cc=andrew+netdev@lunn$(echo .)ch \
    --cc=danieller@nvidia$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=hare@suse$(echo .)de \
    --cc=horms@kernel$(echo .)org \
    --cc=idosch@nvidia$(echo .)com \
    --cc=jakub@cloudflare$(echo .)com \
    --cc=jhasan@marvell$(echo .)com \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=jv@jvosburgh$(echo .)net \
    --cc=kuba@kernel$(echo .)org \
    --cc=lee@kernel$(echo .)org \
    --cc=linux-leds@vger$(echo .)kernel.org \
    --cc=maxime.chevallier@bootlin$(echo .)com \
    --cc=michael.chan@broadcom$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    --cc=pavel@kernel$(echo .)org \
    --cc=razor@blackwall$(echo .)org \
    --cc=vinicius.gomes@intel$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox