2024-02-23 16:55:03

by Ciprian Regus

[permalink] [raw]
Subject: [net-next v2] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval

In order to do a clause 22 access to the PHY registers of the ADIN1110,
we have to write the MDIO frame to the ADIN1110_MDIOACC register, and
then poll the MDIO_TRDONE bit (for a 1) in the same register. The
device will set this bit to 1 once the internal MDIO transaction is
done. In practice, this bit takes ~50 - 60 us to be set.

The first attempt to poll the bit is right after the ADIN1110_MDIOACC
register is written, so it will always be read as 0. The next check will
only be done after 10 ms, which will result in the MDIO transactions
taking a long time to complete. Reduce this polling interval to 100 us.
Since this interval is short enough, switch the poll function to
readx_poll_timeout_atomic() instead.

Reviewed-by: Nuno Sa <[email protected]>
Signed-off-by: Ciprian Regus <[email protected]>
---
Changelog v1 -> v2:
- switch readx_poll_timeout() to readx_poll_timeout_atomic()

drivers/net/ethernet/adi/adin1110.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
index d7c274af6d4d..8b4ef5121308 100644
--- a/drivers/net/ethernet/adi/adin1110.c
+++ b/drivers/net/ethernet/adi/adin1110.c
@@ -466,4 +466,5 @@ static int adin1110_mdio_read(struct mii_bus *bus, int phy_id, int reg)
*/
- ret = readx_poll_timeout(adin1110_read_mdio_acc, priv, val,
- (val & ADIN1110_MDIO_TRDONE), 10000, 30000);
+ ret = readx_poll_timeout_atomic(adin1110_read_mdio_acc, priv, val,
+ (val & ADIN1110_MDIO_TRDONE),
+ 100, 30000);
if (ret < 0)
@@ -497,4 +498,5 @@ static int adin1110_mdio_write(struct mii_bus *bus, int phy_id,

- return readx_poll_timeout(adin1110_read_mdio_acc, priv, val,
- (val & ADIN1110_MDIO_TRDONE), 10000, 30000);
+ return readx_poll_timeout_atomic(adin1110_read_mdio_acc, priv, val,
+ (val & ADIN1110_MDIO_TRDONE),
+ 100, 30000);
}
--
2.39.2



2024-02-26 23:26:30

by Andrew Lunn

[permalink] [raw]
Subject: Re: [net-next v2] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval

On Fri, Feb 23, 2024 at 06:21:27PM +0200, Ciprian Regus wrote:
> In order to do a clause 22 access to the PHY registers of the ADIN1110,
> we have to write the MDIO frame to the ADIN1110_MDIOACC register, and
> then poll the MDIO_TRDONE bit (for a 1) in the same register. The
> device will set this bit to 1 once the internal MDIO transaction is
> done. In practice, this bit takes ~50 - 60 us to be set.
>
> The first attempt to poll the bit is right after the ADIN1110_MDIOACC
> register is written, so it will always be read as 0. The next check will
> only be done after 10 ms, which will result in the MDIO transactions
> taking a long time to complete. Reduce this polling interval to 100 us.
> Since this interval is short enough, switch the poll function to
> readx_poll_timeout_atomic() instead.
>
> Reviewed-by: Nuno Sa <[email protected]>
> Signed-off-by: Ciprian Regus <[email protected]>

Reviewed-by: Andrew Lunn <[email protected]>

Andrew

2024-02-27 10:31:20

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [net-next v2] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval

Hello:

This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <[email protected]>:

On Fri, 23 Feb 2024 18:21:27 +0200 you wrote:
> In order to do a clause 22 access to the PHY registers of the ADIN1110,
> we have to write the MDIO frame to the ADIN1110_MDIOACC register, and
> then poll the MDIO_TRDONE bit (for a 1) in the same register. The
> device will set this bit to 1 once the internal MDIO transaction is
> done. In practice, this bit takes ~50 - 60 us to be set.
>
> The first attempt to poll the bit is right after the ADIN1110_MDIOACC
> register is written, so it will always be read as 0. The next check will
> only be done after 10 ms, which will result in the MDIO transactions
> taking a long time to complete. Reduce this polling interval to 100 us.
> Since this interval is short enough, switch the poll function to
> readx_poll_timeout_atomic() instead.
>
> [...]

Here is the summary with links:
- [net-next,v2] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval
https://git.kernel.org/netdev/net-next/c/2322467a0f5d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html