* [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access
@ 2026-07-07 14:16 Daniel Golle
2026-07-08 17:22 ` Andrew Lunn
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Golle @ 2026-07-07 14:16 UTC (permalink / raw)
To: Andrew Lunn, Vladimir Oltean, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, linux-kernel, netdev
Add mxl862xx_smdio_read() and mxl862xx_smdio_write() for clause-22
SMDIO register access. MCUboot rescue mode only exposes clause-22
registers; the existing clause-45 MMD interface is unavailable during
firmware transfer. The MDIO bus lock is held per-transaction (not
across polls) so that SB PDI polling during flash erase does not
starve other MDIO users.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 35 ++++++++++++++++++++++++
drivers/net/dsa/mxl862xx/mxl862xx-host.h | 2 ++
2 files changed, 37 insertions(+)
diff --git a/drivers/net/dsa/mxl862xx/mxl862xx-host.c b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
index 4acd216f7cc0..6e582caea1fa 100644
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
@@ -495,6 +495,41 @@ int mxl862xx_reset(struct mxl862xx_priv *priv)
return ret;
}
+#define MXL862XX_SMDIO_ADDR_REG 0x1f
+#define MXL862XX_SMDIO_PAGE_MASK 0xfff0
+#define MXL862XX_SMDIO_OFF_MASK 0x000f
+
+int mxl862xx_smdio_read(struct mxl862xx_priv *priv, u32 addr)
+{
+ struct mii_bus *bus = priv->mdiodev->bus;
+ int phy = priv->mdiodev->addr;
+ int ret;
+
+ mutex_lock(&bus->mdio_lock);
+ ret = __mdiobus_write(bus, phy, MXL862XX_SMDIO_ADDR_REG,
+ addr & MXL862XX_SMDIO_PAGE_MASK);
+ if (ret >= 0)
+ ret = __mdiobus_read(bus, phy, addr & MXL862XX_SMDIO_OFF_MASK);
+ mutex_unlock(&bus->mdio_lock);
+ return ret;
+}
+
+int mxl862xx_smdio_write(struct mxl862xx_priv *priv, u32 addr, u16 val)
+{
+ struct mii_bus *bus = priv->mdiodev->bus;
+ int phy = priv->mdiodev->addr;
+ int ret;
+
+ mutex_lock(&bus->mdio_lock);
+ ret = __mdiobus_write(bus, phy, MXL862XX_SMDIO_ADDR_REG,
+ addr & MXL862XX_SMDIO_PAGE_MASK);
+ if (ret >= 0)
+ ret = __mdiobus_write(bus, phy, addr & MXL862XX_SMDIO_OFF_MASK,
+ val);
+ mutex_unlock(&bus->mdio_lock);
+ return ret;
+}
+
void mxl862xx_host_init(struct mxl862xx_priv *priv)
{
INIT_WORK(&priv->crc_err_work, mxl862xx_crc_err_work_fn);
diff --git a/drivers/net/dsa/mxl862xx/mxl862xx-host.h b/drivers/net/dsa/mxl862xx/mxl862xx-host.h
index 66d6ae198aff..4e054c6e4c0e 100644
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.h
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.h
@@ -18,5 +18,7 @@ int mxl862xx_api_wrap(struct mxl862xx_priv *priv, u16 cmd, void *data, u16 size,
mxl862xx_api_wrap(dev, cmd, &(data), sizeof((data)), true, true)
int mxl862xx_reset(struct mxl862xx_priv *priv);
+int mxl862xx_smdio_read(struct mxl862xx_priv *priv, u32 addr);
+int mxl862xx_smdio_write(struct mxl862xx_priv *priv, u32 addr, u16 val);
#endif /* __MXL862XX_HOST_H */
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access
2026-07-07 14:16 [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access Daniel Golle
@ 2026-07-08 17:22 ` Andrew Lunn
2026-07-08 19:45 ` Daniel Golle
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2026-07-08 17:22 UTC (permalink / raw)
To: Daniel Golle
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-kernel, netdev
On Tue, Jul 07, 2026 at 04:16:07PM +0200, Daniel Golle wrote:
> Add mxl862xx_smdio_read() and mxl862xx_smdio_write() for clause-22
> SMDIO register access. MCUboot rescue mode only exposes clause-22
> registers; the existing clause-45 MMD interface is unavailable during
> firmware transfer. The MDIO bus lock is held per-transaction (not
> across polls) so that SB PDI polling during flash erase does not
> starve other MDIO users.
What other MDIO users are there? It sounds like once the switch is in
rescue mode, switch management is dead. So how can there be users?
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access
2026-07-08 17:22 ` Andrew Lunn
@ 2026-07-08 19:45 ` Daniel Golle
2026-07-08 23:15 ` Andrew Lunn
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Golle @ 2026-07-08 19:45 UTC (permalink / raw)
To: Andrew Lunn
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-kernel, netdev
On Wed, Jul 08, 2026 at 07:22:49PM +0200, Andrew Lunn wrote:
> On Tue, Jul 07, 2026 at 04:16:07PM +0200, Daniel Golle wrote:
> > Add mxl862xx_smdio_read() and mxl862xx_smdio_write() for clause-22
> > SMDIO register access. MCUboot rescue mode only exposes clause-22
> > registers; the existing clause-45 MMD interface is unavailable during
> > firmware transfer. The MDIO bus lock is held per-transaction (not
> > across polls) so that SB PDI polling during flash erase does not
> > starve other MDIO users.
>
> What other MDIO users are there? It sounds like once the switch is in
> rescue mode, switch management is dead. So how can there be users?
The MDIO bus lock refers to the host bus which is used to connect
the switch management interface. The same bus can also be used to
connect other unrelated PHYs (eg. to provide a WAN or management
interface independent of the switch).
Especially because this "other" interface can be used to connect
to the host via SSH and perform the firmware update on the switch
holding the MDIO bus lock may impact PHY polling and impair the
link used to conduct the update.
At least that was my thought when implementing this.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access
2026-07-08 19:45 ` Daniel Golle
@ 2026-07-08 23:15 ` Andrew Lunn
2026-07-09 9:44 ` Daniel Golle
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2026-07-08 23:15 UTC (permalink / raw)
To: Daniel Golle
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-kernel, netdev
On Wed, Jul 08, 2026 at 09:45:48PM +0200, Daniel Golle wrote:
> On Wed, Jul 08, 2026 at 07:22:49PM +0200, Andrew Lunn wrote:
> > On Tue, Jul 07, 2026 at 04:16:07PM +0200, Daniel Golle wrote:
> > > Add mxl862xx_smdio_read() and mxl862xx_smdio_write() for clause-22
> > > SMDIO register access. MCUboot rescue mode only exposes clause-22
> > > registers; the existing clause-45 MMD interface is unavailable during
> > > firmware transfer. The MDIO bus lock is held per-transaction (not
> > > across polls) so that SB PDI polling during flash erase does not
> > > starve other MDIO users.
> >
> > What other MDIO users are there? It sounds like once the switch is in
> > rescue mode, switch management is dead. So how can there be users?
>
> The MDIO bus lock refers to the host bus which is used to connect
> the switch management interface. The same bus can also be used to
> connect other unrelated PHYs (eg. to provide a WAN or management
> interface independent of the switch).
Thanks for the explanation. Maybe 'does not starve other non-switch
MDIO users'?
I've not got to the rest of the patch yet, but i wondered if phylib
might still be trying to poll the switches PHYs.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access
2026-07-08 23:15 ` Andrew Lunn
@ 2026-07-09 9:44 ` Daniel Golle
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Golle @ 2026-07-09 9:44 UTC (permalink / raw)
To: Andrew Lunn
Cc: Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-kernel, netdev
On Thu, Jul 09, 2026 at 01:15:34AM +0200, Andrew Lunn wrote:
> On Wed, Jul 08, 2026 at 09:45:48PM +0200, Daniel Golle wrote:
> > On Wed, Jul 08, 2026 at 07:22:49PM +0200, Andrew Lunn wrote:
> > > On Tue, Jul 07, 2026 at 04:16:07PM +0200, Daniel Golle wrote:
> > > > Add mxl862xx_smdio_read() and mxl862xx_smdio_write() for clause-22
> > > > SMDIO register access. MCUboot rescue mode only exposes clause-22
> > > > registers; the existing clause-45 MMD interface is unavailable during
> > > > firmware transfer. The MDIO bus lock is held per-transaction (not
> > > > across polls) so that SB PDI polling during flash erase does not
> > > > starve other MDIO users.
> > >
> > > What other MDIO users are there? It sounds like once the switch is in
> > > rescue mode, switch management is dead. So how can there be users?
> >
> > The MDIO bus lock refers to the host bus which is used to connect
> > the switch management interface. The same bus can also be used to
> > connect other unrelated PHYs (eg. to provide a WAN or management
> > interface independent of the switch).
>
> Thanks for the explanation. Maybe 'does not starve other non-switch
> MDIO users'?
>
> I've not got to the rest of the patch yet, but i wondered if phylib
> might still be trying to poll the switches PHYs.
The driver takes down the CPU ports and thereby implicitely also puts
all user-ports into admin-down state, effectively disabling PHY polling
until the switch comes back and reprobe has happened.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-09 9:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 14:16 [PATCH RFC net-next 2/3] net: dsa: mxl862xx: add SMDIO clause-22 register access Daniel Golle
2026-07-08 17:22 ` Andrew Lunn
2026-07-08 19:45 ` Daniel Golle
2026-07-08 23:15 ` Andrew Lunn
2026-07-09 9:44 ` Daniel Golle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox