[PATCH net v2] net: mdio: aspeed: Add dummy read for fire control

From: Jacky Chou
Date: Tue Nov 19 2024 - 04:52:09 EST


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@xxxxxxxxxxxxxx>
---
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