From: Andrew Lunn <andrew@lunn.ch>
To: Yangfl <mmyangfl@gmail.com>
Cc: netdev@vger.kernel.org, Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Simon Horman <horms@kernel.org>,
Russell King <linux@armlinux.org.uk>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v7 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x
Date: Mon, 8 Sep 2025 15:30:33 +0200 [thread overview]
Message-ID: <e17b65d2-5c66-4d80-84c2-26f2bc639962@lunn.ch> (raw)
In-Reply-To: <CAAXyoMMEUeqxJaAYb8fbeACp7N=hFOQrPbtk4LDJM4CZw7n6mA@mail.gmail.com>
> > 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
prev parent reply other threads:[~2025-09-08 13:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 18:17 [PATCH net-next v7 0/3] " David Yang
2025-09-05 18:17 ` [PATCH net-next v7 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support David Yang
2025-09-06 19:17 ` Rob Herring
2025-09-08 12:34 ` Andrew Lunn
2025-09-05 18:17 ` [PATCH net-next v7 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags David Yang
2025-09-05 18:17 ` [PATCH net-next v7 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x David Yang
2025-09-06 8:19 ` kernel test robot
2025-09-08 13:00 ` Andrew Lunn
2025-09-08 13:10 ` Yangfl
2025-09-08 13:30 ` Andrew Lunn [this message]
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=e17b65d2-5c66-4d80-84c2-26f2bc639962@lunn.ch \
--to=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mmyangfl@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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
all inboxes | Powered by JetHome®