net: mdio: mdio-bcm-unimac: optimizations and clean up
Subsystems (4)
v2 cover net: mdio: mdio-bcm-unimac: optimizations and clean up
Clean up mdio poll to use read_poll_timeout() and reduce the potential poll time.
Justin Chen (2):
net: mdio: mdio-bcm-unimac: Delay before first poll
net: mdio: mdio-bcm-unimac: Use read_poll_timeout
drivers/net/mdio/mdio-bcm-unimac.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 net: mdio: mdio-bcm-unimac: Delay before first poll
With a clock interval of 400 nsec and a 64 bit transactions (32 bit preamble & 16 bit control & 16 bit data), it is reasonable to assume the mdio transaction will take 25.6 usec. Add a 30 usec delay before the first poll to reduce the chance of a 1000-2000 usec sleep.
Reduce the timeout from 1000ms to 100ms as it is unlikely for the bus to take this long.
---
v2
- Add comment to address absense of C45 support
drivers/net/mdio/mdio-bcm-unimac.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/mdio/mdio-bcm-unimac.c +7 -1
@@ -81,7 +81,13 @@ static inline unsigned int unimac_mdio_busy(struct unimac_mdio_priv *priv)static int unimac_mdio_poll (void *wait_func_data) {struct unimac_mdio_priv *priv = wait_func_data; -unsigned int timeout =1000 ; +unsigned int timeout =100 ; + +/* +* C22 transactions should take ~25 usec, will need to adjust +* if C45 support is added. +*/ +udelay (30 ); do { if (!unimac_mdio_busy(priv))
Signature · 1 line
2.34.1
Re: [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll
Quoted 10 lines · Justin Chen
With a clock interval of 400 nsec and a 64 bit transactions (32 bit preamble & 16 bit control & 16 bit data), it is reasonable to assume the mdio transaction will take 25.6 usec. Add a 30 usec delay before the first poll to reduce the chance of a 1000-2000 usec sleep.
Reduce the timeout from 1000ms to 100ms as it is unlikely for the bus to take this long.
Signed-off-by Justin Chen <[email protected]>Acked-by Florian Fainelli <[email protected]>
Andrew
PATCH v2 2/2 net: mdio: mdio-bcm-unimac: Use read_poll_timeout
In reply to Justin ChenSimplify the code by using read_poll_timeout().
--- drivers/net/mdio/mdio-bcm-unimac.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/net/mdio/mdio-bcm-unimac.c +3 -14
@@ -73,15 +73,10 @@ static inline void unimac_mdio_start(struct unimac_mdio_priv *priv)unimac_mdio_writel (priv, reg,MDIO_CMD ); } -static inline unsigned int unimac_mdio_busy (struct unimac_mdio_priv *priv) -{ -return unimac_mdio_readl (priv,MDIO_CMD ) &MDIO_START_BUSY ; -} -static int unimac_mdio_poll (void *wait_func_data) {struct unimac_mdio_priv *priv = wait_func_data; -unsigned int timeout =100 ; +u32 val;/* * C22 transactions should take ~25 usec, will need to adjust
@@ -89,14 +84,8 @@ static int unimac_mdio_poll(void *wait_func_data)*/ udelay (30 ); -do { -if (!unimac_mdio_busy (priv)) -return 0 ; - -usleep_range (1000 ,2000 ); - }while (--timeout); - -return -ETIMEDOUT ; +return read_poll_timeout (unimac_mdio_readl, val, !(val &MDIO_START_BUSY ), +2000 ,100000 , false, priv,MDIO_CMD ); }static int unimac_mdio_read (struct mii_bus *bus,int phy_id,int reg)
Signature · 1 line
2.34.1
Re: [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout
Quoted 3 lines · Justin Chen
Simplify the code by using
read_poll_timeout().Signed-off-by Justin Chen <[email protected]>
Andrew
Jakub Kicinski
maintainerQuoted 2 lines · On Wed, 13 Dec 2023 14:27:42 -0800 Justin Chen wrote:
Clean up mdio poll to use
read_poll_timeout()and reduce the potential poll time.
This is supposed to go to net-next, it's not a fix? No need to repost.
Quoted 6 lines · Jakub Kicinski
Quoted 2 lines · On Wed, 13 Dec 2023 14:27:42 -0800 Justin Chen wrote:
Clean up mdio poll to use
read_poll_timeout()and reduce the potential poll time.This is supposed to go to net-next, it's not a fix? No need to repost.
Yes should be net-next, no fixes just improvements. Apologies.
Justin
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Wed, 13 Dec 2023 14:27:42 -0800 you wrote:
Clean up mdio poll to use
read_poll_timeout()and reduce the potential poll time.Justin Chen (2):
net: mdio: mdio-bcm-unimac: Delay before first poll
net: mdio: mdio-bcm-unimac: Useread_poll_timeout[...]
Here is the summary with links:
- [net,v2,1/2] net: mdio: mdio-bcm-unimac: Delay before first poll
https://git.kernel.org/netdev/net-next/c/268531be211f - [net,v2,2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout https://git.kernel.org/netdev/net-next/c/54a600ed2170
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html