NetBSD Problem Report #51395
From www@NetBSD.org Sun Aug 7 09:31:58 2016
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 7D1D57A13F
for <gnats-bugs@gnats.NetBSD.org>; Sun, 7 Aug 2016 09:31:58 +0000 (UTC)
Message-Id: <20160807093157.7F2297A2B0@mollari.NetBSD.org>
Date: Sun, 7 Aug 2016 09:31:57 +0000 (UTC)
From: bsiegert@NetBSD.org
Reply-To: bsiegert@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: USB Ethernet makes xhci hang
X-Send-Pr-Version: www-1.0
>Number: 51395
>Category: kern
>Synopsis: USB Ethernet makes xhci hang
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Aug 07 09:35:00 +0000 2016
>Closed-Date: Tue Sep 06 08:43:41 +0000 2016
>Last-Modified: Tue Sep 06 08:43:41 +0000 2016
>Originator: Benny Siegert
>Release: NetBSD 7.99.34 (from 2016-07-30)
>Organization:
The NetBSD Foundation
>Environment:
NetBSD 7.99.34 NetBSD 7.99.34 (GENERIC) #0: Wed Aug 3 23:30:33 CEST 2016 root@:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
On an Intel NUC with USB 3.0, plugging in an Apple Ethernet adapter (axe driver) results in (what I think are) long timeouts when sending and receiving. "dhcpcd axe0" takes about 10 minutes to complete, and the USB keyboard becomes unresponsive during that time. I have seen keystrokes appear minutes later, though.
The USB is:
xhci0 at pci0 dev 20 function 0: vendor 8086 product a12f (rev. 0x31)
xhci0: interrupting at msi0 vec 0
xhci0: xHCI version 1.0
usb0 at xhci0: USB revision 3.0
The Ethernet adapter is:
axe0 at uhub0 port 2
axe0: Apple Computer Apple USB to Ethernet, rev 2.00/0.01, addr 4
ukphy0 at axe0 phy 16: OUI 0x007063, model 0x0006, rev. 1
When I run dhcpcd, I get a lease and a default route. Then things start to hang.
>How-To-Repeat:
Plug in USB Ethernet adapter
run dhcpcd axe0
>Fix:
?
>Release-Note:
>Audit-Trail:
From: Takahiro Hayashi <t425hash@gmail.com>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Mon, 8 Aug 2016 03:09:24 +0900
Can you check if your axe works on another machine
and if another axe works on the machine?
Could you rebuild kernel with
options USB_DEBUG
options XHCI_DEBUG
and "sysctl -w hw.xhci.debug=15" before running dhcpcd?
"vmstat -u usbhist" produces debug logs.
--
t-hash
From: Benny Siegert <bsiegert@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
bsiegert@NetBSD.org
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Sun, 7 Aug 2016 21:17:47 +0200
> Can you check if your axe works on another machine
> and if another axe works on the machine?
My other axe fails in exactly the same way. Both of them work on a Mac.
> Could you rebuild kernel with
> options USB_DEBUG
> options XHCI_DEBUG
> and "sysctl -w hw.xhci.debug=15" before running dhcpcd?
> "vmstat -u usbhist" produces debug logs.
Will do!
From: Takahiro Hayashi <t425hash@gmail.com>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
Benny Siegert <bsiegert@gmail.com>
Cc:
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Mon, 8 Aug 2016 22:45:02 +0900
This is a multi-part message in MIME format.
--------------D0B31FF0B77670F21EA67021
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
I've found that the previous fix was imcomplete.
Can you try attached patch?
This patch tries to put Link TRB at the last of ring.
This lacks handling that first TRB should be written at last.
Thank you for reporting this problem.
--
t-hash
--------------D0B31FF0B77670F21EA67021
Content-Type: text/plain; charset=UTF-8;
name="x-linktrb.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="x-linktrb.diff"
--- sys/dev/usb/xhci.c.orig 2016-07-18 07:07:53.000000000 +0900
+++ sys/dev/usb/xhci.c 2016-08-08 22:06:19.000000000 +0900
@@ -2374,25 +2397,24 @@ xhci_ring_put(struct xhci_softc * const
* The code should write the 'cycle' bit on the link trb AFTER
* adding the other trb.
*/
- if (ri + ntrbs >= (xr->xr_ntrb - 1)) {
- parameter = xhci_ring_trbp(xr, 0);
- status = 0;
- control = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) |
- XHCI_TRB_3_TC_BIT | (cs ? XHCI_TRB_3_CYCLE_BIT : 0);
- xhci_trb_put(&xr->xr_trb[ri], parameter, status, control);
- usb_syncmem(&xr->xr_dma, XHCI_TRB_SIZE * ri, XHCI_TRB_SIZE * 1,
- BUS_DMASYNC_PREWRITE);
- xr->xr_cookies[ri] = NULL;
- xr->xr_ep = 0;
- xr->xr_cs ^= 1;
- ri = xr->xr_ep;
- cs = xr->xr_cs;
- }
-
- ri++;
+ for (i = 0; i < ntrbs; ) {
+ if (ri >= (xr->xr_ntrb - 1)) {
+ parameter = xhci_ring_trbp(xr, 0);
+ status = 0;
+ control = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) |
+ XHCI_TRB_3_TC_BIT | (cs ? XHCI_TRB_3_CYCLE_BIT : 0);
+ xhci_trb_put(&xr->xr_trb[ri], parameter, status,
+ control);
+ usb_syncmem(&xr->xr_dma, XHCI_TRB_SIZE * ri,
+ XHCI_TRB_SIZE * 1, BUS_DMASYNC_PREWRITE);
+ xr->xr_cookies[ri] = NULL;
+ xr->xr_ep = 0;
+ xr->xr_cs ^= 1;
+ ri = xr->xr_ep;
+ cs = xr->xr_cs;
+ continue;
+ }
- /* Write any subsequent TRB first */
- for (i = 1; i < ntrbs; i++) {
parameter = trbs[i].trb_0;
status = trbs[i].trb_2;
control = trbs[i].trb_3;
@@ -2408,25 +2430,9 @@ xhci_ring_put(struct xhci_softc * const
BUS_DMASYNC_PREWRITE);
xr->xr_cookies[ri] = cookie;
ri++;
+ i++;
}
- /* Write the first TRB last */
- i = 0;
- parameter = trbs[i].trb_0;
- status = trbs[i].trb_2;
- control = trbs[i].trb_3;
-
- if (xr->xr_cs) {
- control |= XHCI_TRB_3_CYCLE_BIT;
- } else {
- control &= ~XHCI_TRB_3_CYCLE_BIT;
- }
-
- xhci_trb_put(&xr->xr_trb[xr->xr_ep], parameter, status, control);
- usb_syncmem(&xr->xr_dma, XHCI_TRB_SIZE * xr->xr_ep, XHCI_TRB_SIZE * 1,
- BUS_DMASYNC_PREWRITE);
- xr->xr_cookies[xr->xr_ep] = cookie;
-
xr->xr_ep = ri;
xr->xr_cs = cs;
--------------D0B31FF0B77670F21EA67021--
From: Benny Siegert <bsiegert@gmail.com>
To: Takahiro Hayashi <t425hash@gmail.com>
Cc: gnats-bugs@NetBSD.org,
kern-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Tue, 9 Aug 2016 19:38:29 +0200
> Can you try attached patch?
> This patch tries to put Link TRB at the last of ring.
> This lacks handling that first TRB should be written at last.
Unfortunately, the result is still a hang, even with the patch applied. =
Do you want me to grab a new log file?
=97Benny.=
From: Takahiro Hayashi <t425hash@gmail.com>
To: Benny Siegert <bsiegert@gmail.com>, Takahiro Hayashi <t425hash@gmail.com>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Wed, 10 Aug 2016 06:41:53 +0900
On 2016/08/10 02:38, Benny Siegert wrote:
>> Can you try attached patch?
>> This patch tries to put Link TRB at the last of ring.
>> This lacks handling that first TRB should be written at last.
>
> Unfortunately, the result is still a hang, even with the patch applied. Do you want me to grab a new log file?
Yes, please.
--
t-hash
From: Takahiro Hayashi <t425hash@gmail.com>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Wed, 10 Aug 2016 20:11:20 +0900
This problem also happens on ehci of my DN2820FYKH.
# dhcpcd axe0
axe0: adding address fe80::2xx:xxff:fexx:xxxx
ehci_sync_hc: cv_timedwait() = 35
~fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff80114b35 cs 8 rflags 202 cr2 7a1772596240 ilevel 8 rsp fffffe810e673ce8
curlwp 0xfffffe823f729840 pid 0.2 lowest kstack 0xfffffe810e6702c0
Stopped in pid 0.2 (system) at netbsd:breakpoint+0x5: leave
db{0}> ps
PID LID S CPU FLAGS STRUCT LWP * NAME WAIT
13 1 3 0 0 fffffe810e9ea980 dhcpcd usbxfer
2 1 3 0 80 fffffe810e9ea560 sh wait
1 1 3 0 80 fffffe810ea3f180 init wait
0 48 3 1 200 fffffe810eae9a00 aiodoned aiodoned
0 47 3 1 200 fffffe810eb071a0 ioflush syncer
0 46 3 1 200 fffffe810eb075c0 pgdaemon pgdaemon
0 45 5 1 200 fffffe810eb079e0 (zombie)
0 42 3 1 200 fffffe810e9c9960 usb0 usbevt
0 41 3 1 200 fffffe810ea3f5a0 unpgc unpgc
0 40 3 1 200 fffffe810ea3f9c0 nd6_timer tstile
0 39 3 0 200 fffffe810e9ea140 rt_timer rt_timer
0 38 3 0 200 fffffe810e9eb9a0 vmem_rehash vmem_rehash
0 37 3 0 200 fffffe810e9eb160 coretemp1 coretemp1
0 36 3 1 200 fffffe810e9eb580 coretemp0 coretemp0
0 27 3 1 200 fffffe810e929520 iic0 iicintr
0 26 3 0 200 fffffe810e929940 usbtask-dr tstile
0 25 3 0 200 fffffe810e6e30e0 usbtask-hc ehciab
0 24 3 0 200 fffffe810e6e3500 atabus0 atath
0 23 3 1 200 fffffe810e6e3920 xcall/1 xcall
0 22 1 1 200 fffffe810e6c30c0 softser/1
0 21 3 1 200 fffffe810e6c34e0 softclk/1 tstile
0 20 1 1 200 fffffe810e6c3900 softbio/1
0 19 1 1 200 fffffe823eaec0a0 softnet/1
0 > 18 7 1 201 fffffe823eaec4c0 idle/1
0 17 3 0 200 fffffe823eaec8e0 lnxsyswq lnxsyswq
0 16 3 0 200 fffffe823eafe080 sysmon smtaskq
0 15 3 0 200 fffffe823eafe4a0 pmfsuspend pmfsuspend
0 14 3 0 200 fffffe823eafe8c0 pmfevent pmfevent
0 13 3 0 200 fffffe823eb0e060 sopendfree sopendfr
0 12 3 0 200 fffffe823eb0e480 nfssilly nfssilly
0 11 3 0 200 fffffe823eb0e8a0 cachegc cachegc
0 10 3 0 200 fffffe823f714040 vrele vrele
0 9 3 1 200 fffffe823f714460 vdrain vdrain
0 8 3 0 200 fffffe823f714880 modunload mod_unld
0 7 3 0 200 fffffe823f723020 xcall/0 xcall
0 6 1 0 200 fffffe823f723440 softser/0
0 5 1 0 200 fffffe823f723860 softclk/0
0 4 1 0 200 fffffe823f729000 softbio/0
0 3 3 0 200 fffffe823f729420 softnet/0 tstile
0 > 2 7 0 201 fffffe823f729840 idle/0
0 1 3 0 200 ffffffff80abaee0 swapper uvm
db{0}> ps/w
PID LID COMMAND EMUL PRI WAIT-MSG WAIT-CHANNEL
13 1 dhcpcd netbsd 43 usbxfer fffffe810e9ee658
2 1 sh netbsd 43 wait fffffe810ea94ab0
1 1 init netbsd 43 wait fffffe810ea94d50
0 48 system netbsd 125 aiodoned fffffe810ea1d948
0 47 system netbsd 124 syncer fffffe810eb071a0
0 46 system netbsd 126 pgdaemon ffffffff80fe9bb4
0 45 system netbsd 96 0
0 42 system netbsd 96 usbevt fffffe810e93b490
0 41 system netbsd 96 unpgc ffffffff8100bc60
0 40 system netbsd 222 tstile fffffe823fbabf40
0 39 system netbsd 222 rt_timer fffffe810ea1dd88
0 38 system netbsd 125 vmem_rehash fffffe810ea1de88
0 37 system netbsd 43 coretemp1 fffffe823f71e088
0 36 system netbsd 43 coretemp0 fffffe823f71e148
0 27 system netbsd 96 iicintr fffffe823f71e1f0
0 26 system netbsd 96 tstile fffffe823d450e28
0 25 system netbsd 96 ehciab fffffe810e93bde8
0 24 system netbsd 96 atath ffff80000f7d3398
0 23 system netbsd 127 xcall fffffe810e6b30d8
0 22 system netbsd 223 0
0 21 system netbsd 220 tstile fffffe823fbabf40
0 20 system netbsd 221 0
0 19 system netbsd 222 0
0 > 18 system netbsd 0 0
0 17 system netbsd 43 lnxsyswq fffffe823f71eb08
0 16 system netbsd 96 smtaskq ffffffff80fd3d60
0 15 system netbsd 43 pmfsuspend fffffe823f71ecc8
0 14 system netbsd 43 pmfevent fffffe823f71ed88
0 13 system netbsd 96 sopendfr ffffffff8100bbd0
0 12 system netbsd 43 nfssilly fffffe823f71ee88
0 11 system netbsd 125 cachegc fffffe823eb0e8a0
0 10 system netbsd 125 vrele ffffffff80af50c0
0 9 system netbsd 125 vdrain ffffffff80af5180
0 8 system netbsd 125 mod_unld ffffffff80fee890
0 7 system netbsd 127 xcall ffffffff80a834d8
0 6 system netbsd 223 0
0 5 system netbsd 220 0
0 4 system netbsd 221 0
0 3 system netbsd 222 tstile fffffe823fbabf40
0 > 2 system netbsd 0 0
0 1 system netbsd 125 uvm ffffffff80abaee0
db{0}> bt/a fffffe810e9ea980
trace: pid 13 lid 1 at 0xfffffe810ecea3f0
sleepq_block() at netbsd:sleepq_block+0x97
cv_wait() at netbsd:cv_wait+0x11a
usbd_transfer() at netbsd:usbd_transfer+0x795
usbd_do_request_flags() at netbsd:usbd_do_request_flags+0xd9
axe_cmd() at netbsd:axe_cmd+0xa0
axe_setmulti() at netbsd:axe_setmulti+0x76
axe_ioctl() at netbsd:axe_ioctl+0x157
if_mcast_op() at netbsd:if_mcast_op+0x6a
in6_addmulti() at netbsd:in6_addmulti+0x2f8
in6_joingroup() at netbsd:in6_joingroup+0x45
in6_update_ifa1() at netbsd:in6_update_ifa1+0xa80
in6_update_ifa() at netbsd:in6_update_ifa+0x3b
in6_control1() at netbsd:in6_control1+0x4c5
in6_control() at netbsd:in6_control+0x92
udp6_ioctl_wrapper() at netbsd:udp6_ioctl_wrapper+0x32
compat_ifioctl() at netbsd:compat_ifioctl+0x11c
doifioctl() at netbsd:doifioctl+0xa9d
soo_ioctl() at netbsd:soo_ioctl+0x2b5
sys_ioctl() at netbsd:sys_ioctl+0x101
syscall() at netbsd:syscall+0x9c
--- syscall (number 54) ---
7a17726e90fa:
db{0}> bt/a fffffe810e6e30e0
trace: pid 0 lid 25 at 0xfffffe810e930db0
sleepq_block() at netbsd:sleepq_block+0x97
cv_wait() at netbsd:cv_wait+0x11a
ehci_abort_xfer() at netbsd:ehci_abort_xfer+0x506
ehci_timeout_task() at netbsd:ehci_timeout_task+0x3e
usb_task_thread() at netbsd:usb_task_thread+0x157
db{0}> bt/a fffffe810e929940
trace: pid 0 lid 26 at 0xfffffe810e93fcf0
sleepq_block() at netbsd:sleepq_block+0x97
turnstile_block() at netbsd:turnstile_block+0x3a9
mutex_enter() at netbsd:mutex_enter+0x36c
axe_miibus_readreg() at netbsd:axe_miibus_readreg+0x5b
mii_phy_tick() at netbsd:mii_phy_tick+0x5e
ukphy_service() at netbsd:ukphy_service+0x72
mii_tick() at netbsd:mii_tick+0x3b
axe_tick_task() at netbsd:axe_tick_task+0x31
usb_task_thread() at netbsd:usb_task_thread+0x1a4
--
t-hash
From: Takahiro Hayashi <t425hash@gmail.com>
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org,
gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Wed, 10 Aug 2016 22:23:00 +0900
On 2016/08/10 20:11, Takahiro Hayashi wrote:
> This problem also happens on ehci of my DN2820FYKH.
Here are usbhist logs.
http://pastebin.com/dN3kdMM7
http://pastebin.com/7k43byS7
From: Nick Hudson <skrll@netbsd.org>
To: Takahiro Hayashi <t425hash@gmail.com>, gnats-bugs@NetBSD.org,
kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Wed, 10 Aug 2016 22:32:12 +0100
On 08/10/16 12:11, Takahiro Hayashi wrote:
> This problem also happens on ehci of my DN2820FYKH.
>
[snip]
Try this patch...
http://www.netbsd.org/~skrll/usb.softint.diff
I think this PR is the same problem as 50491
Nick
From: Takahiro Hayashi <t425hash@gmail.com>
To: Nick Hudson <skrll@netbsd.org>, gnats-bugs@NetBSD.org,
kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc:
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Thu, 11 Aug 2016 08:16:22 +0900
On 2016/08/11 06:32, Nick Hudson wrote:
> On 08/10/16 12:11, Takahiro Hayashi wrote:
>> This problem also happens on ehci of my DN2820FYKH.
>>
> [snip]
>
> Try this patch...
>
> http://www.netbsd.org/~skrll/usb.softint.diff
It looks good.
My axe works w/o hang on both of ehci and xhci with/without USB_DEBUG.
> I think this PR is the same problem as 50491
--
t-hash
From: Benny Siegert <bsiegert@gmail.com>
To: gnats-bugs@NetBSD.org,
Nick Hudson <skrll@netbsd.org>
Cc: kern-bug-people@netbsd.org,
gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
bsiegert@NetBSD.org
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Sun, 14 Aug 2016 16:59:20 +0200
> On 08/10/16 12:11, Takahiro Hayashi wrote:
>> This problem also happens on ehci of my DN2820FYKH.
>>=20
> [snip]
>=20
> Try this patch...
>=20
> http://www.netbsd.org/~skrll/usb.softint.diff
>=20
> I think this PR is the same problem as 50491
Nick: The patch does not quite apply cleanly to a -current kernel :( In =
particular, current contains a
#define SOFTINT_USB SOFTINT_NET
in usbdi.h. What should I do?
=E2=80=94Benny.
From: Nick Hudson <nick.hudson@gmx.co.uk>
To: Benny Siegert <bsiegert@gmail.com>, gnats-bugs@NetBSD.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org, bsiegert@NetBSD.org
Subject: Re: kern/51395: USB Ethernet makes xhci hang
Date: Sun, 14 Aug 2016 16:04:40 +0100
On 14-Aug-16 3:59 PM, Benny Siegert wrote:
>> On 08/10/16 12:11, Takahiro Hayashi wrote:
>>> This problem also happens on ehci of my DN2820FYKH.
>>>
>> [snip]
>>
>> Try this patch...
>>
>> http://www.netbsd.org/~skrll/usb.softint.diff
>>
>> I think this PR is the same problem as 50491
> Nick: The patch does not quite apply cleanly to a -current kernel :( In particular, current contains a
>
> #define SOFTINT_USB SOFTINT_NET
>
> in usbdi.h. What should I do?
cvs update :)
I commited it.
>
> —Benny.
>
Nick
State-Changed-From-To: open->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Tue, 06 Sep 2016 08:43:41 +0000
State-Changed-Why:
I just built a new "vanilla" GENERIC kernel with sources from today,
and the axe adapter now works perfectly.
Thanks all!
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.