Skip to contentSkip to conversation

drivers: net: davinci_mdio: remove busy loop on wait user access

PATCH Applied Max Uvarov 4 participants 7 messages Aug 10, 2017 – Aug 11, 2017

Subsystems (3)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Max Uvarov

author
#0 lore raw

PATCH v2 1/2 drivers: net: davinci_mdio: remove busy loop on wait user access

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.

---
v2: fix spelling in commit description.

 drivers/net/ethernet/ti/davinci_mdio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/davinci_mdio.c +3 -1
index 33df340..611e7cc 100644
@@ -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
Signature · 1 line
2.5.0
author
#1 lore raw

PATCH v2 2/2 drivers: net: davinci_mdio: print bus frequency

Frequency can be adjusted in DT it make sense to
print current used value on driver init.

---
 drivers/net/ethernet/ti/davinci_mdio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/davinci_mdio.c +4 -2
index 611e7cc..3c33f45 100644
@@ -159,8 +159,10 @@ static int davinci_mdio_reset(struct mii_bus *bus)
 
 	/* dump hardware version info */
 	ver = __raw_readl(&data->regs->version);
-	dev_info(data->dev, "davinci mdio revision %d.%d\n",
-		 (ver >> 8) & 0xff, ver & 0xff);
+	dev_info(data->dev,
+		 "davinci mdio revision %d.%d, bus freq %ld\n",
+		 (ver >> 8) & 0xff, ver & 0xff,
+		 data->pdata.bus_freq);
 
 	if (data->skip_scan)
 		goto done;
Signature · 1 line
2.5.0
Reviewed-by on v2 1/2
#4 lore raw
In reply to Max Uvarov
Quoted 2 lines · Max Uvarov

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.

Andrew

Reviewed-by on v2 2/2
#2 lore raw

Re: [PATCHv2 2/2] drivers: net: davinci_mdio: print bus frequency

In reply to Max Uvarov
Quoted 4 lines · Max Uvarov

Frequency can be adjusted in DT it make sense to
print current used value on driver init.

Quoted 22 lines
---
  drivers/net/ethernet/ti/davinci_mdio.c | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/ti/davinci_mdio.c +4 -2
index 611e7cc..3c33f45 100644
@@ -159,8 +159,10 @@ static int davinci_mdio_reset(struct mii_bus *bus)
 
  	/* dump hardware version info */
  	ver = __raw_readl(&data->regs->version);
-	dev_info(data->dev, "davinci mdio revision %d.%d\n",
-		 (ver >> 8) & 0xff, ver & 0xff);
+	dev_info(data->dev,
+		 "davinci mdio revision %d.%d, bus freq %ld\n",
+		 (ver >> 8) & 0xff, ver & 0xff,
+		 data->pdata.bus_freq);
 
  	if (data->skip_scan)
  		goto done;
Signature · 2 lines
regards,
-grygorii
Reviewed-by on v2 1/2
#5 lore raw
In reply to Max Uvarov
Quoted 4 lines · Max Uvarov

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.

yep. cover letter is good to have.

Quoted 23 lines

---
v2: fix spelling in commit description.

  drivers/net/ethernet/ti/davinci_mdio.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/ti/davinci_mdio.c +3 -1
index 33df340..611e7cc 100644
@@ -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
Signature · 2 lines
regards,
-grygorii