mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] net: arc_emac: remove delay from mdio polling loop
@ 2014-05-19 20:34 Beniamino Galvani
  2014-05-19 20:35 ` [PATCH 2/2] net: arc_emac: disable interrupts Beniamino Galvani
  0 siblings, 1 reply; 3+ messages in thread
From: Beniamino Galvani @ 2014-05-19 20:34 UTC (permalink / raw)
  To: barebox

Avoid unneeded delay when waiting for the completion of a mdio
operation and return as soon as possible.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
 drivers/net/arc_emac.c |   19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 3f6f814..23df3fd 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -17,6 +17,7 @@
  */
 
 #include <asm/mmu.h>
+#include <clock.h>
 #include <common.h>
 #include <net.h>
 #include <io.h>
@@ -342,26 +343,18 @@ static int arc_emac_set_ethaddr(struct eth_device *edev, unsigned char *mac)
 	return 0;
 }
 
-/* Number of seconds we wait for "MDIO complete" flag to appear */
-#define ARC_MDIO_COMPLETE_POLL_COUNT	1
-
 static int arc_mdio_complete_wait(struct arc_emac_priv *priv)
 {
-	unsigned int i;
-
-	for (i = 0; i < ARC_MDIO_COMPLETE_POLL_COUNT * 40; i++) {
-		unsigned int status = arc_reg_get(priv, R_STATUS);
-
-		status &= MDIO_MASK;
+	uint64_t start = get_time_ns();
 
-		if (status) {
+	while (!is_timeout(start, 1000 * MSECOND)) {
+		if (arc_reg_get(priv, R_STATUS) & MDIO_MASK) {
 			/* Reset "MDIO complete" flag */
-			arc_reg_set(priv, R_STATUS, status);
+			arc_reg_set(priv, R_STATUS, MDIO_MASK);
 			return 0;
 		}
-
-		mdelay(25);
 	}
+
 	return -ETIMEDOUT;
 }
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] net: arc_emac: disable interrupts
  2014-05-19 20:34 [PATCH 1/2] net: arc_emac: remove delay from mdio polling loop Beniamino Galvani
@ 2014-05-19 20:35 ` Beniamino Galvani
  2014-05-20  5:48   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Beniamino Galvani @ 2014-05-19 20:35 UTC (permalink / raw)
  To: barebox

The driver doesn't use interrupts and Linux driver crashes when emac
interrupts are enabled at boot: keep them disabled.

Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
 drivers/net/arc_emac.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 23df3fd..8b74ea5 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -210,9 +210,6 @@ static int arc_emac_open(struct eth_device *edev)
 	arc_reg_set(priv, R_RX_RING, (unsigned int)priv->rxbd);
 	arc_reg_set(priv, R_TX_RING, (unsigned int)priv->txbd);
 
-	/* Enable interrupts */
-	arc_reg_set(priv, R_ENABLE, RXINT_MASK | ERR_MASK);
-
 	/* Set CONTROL */
 	arc_reg_set(priv, R_CTRL,
 		     (RX_BD_NUM << 24) |	/* RX BD table length */
@@ -317,9 +314,6 @@ static void arc_emac_halt(struct eth_device *edev)
 {
 	struct arc_emac_priv *priv = edev->priv;
 
-	/* Disable interrupts */
-	arc_reg_clr(priv, R_ENABLE, RXINT_MASK | ERR_MASK);
-
 	/* Disable EMAC */
 	arc_reg_clr(priv, R_CTRL, EN_MASK);
 }
@@ -440,6 +434,9 @@ static int arc_emac_probe(struct device_d *dev)
 	/* Set poll rate so that it polls every 1 ms */
 	arc_reg_set(priv, R_POLLRATE, clock_frequency / 1000000);
 
+	/* Disable interrupts */
+	arc_reg_set(priv, R_ENABLE, 0);
+
 	mdiobus_register(miibus);
 	eth_register(edev);
 
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/2] net: arc_emac: disable interrupts
  2014-05-19 20:35 ` [PATCH 2/2] net: arc_emac: disable interrupts Beniamino Galvani
@ 2014-05-20  5:48   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-05-20  5:48 UTC (permalink / raw)
  To: Beniamino Galvani; +Cc: barebox

On Mon, May 19, 2014 at 10:35:00PM +0200, Beniamino Galvani wrote:
> The driver doesn't use interrupts and Linux driver crashes when emac
> interrupts are enabled at boot: keep them disabled.

This is the right thing to do in barebox, so applied.

However, the Linux driver should not crash in this case.

Sascha

> 
> Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
> ---
>  drivers/net/arc_emac.c |    9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
> index 23df3fd..8b74ea5 100644
> --- a/drivers/net/arc_emac.c
> +++ b/drivers/net/arc_emac.c
> @@ -210,9 +210,6 @@ static int arc_emac_open(struct eth_device *edev)
>  	arc_reg_set(priv, R_RX_RING, (unsigned int)priv->rxbd);
>  	arc_reg_set(priv, R_TX_RING, (unsigned int)priv->txbd);
>  
> -	/* Enable interrupts */
> -	arc_reg_set(priv, R_ENABLE, RXINT_MASK | ERR_MASK);
> -
>  	/* Set CONTROL */
>  	arc_reg_set(priv, R_CTRL,
>  		     (RX_BD_NUM << 24) |	/* RX BD table length */
> @@ -317,9 +314,6 @@ static void arc_emac_halt(struct eth_device *edev)
>  {
>  	struct arc_emac_priv *priv = edev->priv;
>  
> -	/* Disable interrupts */
> -	arc_reg_clr(priv, R_ENABLE, RXINT_MASK | ERR_MASK);
> -
>  	/* Disable EMAC */
>  	arc_reg_clr(priv, R_CTRL, EN_MASK);
>  }
> @@ -440,6 +434,9 @@ static int arc_emac_probe(struct device_d *dev)
>  	/* Set poll rate so that it polls every 1 ms */
>  	arc_reg_set(priv, R_POLLRATE, clock_frequency / 1000000);
>  
> +	/* Disable interrupts */
> +	arc_reg_set(priv, R_ENABLE, 0);
> +
>  	mdiobus_register(miibus);
>  	eth_register(edev);
>  
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-05-20  5:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-19 20:34 [PATCH 1/2] net: arc_emac: remove delay from mdio polling loop Beniamino Galvani
2014-05-19 20:35 ` [PATCH 2/2] net: arc_emac: disable interrupts Beniamino Galvani
2014-05-20  5:48   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox