* [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
@ 2017-01-19 11:40 Felipe Balbi
[not found] ` <30102591E157244384E984126FC3CB4F2FF567F3@US01WEMBX2.internal.synopsys.com>
2017-04-04 8:09 ` Felipe Balbi
0 siblings, 2 replies; 8+ messages in thread
From: Felipe Balbi @ 2017-01-19 11:40 UTC (permalink / raw)
To: Linux USB; +Cc: Felipe Balbi, stable
At least macOS seems to be sending
ClearFeature(ENDPOINT_HALT) to endpoints which
aren't Halted. This makes DWC3's CLEARSTALL command
time out which causes several issues for the driver.
Instead, let's just return 0 and bail out early.
Cc: <stable@vger.kernel.org>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---
this falls into "has never worked before" category, so I'll be sending
it together with other patches for v4.11 merge window. Still, it's a
valid bug that's likely needed for stable trees.
drivers/usb/dwc3/gadget.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 6faf484e5dfc..0a664d8eba3f 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
unsigned transfer_in_flight;
unsigned started;
+ if (dep->flags & DWC3_EP_STALL)
+ return 0;
+
if (dep->number > 1)
trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
else
@@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
else
dep->flags |= DWC3_EP_STALL;
} else {
+ if (!(dep->flags & DWC3_EP_STALL))
+ return 0;
ret = dwc3_send_clear_stall_ep_cmd(dep);
if (ret)
--
2.11.0.295.gd7dffce1ce
^ permalink raw reply related [flat|nested] 8+ messages in thread
* RE: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
[not found] ` <30102591E157244384E984126FC3CB4F2FF567F3@US01WEMBX2.internal.synopsys.com>
@ 2017-03-08 9:29 ` Felipe Balbi
2017-03-08 9:33 ` Felipe Balbi
0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2017-03-08 9:29 UTC (permalink / raw)
To: Thinh Nguyen; +Cc: Linux USB, stable, John Youn
[-- Attachment #1: Type: text/plain, Size: 2250 bytes --]
Hi Thinh,
Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>> drivers/usb/dwc3/gadget.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 6faf484e5dfc..0a664d8eba3f 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep
>> *dep, int value, int protocol)
>> unsigned transfer_in_flight;
>> unsigned started;
>>
>> + if (dep->flags & DWC3_EP_STALL)
>> + return 0;
>> +
>> if (dep->number > 1)
>> trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
>> else
>> @@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep
>> *dep, int value, int protocol)
>> else
>> dep->flags |= DWC3_EP_STALL;
>> } else {
>> + if (!(dep->flags & DWC3_EP_STALL))
>> + return 0;
>>
>> ret = dwc3_send_clear_stall_ep_cmd(dep);
>> if (ret)
>> --
>> 2.11.0.295.gd7dffce1ce
>>
>> --
>
> I encounter an issue when I test mainline with USB 3 CV MSC test and
> bisected to this patch.
>
> Tester: USB 3 CV test (v2.1.3.0).
> Function Driver: f_mass_storage
> Reproducibility: always
>
> The failure occurs under MSC Error Recovery Test (TD 1.4).
>
> Failure from the test sequence as follow (MSC compliance test spec) :
> 1. Place the device in the desired starting state.
> 2. Issue a Case 9 CBW (see Table 2) but with invalid signature of 0xDEADBEEF.
> 3. Issue several In requests to the Bulk-Only Data Interface Bulk In endpoint. Verify a
> STALL handshake is returned. If STALL handshake is not returned, skip to step 11.
> 4. Issue a Get_Status(endpoint) request targeting the Bulk-Only Data Interface bulk In
> endpoint. Verify that it completes normally, reports endpoint halt status.
>
> ***After this point the device idles for 10 seconds and resets. ***
>
> Test fails.
I've been looking at this and based on sniffer and dwc3 tracepoints, it
seems like dwc3 is behaving properly. The real issue seems to be that
g_mass_storage isn't queueing a new request to IN endpoint.
I'll continue debugging this and try to find a solution that doesn't
involve reverting $subject.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
2017-03-08 9:29 ` Felipe Balbi
@ 2017-03-08 9:33 ` Felipe Balbi
2017-03-08 11:29 ` Felipe Balbi
0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2017-03-08 9:33 UTC (permalink / raw)
To: Thinh Nguyen; +Cc: Linux USB, stable, John Youn
[-- Attachment #1: Type: text/plain, Size: 3397 bytes --]
Felipe Balbi <felipe.balbi@linux.intel.com> writes:
> Hi Thinh,
>
> Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>>> drivers/usb/dwc3/gadget.c | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>> index 6faf484e5dfc..0a664d8eba3f 100644
>>> --- a/drivers/usb/dwc3/gadget.c
>>> +++ b/drivers/usb/dwc3/gadget.c
>>> @@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep
>>> *dep, int value, int protocol)
>>> unsigned transfer_in_flight;
>>> unsigned started;
>>>
>>> + if (dep->flags & DWC3_EP_STALL)
>>> + return 0;
>>> +
>>> if (dep->number > 1)
>>> trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
>>> else
>>> @@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep
>>> *dep, int value, int protocol)
>>> else
>>> dep->flags |= DWC3_EP_STALL;
>>> } else {
>>> + if (!(dep->flags & DWC3_EP_STALL))
>>> + return 0;
>>>
>>> ret = dwc3_send_clear_stall_ep_cmd(dep);
>>> if (ret)
>>> --
>>> 2.11.0.295.gd7dffce1ce
>>>
>>> --
>>
>> I encounter an issue when I test mainline with USB 3 CV MSC test and
>> bisected to this patch.
>>
>> Tester: USB 3 CV test (v2.1.3.0).
>> Function Driver: f_mass_storage
>> Reproducibility: always
>>
>> The failure occurs under MSC Error Recovery Test (TD 1.4).
>>
>> Failure from the test sequence as follow (MSC compliance test spec) :
>> 1. Place the device in the desired starting state.
>> 2. Issue a Case 9 CBW (see Table 2) but with invalid signature of 0xDEADBEEF.
>> 3. Issue several In requests to the Bulk-Only Data Interface Bulk In endpoint. Verify a
>> STALL handshake is returned. If STALL handshake is not returned, skip to step 11.
>> 4. Issue a Get_Status(endpoint) request targeting the Bulk-Only Data Interface bulk In
>> endpoint. Verify that it completes normally, reports endpoint halt status.
>>
>> ***After this point the device idles for 10 seconds and resets. ***
>>
>> Test fails.
>
> I've been looking at this and based on sniffer and dwc3 tracepoints, it
> seems like dwc3 is behaving properly. The real issue seems to be that
> g_mass_storage isn't queueing a new request to IN endpoint.
>
> I'll continue debugging this and try to find a solution that doesn't
> involve reverting $subject.
oh no, wait. ep2out misses XferInProgress:
file-storage-1592 [000] d..1 152.809922: dwc3_ep_queue: ep2out: req ffff88003cd6ee40 length 0/512 zsI ==> -115
file-storage-1592 [000] d..1 152.809931: dwc3_prepare_trb: ep2out: 3/8 trb ffff88003a196050 buf 000000002d5e4000 size 512 ctrl 00000819 (HlcS:sC:normal)
file-storage-1592 [000] d..1 152.809942: dwc3_gadget_ep_cmd: ep2out: cmd 'Update Transfer' [262151] params 00000000 00000000 00000000 --> status: Successful
file-storage-1592 [000] .... 152.809951: usb_ep_queue: ep2out: length 0/512 sgs 0/0 stream 0 zsI status -115 --> 0
irq/34-dwc3-1593 [001] d..1 152.810212: dwc3_event: event (0000c040): ep0out: Transfer Complete [Setup Phase]
irq/34-dwc3-1593 [001] d..1 152.810218: dwc3_ctrl_req: bRequestType 02 bRequest 01 wValue 0000 wIndex 0002 wLength 0
irq/34-dwc3-1593 [001] d..1 152.810228: __dwc3_gadget_ep_set_halt: ep2out: NOT stalled
Sniffer shows me this completing, but I don't see IRQ for this.
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
2017-03-08 9:33 ` Felipe Balbi
@ 2017-03-08 11:29 ` Felipe Balbi
2017-03-08 11:55 ` Felipe Balbi
0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2017-03-08 11:29 UTC (permalink / raw)
To: Thinh Nguyen; +Cc: Linux USB, stable, John Youn
[-- Attachment #1: Type: text/plain, Size: 3632 bytes --]
Hi,
Felipe Balbi <felipe.balbi@linux.intel.com> writes:
>> Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>>>> drivers/usb/dwc3/gadget.c | 5 +++++
>>>> 1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>>> index 6faf484e5dfc..0a664d8eba3f 100644
>>>> --- a/drivers/usb/dwc3/gadget.c
>>>> +++ b/drivers/usb/dwc3/gadget.c
>>>> @@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep
>>>> *dep, int value, int protocol)
>>>> unsigned transfer_in_flight;
>>>> unsigned started;
>>>>
>>>> + if (dep->flags & DWC3_EP_STALL)
>>>> + return 0;
>>>> +
>>>> if (dep->number > 1)
>>>> trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
>>>> else
>>>> @@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep
>>>> *dep, int value, int protocol)
>>>> else
>>>> dep->flags |= DWC3_EP_STALL;
>>>> } else {
>>>> + if (!(dep->flags & DWC3_EP_STALL))
>>>> + return 0;
>>>>
>>>> ret = dwc3_send_clear_stall_ep_cmd(dep);
>>>> if (ret)
>>>> --
>>>> 2.11.0.295.gd7dffce1ce
>>>>
>>>> --
>>>
>>> I encounter an issue when I test mainline with USB 3 CV MSC test and
>>> bisected to this patch.
>>>
>>> Tester: USB 3 CV test (v2.1.3.0).
>>> Function Driver: f_mass_storage
>>> Reproducibility: always
>>>
>>> The failure occurs under MSC Error Recovery Test (TD 1.4).
>>>
>>> Failure from the test sequence as follow (MSC compliance test spec) :
>>> 1. Place the device in the desired starting state.
>>> 2. Issue a Case 9 CBW (see Table 2) but with invalid signature of 0xDEADBEEF.
>>> 3. Issue several In requests to the Bulk-Only Data Interface Bulk In endpoint. Verify a
>>> STALL handshake is returned. If STALL handshake is not returned, skip to step 11.
>>> 4. Issue a Get_Status(endpoint) request targeting the Bulk-Only Data Interface bulk In
>>> endpoint. Verify that it completes normally, reports endpoint halt status.
>>>
>>> ***After this point the device idles for 10 seconds and resets. ***
>>>
>>> Test fails.
>>
>> I've been looking at this and based on sniffer and dwc3 tracepoints, it
>> seems like dwc3 is behaving properly. The real issue seems to be that
>> g_mass_storage isn't queueing a new request to IN endpoint.
>>
>> I'll continue debugging this and try to find a solution that doesn't
>> involve reverting $subject.
>
> oh no, wait. ep2out misses XferInProgress:
>
> file-storage-1592 [000] d..1 152.809922: dwc3_ep_queue: ep2out: req ffff88003cd6ee40 length 0/512 zsI ==> -115
> file-storage-1592 [000] d..1 152.809931: dwc3_prepare_trb: ep2out: 3/8 trb ffff88003a196050 buf 000000002d5e4000 size 512 ctrl 00000819 (HlcS:sC:normal)
> file-storage-1592 [000] d..1 152.809942: dwc3_gadget_ep_cmd: ep2out: cmd 'Update Transfer' [262151] params 00000000 00000000 00000000 --> status: Successful
> file-storage-1592 [000] .... 152.809951: usb_ep_queue: ep2out: length 0/512 sgs 0/0 stream 0 zsI status -115 --> 0
> irq/34-dwc3-1593 [001] d..1 152.810212: dwc3_event: event (0000c040): ep0out: Transfer Complete [Setup Phase]
> irq/34-dwc3-1593 [001] d..1 152.810218: dwc3_ctrl_req: bRequestType 02 bRequest 01 wValue 0000 wIndex 0002 wLength 0
> irq/34-dwc3-1593 [001] d..1 152.810228: __dwc3_gadget_ep_set_halt: ep2out: NOT stalled
>
> Sniffer shows me this completing, but I don't see IRQ for this.
BTW, I just tested without $subject and it fails the same way. This is
caused by something else. Can you rerun your bisect while I look at the
problem here?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
2017-03-08 11:29 ` Felipe Balbi
@ 2017-03-08 11:55 ` Felipe Balbi
0 siblings, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2017-03-08 11:55 UTC (permalink / raw)
To: Thinh Nguyen; +Cc: Linux USB, stable, John Youn
[-- Attachment #1: Type: text/plain, Size: 1807 bytes --]
Hi,
Felipe Balbi <felipe.balbi@linux.intel.com> writes:
>>> I've been looking at this and based on sniffer and dwc3 tracepoints, it
>>> seems like dwc3 is behaving properly. The real issue seems to be that
>>> g_mass_storage isn't queueing a new request to IN endpoint.
>>>
>>> I'll continue debugging this and try to find a solution that doesn't
>>> involve reverting $subject.
>>
>> oh no, wait. ep2out misses XferInProgress:
>>
>> file-storage-1592 [000] d..1 152.809922: dwc3_ep_queue: ep2out: req ffff88003cd6ee40 length 0/512 zsI ==> -115
>> file-storage-1592 [000] d..1 152.809931: dwc3_prepare_trb: ep2out: 3/8 trb ffff88003a196050 buf 000000002d5e4000 size 512 ctrl 00000819 (HlcS:sC:normal)
>> file-storage-1592 [000] d..1 152.809942: dwc3_gadget_ep_cmd: ep2out: cmd 'Update Transfer' [262151] params 00000000 00000000 00000000 --> status: Successful
>> file-storage-1592 [000] .... 152.809951: usb_ep_queue: ep2out: length 0/512 sgs 0/0 stream 0 zsI status -115 --> 0
>> irq/34-dwc3-1593 [001] d..1 152.810212: dwc3_event: event (0000c040): ep0out: Transfer Complete [Setup Phase]
>> irq/34-dwc3-1593 [001] d..1 152.810218: dwc3_ctrl_req: bRequestType 02 bRequest 01 wValue 0000 wIndex 0002 wLength 0
>> irq/34-dwc3-1593 [001] d..1 152.810228: __dwc3_gadget_ep_set_halt: ep2out: NOT stalled
>>
>> Sniffer shows me this completing, but I don't see IRQ for this.
>
> BTW, I just tested without $subject and it fails the same way. This is
> caused by something else. Can you rerun your bisect while I look at the
> problem here?
Okay, found it. This is caused by the ep_dequeue bug that I already
fixed. see [1] for that
[1] https://marc.info/?i=20170217105759.24356-1-felipe.balbi@linux.intel.com
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
2017-01-19 11:40 [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid Felipe Balbi
[not found] ` <30102591E157244384E984126FC3CB4F2FF567F3@US01WEMBX2.internal.synopsys.com>
@ 2017-04-04 8:09 ` Felipe Balbi
2017-04-04 15:53 ` John Youn
1 sibling, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2017-04-04 8:09 UTC (permalink / raw)
To: Linux USB, John Youn; +Cc: stable
[-- Attachment #1: Type: text/plain, Size: 2050 bytes --]
Hi John,
Felipe Balbi <felipe.balbi@linux.intel.com> writes:
> At least macOS seems to be sending
> ClearFeature(ENDPOINT_HALT) to endpoints which
> aren't Halted. This makes DWC3's CLEARSTALL command
> time out which causes several issues for the driver.
>
> Instead, let's just return 0 and bail out early.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
> ---
>
> this falls into "has never worked before" category, so I'll be sending
> it together with other patches for v4.11 merge window. Still, it's a
> valid bug that's likely needed for stable trees.
>
> drivers/usb/dwc3/gadget.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 6faf484e5dfc..0a664d8eba3f 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
> unsigned transfer_in_flight;
> unsigned started;
>
> + if (dep->flags & DWC3_EP_STALL)
> + return 0;
> +
> if (dep->number > 1)
> trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
> else
> @@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
> else
> dep->flags |= DWC3_EP_STALL;
> } else {
> + if (!(dep->flags & DWC3_EP_STALL))
> + return 0;
>
> ret = dwc3_send_clear_stall_ep_cmd(dep);
> if (ret)
Reviving this old thread here. While $subject allowed dwc3 to work when
attached to macOS Host, I fear that we might have more issues than not
in the future. The reason is that USB20 spec allows hosts to use
ClearFeature(ENDPOINT_HALT) as a "Reset Data Toggle/SeqN" hint.
With this, we're basically blocking that possibility. Still, without
$subject, ClearStall commands were timing out. I'll try to do a local
revert here and check what happens in this case, but would you have any
idea why ClearStall would time out like that?
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
2017-04-04 8:09 ` Felipe Balbi
@ 2017-04-04 15:53 ` John Youn
2017-04-05 8:31 ` Felipe Balbi
0 siblings, 1 reply; 8+ messages in thread
From: John Youn @ 2017-04-04 15:53 UTC (permalink / raw)
To: Felipe Balbi, Linux USB, John Youn; +Cc: stable
On 04/04/2017 01:09 AM, Felipe Balbi wrote:
>
> Hi John,
>
> Felipe Balbi <felipe.balbi@linux.intel.com> writes:
>> At least macOS seems to be sending
>> ClearFeature(ENDPOINT_HALT) to endpoints which
>> aren't Halted. This makes DWC3's CLEARSTALL command
>> time out which causes several issues for the driver.
>>
>> Instead, let's just return 0 and bail out early.
>>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
>> ---
>>
>> this falls into "has never worked before" category, so I'll be sending
>> it together with other patches for v4.11 merge window. Still, it's a
>> valid bug that's likely needed for stable trees.
>>
>> drivers/usb/dwc3/gadget.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> index 6faf484e5dfc..0a664d8eba3f 100644
>> --- a/drivers/usb/dwc3/gadget.c
>> +++ b/drivers/usb/dwc3/gadget.c
>> @@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
>> unsigned transfer_in_flight;
>> unsigned started;
>>
>> + if (dep->flags & DWC3_EP_STALL)
>> + return 0;
>> +
>> if (dep->number > 1)
>> trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
>> else
>> @@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
>> else
>> dep->flags |= DWC3_EP_STALL;
>> } else {
>> + if (!(dep->flags & DWC3_EP_STALL))
>> + return 0;
>>
>> ret = dwc3_send_clear_stall_ep_cmd(dep);
>> if (ret)
>
> Reviving this old thread here. While $subject allowed dwc3 to work when
> attached to macOS Host, I fear that we might have more issues than not
> in the future. The reason is that USB20 spec allows hosts to use
> ClearFeature(ENDPOINT_HALT) as a "Reset Data Toggle/SeqN" hint.
>
> With this, we're basically blocking that possibility. Still, without
> $subject, ClearStall commands were timing out. I'll try to do a local
> revert here and check what happens in this case, but would you have any
> idea why ClearStall would time out like that?
>
Hi Felipe,
I think Thinh Nguyen e-mailed you about this before saying it caused a
regression for us. But he has not had time to look into it further and
follow-up yet.
No idea about the timing out on Mac though. We can try to reproduce
this when we have some time and take a look. Do you have a USB trace?
Regards,
John
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid
2017-04-04 15:53 ` John Youn
@ 2017-04-05 8:31 ` Felipe Balbi
0 siblings, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2017-04-05 8:31 UTC (permalink / raw)
To: John Youn, Linux USB, John Youn; +Cc: stable
Hi,
John Youn <John.Youn@synopsys.com> writes:
>> Felipe Balbi <felipe.balbi@linux.intel.com> writes:
>>> At least macOS seems to be sending
>>> ClearFeature(ENDPOINT_HALT) to endpoints which
>>> aren't Halted. This makes DWC3's CLEARSTALL command
>>> time out which causes several issues for the driver.
>>>
>>> Instead, let's just return 0 and bail out early.
>>>
>>> Cc: <stable@vger.kernel.org>
>>> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
>>> ---
>>>
>>> this falls into "has never worked before" category, so I'll be sending
>>> it together with other patches for v4.11 merge window. Still, it's a
>>> valid bug that's likely needed for stable trees.
>>>
>>> drivers/usb/dwc3/gadget.c | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>>> index 6faf484e5dfc..0a664d8eba3f 100644
>>> --- a/drivers/usb/dwc3/gadget.c
>>> +++ b/drivers/usb/dwc3/gadget.c
>>> @@ -1379,6 +1379,9 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
>>> unsigned transfer_in_flight;
>>> unsigned started;
>>>
>>> + if (dep->flags & DWC3_EP_STALL)
>>> + return 0;
>>> +
>>> if (dep->number > 1)
>>> trb = dwc3_ep_prev_trb(dep, dep->trb_enqueue);
>>> else
>>> @@ -1400,6 +1403,8 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
>>> else
>>> dep->flags |= DWC3_EP_STALL;
>>> } else {
>>> + if (!(dep->flags & DWC3_EP_STALL))
>>> + return 0;
>>>
>>> ret = dwc3_send_clear_stall_ep_cmd(dep);
>>> if (ret)
>>
>> Reviving this old thread here. While $subject allowed dwc3 to work when
>> attached to macOS Host, I fear that we might have more issues than not
>> in the future. The reason is that USB20 spec allows hosts to use
>> ClearFeature(ENDPOINT_HALT) as a "Reset Data Toggle/SeqN" hint.
>>
>> With this, we're basically blocking that possibility. Still, without
>> $subject, ClearStall commands were timing out. I'll try to do a local
>> revert here and check what happens in this case, but would you have any
>> idea why ClearStall would time out like that?
>>
>
> Hi Felipe,
>
> I think Thinh Nguyen e-mailed you about this before saying it caused a
> regression for us. But he has not had time to look into it further and
> follow-up yet.
>
> No idea about the timing out on Mac though. We can try to reproduce
> this when we have some time and take a look. Do you have a USB trace?
not anymore, but as soon I have some free time, I can revert the patch
locally and try to reproduce. I'll also implement a little libusb-based
test to issue that request hundreds of times in a row and see if I can
force the problem to happen ;-)
Thanks for responding so quickly :-)
--
balbi
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-04-05 8:31 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-19 11:40 [PATCH] usb: dwc3: gadget: skip Set/Clear Halt when invalid Felipe Balbi
[not found] ` <30102591E157244384E984126FC3CB4F2FF567F3@US01WEMBX2.internal.synopsys.com>
2017-03-08 9:29 ` Felipe Balbi
2017-03-08 9:33 ` Felipe Balbi
2017-03-08 11:29 ` Felipe Balbi
2017-03-08 11:55 ` Felipe Balbi
2017-04-04 8:09 ` Felipe Balbi
2017-04-04 15:53 ` John Youn
2017-04-05 8:31 ` Felipe Balbi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.