[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <e17b65d2-5c66-4d80-84c2-26f2bc639962@lunn.ch>
Date: Mon, 8 Sep 2025 15:30:33 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Yangfl <mmyangfl@...il.com>
Cc: netdev@...r.kernel.org, Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Simon Horman <horms@...nel.org>,
Russell King <linux@...linux.org.uk>, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v7 3/3] net: dsa: yt921x: Add support for
Motorcomm YT921x
> > The DSA framework makes no such guarantees. The DSA framework is also
> > not the only entry point into the driver, phylink will directly call
> > into the driver, and if you implement things like LEDs, they will have
> > direct access to the driver.
> >
> > So i suggest only having a high level lock, acquired on entry,
> > released on exit, e.g. as mv88e6xxx does. KISS.
> So you mean holding bus->mdio_lock during any operations instead of
> implementing driver's own lock? Wouldn't other bus participants starve
> if I want to poll a register for like 100ms?
No, leave the mdio lock alone.
The mv88e6xxx driver has a lock in the 'priv' structure:
https://elixir.bootlin.com/linux/v6.16.5/source/drivers/net/dsa/mv88e6xxx/chip.h#L354
Function which are exposed in dsa_switch_ops take the lock at the
beginning, and release it at the end:
static int mv88e6xxx_port_mdb_add(struct dsa_switch *ds, int port,
const struct switchdev_obj_port_mdb *mdb,
struct dsa_db db)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err;
mv88e6xxx_reg_lock(chip);
err = mv88e6xxx_port_db_load_purge(chip, port, mdb->addr, mdb->vid,
MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC);
if (err)
goto out;
if (!mv88e6xxx_port_db_find(chip, mdb->addr, mdb->vid))
err = -ENOSPC;
out:
mv88e6xxx_reg_unlock(chip);
return err;
}
There are functions which wait for the device, polling:
https://elixir.bootlin.com/linux/v6.16.5/source/drivers/net/dsa/mv88e6xxx/chip.c#L87
and we do this while holding the lock. We have a timeout of 50ms, but
it never takes that long, on average it is just a couple of MDIO bus
transactions.
Andrew
Powered by blists - more mailing lists