Subject: Re: net/usb/ax88179_178a driver broken in linux-3.12

From: Mark Lord <[email-masked]>
Date: Tue, 19 Nov 2013 08:44:58 -0500

On 13-11-19 05:04 AM, David Laight wrote:
>
> Which changes did you revert?

Just the bits that changed how the headroom/tailroom sizes
were checked and adjusted.  See attachment for the revert patch
I am using here.  My mailer unfortunately likes to mangle inline patches.

=========snip===========
Revert USB 3.0 network driver changes that break the adapter (lockups)
in 3.12.  This just puts back the original code from previous kernels.

Signed-off-by: Mark Lord <[email-masked]>

--- linux/drivers/net/usb/ax88179_178a.c.orig   2013-11-03 18:41:51.000000000 -0500
+++ linux/drivers/net/usb/ax88179_178a.c        2013-11-17 13:23:39.525734277 -0500
@@ -1177,18 +1177,31 @@
        int frame_size = dev->maxpacket;
        int mss = skb_shinfo(skb)->gso_size;
        int headroom;
+       int tailroom;

        tx_hdr1 = skb->len;
        tx_hdr2 = mss;
        if (((skb->len + 8) % frame_size) == 0)
                tx_hdr2 |= 0x80008000;  /* Enable padding */

-       headroom = skb_headroom(skb) - 8;
+       headroom = skb_headroom(skb);
+       tailroom = skb_tailroom(skb);

-       if ((skb_header_cloned(skb) || headroom < 0) &&
-           pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) {
+       if (!skb_header_cloned(skb) &&
+           !skb_cloned(skb) &&
+           (headroom + tailroom) >= 8) {
+               if (headroom < 8) {
+                       skb->data = memmove(skb->head + 8, skb->data, skb->len);
+                       skb_set_tail_pointer(skb, skb->len);
+               }
+       } else {
+               struct sk_buff *skb2;
+
+               skb2 = skb_copy_expand(skb, 8, 0, flags);
                dev_kfree_skb_any(skb);
-               return NULL;
+               skb = skb2;
+               if (!skb)
+                       return NULL;
        }

        skb_push(skb, 4);
-- 
Mark Lord
Real-Time Remedies Inc.
[email-masked]
Revert USB 3.0 network driver changes that break the adapter (lockups)
in 3.12.  This just puts back the original code from previous kernels.

Signed-off-by: Mark Lord <[email-masked]>

--- linux/drivers/net/usb/ax88179_178a.c.orig	2013-11-03 18:41:51.000000000 -0500
+++ linux/drivers/net/usb/ax88179_178a.c	2013-11-17 13:23:39.525734277 -0500
@@ -1177,18 +1177,31 @@
 	int frame_size = dev->maxpacket;
 	int mss = skb_shinfo(skb)->gso_size;
 	int headroom;
+	int tailroom;
 
 	tx_hdr1 = skb->len;
 	tx_hdr2 = mss;
 	if (((skb->len + 8) % frame_size) == 0)
 		tx_hdr2 |= 0x80008000;	/* Enable padding */
 
-	headroom = skb_headroom(skb) - 8;
+	headroom = skb_headroom(skb);
+	tailroom = skb_tailroom(skb);
 
-	if ((skb_header_cloned(skb) || headroom < 0) &&
-	    pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) {
+	if (!skb_header_cloned(skb) &&
+	    !skb_cloned(skb) &&
+	    (headroom + tailroom) >= 8) {
+		if (headroom < 8) {
+			skb->data = memmove(skb->head + 8, skb->data, skb->len);
+			skb_set_tail_pointer(skb, skb->len);
+		}
+	} else {
+		struct sk_buff *skb2;
+
+		skb2 = skb_copy_expand(skb, 8, 0, flags);
 		dev_kfree_skb_any(skb);
-		return NULL;
+		skb = skb2;
+		if (!skb)
+			return NULL;
 	}
 
 	skb_push(skb, 4);