netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net 0/8] gianfar: ARM port driver updates (1/2)
@ 2014-10-03 16:02 Claudiu Manoil
  2014-10-03 16:02 ` [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM Claudiu Manoil
                   ` (9 more replies)
  0 siblings, 10 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

This is the first round of driver protability fixes and clean-up
with the main purpose to make gianfar portable on ARM, for the ARM
based SoC that integrates the eTSEC ethernet controller - "ls1021a".
The patches primarily address compile time errors, when compiling
gianfar on ARM.  They replace PPC specific functions and macros
with architecture independent ones, solve arch specific header
inclusions, guard code that relates to PPC only, and even address
some simple endianess issues (see MAC address setup patch).
The patches addressing the bulk of remaining endianess issues,
like handling DMA fields (BD and FCB), will follow with the sencond
round.
These patches were verified on the ls1021a SoC.

Claudiu Manoil (8):
  net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM
  net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors
  net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent
  gianfar: Include missing headers for ARM builds
  gianfar: Exclude PPC specific errata handling from ARM builds
  gianfar: Make MAC addr setup endian safe, cleanup
  gianfar: Replace spin_event_timeout() with arch independent
  gianfar: Replace eieio with wmb for non-PPC archs

 drivers/net/ethernet/freescale/fsl_pq_mdio.c | 56 ++++++++++++++---------
 drivers/net/ethernet/freescale/gianfar.c     | 68 +++++++++++++++-------------
 drivers/net/ethernet/freescale/gianfar.h     | 31 +++++++++++++
 3 files changed, 102 insertions(+), 53 deletions(-)

-- 
1.7.11.7

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

* [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 18:39   ` Sergei Shtylyov
  2014-10-03 16:02 ` [net 2/8] net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors Claudiu Manoil
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

The UCC specific code included in fsl_pq_mdio.c (with
function calls from asm/ucc.h) is already guarded
by these config options, so this ARM build fix provides
consistency with the rest UCC specific code.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 583e71a..89b3fea 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -28,7 +28,9 @@
 #include <linux/of_device.h>
 
 #include <asm/io.h>
+#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
 #include <asm/ucc.h>	/* for ucc_set_qe_mux_mii_mng() */
+#endif
 
 #include "gianfar.h"
 
-- 
1.7.11.7

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

* [net 2/8] net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
  2014-10-03 16:02 ` [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 16:02 ` [net 3/8] net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent Claudiu Manoil
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

in_be32()/out_be32() are not defined by ARM.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/fsl_pq_mdio.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 89b3fea..773b50b 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -107,14 +107,14 @@ static int fsl_pq_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 	u32 status;
 
 	/* Set the PHY address and the register address we want to write */
-	out_be32(&regs->miimadd, (mii_id << 8) | regnum);
+	iowrite32be((mii_id << 8) | regnum, &regs->miimadd);
 
 	/* Write out the value we want */
-	out_be32(&regs->miimcon, value);
+	iowrite32be(value, &regs->miimcon);
 
 	/* Wait for the transaction to finish */
-	status = spin_event_timeout(!(in_be32(&regs->miimind) &	MIIMIND_BUSY),
-				    MII_TIMEOUT, 0);
+	status = spin_event_timeout(!(ioread32be(&regs->miimind) &
+				    MIIMIND_BUSY), MII_TIMEOUT, 0);
 
 	return status ? 0 : -ETIMEDOUT;
 }
@@ -137,21 +137,21 @@ static int fsl_pq_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 	u16 value;
 
 	/* Set the PHY address and the register address we want to read */
-	out_be32(&regs->miimadd, (mii_id << 8) | regnum);
+	iowrite32be((mii_id << 8) | regnum, &regs->miimadd);
 
 	/* Clear miimcom, and then initiate a read */
-	out_be32(&regs->miimcom, 0);
-	out_be32(&regs->miimcom, MII_READ_COMMAND);
+	iowrite32be(0, &regs->miimcom);
+	iowrite32be(MII_READ_COMMAND, &regs->miimcom);
 
 	/* Wait for the transaction to finish, normally less than 100us */
-	status = spin_event_timeout(!(in_be32(&regs->miimind) &
+	status = spin_event_timeout(!(ioread32be(&regs->miimind) &
 				    (MIIMIND_NOTVALID | MIIMIND_BUSY)),
 				    MII_TIMEOUT, 0);
 	if (!status)
 		return -ETIMEDOUT;
 
 	/* Grab the value of the register from miimstat */
-	value = in_be32(&regs->miimstat);
+	value = ioread32be(&regs->miimstat);
 
 	dev_dbg(&bus->dev, "read %04x from address %x/%x\n", value, mii_id, regnum);
 	return value;
@@ -167,14 +167,14 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
 	mutex_lock(&bus->mdio_lock);
 
 	/* Reset the management interface */
-	out_be32(&regs->miimcfg, MIIMCFG_RESET);
+	iowrite32be(MIIMCFG_RESET, &regs->miimcfg);
 
 	/* Setup the MII Mgmt clock speed */
-	out_be32(&regs->miimcfg, MIIMCFG_INIT_VALUE);
+	iowrite32be(MIIMCFG_INIT_VALUE, &regs->miimcfg);
 
 	/* Wait until the bus is free */
-	status = spin_event_timeout(!(in_be32(&regs->miimind) &	MIIMIND_BUSY),
-				    MII_TIMEOUT, 0);
+	status = spin_event_timeout(!(ioread32be(&regs->miimind) &
+				    MIIMIND_BUSY), MII_TIMEOUT, 0);
 
 	mutex_unlock(&bus->mdio_lock);
 
@@ -435,7 +435,7 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
 
 			tbipa = data->get_tbipa(priv->map);
 
-			out_be32(tbipa, be32_to_cpup(prop));
+			iowrite32be(be32_to_cpup(prop), tbipa);
 		}
 	}
 
-- 
1.7.11.7

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

* [net 3/8] net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
  2014-10-03 16:02 ` [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM Claudiu Manoil
  2014-10-03 16:02 ` [net 2/8] net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 16:02 ` [net 4/8] gianfar: Include missing headers for ARM builds Claudiu Manoil
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

spin_event_timeout() is PPC dependent, use an arch independent
equivalent instead.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/fsl_pq_mdio.c | 36 ++++++++++++++++++----------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 773b50b..fcbcab1 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -104,7 +104,7 @@ static int fsl_pq_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 {
 	struct fsl_pq_mdio_priv *priv = bus->priv;
 	struct fsl_pq_mii __iomem *regs = priv->regs;
-	u32 status;
+	unsigned int timeout;
 
 	/* Set the PHY address and the register address we want to write */
 	iowrite32be((mii_id << 8) | regnum, &regs->miimadd);
@@ -113,10 +113,13 @@ static int fsl_pq_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
 	iowrite32be(value, &regs->miimcon);
 
 	/* Wait for the transaction to finish */
-	status = spin_event_timeout(!(ioread32be(&regs->miimind) &
-				    MIIMIND_BUSY), MII_TIMEOUT, 0);
+	timeout = MII_TIMEOUT;
+	while ((ioread32be(&regs->miimind) & MIIMIND_BUSY) && timeout) {
+		cpu_relax();
+		timeout--;
+	}
 
-	return status ? 0 : -ETIMEDOUT;
+	return timeout ? 0 : -ETIMEDOUT;
 }
 
 /*
@@ -133,7 +136,7 @@ static int fsl_pq_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 {
 	struct fsl_pq_mdio_priv *priv = bus->priv;
 	struct fsl_pq_mii __iomem *regs = priv->regs;
-	u32 status;
+	unsigned int timeout;
 	u16 value;
 
 	/* Set the PHY address and the register address we want to read */
@@ -144,10 +147,14 @@ static int fsl_pq_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
 	iowrite32be(MII_READ_COMMAND, &regs->miimcom);
 
 	/* Wait for the transaction to finish, normally less than 100us */
-	status = spin_event_timeout(!(ioread32be(&regs->miimind) &
-				    (MIIMIND_NOTVALID | MIIMIND_BUSY)),
-				    MII_TIMEOUT, 0);
-	if (!status)
+	timeout = MII_TIMEOUT;
+	while ((ioread32be(&regs->miimind) &
+	       (MIIMIND_NOTVALID | MIIMIND_BUSY)) && timeout) {
+		cpu_relax();
+		timeout--;
+	}
+
+	if (!timeout)
 		return -ETIMEDOUT;
 
 	/* Grab the value of the register from miimstat */
@@ -162,7 +169,7 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
 {
 	struct fsl_pq_mdio_priv *priv = bus->priv;
 	struct fsl_pq_mii __iomem *regs = priv->regs;
-	u32 status;
+	unsigned int timeout;
 
 	mutex_lock(&bus->mdio_lock);
 
@@ -173,12 +180,15 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
 	iowrite32be(MIIMCFG_INIT_VALUE, &regs->miimcfg);
 
 	/* Wait until the bus is free */
-	status = spin_event_timeout(!(ioread32be(&regs->miimind) &
-				    MIIMIND_BUSY), MII_TIMEOUT, 0);
+	timeout = MII_TIMEOUT;
+	while ((ioread32be(&regs->miimind) & MIIMIND_BUSY) && timeout) {
+		cpu_relax();
+		timeout--;
+	}
 
 	mutex_unlock(&bus->mdio_lock);
 
-	if (!status) {
+	if (!timeout) {
 		dev_err(&bus->dev, "timeout waiting for MII bus\n");
 		return -EBUSY;
 	}
-- 
1.7.11.7

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

* [net 4/8] gianfar: Include missing headers for ARM builds
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (2 preceding siblings ...)
  2014-10-03 16:02 ` [net 3/8] net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 16:02 ` [net 5/8] gianfar: Exclude PPC specific errata handling from " Claudiu Manoil
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

Include linux/of_address.h for of_iomap() and linux/of_irq.h
for irq_of_parse_and_map().

This wasn't an issue for PPC, because these were implicitly
included from asm/prom.h (via linux/of.h) for PPC builds only.
ARM builds need these includes explicitly.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index fb29d04..a488105 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -100,6 +100,8 @@
 #include <linux/phy_fixed.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
 
 #include "gianfar.h"
 
-- 
1.7.11.7

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

* [net 5/8] gianfar: Exclude PPC specific errata handling from ARM builds
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (3 preceding siblings ...)
  2014-10-03 16:02 ` [net 4/8] gianfar: Include missing headers for ARM builds Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 16:02 ` [net 6/8] gianfar: Make MAC addr setup endian safe, cleanup Claudiu Manoil
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

This excludes the PPC specific instructions for PPC based SoC
(MPC85xx family) version identification from ARM builds.
The PPC specific macro mfspr() from asm/reg.h is not defined
by the ARM architecture.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index a488105..37e0604 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -88,8 +88,10 @@
 #include <linux/net_tstamp.h>
 
 #include <asm/io.h>
+#ifdef CONFIG_PPC
 #include <asm/reg.h>
 #include <asm/mpc85xx.h>
+#endif
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 #include <linux/module.h>
@@ -1063,6 +1065,7 @@ static void gfar_init_filer_table(struct gfar_private *priv)
 	}
 }
 
+#ifdef CONFIG_PPC
 static void __gfar_detect_errata_83xx(struct gfar_private *priv)
 {
 	unsigned int pvr = mfspr(SPRN_PVR);
@@ -1095,6 +1098,7 @@ static void __gfar_detect_errata_85xx(struct gfar_private *priv)
 	    ((SVR_SOC_VER(svr) == SVR_P2010) && (SVR_REV(svr) < 0x20)))
 		priv->errata |= GFAR_ERRATA_76; /* aka eTSEC 20 */
 }
+#endif
 
 static void gfar_detect_errata(struct gfar_private *priv)
 {
@@ -1103,10 +1107,12 @@ static void gfar_detect_errata(struct gfar_private *priv)
 	/* no plans to fix */
 	priv->errata |= GFAR_ERRATA_A002;
 
+#ifdef CONFIG_PPC
 	if (pvr_version_is(PVR_VER_E500V1) || pvr_version_is(PVR_VER_E500V2))
 		__gfar_detect_errata_85xx(priv);
 	else /* non-mpc85xx parts, i.e. e300 core based */
 		__gfar_detect_errata_83xx(priv);
+#endif
 
 	if (priv->errata)
 		dev_info(dev, "enabled errata workarounds, flags: 0x%x\n",
-- 
1.7.11.7

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

* [net 6/8] gianfar: Make MAC addr setup endian safe, cleanup
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (4 preceding siblings ...)
  2014-10-03 16:02 ` [net 5/8] gianfar: Exclude PPC specific errata handling from " Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 16:02 ` [net 7/8] gianfar: Replace spin_event_timeout() with arch independent Claudiu Manoil
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

Fix the 32-bit memory access that is not endian safe,
i.e. not giving the desired byte layout for a LE CPU:
tempval = *((u32 *) (tmpbuf + 4)), where 'char tmpbuf[]'.

Get rid of rendundant local vars (tmpbuf[] and idx) and
forced casts.  Cleanup comments.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 37e0604..961198a 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -3248,22 +3248,21 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num,
 {
 	struct gfar_private *priv = netdev_priv(dev);
 	struct gfar __iomem *regs = priv->gfargrp[0].regs;
-	int idx;
-	char tmpbuf[ETH_ALEN];
 	u32 tempval;
 	u32 __iomem *macptr = &regs->macstnaddr1;
 
 	macptr += num*2;
 
-	/* Now copy it into the mac registers backwards, cuz
-	 * little endian is silly
+	/* For a station address of 0x12345678ABCD in transmission
+	 * order (BE), MACnADDR1 is set to 0xCDAB7856 and
+	 * MACnADDR2 is set to 0x34120000.
 	 */
-	for (idx = 0; idx < ETH_ALEN; idx++)
-		tmpbuf[ETH_ALEN - 1 - idx] = addr[idx];
+	tempval = (addr[5] << 24) | (addr[4] << 16) |
+		  (addr[3] << 8)  |  addr[2];
 
-	gfar_write(macptr, *((u32 *) (tmpbuf)));
+	gfar_write(macptr, tempval);
 
-	tempval = *((u32 *) (tmpbuf + 4));
+	tempval = (addr[1] << 24) | (addr[0] << 16);
 
 	gfar_write(macptr+1, tempval);
 }
-- 
1.7.11.7

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

* [net 7/8] gianfar: Replace spin_event_timeout() with arch independent
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (5 preceding siblings ...)
  2014-10-03 16:02 ` [net 6/8] gianfar: Make MAC addr setup endian safe, cleanup Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 16:02 ` [net 8/8] gianfar: Replace eieio with wmb for non-PPC archs Claudiu Manoil
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

Use arch independent code to replace the powerpc dependent
spin_event_timeout() from gfar_halt_nodisable().
Added GRS/GTS read accessors to clean-up the implementation
of gfar_halt_nodisable().

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 32 +++++++++++++++++++-------------
 drivers/net/ethernet/freescale/gianfar.h | 15 +++++++++++++++
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 961198a..356a998 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1762,26 +1762,32 @@ static void gfar_halt_nodisable(struct gfar_private *priv)
 {
 	struct gfar __iomem *regs = priv->gfargrp[0].regs;
 	u32 tempval;
+	unsigned int timeout;
+	int stopped;
 
 	gfar_ints_disable(priv);
 
+	if (gfar_is_dma_stopped(priv))
+		return;
+
 	/* Stop the DMA, and wait for it to stop */
 	tempval = gfar_read(&regs->dmactrl);
-	if ((tempval & (DMACTRL_GRS | DMACTRL_GTS)) !=
-	    (DMACTRL_GRS | DMACTRL_GTS)) {
-		int ret;
-
-		tempval |= (DMACTRL_GRS | DMACTRL_GTS);
-		gfar_write(&regs->dmactrl, tempval);
+	tempval |= (DMACTRL_GRS | DMACTRL_GTS);
+	gfar_write(&regs->dmactrl, tempval);
 
-		do {
-			ret = spin_event_timeout(((gfar_read(&regs->ievent) &
-				 (IEVENT_GRSC | IEVENT_GTSC)) ==
-				 (IEVENT_GRSC | IEVENT_GTSC)), 1000000, 0);
-			if (!ret && !(gfar_read(&regs->ievent) & IEVENT_GRSC))
-				ret = __gfar_is_rx_idle(priv);
-		} while (!ret);
+retry:
+	timeout = 1000;
+	while (!(stopped = gfar_is_dma_stopped(priv)) && timeout) {
+		cpu_relax();
+		timeout--;
 	}
+
+	if (!timeout)
+		stopped = gfar_is_dma_stopped(priv);
+
+	if (!stopped && !gfar_is_rx_dma_stopped(priv) &&
+	    !__gfar_is_rx_idle(priv))
+		goto retry;
 }
 
 /* Halt the receive and transmit queues */
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 84632c5..0b37722 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1226,6 +1226,21 @@ static inline void gfar_write_isrg(struct gfar_private *priv)
 	}
 }
 
+static inline int gfar_is_dma_stopped(struct gfar_private *priv)
+{
+	struct gfar __iomem *regs = priv->gfargrp[0].regs;
+
+	return ((gfar_read(&regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) ==
+	       (IEVENT_GRSC | IEVENT_GTSC));
+}
+
+static inline int gfar_is_rx_dma_stopped(struct gfar_private *priv)
+{
+	struct gfar __iomem *regs = priv->gfargrp[0].regs;
+
+	return gfar_read(&regs->ievent) & IEVENT_GRSC;
+}
+
 irqreturn_t gfar_receive(int irq, void *dev_id);
 int startup_gfar(struct net_device *dev);
 void stop_gfar(struct net_device *dev);
-- 
1.7.11.7

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

* [net 8/8] gianfar: Replace eieio with wmb for non-PPC archs
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (6 preceding siblings ...)
  2014-10-03 16:02 ` [net 7/8] gianfar: Replace spin_event_timeout() with arch independent Claudiu Manoil
@ 2014-10-03 16:02 ` Claudiu Manoil
  2014-10-03 21:20 ` [net 0/8] gianfar: ARM port driver updates (1/2) Kim Phillips
  2014-10-06  1:27 ` David Miller
  9 siblings, 0 replies; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-03 16:02 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

Replace PPC specific eieio() with arch independent wmb()
for other architectures, i.e. ARM.
The eieio() macro is not defined on ARM and generates
build error.

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
 drivers/net/ethernet/freescale/gianfar.c | 13 +++----------
 drivers/net/ethernet/freescale/gianfar.h | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 356a998..379b1a5 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -165,7 +165,7 @@ static void gfar_init_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
 	if (bdp == rx_queue->rx_bd_base + rx_queue->rx_ring_size - 1)
 		lstatus |= BD_LFLAG(RXBD_WRAP);
 
-	eieio();
+	gfar_wmb();
 
 	bdp->lstatus = lstatus;
 }
@@ -2371,18 +2371,11 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	 */
 	spin_lock_irqsave(&tx_queue->txlock, flags);
 
-	/* The powerpc-specific eieio() is used, as wmb() has too strong
-	 * semantics (it requires synchronization between cacheable and
-	 * uncacheable mappings, which eieio doesn't provide and which we
-	 * don't need), thus requiring a more expensive sync instruction.  At
-	 * some point, the set of architecture-independent barrier functions
-	 * should be expanded to include weaker barriers.
-	 */
-	eieio();
+	gfar_wmb();
 
 	txbdp_start->lstatus = lstatus;
 
-	eieio(); /* force lstatus write before tx_skbuff */
+	gfar_wmb(); /* force lstatus write before tx_skbuff */
 
 	tx_queue->tx_skbuff[tx_queue->skb_curtx] = skb;
 
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 0b37722..2805cfb 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1241,6 +1241,22 @@ static inline int gfar_is_rx_dma_stopped(struct gfar_private *priv)
 	return gfar_read(&regs->ievent) & IEVENT_GRSC;
 }
 
+static inline void gfar_wmb(void)
+{
+#if defined(CONFIG_PPC)
+	/* The powerpc-specific eieio() is used, as wmb() has too strong
+	 * semantics (it requires synchronization between cacheable and
+	 * uncacheable mappings, which eieio() doesn't provide and which we
+	 * don't need), thus requiring a more expensive sync instruction.  At
+	 * some point, the set of architecture-independent barrier functions
+	 * should be expanded to include weaker barriers.
+	 */
+	eieio();
+#else
+	wmb(); /* order write acesses for BD (or FCB) fields */
+#endif
+}
+
 irqreturn_t gfar_receive(int irq, void *dev_id);
 int startup_gfar(struct net_device *dev);
 void stop_gfar(struct net_device *dev);
-- 
1.7.11.7

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

* Re: [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM
  2014-10-03 16:02 ` [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM Claudiu Manoil
@ 2014-10-03 18:39   ` Sergei Shtylyov
  0 siblings, 0 replies; 14+ messages in thread
From: Sergei Shtylyov @ 2014-10-03 18:39 UTC (permalink / raw)
  To: Claudiu Manoil, netdev; +Cc: David S. Miller, Xiubo Li, Shruti Kanetkar

Hello.

On 10/03/2014 08:02 PM, Claudiu Manoil wrote:

> The UCC specific code included in fsl_pq_mdio.c (with
> function calls from asm/ucc.h) is already guarded
> by these config options, so this ARM build fix provides
> consistency with the rest UCC specific code.

> Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
> ---
>   drivers/net/ethernet/freescale/fsl_pq_mdio.c | 2 ++
>   1 file changed, 2 insertions(+)

> diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
> index 583e71a..89b3fea 100644
> --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
> +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
> @@ -28,7 +28,9 @@
>   #include <linux/of_device.h>
>
>   #include <asm/io.h>
> +#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)

    Use IS_ENABLED(CONFIG_UCC_GETH) instead.

WBR, Sergei

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

* Re: [net 0/8] gianfar: ARM port driver updates (1/2)
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (7 preceding siblings ...)
  2014-10-03 16:02 ` [net 8/8] gianfar: Replace eieio with wmb for non-PPC archs Claudiu Manoil
@ 2014-10-03 21:20 ` Kim Phillips
  2014-10-06  1:27 ` David Miller
  9 siblings, 0 replies; 14+ messages in thread
From: Kim Phillips @ 2014-10-03 21:20 UTC (permalink / raw)
  To: Claudiu Manoil; +Cc: netdev, David S. Miller, Xiubo Li, Shruti Kanetkar

On Fri, 3 Oct 2014 19:02:41 +0300
Claudiu Manoil <claudiu.manoil@freescale.com> wrote:

> Claudiu Manoil (8):
>   net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM
>   net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors
>   net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent
>   gianfar: Include missing headers for ARM builds
>   gianfar: Exclude PPC specific errata handling from ARM builds
>   gianfar: Make MAC addr setup endian safe, cleanup
>   gianfar: Replace spin_event_timeout() with arch independent
>   gianfar: Replace eieio with wmb for non-PPC archs
> 
>  drivers/net/ethernet/freescale/fsl_pq_mdio.c | 56 ++++++++++++++---------
>  drivers/net/ethernet/freescale/gianfar.c     | 68 +++++++++++++++-------------
>  drivers/net/ethernet/freescale/gianfar.h     | 31 +++++++++++++
>  3 files changed, 102 insertions(+), 53 deletions(-)

this series:

Reviewed-by: Kim Phillips <kim.phillips@freescale.com>

Thanks,

Kim

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

* Re: [net 0/8] gianfar: ARM port driver updates (1/2)
  2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
                   ` (8 preceding siblings ...)
  2014-10-03 21:20 ` [net 0/8] gianfar: ARM port driver updates (1/2) Kim Phillips
@ 2014-10-06  1:27 ` David Miller
  2014-10-06  7:55   ` Claudiu Manoil
  9 siblings, 1 reply; 14+ messages in thread
From: David Miller @ 2014-10-06  1:27 UTC (permalink / raw)
  To: claudiu.manoil; +Cc: netdev, Li.Xiubo, Shruti

From: Claudiu Manoil <claudiu.manoil@freescale.com>
Date: Fri, 3 Oct 2014 19:02:41 +0300

> This is the first round of driver protability fixes and clean-up
> with the main purpose to make gianfar portable on ARM, for the ARM
> based SoC that integrates the eTSEC ethernet controller - "ls1021a".
> The patches primarily address compile time errors, when compiling
> gianfar on ARM.  They replace PPC specific functions and macros
> with architecture independent ones, solve arch specific header
> inclusions, guard code that relates to PPC only, and even address
> some simple endianess issues (see MAC address setup patch).
> The patches addressing the bulk of remaining endianess issues,
> like handling DMA fields (BD and FCB), will follow with the sencond
> round.
> These patches were verified on the ls1021a SoC.

If more endianness fixes are necessary and "will follow with the
second round", I do not see how you could have verified specifically
these changes on the ls1021a.

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

* Re: [net 0/8] gianfar: ARM port driver updates (1/2)
  2014-10-06  1:27 ` David Miller
@ 2014-10-06  7:55   ` Claudiu Manoil
  2014-10-06 19:07     ` David Miller
  0 siblings, 1 reply; 14+ messages in thread
From: Claudiu Manoil @ 2014-10-06  7:55 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Li.Xiubo, Shruti

On 10/6/2014 4:27 AM, David Miller wrote:
> From: Claudiu Manoil <claudiu.manoil@freescale.com>
> Date: Fri, 3 Oct 2014 19:02:41 +0300
>
>> This is the first round of driver protability fixes and clean-up
>> with the main purpose to make gianfar portable on ARM, for the ARM
>> based SoC that integrates the eTSEC ethernet controller - "ls1021a".
>> The patches primarily address compile time errors, when compiling
>> gianfar on ARM.  They replace PPC specific functions and macros
>> with architecture independent ones, solve arch specific header
>> inclusions, guard code that relates to PPC only, and even address
>> some simple endianess issues (see MAC address setup patch).
>> The patches addressing the bulk of remaining endianess issues,
>> like handling DMA fields (BD and FCB), will follow with the sencond
>> round.
>> These patches were verified on the ls1021a SoC.
>
> If more endianness fixes are necessary and "will follow with the
> second round", I do not see how you could have verified specifically
> these changes on the ls1021a.
>

Hi David,

What I did is to split the initial patchset in 2, to ease up the review
process.
This first part is fairly straightforward, these patches make localized
code changes and can be more easily ported among different kernel 
versions.  The second part has fewer patches but touches more code,
because it handles endianess conversions for all the reads/writes to
the buffer descriptors.  Please let me now if you have objections to
this approach.
As for testing, we have our internal kernel tree for ARM supporting
ls1021a, and these gianfar patches have been there for a while and 
tested.  Now it's time to upstream (a cleaned-up version of) them.
(see git.freescale.com/git/cgit.cgi/layerscape/ls1021a/linux.git/)
Please note that the current (upstream) net tree does not include the
support for ls1021a (which is to be propagated via the arm tree).

Thanks and regards,
Claudiu

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

* Re: [net 0/8] gianfar: ARM port driver updates (1/2)
  2014-10-06  7:55   ` Claudiu Manoil
@ 2014-10-06 19:07     ` David Miller
  0 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2014-10-06 19:07 UTC (permalink / raw)
  To: claudiu.manoil; +Cc: netdev, Li.Xiubo, Shruti

From: Claudiu Manoil <claudiu.manoil@freescale.com>
Date: Mon, 6 Oct 2014 10:55:42 +0300

> On 10/6/2014 4:27 AM, David Miller wrote:
>> From: Claudiu Manoil <claudiu.manoil@freescale.com>
>> Date: Fri, 3 Oct 2014 19:02:41 +0300
>>
>>> This is the first round of driver protability fixes and clean-up
>>> with the main purpose to make gianfar portable on ARM, for the ARM
>>> based SoC that integrates the eTSEC ethernet controller - "ls1021a".
>>> The patches primarily address compile time errors, when compiling
>>> gianfar on ARM.  They replace PPC specific functions and macros
>>> with architecture independent ones, solve arch specific header
>>> inclusions, guard code that relates to PPC only, and even address
>>> some simple endianess issues (see MAC address setup patch).
>>> The patches addressing the bulk of remaining endianess issues,
>>> like handling DMA fields (BD and FCB), will follow with the sencond
>>> round.
>>> These patches were verified on the ls1021a SoC.
>>
>> If more endianness fixes are necessary and "will follow with the
>> second round", I do not see how you could have verified specifically
>> these changes on the ls1021a.
>>
> 
> Hi David,
> 
> What I did is to split the initial patchset in 2, to ease up the
> review
> process.
> This first part is fairly straightforward, these patches make
> localized
> code changes and can be more easily ported among different kernel
> versions.  The second part has fewer patches but touches more code,
> because it handles endianess conversions for all the reads/writes to
> the buffer descriptors.  Please let me now if you have objections to
> this approach.
> As for testing, we have our internal kernel tree for ARM supporting
> ls1021a, and these gianfar patches have been there for a while and
> tested.  Now it's time to upstream (a cleaned-up version of) them.
> (see git.freescale.com/git/cgit.cgi/layerscape/ls1021a/linux.git/)
> Please note that the current (upstream) net tree does not include the
> support for ls1021a (which is to be propagated via the arm tree).

I'm merely saying that it's inaccurate to say that you "verified" this
specific patch series on that chip, when in fact the second upcoming
series is necessary as well for the driver to work on that chip properly.

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

end of thread, other threads:[~2014-10-06 19:07 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-03 16:02 [net 0/8] gianfar: ARM port driver updates (1/2) Claudiu Manoil
2014-10-03 16:02 ` [net 1/8] net/fsl_pq_mdio: Fix asm/ucc.h compile error for ARM Claudiu Manoil
2014-10-03 18:39   ` Sergei Shtylyov
2014-10-03 16:02 ` [net 2/8] net/fsl_pq_mdio: Use ioread/iowrite32be() portable accessors Claudiu Manoil
2014-10-03 16:02 ` [net 3/8] net/fsl_pq_mdio: Replace spin_event_timeout() with arch independent Claudiu Manoil
2014-10-03 16:02 ` [net 4/8] gianfar: Include missing headers for ARM builds Claudiu Manoil
2014-10-03 16:02 ` [net 5/8] gianfar: Exclude PPC specific errata handling from " Claudiu Manoil
2014-10-03 16:02 ` [net 6/8] gianfar: Make MAC addr setup endian safe, cleanup Claudiu Manoil
2014-10-03 16:02 ` [net 7/8] gianfar: Replace spin_event_timeout() with arch independent Claudiu Manoil
2014-10-03 16:02 ` [net 8/8] gianfar: Replace eieio with wmb for non-PPC archs Claudiu Manoil
2014-10-03 21:20 ` [net 0/8] gianfar: ARM port driver updates (1/2) Kim Phillips
2014-10-06  1:27 ` David Miller
2014-10-06  7:55   ` Claudiu Manoil
2014-10-06 19:07     ` David Miller

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