* [net-next] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval
@ 2024-02-16 10:36 Ciprian Regus
2024-02-16 12:14 ` Nuno Sá
2024-02-17 15:42 ` Andrew Lunn
0 siblings, 2 replies; 3+ messages in thread
From: Ciprian Regus @ 2024-02-16 10:36 UTC (permalink / raw)
To: linux-kernel
Cc: Ciprian Regus, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Dell Jin, Amit Kumar Mahapatra,
Yang Yingliang, netdev
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.
Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
---
drivers/net/ethernet/adi/adin1110.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
index d7c274af6d4d..6fca19e6ae67 100644
--- a/drivers/net/ethernet/adi/adin1110.c
+++ b/drivers/net/ethernet/adi/adin1110.c
@@ -467,3 +467,3 @@ 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);
+ (val & ADIN1110_MDIO_TRDONE), 100, 30000);
if (ret < 0)
@@ -498,3 +498,3 @@ 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);
+ (val & ADIN1110_MDIO_TRDONE), 100, 30000);
}
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [net-next] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval
2024-02-16 10:36 [net-next] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval Ciprian Regus
@ 2024-02-16 12:14 ` Nuno Sá
2024-02-17 15:42 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Nuno Sá @ 2024-02-16 12:14 UTC (permalink / raw)
To: Ciprian Regus, linux-kernel
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Dell Jin, Amit Kumar Mahapatra, Yang Yingliang,
netdev
On Fri, 2024-02-16 at 12:36 +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.
>
> Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
> ---
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> drivers/net/ethernet/adi/adin1110.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/adi/adin1110.c
> b/drivers/net/ethernet/adi/adin1110.c
> index d7c274af6d4d..6fca19e6ae67 100644
> --- a/drivers/net/ethernet/adi/adin1110.c
> +++ b/drivers/net/ethernet/adi/adin1110.c
> @@ -467,3 +467,3 @@ 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);
> + (val & ADIN1110_MDIO_TRDONE), 100, 30000);
> if (ret < 0)
> @@ -498,3 +498,3 @@ 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);
> + (val & ADIN1110_MDIO_TRDONE), 100, 30000);
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [net-next] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval
2024-02-16 10:36 [net-next] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval Ciprian Regus
2024-02-16 12:14 ` Nuno Sá
@ 2024-02-17 15:42 ` Andrew Lunn
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2024-02-17 15:42 UTC (permalink / raw)
To: Ciprian Regus
Cc: linux-kernel, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Dell Jin, Amit Kumar Mahapatra,
Yang Yingliang, netdev
On Fri, Feb 16, 2024 at 12:36:32PM +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.
>
> Signed-off-by: Ciprian Regus <ciprian.regus@analog.com>
> ---
> drivers/net/ethernet/adi/adin1110.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
> index d7c274af6d4d..6fca19e6ae67 100644
> --- a/drivers/net/ethernet/adi/adin1110.c
> +++ b/drivers/net/ethernet/adi/adin1110.c
> @@ -467,3 +467,3 @@ 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);
> + (val & ADIN1110_MDIO_TRDONE), 100, 30000);
> if (ret < 0)
> @@ -498,3 +498,3 @@ 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);
> + (val & ADIN1110_MDIO_TRDONE), 100, 30000);
The kernel can have trouble sleeping for such short times. It might
make sense to swap to the _atomic version which spins rather than
sleeps. If you are just reading a few PHY registers every so often, it
might not be worth it. But if you have an Ethernet switch and need to
access a lot of registers, it could make it a bit faster.
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-17 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16 10:36 [net-next] net: ethernet: adi: adin1110: Reduce the MDIO_TRDONE poll interval Ciprian Regus
2024-02-16 12:14 ` Nuno Sá
2024-02-17 15:42 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®