Skip to contentSkip to conversation

: arm: Kirkwood: Various egiga send fixes

PATCH New Simon Kagstrom 3 participants 12 messages Jul 2, 2009 – Aug 17, 2009 Network drivers

lore
Share & tools
lore
#0 lore raw

cover : arm: Kirkwood: Various egiga send fixes

Hi!

These three patches fix a few issues I've had with sending data on the network interface on the OpenRD base board. In summary, they do:

- Fix compiler optimization bug in kwgbe_send
- Check the error summary bit during send
- Allow sending data which is not 8-byte aligned

// Simon

#1 lore raw

PATCH 1/3 : arm: Kirkwood: Fix compiler optimization bug for kwgbe_send

Fix compiler optimization bug for kwgbe_send

kwgbe_send/recv both have loops waiting for the hardware to set a bit. GCC 4.3.3 cleverly optimizes the send case to ... a while(1); loop. This patch makes the structure volatile to force re-loading of the transmit descriptor.

---
 drivers/net/kirkwood_egiga.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/kirkwood_egiga.c +3 -3
index 3c5db19..db55d9d 100644
@@ -484,9 +484,9 @@ static int kwgbe_halt(struct eth_device *dev)
 static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
 		      int datasize)
 {
-	struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
-	struct kwgbe_registers *regs = dkwgbe->regs;
-	struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
+	volatile struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
+	volatile struct kwgbe_registers *regs = dkwgbe->regs;
+	volatile struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
 
 	if ((u32) dataptr & 0x07) {
 		printf("Err..(%s) xmit dataptr not 64bit aligned\n",
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 1/3 : arm: Kirkwood: Fix compiler optimization bug for kwgbe_send

Quoted 29 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Simon Kagstrom
Sent: Thursday, July 02, 2009 6:32 PM
To: Simon Kagstrom
Cc: U-Boot ML
Subject: [U-Boot] [PATCH 1/3]: arm: Kirkwood: Fix compiler optimization bug for kwgbe_send

Fix compiler optimization bug for kwgbe_send

kwgbe_send/recv both have loops waiting for the hardware to set a bit.
GCC 4.3.3 cleverly optimizes the send case to ... a while(1); loop. This patch makes the structure volatile to force re-loading of the transmit descriptor.

---
 drivers/net/kirkwood_egiga.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/net/kirkwood_egiga.c index 3c5db19..db55d9d 100644

drivers/net/kirkwood_egiga.c static int kwgbe_halt(struct eth_device · line 490

Quoted 10 lines
drivers/net/kirkwood_egiga.c +3 -3
@@ -484,9 +484,9 @@ static int kwgbe_halt(struct eth_device 
 *dev)  static int kwgbe_send(struct eth_device *dev, volatile 
 void *dataptr,
 		      int datasize)
 {
-	struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
-	struct kwgbe_registers *regs = dkwgbe->regs;
-	struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
+	volatile struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
+	volatile struct kwgbe_registers *regs = dkwgbe->regs;
+	volatile struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;

Only p_txdesc needed volatile, not others...

Regards ....
Prafulla . .

#3 lore raw

PATCH 1/3 : arm: Kirkwood: Fix compiler optimization bug for kwgbe_send

Thanks for the comments Prafulla!

Quoted 4 lines · On Thu, 2 Jul 2009 21:36:19 -0700 Prafulla Wadaskar <[email protected]>…

Review

Quoted 3 lines
(quoted diff) +3 -0
+	volatile struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
+	volatile struct kwgbe_registers *regs = dkwgbe->regs;
+	volatile struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;

Only p_txdesc needed volatile, not others...

Right - I just took the approach from kwgbe_recv. Here is an updated patch which only makes the transmit descriptor volatile.

// Simon
--
Fix compiler optimization bug for kwgbe_send

kwgbe_send/recv both have loops waiting for the hardware to set a bit. GCC 4.3.3 cleverly optimizes the send case to ... a while(1); loop. This patch makes the structure volatile to force re-loading of the transmit descriptor.

---
 drivers/net/kirkwood_egiga.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/kirkwood_egiga.c +1 -1
index 3c5db19..b8a771f 100644
@@ -486,7 +486,7 @@ static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
 {
 	struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
 	struct kwgbe_registers *regs = dkwgbe->regs;
-	struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
+	volatile struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
 
 	if ((u32) dataptr & 0x07) {
 		printf("Err..(%s) xmit dataptr not 64bit aligned\n",
Signature · 1 line
1.6.0.4
#4 lore raw

PATCH 2/3 : arm: Kirkwood: Check the error summary bit for error detection

In reply to Simon Kagstrom

Check the error summary bit for error detection

The Marvell documentation for the 88f6281 states that the error coding is only valid if the error summary and last frame bits in the transmit descriptor status field are set. This patch adds checks for these for transmit (I would get transmit errors on bootp with the current check, which I believe are spurious).

---
 drivers/net/kirkwood_egiga.c |    4 +++-
 drivers/net/kirkwood_egiga.h |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/kirkwood_egiga.c +3 -1
index db55d9d..ecd3a28 100644
@@ -509,7 +509,9 @@ static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
 	 */
 	while (p_txdesc->cmd_sts & KWGBE_BUFFER_OWNED_BY_DMA) {
 		/* return fail if error is detected */
-		if (p_txdesc->cmd_sts & (KWGBE_UR_ERROR | KWGBE_RL_ERROR)) {
+		if ((p_txdesc->cmd_sts & (KWGBE_ERROR_SUMMARY | KWGBE_TX_LAST_FRAME)) ==
+				(KWGBE_ERROR_SUMMARY | KWGBE_TX_LAST_FRAME) &&
+				p_txdesc->cmd_sts & (KWGBE_UR_ERROR | KWGBE_RL_ERROR)) {
 			printf("Err..(%s) in xmit packet\n", __FUNCTION__);
 			return -1;
 		}
drivers/net/kirkwood_egiga.h +1 -0
index 8b67c9c..be85280 100644
@@ -256,6 +256,7 @@
 #define KWGBE_UR_ERROR			(1 << 1)
 #define KWGBE_RL_ERROR			(1 << 2)
 #define KWGBE_LLC_SNAP_FORMAT		(1 << 9)
+#define KWGBE_TX_LAST_FRAME     (1 << 20)
 
 /* Rx descriptors status */
 #define KWGBE_CRC_ERROR			0
Signature · 1 line
1.6.0.4
#5 lore raw

PATCH 2/3 : arm: Kirkwood: Check the error summary bit for error detection

Dear Ben,

In message <[email protected]> Simon

Quoted 8 lines · Kagstrom

Check the error summary bit for error detection

The Marvell documentation for the 88f6281 states that the error coding is only valid if the error summary and last frame bits in the transmit descriptor status field are set. This patch adds checks for these for transmit (I would get transmit errors on bootp with the current check, which I believe are spurious).

Quoted 5 lines
---
 drivers/net/kirkwood_egiga.c |    4 +++-
 drivers/net/kirkwood_egiga.h |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)

Ping?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's hard to make a program foolproof because fools are so ingenious.
#6 lore raw

PATCH 2/3 : arm: Kirkwood: Check the error summary bit for error detection

Quoted 27 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Wolfgang Denk
Sent: Thursday, August 06, 2009 2:37 AM
To: Ben Warren
Cc: U-Boot ML
Subject: Re: [U-Boot] [PATCH 2/3]: arm: Kirkwood: Check the error summary bit for error detection

Dear Ben,

In message <[email protected]>

Quoted 3 lines · Simon Kagstrom

Check the error summary bit for error detection

The Marvell documentation for the 88f6281 states that the

error coding

Quoted 1 line

is only valid if the error summary and last frame bits in

the transmit

Quoted 1 line

descriptor status field are set. This patch adds checks for

these for

Quoted 1 line

transmit (I would get transmit errors on bootp with the

current check,

Quoted 2 lines

which I believe are spurious).

Quoted 7 lines
Quoted 5 lines
---
 drivers/net/kirkwood_egiga.c |    4 +++-
 drivers/net/kirkwood_egiga.h |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)

Ping?

This patch is already applied
Regards..
Prafulla . .

Quoted 16 lines

Best regards,

Wolfgang Denk

Signature · 9 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: 
wd at denx.de It's hard to make a program foolproof because 
fools are so ingenious.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#7 lore raw

PATCH 2/3 : arm: Kirkwood: Check the error summary bit for error detection

Dear Prafulla Wadaskar,

Quoted 3 lines · In message <[email protected]>…
Quoted 2 lines

Ping?

This patch is already applied

Ah. thanks for pointing out.

Best regards,

Wolfgang Denk

Signature · 8 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The people of Gideon have always believed that life is  sacred.  That
the  love  of  life  is  the  greatest  gift  ... We are incapable of
destroying or interfering with the creation of that which we love  so
deeply -- life in every form from fetus to developed being.
	-- Hodin of Gideon, "The Mark of Gideon", stardate 5423.4
#8 lore raw

PATCH 3/3 : arm: Kirkwood: See to it that sent data is 8-byte aligned

In reply to Simon Kagstrom

See to it that sent data is 8-byte aligned

U-boot might use non-8-byte-aligned addresses for sending data, which the kwgbe_send doesn't accept (bootp does this for me). This patch copies the data to be sent to a temporary buffer if it is non-aligned.

---
 drivers/net/kirkwood_egiga.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)
drivers/net/kirkwood_egiga.c +20 -6
index ecd3a28..1fe549c 100644
@@ -481,18 +481,13 @@ static int kwgbe_halt(struct eth_device *dev)
 	return 0;
 }
 
-static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
+static int kwgbe_send_aligned(struct eth_device *dev, volatile void *dataptr,
 		      int datasize)
 {
 	volatile struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
 	volatile struct kwgbe_registers *regs = dkwgbe->regs;
 	volatile struct kwgbe_txdesc *p_txdesc = dkwgbe->p_txdesc;
 
-	if ((u32) dataptr & 0x07) {
-		printf("Err..(%s) xmit dataptr not 64bit aligned\n",
-			__FUNCTION__);
-		return -1;
-	}
 	p_txdesc->cmd_sts = KWGBE_ZERO_PADDING | KWGBE_GEN_CRC;
 	p_txdesc->cmd_sts |= KWGBE_TX_FIRST_DESC | KWGBE_TX_LAST_DESC;
 	p_txdesc->cmd_sts |= KWGBE_BUFFER_OWNED_BY_DMA;
@@ -519,6 +514,25 @@ static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
 	return 0;
 }
 
+static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
+		      int datasize)
+{
+	static u8 __attribute__((aligned(8))) aligned_buf[9000];
+	void *p = (void*)dataptr;
+
+	if ((u32) dataptr & 0x07) {
+		if (datasize > sizeof(aligned_buf)) {
+			printf("Err..(%s) Non-aligned data is too large: %d bytes\n",
+				__FUNCTION__, datasize);
+			return -1;
+		}
+		memcpy(aligned_buf, p, datasize);
+		p = aligned_buf;
+	}
+
+	return kwgbe_send_aligned(dev, p, datasize);
+}
+
 static int kwgbe_recv(struct eth_device *dev)
 {
 	volatile struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
Signature · 1 line
1.6.0.4
#9 lore raw

PATCH 3/3 : arm: Kirkwood: See to it that sent data is 8-byte aligned

Dear Simon Kagstrom,

In message <[email protected]> Simon

Quoted 10 lines · Kagstrom

See to it that sent data is 8-byte aligned

U-boot might use non-8-byte-aligned addresses for sending data, which the kwgbe_send doesn't accept (bootp does this for me). This patch copies the data to be sent to a temporary buffer if it is non-aligned.

---
 drivers/net/kirkwood_egiga.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

Ping?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q:  Why do mountain climbers rope themselves together?
A:  To prevent the sensible ones from going home.
#10 lore raw

PATCH 3/3 : arm: Kirkwood: See to it that sent data is 8-byte aligned

Quoted 15 lines

-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Wolfgang Denk
Sent: Thursday, August 06, 2009 2:38 AM
To: Ben Warren
Cc: U-Boot ML
Subject: Re: [U-Boot] [PATCH 3/3]: arm: Kirkwood: See to it that sent data is 8-byte aligned

Dear Simon Kagstrom,

In message <[email protected]> Simon Kagstrom wrote:

Quoted 7 lines
Quoted 3 lines

See to it that sent data is 8-byte aligned

U-boot might use non-8-byte-aligned addresses for sending

data, which

Quoted 2 lines

the kwgbe_send doesn't accept (bootp does this for me). This patch copies the data to be sent to a temporary buffer if it is

non-aligned.

Ack,
This is useful patch for kirkwood egiga driver,
I have tested it -possible pls get this in.

On the other hand-
I had a suggestion to do this in upper layer (i.e. in net/eth.c) so that every client driver can benefit from this. But we can do this latter too.

Regards..
Prafulla . .

Quoted 23 lines
Quoted 5 lines
---
 drivers/net/kirkwood_egiga.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

Ping?

Best regards,

Wolfgang Denk

Signature · 9 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q:  Why do mountain climbers rope themselves together?
A:  To prevent the sensible ones from going home.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#11 lore raw

PATCH 3/3 : arm: Kirkwood: See to it that sent data is 8-byte aligned

In reply to Wolfgang Denk
Quoted 8 lines · On Wed, 05 Aug 2009 23:08:16 +0200 Wolfgang Denk <[email protected]> wrote:

In message <[email protected]> Simon

Quoted 6 lines · Kagstrom

See to it that sent data is 8-byte aligned

U-boot might use non-8-byte-aligned addresses for sending data, which the kwgbe_send doesn't accept (bootp does this for me). This patch copies the data to be sent to a temporary buffer if it is non-aligned.

Quoted 6 lines
Quoted 4 lines
---
 drivers/net/kirkwood_egiga.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

Ping?

Ack!

I've been on vacation but I'm back now. I'll start reworking the non-accepted patches from this series according to the comments I got. The series consisted of

(not accepted) [PATCH 1/4]: arm: Kirkwood: Set MAC address during registration for kirkwood egiga
(accepted, applied) [PATCH 2/4]: arm: Kirkwood: Fix compiler optimization bug for kwgbe_send (accepted, applied) [PATCH 3/4]: arm: Kirkwood: Check the error summary bit for error detection
(not accepted) [PATCH 4/4]: arm: Kirkwood: See to it that sent data is 8-byte aligned

// Simon