<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/net/usb/asix_common.c, branch linux-4.16.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-4.16.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-4.16.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2017-09-23T03:43:13+00:00</updated>
<entry>
<title>net: Remove useless function skb_header_release</title>
<updated>2017-09-23T03:43:13+00:00</updated>
<author>
<name>Gao Feng</name>
<email>gfree.wind@vip.163.com</email>
</author>
<published>2017-09-22T02:25:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=242c1a28eb61cb34974e8aa05235d84355940a8a'/>
<id>urn:sha1:242c1a28eb61cb34974e8aa05235d84355940a8a</id>
<content type='text'>
There is no one which would invokes the function skb_header_release.
So just remove it now.

Signed-off-by: Gao Feng &lt;gfree.wind@vip.163.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>asix: Fix small memory leak in ax88772_unbind()</title>
<updated>2017-08-07T17:10:19+00:00</updated>
<author>
<name>Dean Jenkins</name>
<email>Dean_Jenkins@mentor.com</email>
</author>
<published>2017-08-07T08:50:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d0c8f338ab41438bdf8472cb4209d4ab54d439d5'/>
<id>urn:sha1:d0c8f338ab41438bdf8472cb4209d4ab54d439d5</id>
<content type='text'>
When Ethernet frames span mulitple URBs, the netdev buffer memory
pointed to by the asix_rx_fixup_info structure remains allocated
during the time gap between the 2 executions of asix_rx_fixup_internal().

This means that if ax88772_unbind() is called within this time
gap to free the memory of the parent private data structure then
a memory leak of the part filled netdev buffer memory will occur.

Therefore, create a new function asix_rx_fixup_common_free() to
free the memory of the netdev buffer and add a call to
asix_rx_fixup_common_free() from inside ax88772_unbind().

Consequently when an unbind occurs part way through receiving
an Ethernet frame, the netdev buffer memory that is holding part
of the received Ethernet frame will now be freed.

Signed-off-by: Dean Jenkins &lt;Dean_Jenkins@mentor.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>asix: Ensure asix_rx_fixup_info members are all reset</title>
<updated>2017-08-07T17:10:19+00:00</updated>
<author>
<name>Dean Jenkins</name>
<email>Dean_Jenkins@mentor.com</email>
</author>
<published>2017-08-07T08:50:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=960eb4eeaa47a3a5061a4e47e28411e85840ab2c'/>
<id>urn:sha1:960eb4eeaa47a3a5061a4e47e28411e85840ab2c</id>
<content type='text'>
There is a risk that the members of the structure asix_rx_fixup_info
become unsynchronised leading to the possibility of a malfunction.

For example, rx-&gt;split_head was not being set to false after an
error was detected so potentially could cause a malformed 32-bit
Data header word to be formed.

Therefore add function reset_asix_rx_fixup_info() to reset all the
members of asix_rx_fixup_info so that future processing will start
with known initial conditions.

Also, if (skb-&gt;len != offset) becomes true then call
reset_asix_rx_fixup_info() so that the processing of the next URB
starts with known initial conditions. Without the call, the check
does nothing which potentially could lead to a malfunction
when the next URB is processed.

In addition, for robustness, call reset_asix_rx_fixup_info() before
every error path's "return 0". This ensures that the next URB is
processed from known initial conditions.

Signed-off-by: Dean Jenkins &lt;Dean_Jenkins@mentor.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>asix: Add rx-&gt;ax_skb = NULL after usbnet_skb_return()</title>
<updated>2017-08-07T17:10:19+00:00</updated>
<author>
<name>Dean Jenkins</name>
<email>Dean_Jenkins@mentor.com</email>
</author>
<published>2017-08-07T08:50:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=22889dbbd98a0e3390e9120074c39c6e5a3fea5e'/>
<id>urn:sha1:22889dbbd98a0e3390e9120074c39c6e5a3fea5e</id>
<content type='text'>
In asix_rx_fixup_internal() there is a risk that rx-&gt;ax_skb gets
reused after passing the Ethernet frame into the network stack via
usbnet_skb_return().

The risks include:

a) asynchronously freeing rx-&gt;ax_skb after passing the netdev buffer
   to the NAPI layer which might corrupt the backlog queue.

b) erroneously reusing rx-&gt;ax_skb such as calling skb_put_data() multiple
   times which causes writing off the end of the netdev buffer.

Therefore add a defensive rx-&gt;ax_skb = NULL after usbnet_skb_return()
so that it is not possible to free rx-&gt;ax_skb or to apply
skb_put_data() too many times.

Signed-off-by: Dean Jenkins &lt;Dean_Jenkins@mentor.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: manual clean code which call skb_put_[data:zero]</title>
<updated>2017-06-20T17:30:15+00:00</updated>
<author>
<name>yuan linyu</name>
<email>Linyu.Yuan@alcatel-sbell.com.cn</email>
</author>
<published>2017-06-18T14:52:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b952f4dff2751252db073c27c0f8a16a416a2ddc'/>
<id>urn:sha1:b952f4dff2751252db073c27c0f8a16a416a2ddc</id>
<content type='text'>
Signed-off-by: yuan linyu &lt;Linyu.Yuan@alcatel-sbell.com.cn&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>networking: introduce and use skb_put_data()</title>
<updated>2017-06-16T15:48:37+00:00</updated>
<author>
<name>Johannes Berg</name>
<email>johannes.berg@intel.com</email>
</author>
<published>2017-06-16T12:29:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=59ae1d127ac0ae404baf414c434ba2651b793f46'/>
<id>urn:sha1:59ae1d127ac0ae404baf414c434ba2651b793f46</id>
<content type='text'>
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.

An spatch similar to the one for skb_put_zero() converts many
of the places using it:

    @@
    identifier p, p2;
    expression len, skb, data;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, len);
    |
    -memcpy(p, data, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb, data;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, sizeof(*p));
    |
    -memcpy(p, data, sizeof(*p));
    )

    @@
    expression skb, len, data;
    @@
    -memcpy(skb_put(skb, len), data, len);
    +skb_put_data(skb, data, len);

(again, manually post-processed to retain some comments)

Reviewed-by: Stephen Hemminger &lt;stephen@networkplumber.org&gt;
Signed-off-by: Johannes Berg &lt;johannes.berg@intel.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: asix: Avoid looping when the device does not respond</title>
<updated>2016-10-14T20:06:54+00:00</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2016-10-13T23:43:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=610df1d2342d639ec87a8fb5290ca4799d91d59b'/>
<id>urn:sha1:610df1d2342d639ec87a8fb5290ca4799d91d59b</id>
<content type='text'>
Check answers from USB stack and avoid re-sending the request
multiple times if the device does not respond.

This fixes the following problem, observed with a probably flaky adapter.

[62108.732707] usb 1-3: new high-speed USB device number 5 using xhci_hcd
[62108.914421] usb 1-3: New USB device found, idVendor=0b95, idProduct=7720
[62108.914463] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[62108.914476] usb 1-3: Product: AX88x72A
[62108.914486] usb 1-3: Manufacturer: ASIX Elec. Corp.
[62108.914495] usb 1-3: SerialNumber: 000001
[62114.109109] asix 1-3:1.0 (unnamed net_device) (uninitialized):
	Failed to write reg index 0x0000: -110
[62114.109139] asix 1-3:1.0 (unnamed net_device) (uninitialized):
	Failed to send software reset: ffffff92
[62119.109048] asix 1-3:1.0 (unnamed net_device) (uninitialized):
	Failed to write reg index 0x0000: -110
...

Since the USB timeout is 5 seconds, and the operation is retried 30 times,
this results in

[62278.180353] INFO: task mtpd:1725 blocked for more than 120 seconds.
[62278.180373]       Tainted: G        W      3.18.0-13298-g94ace9e #1
[62278.180383] "echo 0 &gt; /proc/sys/kernel/hung_task_timeout_secs" disables this message.
...
[62278.180957] kworker/2:0     D 0000000000000000     0  5744      2 0x00000000
[62278.180978] Workqueue: usb_hub_wq hub_event
[62278.181029]  ffff880177f833b8 0000000000000046 ffff88017fd00000 ffff88017b126d80
[62278.181048]  ffff880177f83fd8 ffff880065a71b60 0000000000013340 ffff880065a71b60
[62278.181065]  0000000000000286 0000000103b1c199 0000000000001388 0000000000000002
[62278.181081] Call Trace:
[62278.181092]  [&lt;ffffffff8e0971fd&gt;] ? console_conditional_schedule+0x2c/0x2c
[62278.181105]  [&lt;ffffffff8e094f7b&gt;] schedule+0x69/0x6b
[62278.181117]  [&lt;ffffffff8e0972e0&gt;] schedule_timeout+0xe3/0x11d
[62278.181133]  [&lt;ffffffff8daadb1b&gt;] ? trace_timer_start+0x51/0x51
[62278.181146]  [&lt;ffffffff8e095a05&gt;] do_wait_for_common+0x12f/0x16c
[62278.181162]  [&lt;ffffffff8da856a7&gt;] ? wake_up_process+0x39/0x39
[62278.181174]  [&lt;ffffffff8e095aee&gt;] wait_for_common+0x52/0x6d
[62278.181187]  [&lt;ffffffff8e095b3b&gt;] wait_for_completion_timeout+0x13/0x15
[62278.181201]  [&lt;ffffffff8de676ce&gt;] usb_start_wait_urb+0x93/0xf1
[62278.181214]  [&lt;ffffffff8de6780d&gt;] usb_control_msg+0xe1/0x11d
[62278.181230]  [&lt;ffffffffc037d629&gt;] usbnet_write_cmd+0x9c/0xc6 [usbnet]
[62278.181286]  [&lt;ffffffffc03af793&gt;] asix_write_cmd+0x4e/0x7e [asix]
[62278.181300]  [&lt;ffffffffc03afb41&gt;] asix_set_sw_mii+0x25/0x4e [asix]
[62278.181314]  [&lt;ffffffffc03b001d&gt;] asix_mdio_read+0x51/0x109 [asix]
...

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: asix: Avoid looping when the device is disconnected</title>
<updated>2016-09-01T04:07:05+00:00</updated>
<author>
<name>Robert Foss</name>
<email>robert.foss@collabora.com</email>
</author>
<published>2016-08-29T13:32:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8a46f665833a2085e402bd0827be380f161f09ef'/>
<id>urn:sha1:8a46f665833a2085e402bd0827be380f161f09ef</id>
<content type='text'>
From: Vincent Palatin &lt;vpalatin@chromium.org&gt;

Check the answers from the USB stack and avoid re-sending multiple times
the request if the device has disappeared.

Signed-off-by: Vincent Palatin &lt;vpalatin@chromium.org&gt;
Signed-off-by: Robert Foss &lt;robert.foss@collabora.com&gt;
Tested-by: Robert Foss &lt;robert.foss@collabora.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: asix: Add in_pm parameter</title>
<updated>2016-09-01T04:07:05+00:00</updated>
<author>
<name>Robert Foss</name>
<email>robert.foss@collabora.com</email>
</author>
<published>2016-08-29T13:32:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=d9fe64e511144c1ee7d7555b4111f09dde9692ef'/>
<id>urn:sha1:d9fe64e511144c1ee7d7555b4111f09dde9692ef</id>
<content type='text'>
From: Freddy Xin &lt;freddy@asix.com.tw&gt;

In order to R/W registers in suspend/resume functions, in_pm flags are
added to some functions to determine whether the nopm version of usb
functions is called.

Save BMCR and ANAR PHY registers in suspend function and restore them
in resume function.

Reset HW in resume function to ensure the PHY works correctly.

Signed-off-by: Freddy Xin &lt;freddy@asix.com.tw&gt;
Signed-off-by: Robert Foss &lt;robert.foss@collabora.com&gt;
Tested-by: Robert Foss &lt;robert.foss@collabora.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>asix: Fix offset calculation in asix_rx_fixup() causing slow transmissions</title>
<updated>2016-05-17T18:02:33+00:00</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2016-05-17T03:36:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cd9e2e5d3ff148be9ea210f622ce3e8e8292fcd6'/>
<id>urn:sha1:cd9e2e5d3ff148be9ea210f622ce3e8e8292fcd6</id>
<content type='text'>
In testing with HiKey, we found that since
commit 3f30b158eba5 ("asix: On RX avoid creating bad Ethernet
frames"),
we're seeing lots of noise during network transfers:

[  239.027993] asix 1-1.1:1.0 eth0: asix_rx_fixup() Data Header synchronisation was lost, remaining 988
[  239.037310] asix 1-1.1:1.0 eth0: asix_rx_fixup() Bad Header Length 0x54ebb5ec, offset 4
[  239.045519] asix 1-1.1:1.0 eth0: asix_rx_fixup() Bad Header Length 0xcdffe7a2, offset 4
[  239.275044] asix 1-1.1:1.0 eth0: asix_rx_fixup() Data Header synchronisation was lost, remaining 988
[  239.284355] asix 1-1.1:1.0 eth0: asix_rx_fixup() Bad Header Length 0x1d36f59d, offset 4
[  239.292541] asix 1-1.1:1.0 eth0: asix_rx_fixup() Bad Header Length 0xaef3c1e9, offset 4
[  239.518996] asix 1-1.1:1.0 eth0: asix_rx_fixup() Data Header synchronisation was lost, remaining 988
[  239.528300] asix 1-1.1:1.0 eth0: asix_rx_fixup() Bad Header Length 0x2881912, offset 4
[  239.536413] asix 1-1.1:1.0 eth0: asix_rx_fixup() Bad Header Length 0x5638f7e2, offset 4

And network throughput ends up being pretty bursty and slow with
a overall throughput of at best ~30kB/s (where as previously we
got 1.1MB/s with the slower USB1.1 "full speed" host).

We found the issue also was reproducible on a x86_64 system,
using a "high-speed" USB2.0 port but the throughput did not
measurably drop (possibly due to the scp transfer being cpu
bound on my slow test hardware).

After lots of debugging, I found the check added in the
problematic commit seems to be calculating the offset
incorrectly.

In the normal case, in the main loop of the function, we do:
(where offset is zero, or set to "offset += (copy_length + 1) &amp;
0xfffe" in the previous loop)
    rx-&gt;header = get_unaligned_le32(skb-&gt;data +
                                    offset);
    offset += sizeof(u32);

But the problematic patch calculates:
    offset = ((rx-&gt;remaining + 1) &amp; 0xfffe) + sizeof(u32);
    rx-&gt;header = get_unaligned_le32(skb-&gt;data + offset);

Adding some debug logic to check those offset calculation used
to find rx-&gt;header, the one in problematic code is always too
large by sizeof(u32).

Thus, this patch removes the incorrect " + sizeof(u32)" addition
in the problematic calculation, and resolves the issue.

Cc: Dean Jenkins &lt;Dean_Jenkins@mentor.com&gt;
Cc: "David B. Robins" &lt;linux@davidrobins.net&gt;
Cc: Mark Craske &lt;Mark_Craske@mentor.com&gt;
Cc: Emil Goode &lt;emilgoode@gmail.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
Cc: YongQin Liu &lt;yongqin.liu@linaro.org&gt;
Cc: Guodong Xu &lt;guodong.xu@linaro.org&gt;
Cc: Ivan Vecera &lt;ivecera@redhat.com&gt;
Cc: linux-usb@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: stable &lt;stable@vger.kernel.org&gt; #4.4+
Reported-by: Yongqin Liu &lt;yongqin.liu@linaro.org&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
