From: Andrew Lunn <andrew@lunn.ch>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: David Yang <mmyangfl@gmail.com>,
netdev@vger.kernel.org, "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 v9 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x
Date: Wed, 17 Sep 2025 02:08:31 +0200 [thread overview]
Message-ID: <b0fc2de5-bccc-4ef8-a04d-0c3b13cde914@lunn.ch> (raw)
In-Reply-To: <20250916231714.7cg5zgpnxj6qmg3d@skbuf>
> > +static int yt921x_reg_mdio_read(void *context, u32 reg, u32 *valp)
> > +{
> > + struct yt921x_reg_mdio *mdio = context;
> > + struct mii_bus *bus = mdio->bus;
> > + int addr = mdio->addr;
> > + u32 reg_addr;
> > + u32 reg_data;
> > + u32 val;
> > + int res;
> > +
> > + /* Hold the mdio bus lock to avoid (un)locking for 4 times */
> > + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
>
> Andrew, are you satisfied with this lock?
This is O.K. You snipped too much context. As the comment says, the
code is about to do 4 MDIO bus transactions. Each will take and
release the lock. By taking it now, and then using the unlocked
version for read/write, it will make it a tiny bit faster. The time to
do the bus transaction will however dominate.
> Perhaps I missed some part of
> the conversation, but didn't you say "leave the mdio lock alone"?
Yes, i did, but then the mdio lock was being abused as a DSA driver
lock. The DSA driver now has its own lock. So what we see above is
purely an optimisation, not a locking scheme.
Andrew
next prev parent reply other threads:[~2025-09-17 0:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-13 4:43 [PATCH net-next v9 0/3] " David Yang
2025-09-13 4:43 ` [PATCH net-next v9 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support David Yang
2025-09-13 4:44 ` [PATCH net-next v9 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags David Yang
2025-09-13 4:44 ` [PATCH net-next v9 3/3] net: dsa: yt921x: Add support for Motorcomm YT921x David Yang
2025-09-15 10:30 ` Simon Horman
2025-09-15 22:42 ` Russell King (Oracle)
2025-09-16 1:32 ` Andrew Lunn
2025-09-16 23:17 ` Vladimir Oltean
2025-09-17 0:08 ` Andrew Lunn [this message]
2025-09-17 10:02 ` Vladimir Oltean
2025-09-17 12:37 ` Andrew Lunn
2025-09-18 14:23 ` Yangfl
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=b0fc2de5-bccc-4ef8-a04d-0c3b13cde914@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®