public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC] MUSB: Workaround for Ethernet data alignment issue
@ 2009-12-14  4:50 Patra, Nilkesh
       [not found] ` <B85A65D85D7EB246BE421B3FB0FBB59301DEAB8723-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
  2009-12-15 10:13 ` Matthieu CASTET
  0 siblings, 2 replies; 6+ messages in thread
From: Patra, Nilkesh @ 2009-12-14  4:50 UTC (permalink / raw)
  To: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
  Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	David Brownell, Gadiyar, Anand

On the latest version of MUSB, DMA is not working properly if the Data in the packet doesn't start at 32bit aligned address. This issue was found while using MUSB as g_ether. The basic ping does not work, if the data in the Ethernet  packet does not start at 32bit aligned address.

To overcome this issue, we found one solution mentioned in the below patch. This patch moves data (skb->data) by 2 bytes backwards in ethernet packet, which is nothing but skb->head.

I want to know, if there are any better approaches to fix this issue.

Signed-off-by: Nilkesh Patra <nilkesh.patra-l0cyMroinI0@public.gmane.org>
---
 drivers/usb/gadget/u_ether.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 2fc02bd..432b1bd 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -249,7 +249,6 @@ rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags)
 	 * but on at least one, checksumming fails otherwise.  Note:
 	 * RNDIS headers involve variable numbers of LE32 values.
 	 */
-	skb_reserve(skb, NET_IP_ALIGN);
 
 	req->buf = skb->data;
 	req->length = size;
@@ -500,6 +499,8 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
 	unsigned long		flags;
 	struct usb_ep		*in;
 	u16			cdc_filter;
+	int			i = 0;
+
 
 	spin_lock_irqsave(&dev->lock, flags);
 	if (dev->port_usb) {
@@ -573,9 +574,6 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
 
 		length = skb->len;
 	}
-	req->buf = skb->data;
-	req->context = skb;
-	req->complete = tx_complete;
 
 	/* use zlp framing on tx for strict CDC-Ether conformance,
 	 * though any robust network rx path ignores extra padding.
@@ -585,6 +583,14 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
 	if (!dev->zlp && (length % in->maxpacket) == 0)
 		length++;
 
+	if ((int)skb->data & 0x2) {
+		skb_push(skb, 2);
+		for (i = 0; i < length; i++)
+			skb->data[i] = skb->data[i+2];
+	}
+	req->buf = skb->data;
+	req->context = skb;
+	req->complete = tx_complete;
 	req->length = length;
 
 	/* throttle highspeed IRQ rate back slightly */
-- 
1.5.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2009-12-16  7:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-14  4:50 [RFC] MUSB: Workaround for Ethernet data alignment issue Patra, Nilkesh
     [not found] ` <B85A65D85D7EB246BE421B3FB0FBB59301DEAB8723-/tLxBxkBPtCIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-12-14 17:39   ` Pandita, Vikram
2009-12-14 20:30     ` Sonasath, Moiz
2009-12-16  7:11     ` Patra, Nilkesh
2009-12-15 10:13 ` Matthieu CASTET
     [not found]   ` <4B276145.1080909-ITF29qwbsa/QT0dZR+AlfA@public.gmane.org>
2009-12-15 10:28     ` Matthieu CASTET

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