From: Simon Haggett <simon.haggett@realvnc.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Li Yang-R58472 <r58472@freescale.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"balbi@ti.com" <balbi@ti.com>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Subject: Re: [PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware
Date: Mon, 22 Oct 2012 12:49:51 +0100 [thread overview]
Message-ID: <508532DF.7050809@realvnc.com> (raw)
In-Reply-To: <1535820.NU10ADjvOZ@avalon>
Hi
On 22/10/12 11:47, Laurent Pinchart wrote:
> Hi,
>
> On Monday 22 October 2012 03:33:19 Li Yang-R58472 wrote:
>> On Saturday, October 20, 2012 1:37 AM Felipe Balbi wrote:
>>> On Fri, Oct 19, 2012 at 06:19:26PM +0100, Simon Haggett wrote:
>>>> Some gadget drivers may attempt to dequeue requests for an endpoint
>>>> that has already been disabled. For example, in the UVC gadget driver,
>>>> uvc_function_set_alt() will call usb_ep_disable() when alt setting 0
>>>> is selected. When the userspace application subsequently issues the
>>>> VIDIOC_STREAMOFF ioctl, uvc_video_enable() invokes usb_ep_dequeue() to
>>>
>>> ensure that all requests have been cancelled.
>>>
>>> bug is on uvc gadget, then. Laurent ?
>
> We've discussed this topic a couple of months before. I believe that's not a
> bug.
>
> http://68.183.106.108/lists/linux-usb/msg68869.html
>
>>> Also, fsl should be removed from the tree, I'm trying to persuade iMX
>>> folks to use drivers/usb/chipidea instead.
>>
>> Besides the iMX usage, the driver is also being used by many Freescale
>> PowerPC/Coldfire SoCs. I agree that it's ideal to move to a common driver.
>> But it is a large task to make the chipidea driver works for all the
>> hardware that fsl_udc had supported and been tested on.
>>
>>>> For the Freescale High Speed Dual-Role USB controller,
>>>> fsl_ep_dequeue() provides the implementation of usb_ep_dequeue(). If
>>>> this is called for a disabled endpoint, a kernel oops will occur when
>>>
>>> the ep->ep.desc field is dereferenced (by ep_index()).
>>>
>>>> fsl_ep_disable() sets this field to NULL, as well as deleting all
>>>> pending requests for the endpoint.
>>>>
>>>> This patch adds an additional check to fsl_ep_dequeue() to ensure that
>>>> the endpoint has not already been disabled before attempting to dequeue
>>>
>>> requests.
>>>
>>>> Signed-off-by: Simon Haggett <simon.haggett@realvnc.com>
>>>> ---
>>>>
>>>> drivers/usb/gadget/fsl_udc_core.c | 5 ++++-
>>>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/gadget/fsl_udc_core.c
>>>> b/drivers/usb/gadget/fsl_udc_core.c
>>>> index 6ae70cb..acd513b 100644
>>>> --- a/drivers/usb/gadget/fsl_udc_core.c
>>>> +++ b/drivers/usb/gadget/fsl_udc_core.c
>>>> @@ -955,7 +955,10 @@ static int fsl_ep_dequeue(struct usb_ep *_ep,
>>> struct usb_request *_req)
>>>
>>>> int ep_num, stopped, ret = 0;
>>>> u32 epctrl;
>>>>
>>>> - if (!_ep || !_req)
>>>> + /* Ensure that the ep and request are valid, and the ep is not
>>>> + * disabled
>>>> + */
>>>> + if (!_ep || !_req || !ep->ep.desc)
>>>> return -EINVAL;
>
> Shouldn't that last check be done with a lock taken ?
I had presumed a lock wasn't necessary because ep->ep.desc is only set
to NULL by fsl_ep_disable() which, since it is called by
usb_ep_disable(), should only be invoked when no other task is using the
endpoint (according to include/linux/usb/gadget.h). Furthermore, the
chipidea UDC driver does check the equivalent of this field is not NULL
without taking a lock (ep_dequeue() in drivers/usb/chipidea/udc.c).
However, it is possible that I'm misunderstanding something here, so
apologies if I am.
>
>>>> spin_lock_irqsave(&ep->udc->lock, flags);
>
Many thanks
Simon
WARNING: multiple messages have this Message-ID (diff)
From: Simon Haggett <simon.haggett@realvnc.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Li Yang-R58472 <r58472@freescale.com>,
"balbi@ti.com" <balbi@ti.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware
Date: Mon, 22 Oct 2012 12:49:51 +0100 [thread overview]
Message-ID: <508532DF.7050809@realvnc.com> (raw)
In-Reply-To: <1535820.NU10ADjvOZ@avalon>
Hi
On 22/10/12 11:47, Laurent Pinchart wrote:
> Hi,
>
> On Monday 22 October 2012 03:33:19 Li Yang-R58472 wrote:
>> On Saturday, October 20, 2012 1:37 AM Felipe Balbi wrote:
>>> On Fri, Oct 19, 2012 at 06:19:26PM +0100, Simon Haggett wrote:
>>>> Some gadget drivers may attempt to dequeue requests for an endpoint
>>>> that has already been disabled. For example, in the UVC gadget driver,
>>>> uvc_function_set_alt() will call usb_ep_disable() when alt setting 0
>>>> is selected. When the userspace application subsequently issues the
>>>> VIDIOC_STREAMOFF ioctl, uvc_video_enable() invokes usb_ep_dequeue() to
>>>
>>> ensure that all requests have been cancelled.
>>>
>>> bug is on uvc gadget, then. Laurent ?
>
> We've discussed this topic a couple of months before. I believe that's not a
> bug.
>
> http://68.183.106.108/lists/linux-usb/msg68869.html
>
>>> Also, fsl should be removed from the tree, I'm trying to persuade iMX
>>> folks to use drivers/usb/chipidea instead.
>>
>> Besides the iMX usage, the driver is also being used by many Freescale
>> PowerPC/Coldfire SoCs. I agree that it's ideal to move to a common driver.
>> But it is a large task to make the chipidea driver works for all the
>> hardware that fsl_udc had supported and been tested on.
>>
>>>> For the Freescale High Speed Dual-Role USB controller,
>>>> fsl_ep_dequeue() provides the implementation of usb_ep_dequeue(). If
>>>> this is called for a disabled endpoint, a kernel oops will occur when
>>>
>>> the ep->ep.desc field is dereferenced (by ep_index()).
>>>
>>>> fsl_ep_disable() sets this field to NULL, as well as deleting all
>>>> pending requests for the endpoint.
>>>>
>>>> This patch adds an additional check to fsl_ep_dequeue() to ensure that
>>>> the endpoint has not already been disabled before attempting to dequeue
>>>
>>> requests.
>>>
>>>> Signed-off-by: Simon Haggett <simon.haggett@realvnc.com>
>>>> ---
>>>>
>>>> drivers/usb/gadget/fsl_udc_core.c | 5 ++++-
>>>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/gadget/fsl_udc_core.c
>>>> b/drivers/usb/gadget/fsl_udc_core.c
>>>> index 6ae70cb..acd513b 100644
>>>> --- a/drivers/usb/gadget/fsl_udc_core.c
>>>> +++ b/drivers/usb/gadget/fsl_udc_core.c
>>>> @@ -955,7 +955,10 @@ static int fsl_ep_dequeue(struct usb_ep *_ep,
>>> struct usb_request *_req)
>>>
>>>> int ep_num, stopped, ret = 0;
>>>> u32 epctrl;
>>>>
>>>> - if (!_ep || !_req)
>>>> + /* Ensure that the ep and request are valid, and the ep is not
>>>> + * disabled
>>>> + */
>>>> + if (!_ep || !_req || !ep->ep.desc)
>>>> return -EINVAL;
>
> Shouldn't that last check be done with a lock taken ?
I had presumed a lock wasn't necessary because ep->ep.desc is only set
to NULL by fsl_ep_disable() which, since it is called by
usb_ep_disable(), should only be invoked when no other task is using the
endpoint (according to include/linux/usb/gadget.h). Furthermore, the
chipidea UDC driver does check the equivalent of this field is not NULL
without taking a lock (ep_dequeue() in drivers/usb/chipidea/udc.c).
However, it is possible that I'm misunderstanding something here, so
apologies if I am.
>
>>>> spin_lock_irqsave(&ep->udc->lock, flags);
>
Many thanks
Simon
next prev parent reply other threads:[~2012-10-22 12:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-19 17:19 [PATCH 1/1] usb: gadget: Don't attempt to dequeue requests for a disabled USB endpoint on Freescale hardware Simon Haggett
2012-10-19 17:19 ` Simon Haggett
2012-10-19 17:37 ` Felipe Balbi
2012-10-19 17:37 ` Felipe Balbi
2012-10-22 3:33 ` Li Yang-R58472
2012-10-22 3:33 ` Li Yang-R58472
2012-10-22 7:53 ` Felipe Balbi
2012-10-22 7:53 ` Felipe Balbi
2012-10-22 10:47 ` Laurent Pinchart
2012-10-22 10:47 ` Laurent Pinchart
2012-10-22 10:56 ` Felipe Balbi
2012-10-22 10:56 ` Felipe Balbi
2012-10-25 0:36 ` Laurent Pinchart
2012-10-25 0:36 ` Laurent Pinchart
2012-10-26 8:14 ` Felipe Balbi
2012-10-26 8:14 ` Felipe Balbi
2012-10-22 11:49 ` Simon Haggett [this message]
2012-10-22 11:49 ` Simon Haggett
2012-10-25 0:33 ` Laurent Pinchart
2012-10-25 0:33 ` Laurent Pinchart
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=508532DF.7050809@realvnc.com \
--to=simon.haggett@realvnc.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=r58472@freescale.com \
/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.