diff mbox

[PATCHv2,1/2] drivers: net: davinci_mdio: remove busy loop on wait user access

Message ID 1502351267-23841-1-git-send-email-muvarov@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Maxim Uvarov Aug. 10, 2017, 7:47 a.m. UTC
Polling 14 mdio devices on single mdio bus eats 30% of 1Ghz cpu time
due to busy loop in wait(). Add small delay to relax cpu.

Signed-off-by: Max Uvarov <muvarov@gmail.com>
---
 v2: fix spelling in commit description.

 drivers/net/ethernet/ti/davinci_mdio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Lunn Aug. 10, 2017, 2:40 p.m. UTC | #1
On Thu, Aug 10, 2017 at 10:47:46AM +0300, Max Uvarov wrote:
> Polling 14 mdio devices on single mdio bus eats 30% of 1Ghz cpu time
> due to busy loop in wait(). Add small delay to relax cpu.

Hi Max

Please include a cover note when you have multiple patches in a
series.

With 14 devices, it makes sense to swap to using PHY interrupts if you
can. That should prevent the PHY state machine polling the PHYs every
second.

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

    Andrew
Grygorii Strashko Aug. 10, 2017, 4:24 p.m. UTC | #2
On 08/10/2017 02:47 AM, Max Uvarov wrote:
> Polling 14 mdio devices on single mdio bus eats 30% of 1Ghz cpu time
> due to busy loop in wait(). Add small delay to relax cpu.
> 
> Signed-off-by: Max Uvarov <muvarov@gmail.com>

yep. cover letter is good to have.

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

> ---
>   v2: fix spelling in commit description.
> 
>   drivers/net/ethernet/ti/davinci_mdio.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
> index 33df340..611e7cc 100644
> --- a/drivers/net/ethernet/ti/davinci_mdio.c
> +++ b/drivers/net/ethernet/ti/davinci_mdio.c
> @@ -198,8 +198,10 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
>   			return 0;
>   
>   		reg = __raw_readl(&regs->control);
> -		if ((reg & CONTROL_IDLE) == 0)
> +		if ((reg & CONTROL_IDLE) == 0) {
> +			usleep_range(100, 200);
>   			continue;
> +		}
>   
>   		/*
>   		 * An emac soft_reset may have clobbered the mdio controller's
>
David Miller Aug. 11, 2017, 9:24 p.m. UTC | #3
From: Max Uvarov <muvarov@gmail.com>
Date: Thu, 10 Aug 2017 10:47:46 +0300

> Polling 14 mdio devices on single mdio bus eats 30% of 1Ghz cpu time
> due to busy loop in wait(). Add small delay to relax cpu.
> 
> Signed-off-by: Max Uvarov <muvarov@gmail.com>

Applied to net-next.
diff mbox

Patch

diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 33df340..611e7cc 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -198,8 +198,10 @@  static inline int wait_for_user_access(struct davinci_mdio_data *data)
 			return 0;
 
 		reg = __raw_readl(&regs->control);
-		if ((reg & CONTROL_IDLE) == 0)
+		if ((reg & CONTROL_IDLE) == 0) {
+			usleep_range(100, 200);
 			continue;
+		}
 
 		/*
 		 * An emac soft_reset may have clobbered the mdio controller's