Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1501752
| From | Felipe Balbi <balbi@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq |
| Date | 2016-10-17 10:20 +0200 |
| Message-ID | <stbjm-YS-85@gated-at.bofh.it> (permalink) |
| References | <ssbOq-2ti-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
Hi,
(I have added you to another thread which is where we'll be collecting
discussion about this, however ...)
Alan Stern <stern@rowland.harvard.edu> writes:
> On Fri, 14 Oct 2016, Felipe Balbi wrote:
>
>> argh, we have nested spinlocks :-( Well, we shouldn't call
>> usb_ep_disable() with locks held AFAICR. So the following should be
>> enough:
>>
>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>> index 919d7d1b611c..2e9359c58eb9 100644
>> --- a/drivers/usb/gadget/composite.c
>> +++ b/drivers/usb/gadget/composite.c
>> @@ -732,8 +732,10 @@ static void reset_config(struct usb_composite_dev *cdev)
>> DBG(cdev, "reset config\n");
>>
>> list_for_each_entry(f, &cdev->config->functions, list) {
>> + spin_unlock_irq(&cdev->lock);
>> if (f->disable)
>> f->disable(f);
>> + spin_lock_irq(&cdev->lock);
>>
>> bitmap_zero(f->endpoints, 32);
>> }
>>
>> Alan, do you remember if we have a requirement for not holding locks
>> when calling usb_ep_disable()? I can't find Documentation about it, but
>> history shows me that usb_ep_disable() was called without locks and IRQs
>> enabled. Do you think we should update documentation about this?
>
> I don't think there is any requirement for interrupts to be enabled
> when usb_ep_disable() runs. At least, a quick check shows that both
> net2280 and dummy-hcd use spin_lock_irqsave() rather than spin_lock()
> in their disable routines.
>
> Holding locks is a different story. It should be okay for a gadget
> driver to hold one of its own locks when disabling an endpoint (which
> means that the gadget's disable routine shouldn't wait for a concurrent
> giveback to finish), but we might want to avoid holding a lock in the
> composite core. Although even that might be okay -- I can't think of
> any reason why a udc driver would need to call back into the composite
> core while disabling an endpoint. It should be a pretty self-contained
> operation.
True, but how do we handle controllers which need to wait for an
interrupt in order to cancel a transfer? Maybe we should change the
calling context of usb_ep_disable() so that it _must_ be called with
IRQs enabled?
--
balbi
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-13 09:30 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang <baolin.wang@linaro.org> - 2016-10-13 09:40 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-13 10:00 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang <baolin.wang@linaro.org> - 2016-10-13 10:10 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-13 12:00 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-13 13:00 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang <baolin.wang@linaro.org> - 2016-10-13 13:20 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-13 13:30 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang <baolin.wang@linaro.org> - 2016-10-13 15:10 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-13 15:40 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang <baolin.wang@linaro.org> - 2016-10-14 09:10 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-14 09:50 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang <baolin.wang@linaro.org> - 2016-10-14 11:20 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-14 12:00 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Alan Stern <stern@rowland.harvard.edu> - 2016-10-14 16:40 +0200
Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Felipe Balbi <balbi@kernel.org> - 2016-10-17 10:20 +0200
csiph-web