netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up
@ 2023-12-13 22:27 Justin Chen
  2023-12-13 22:27 ` [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll Justin Chen
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Justin Chen @ 2023-12-13 22:27 UTC (permalink / raw)
  To: netdev
  Cc: opendmb, florian.fainelli, bcm-kernel-feedback-list, andrew,
	hkallweit1, linux, davem, edumazet, kuba, pabeni, Justin Chen

[-- Attachment #1: Type: text/plain, Size: 333 bytes --]

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(-)

-- 
2.34.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll
  2023-12-13 22:27 [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Justin Chen
@ 2023-12-13 22:27 ` Justin Chen
  2023-12-14 11:46   ` Andrew Lunn
  2023-12-13 22:27 ` [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout Justin Chen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Justin Chen @ 2023-12-13 22:27 UTC (permalink / raw)
  To: netdev
  Cc: opendmb, florian.fainelli, bcm-kernel-feedback-list, andrew,
	hkallweit1, linux, davem, edumazet, kuba, pabeni, Justin Chen

[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]

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 <justin.chen@broadcom.com>
Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
v2
	- Add comment to address absense of C45 support

 drivers/net/mdio/mdio-bcm-unimac.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
index e8cd8eef319b..297ea4a58d79 100644
--- a/drivers/net/mdio/mdio-bcm-unimac.c
+++ b/drivers/net/mdio/mdio-bcm-unimac.c
@@ -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))
-- 
2.34.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout
  2023-12-13 22:27 [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Justin Chen
  2023-12-13 22:27 ` [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll Justin Chen
@ 2023-12-13 22:27 ` Justin Chen
  2023-12-14 11:47   ` Andrew Lunn
  2023-12-14 19:42 ` [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Jakub Kicinski
  2023-12-15  2:20 ` patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Justin Chen @ 2023-12-13 22:27 UTC (permalink / raw)
  To: netdev
  Cc: opendmb, florian.fainelli, bcm-kernel-feedback-list, andrew,
	hkallweit1, linux, davem, edumazet, kuba, pabeni, Justin Chen

[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]

Simplify the code by using read_poll_timeout().

Signed-off-by: Justin Chen <justin.chen@broadcom.com>
---
 drivers/net/mdio/mdio-bcm-unimac.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
index 297ea4a58d79..68f8ee0ec8ba 100644
--- a/drivers/net/mdio/mdio-bcm-unimac.c
+++ b/drivers/net/mdio/mdio-bcm-unimac.c
@@ -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)
-- 
2.34.1


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll
  2023-12-13 22:27 ` [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll Justin Chen
@ 2023-12-14 11:46   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2023-12-14 11:46 UTC (permalink / raw)
  To: Justin Chen
  Cc: netdev, opendmb, florian.fainelli, bcm-kernel-feedback-list,
	hkallweit1, linux, davem, edumazet, kuba, pabeni

On Wed, Dec 13, 2023 at 02:27:43PM -0800, Justin Chen wrote:
> 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 <justin.chen@broadcom.com>
> Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout
  2023-12-13 22:27 ` [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout Justin Chen
@ 2023-12-14 11:47   ` Andrew Lunn
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2023-12-14 11:47 UTC (permalink / raw)
  To: Justin Chen
  Cc: netdev, opendmb, florian.fainelli, bcm-kernel-feedback-list,
	hkallweit1, linux, davem, edumazet, kuba, pabeni

On Wed, Dec 13, 2023 at 02:27:44PM -0800, Justin Chen wrote:
> Simplify the code by using read_poll_timeout().
> 
> Signed-off-by: Justin Chen <justin.chen@broadcom.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up
  2023-12-13 22:27 [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Justin Chen
  2023-12-13 22:27 ` [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll Justin Chen
  2023-12-13 22:27 ` [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout Justin Chen
@ 2023-12-14 19:42 ` Jakub Kicinski
  2023-12-14 20:01   ` Justin Chen
  2023-12-15  2:20 ` patchwork-bot+netdevbpf
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2023-12-14 19:42 UTC (permalink / raw)
  To: Justin Chen
  Cc: netdev, opendmb, florian.fainelli, bcm-kernel-feedback-list,
	andrew, hkallweit1, linux, davem, edumazet, pabeni

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up
  2023-12-14 19:42 ` [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Jakub Kicinski
@ 2023-12-14 20:01   ` Justin Chen
  0 siblings, 0 replies; 8+ messages in thread
From: Justin Chen @ 2023-12-14 20:01 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: netdev, opendmb, florian.fainelli, bcm-kernel-feedback-list,
	andrew, hkallweit1, linux, davem, edumazet, pabeni

[-- Attachment #1: Type: text/plain, Size: 340 bytes --]



On 12/14/23 11:42 AM, Jakub Kicinski wrote:
> 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

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4206 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up
  2023-12-13 22:27 [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Justin Chen
                   ` (2 preceding siblings ...)
  2023-12-14 19:42 ` [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Jakub Kicinski
@ 2023-12-15  2:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-12-15  2:20 UTC (permalink / raw)
  To: Justin Chen
  Cc: netdev, opendmb, florian.fainelli, bcm-kernel-feedback-list,
	andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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: Use read_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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-12-15  2:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-13 22:27 [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Justin Chen
2023-12-13 22:27 ` [PATCH net v2 1/2] net: mdio: mdio-bcm-unimac: Delay before first poll Justin Chen
2023-12-14 11:46   ` Andrew Lunn
2023-12-13 22:27 ` [PATCH net v2 2/2] net: mdio: mdio-bcm-unimac: Use read_poll_timeout Justin Chen
2023-12-14 11:47   ` Andrew Lunn
2023-12-14 19:42 ` [PATCH net v2 0/2] net: mdio: mdio-bcm-unimac: optimizations and clean up Jakub Kicinski
2023-12-14 20:01   ` Justin Chen
2023-12-15  2:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).