From: Romain Gantois <romain.gantois@bootlin.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Antoine Tenart <atenart@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] net: phy: dp83869: Support 1000Base-X SFP modules
Date: Wed, 14 May 2025 14:48:52 +0200 [thread overview]
Message-ID: <9500044.CDJkKcVGEf@fw-rgant> (raw)
In-Reply-To: <519e17e0-9739-43bc-b77a-a77fd103d8d7@lunn.ch>
[-- Attachment #1: Type: text/plain, Size: 2463 bytes --]
On Wednesday, 14 May 2025 14:32:22 CEST Andrew Lunn wrote:
> > > > + /* Update advertisement */
> > > > + if (mutex_trylock(&phydev->lock)) {
> > > > + ret = dp83869_config_aneg(phydev);
> > > > + mutex_unlock(&phydev->lock);
> > > > + }
> > >
> > > Just skimmed through this quickly and it's not clear to me why aneg is
> > > restarted only if there was no contention on the global phydev lock;
> > > it's not guaranteed a concurrent holder would do the same. If this is
> > > intended, a comment would be welcomed.
> >
> > The reasoning here is that there are code paths which call
> > dp83869_port_configure_serdes() with phydev->lock already held, for
> > example:
> >
> > phy_start() -> sfp_upstream_start() -> sfp_start() -> \
> >
> > sfp_sm_event() -> __sfp_sm_event() -> sfp_sm_module() -> \
> > sfp_module_insert() -> phy_sfp_module_insert() -> \
> > dp83869_port_configure_serdes()
> >
> > so taking this lock could result in a deadlock.
> >
> > mutex_trylock() is definitely not a perfect solution though, but I went
> > with it partly because the marvell-88x2222 driver already does it this
> > way, and partly because if phydev->lock() is held, then there's a solid
> > chance that the phy state machine is already taking care of reconfiguring
> > the advertisement. However, I'll admit that this is a bit of a shaky
> > argument.
> >
> > If someone has a better solution in mind, I'll gladly hear it out, but for
> > now I guess I'll just add a comment explaining why trylock() is being
> > used.
> The marvell10g driver should be the reference to look at.
>
> As you say, phy_start() will eventually get around to calling
> dp83869_config_aneg(). What is more interesting here are the paths
> which lead to this function which don't result in a call to
> dp83869_config_aneg(). What are those?
Whenever you insert an SFP module, either sfp_irq() or sfp_poll() will will
detect it and eventually call module_insert() from the SFP state machine. As
far as I'm aware, this doesn't imply any calls to config_aneg().
Since the DP83869 remaps fiber registers to 0 when we switch it to RGMII-
to-1000Base-X mode, the value in MII_ADVERTISE won't be correct anymore,
which is why we have to reconfigure the advertisement after a module is
inserted. It doesn't seem like the marvell10g driver does this, and I'm not
sure why that's the case.
Thanks,
--
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-05-14 13:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 7:49 [PATCH net-next 0/3] net: phy: dp83869: Support 1Gbps fiber SFP modules Romain Gantois
2025-05-14 7:49 ` [PATCH net-next 1/3] net: phy: dp83869: Restart PHY when configuring mode Romain Gantois
2025-05-14 7:49 ` [PATCH net-next 2/3] net: phy: dp83869: ensure FORCE_LINK_GOOD is cleared Romain Gantois
2025-05-14 7:49 ` [PATCH net-next 3/3] net: phy: dp83869: Support 1000Base-X SFP modules Romain Gantois
2025-05-14 9:01 ` Antoine Tenart
2025-05-14 10:00 ` Romain Gantois
2025-05-14 12:32 ` Andrew Lunn
2025-05-14 12:48 ` Romain Gantois [this message]
2025-05-14 12:22 ` Andrew Lunn
2025-05-14 12:32 ` Romain Gantois
2025-05-14 12:34 ` Andrew Lunn
2025-05-14 12:20 ` [PATCH net-next 0/3] net: phy: dp83869: Support 1Gbps fiber " Maxime Chevallier
2025-05-14 12:53 ` Romain Gantois
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=9500044.CDJkKcVGEf@fw-rgant \
--to=romain.gantois@bootlin.com \
--cc=andrew@lunn.ch \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
/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