* [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle
@ 2025-04-22 14:24 Russell King (Oracle)
2025-04-22 14:42 ` Maxime Chevallier
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Russell King (Oracle) @ 2025-04-22 14:24 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit
Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Jon Hunter, linux-arm-kernel, linux-stm32,
Maxime Coquelin, netdev, Paolo Abeni, Thierry Reding
Thierry states that there are prerequists for Tegra's calibration
that should be met before starting calibration - both the RGMII and
MDIO interfaces should be idle.
This commit adds the necessary MII bus locking to ensure that the MDIO
interface is idle during calibration.
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
.../net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index fa900b4991d0..09ae16e026eb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -136,10 +136,11 @@ static int dwc_qos_probe(struct platform_device *pdev,
#define AUTO_CAL_STATUS 0x880c
#define AUTO_CAL_STATUS_ACTIVE BIT(31)
-static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
+static void tegra_eqos_fix_speed(void *bsp_priv, int speed, unsigned int mode)
{
- struct tegra_eqos *eqos = priv;
+ struct tegra_eqos *eqos = bsp_priv;
bool needs_calibration = false;
+ struct stmmac_priv *priv;
u32 value;
int err;
@@ -158,6 +159,11 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
}
if (needs_calibration) {
+ priv = netdev_priv(dev_get_drvdata(eqos->dev));
+
+ /* Calibration should be done with the MDIO bus idle */
+ mutex_lock(&priv->mii->mdio_lock);
+
/* calibrate */
value = readl(eqos->regs + SDMEMCOMPPADCTRL);
value |= SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD;
@@ -191,6 +197,8 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
value = readl(eqos->regs + SDMEMCOMPPADCTRL);
value &= ~SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD;
writel(value, eqos->regs + SDMEMCOMPPADCTRL);
+
+ mutex_unlock(&priv->mii->mdio_lock);
} else {
value = readl(eqos->regs + AUTO_CAL_CONFIG);
value &= ~AUTO_CAL_CONFIG_ENABLE;
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle
2025-04-22 14:24 [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle Russell King (Oracle)
@ 2025-04-22 14:42 ` Maxime Chevallier
2025-04-23 9:13 ` Thierry Reding
2025-04-23 9:14 ` Thierry Reding
2025-04-23 23:15 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Maxime Chevallier @ 2025-04-22 14:42 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, netdev,
Paolo Abeni, Thierry Reding
Hello Russell,
On Tue, 22 Apr 2025 15:24:55 +0100
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:
> Thierry states that there are prerequists for Tegra's calibration
> that should be met before starting calibration - both the RGMII and
> MDIO interfaces should be idle.
>
> This commit adds the necessary MII bus locking to ensure that the MDIO
> interface is idle during calibration.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
[...]
> -static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
> +static void tegra_eqos_fix_speed(void *bsp_priv, int speed, unsigned int mode)
> {
> - struct tegra_eqos *eqos = priv;
> + struct tegra_eqos *eqos = bsp_priv;
> bool needs_calibration = false;
> + struct stmmac_priv *priv;
> u32 value;
> int err;
>
> @@ -158,6 +159,11 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
> }
>
> if (needs_calibration) {
> + priv = netdev_priv(dev_get_drvdata(eqos->dev));
> +
> + /* Calibration should be done with the MDIO bus idle */
> + mutex_lock(&priv->mii->mdio_lock);
Can't priv->mii be NULL, if the PHY for that MAC is connected to
another MDIO bus for instance ?
Maxime
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle
2025-04-22 14:42 ` Maxime Chevallier
@ 2025-04-23 9:13 ` Thierry Reding
0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2025-04-23 9:13 UTC (permalink / raw)
To: Maxime Chevallier
Cc: Russell King (Oracle), Andrew Lunn, Heiner Kallweit,
Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Jon Hunter, linux-arm-kernel, linux-stm32,
Maxime Coquelin, netdev, Paolo Abeni
[-- Attachment #1: Type: text/plain, Size: 1792 bytes --]
On Tue, Apr 22, 2025 at 04:42:30PM +0200, Maxime Chevallier wrote:
> Hello Russell,
>
> On Tue, 22 Apr 2025 15:24:55 +0100
> "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk> wrote:
>
> > Thierry states that there are prerequists for Tegra's calibration
> > that should be met before starting calibration - both the RGMII and
> > MDIO interfaces should be idle.
> >
> > This commit adds the necessary MII bus locking to ensure that the MDIO
> > interface is idle during calibration.
> >
> > Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
>
> [...]
>
> > -static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
> > +static void tegra_eqos_fix_speed(void *bsp_priv, int speed, unsigned int mode)
> > {
> > - struct tegra_eqos *eqos = priv;
> > + struct tegra_eqos *eqos = bsp_priv;
> > bool needs_calibration = false;
> > + struct stmmac_priv *priv;
> > u32 value;
> > int err;
> >
> > @@ -158,6 +159,11 @@ static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
> > }
> >
> > if (needs_calibration) {
> > + priv = netdev_priv(dev_get_drvdata(eqos->dev));
> > +
> > + /* Calibration should be done with the MDIO bus idle */
> > + mutex_lock(&priv->mii->mdio_lock);
>
> Can't priv->mii be NULL, if the PHY for that MAC is connected to
> another MDIO bus for instance ?
Looking at the code, priv->mii will either be valid when mdio_bus_data
is non-NULL, or the driver probe will fail. mdio_bus_data depends on the
presence of the "mdio" child node in DT (via plat->mdio_node).
As far as I can tell this is always the case on Tegra devices, so I
don't think we need to worry about this case. If it ever wasn't valid,
I'd probably consider that a bug.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle
2025-04-22 14:24 [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle Russell King (Oracle)
2025-04-22 14:42 ` Maxime Chevallier
@ 2025-04-23 9:14 ` Thierry Reding
2025-04-23 23:15 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2025-04-23 9:14 UTC (permalink / raw)
To: Russell King (Oracle)
Cc: Andrew Lunn, Heiner Kallweit, Alexandre Torgue, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Jon Hunter,
linux-arm-kernel, linux-stm32, Maxime Coquelin, netdev,
Paolo Abeni
[-- Attachment #1: Type: text/plain, Size: 623 bytes --]
On Tue, Apr 22, 2025 at 03:24:55PM +0100, Russell King (Oracle) wrote:
> Thierry states that there are prerequists for Tegra's calibration
> that should be met before starting calibration - both the RGMII and
> MDIO interfaces should be idle.
>
> This commit adds the necessary MII bus locking to ensure that the MDIO
> interface is idle during calibration.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
> .../net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
Acked-by: Thierry Reding <treding@nvidia.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle
2025-04-22 14:24 [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle Russell King (Oracle)
2025-04-22 14:42 ` Maxime Chevallier
2025-04-23 9:14 ` Thierry Reding
@ 2025-04-23 23:15 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-23 23:15 UTC (permalink / raw)
To: Russell King
Cc: andrew, hkallweit1, alexandre.torgue, andrew+netdev, davem,
edumazet, kuba, jonathanh, linux-arm-kernel, linux-stm32,
mcoquelin.stm32, netdev, pabeni, treding
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 22 Apr 2025 15:24:55 +0100 you wrote:
> Thierry states that there are prerequists for Tegra's calibration
> that should be met before starting calibration - both the RGMII and
> MDIO interfaces should be idle.
>
> This commit adds the necessary MII bus locking to ensure that the MDIO
> interface is idle during calibration.
>
> [...]
Here is the summary with links:
- [net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle
https://git.kernel.org/netdev/net-next/c/87f43e6f06a2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-23 23:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22 14:24 [PATCH net-next] net: stmmac: dwc-qos: calibrate tegra with mdio bus idle Russell King (Oracle)
2025-04-22 14:42 ` Maxime Chevallier
2025-04-23 9:13 ` Thierry Reding
2025-04-23 9:14 ` Thierry Reding
2025-04-23 23:15 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).