All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Baolin Wang <baolin.wang@linaro.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Mark Brown <broonie@kernel.org>, USB <linux-usb@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq
Date: Mon, 17 Oct 2016 11:10:45 +0300	[thread overview]
Message-ID: <871szftmyi.fsf@linux.intel.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1610141021490.1816-100000@iolanthe.rowland.org>

[-- Attachment #1: Type: text/plain, Size: 2346 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 800 bytes --]

      reply	other threads:[~2016-10-17  8:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 11:37 [PATCH v2] usb: dwc3: gadget: Wait for end transfer complete before free irq Baolin Wang
2016-10-13  7:02 ` Felipe Balbi
2016-10-13  7:34   ` Baolin Wang
2016-10-13  7:51     ` Felipe Balbi
2016-10-13  8:00       ` Baolin Wang
2016-10-13  9:55         ` Felipe Balbi
2016-10-13 10:56           ` Felipe Balbi
2016-10-13 11:16             ` Baolin Wang
2016-10-13 11:23               ` Felipe Balbi
2016-10-13 12:41                 ` Baolin Wang
2016-10-13 13:34                   ` Felipe Balbi
2016-10-14  7:03                     ` Baolin Wang
2016-10-14  7:46                       ` Felipe Balbi
2016-10-14  9:10                         ` Baolin Wang
2016-10-14  9:50                           ` Felipe Balbi
2016-10-14 14:36                         ` Alan Stern
2016-10-17  8:10                           ` Felipe Balbi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871szftmyi.fsf@linux.intel.com \
    --to=balbi@kernel.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.