* [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control
@ 2024-11-19 9:51 Jacky Chou
2024-11-19 13:55 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jacky Chou @ 2024-11-19 9:51 UTC (permalink / raw)
To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, joel,
andrew, f.fainelli, netdev, linux-arm-kernel, linux-aspeed,
linux-kernel
Cc: jacky_chou
When the command bus is sometimes busy, it may cause the command is not
arrived to MDIO controller immediately. On software, the driver issues a
write command to the command bus does not wait for command complete and
it returned back to code immediately. But a read command will wait for
the data back, once a read command was back indicates the previous write
command had arrived to controller.
Add a dummy read to ensure triggering mdio controller before starting
polling the status of mdio controller to avoid polling unexpected timeout.
Fixes: a9770eac511a ("net: mdio: Move MDIO drivers into a new subdirectory")
Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
---
drivers/net/mdio/mdio-aspeed.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c
index c2170650415c..373902d33b96 100644
--- a/drivers/net/mdio/mdio-aspeed.c
+++ b/drivers/net/mdio/mdio-aspeed.c
@@ -62,6 +62,8 @@ static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad,
| FIELD_PREP(ASPEED_MDIO_DATA_MIIRDATA, data);
iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL);
+ /* Add dummy read to ensure triggering mdio controller */
+ (void)ioread32(ctx->base + ASPEED_MDIO_CTRL);
return readl_poll_timeout(ctx->base + ASPEED_MDIO_CTRL, ctrl,
!(ctrl & ASPEED_MDIO_CTRL_FIRE),
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control
2024-11-19 9:51 [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control Jacky Chou
@ 2024-11-19 13:55 ` Andrew Lunn
2024-11-20 2:34 ` 回覆: " Jacky Chou
2024-11-20 4:43 ` Andrew Jeffery
2024-11-20 9:42 ` Russell King (Oracle)
2 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2024-11-19 13:55 UTC (permalink / raw)
To: Jacky Chou
Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, joel, andrew,
f.fainelli, netdev, linux-arm-kernel, linux-aspeed, linux-kernel
On Tue, Nov 19, 2024 at 05:51:41PM +0800, Jacky Chou wrote:
> When the command bus is sometimes busy, it may cause the command is not
> arrived to MDIO controller immediately. On software, the driver issues a
> write command to the command bus does not wait for command complete and
> it returned back to code immediately. But a read command will wait for
> the data back, once a read command was back indicates the previous write
> command had arrived to controller.
> Add a dummy read to ensure triggering mdio controller before starting
> polling the status of mdio controller to avoid polling unexpected timeout.
Please have another attempt at writing the commit message.
> Fixes: a9770eac511a ("net: mdio: Move MDIO drivers into a new subdirectory")
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
> drivers/net/mdio/mdio-aspeed.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c
> index c2170650415c..373902d33b96 100644
> --- a/drivers/net/mdio/mdio-aspeed.c
> +++ b/drivers/net/mdio/mdio-aspeed.c
> @@ -62,6 +62,8 @@ static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad,
> | FIELD_PREP(ASPEED_MDIO_DATA_MIIRDATA, data);
>
> iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL);
> + /* Add dummy read to ensure triggering mdio controller */
> + (void)ioread32(ctx->base + ASPEED_MDIO_CTRL);
Maybe: /* Dummy read to flush previous write to controller */
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 6+ messages in thread* 回覆: [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control
2024-11-19 13:55 ` Andrew Lunn
@ 2024-11-20 2:34 ` Jacky Chou
0 siblings, 0 replies; 6+ messages in thread
From: Jacky Chou @ 2024-11-20 2:34 UTC (permalink / raw)
To: Andrew Lunn
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
joel@jms.id.au, andrew@codeconstruct.com.au, f.fainelli@gmail.com,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org
Hi Andrew Lunn,
Thank you for your reply.
> > When the command bus is sometimes busy, it may cause the command is
> > not arrived to MDIO controller immediately. On software, the driver
> > issues a write command to the command bus does not wait for command
> > complete and it returned back to code immediately. But a read command
> > will wait for the data back, once a read command was back indicates
> > the previous write command had arrived to controller.
> > Add a dummy read to ensure triggering mdio controller before starting
> > polling the status of mdio controller to avoid polling unexpected timeout.
>
> Please have another attempt at writing the commit message.
>
> > Fixes: a9770eac511a ("net: mdio: Move MDIO drivers into a new
> > subdirectory")
> > Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> > ---
> > drivers/net/mdio/mdio-aspeed.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/net/mdio/mdio-aspeed.c
> > b/drivers/net/mdio/mdio-aspeed.c index c2170650415c..373902d33b96
> > 100644
> > --- a/drivers/net/mdio/mdio-aspeed.c
> > +++ b/drivers/net/mdio/mdio-aspeed.c
> > @@ -62,6 +62,8 @@ static int aspeed_mdio_op(struct mii_bus *bus, u8 st,
> u8 op, u8 phyad, u8 regad,
> > | FIELD_PREP(ASPEED_MDIO_DATA_MIIRDATA, data);
> >
> > iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL);
> > + /* Add dummy read to ensure triggering mdio controller */
> > + (void)ioread32(ctx->base + ASPEED_MDIO_CTRL);
>
> Maybe: /* Dummy read to flush previous write to controller */
Agree. I will change the title in next version.
Thanks,
Jacky
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control
2024-11-19 9:51 [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control Jacky Chou
2024-11-19 13:55 ` Andrew Lunn
@ 2024-11-20 4:43 ` Andrew Jeffery
2024-11-20 5:45 ` 回覆: " Jacky Chou
2024-11-20 9:42 ` Russell King (Oracle)
2 siblings, 1 reply; 6+ messages in thread
From: Andrew Jeffery @ 2024-11-20 4:43 UTC (permalink / raw)
To: Jacky Chou, andrew, hkallweit1, linux, davem, edumazet, kuba,
pabeni, joel, f.fainelli, netdev, linux-arm-kernel, linux-aspeed,
linux-kernel
On Tue, 2024-11-19 at 17:51 +0800, Jacky Chou wrote:
> When the command bus is sometimes busy, it may cause the command is
> not
> arrived to MDIO controller immediately. On software, the driver
> issues a
> write command to the command bus does not wait for command complete
> and
> it returned back to code immediately. But a read command will wait
> for
> the data back, once a read command was back indicates the previous
> write
> command had arrived to controller.
> Add a dummy read to ensure triggering mdio controller before starting
> polling the status of mdio controller to avoid polling unexpected
> timeout.
Why use the explicit dummy read rather than adjust the poll interval or
duration? I still don't think that's been adequately explained given
the hardware-clear of the fire bit on completion, which is what we're
polling for.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* 回覆: [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control
2024-11-20 4:43 ` Andrew Jeffery
@ 2024-11-20 5:45 ` Jacky Chou
0 siblings, 0 replies; 6+ messages in thread
From: Jacky Chou @ 2024-11-20 5:45 UTC (permalink / raw)
To: Andrew Jeffery, andrew@lunn.ch, hkallweit1@gmail.com,
linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, joel@jms.id.au,
f.fainelli@gmail.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org
Hi Andrew Jeffery,
Thank you for your reply.
> > When the command bus is sometimes busy, it may cause the command is
> > not arrived to MDIO controller immediately. On software, the driver
> > issues a write command to the command bus does not wait for command
> > complete and it returned back to code immediately. But a read command
> > will wait for the data back, once a read command was back indicates
> > the previous write command had arrived to controller.
> > Add a dummy read to ensure triggering mdio controller before starting
> > polling the status of mdio controller to avoid polling unexpected
> > timeout.
>
> Why use the explicit dummy read rather than adjust the poll interval or
> duration? I still don't think that's been adequately explained given the
> hardware-clear of the fire bit on completion, which is what we're polling for.
We cannot know exactly what the timeout value of polling should be set to.
Because no one could know when the write command has arrived MDIO controller.
A dummy read can ensure the previous write command had arrived MDIO controller
Therefore, we chose to use a dummy read instead of increasing the timeout value.
Thanks,
Jacky
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control
2024-11-19 9:51 [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control Jacky Chou
2024-11-19 13:55 ` Andrew Lunn
2024-11-20 4:43 ` Andrew Jeffery
@ 2024-11-20 9:42 ` Russell King (Oracle)
2 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2024-11-20 9:42 UTC (permalink / raw)
To: Jacky Chou
Cc: andrew, hkallweit1, davem, edumazet, kuba, pabeni, joel, andrew,
f.fainelli, netdev, linux-arm-kernel, linux-aspeed, linux-kernel
On Tue, Nov 19, 2024 at 05:51:41PM +0800, Jacky Chou wrote:
> When the command bus is sometimes busy, it may cause the command is not
> arrived to MDIO controller immediately. On software, the driver issues a
> write command to the command bus does not wait for command complete and
> it returned back to code immediately. But a read command will wait for
> the data back, once a read command was back indicates the previous write
> command had arrived to controller.
> Add a dummy read to ensure triggering mdio controller before starting
> polling the status of mdio controller to avoid polling unexpected timeout.
>
> Fixes: a9770eac511a ("net: mdio: Move MDIO drivers into a new subdirectory")
> Signed-off-by: Jacky Chou <jacky_chou@aspeedtech.com>
> ---
> drivers/net/mdio/mdio-aspeed.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/mdio/mdio-aspeed.c b/drivers/net/mdio/mdio-aspeed.c
> index c2170650415c..373902d33b96 100644
> --- a/drivers/net/mdio/mdio-aspeed.c
> +++ b/drivers/net/mdio/mdio-aspeed.c
> @@ -62,6 +62,8 @@ static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad,
> | FIELD_PREP(ASPEED_MDIO_DATA_MIIRDATA, data);
>
> iowrite32(ctrl, ctx->base + ASPEED_MDIO_CTRL);
> + /* Add dummy read to ensure triggering mdio controller */
> + (void)ioread32(ctx->base + ASPEED_MDIO_CTRL);
I'd change that comment to:
/* The above write could be posted, causing the timeout below to
* be inaccurate. Ensure the controller starts before we start the
* timeout.
*/
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-20 9:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-19 9:51 [PATCH net v2] net: mdio: aspeed: Add dummy read for fire control Jacky Chou
2024-11-19 13:55 ` Andrew Lunn
2024-11-20 2:34 ` 回覆: " Jacky Chou
2024-11-20 4:43 ` Andrew Jeffery
2024-11-20 5:45 ` 回覆: " Jacky Chou
2024-11-20 9:42 ` Russell King (Oracle)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox