2012-11-19 21:40:03

by Cyril Roelandt

[permalink] [raw]
Subject: [PATCH] UVC: use GFP_ATOMIC under spin lock.

Found using the following semantic patch:
<spml>
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
</spml>

Signed-off-by: Cyril Roelandt <[email protected]>
---
drivers/usb/gadget/uvc_video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index b0e53a8..79b4132 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -309,7 +309,7 @@ uvc_video_pump(struct uvc_video *video)
video->encode(req, video, buf);

/* Queue the USB request */
- if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
+ if ((ret = usb_ep_queue(video->ep, req, GFP_ATOMIC)) < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(&video->queue.irqlock, flags);
--
1.7.10.4


2012-11-22 18:29:18

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH] UVC: use GFP_ATOMIC under spin lock.

On Thu, Nov 22, 2012 at 09:09:57AM +0100, walter harms wrote:
>
>
> Am 19.11.2012 22:34, schrieb Cyril Roelandt:
> > Found using the following semantic patch:
> > <spml>
> > @@
> > @@
> > spin_lock_irqsave(...);
> > ... when != spin_unlock_irqrestore(...);
> > * GFP_KERNEL
> > </spml>
> >
> > Signed-off-by: Cyril Roelandt <[email protected]>
> > ---
> > drivers/usb/gadget/uvc_video.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
> > index b0e53a8..79b4132 100644
> > --- a/drivers/usb/gadget/uvc_video.c
> > +++ b/drivers/usb/gadget/uvc_video.c
> > @@ -309,7 +309,7 @@ uvc_video_pump(struct uvc_video *video)
> > video->encode(req, video, buf);
> >
> > /* Queue the USB request */
> > - if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
> > + if ((ret = usb_ep_queue(video->ep, req, GFP_ATOMIC)) < 0) {
> > printk(KERN_INFO "Failed to queue request (%d)\n", ret);
> > usb_ep_set_halt(video->ep);
> > spin_unlock_irqrestore(&video->queue.irqlock, flags);
>
>
> IMHO, this should be two lines, aka:
>
> ret = usb_ep_queue(video->ep, req, GFP_KERNEL);
> if (ret<0)

correct, please resend with the fix.

--
balbi


Attachments:
(No filename) (1.23 kB)
signature.asc (836.00 B)
Digital signature
Download all attachments

2012-11-22 19:11:09

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH] UVC: use GFP_ATOMIC under spin lock.

On Thursday 22 November 2012 14:22:23 Felipe Balbi wrote:
> On Thu, Nov 22, 2012 at 09:09:57AM +0100, walter harms wrote:
> > Am 19.11.2012 22:34, schrieb Cyril Roelandt:
> > > Found using the following semantic patch:
> > > <spml>
> > > @@
> > > @@
> > > spin_lock_irqsave(...);
> > > ... when != spin_unlock_irqrestore(...);
> > > * GFP_KERNEL
> > > </spml>
> > >
> > > Signed-off-by: Cyril Roelandt <[email protected]>
> > > ---
> > >
> > > drivers/usb/gadget/uvc_video.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/usb/gadget/uvc_video.c
> > > b/drivers/usb/gadget/uvc_video.c index b0e53a8..79b4132 100644
> > > --- a/drivers/usb/gadget/uvc_video.c
> > > +++ b/drivers/usb/gadget/uvc_video.c
> > > @@ -309,7 +309,7 @@ uvc_video_pump(struct uvc_video *video)
> > >
> > > video->encode(req, video, buf);
> > >
> > > /* Queue the USB request */
> > >
> > > - if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
> > > + if ((ret = usb_ep_queue(video->ep, req, GFP_ATOMIC)) < 0) {
> > >
> > > printk(KERN_INFO "Failed to queue request (%d)\n", ret);
> > > usb_ep_set_halt(video->ep);
> > > spin_unlock_irqrestore(&video->queue.irqlock, flags);
> >
> > IMHO, this should be two lines, aka:
> >
> > ret = usb_ep_queue(video->ep, req, GFP_KERNEL);
> > if (ret<0)
>
> correct, please resend with the fix.

I agree as well.

--
Regards,

Laurent Pinchart


Attachments:
signature.asc (490.00 B)
This is a digitally signed message part.

2012-11-22 19:25:28

by walter harms

[permalink] [raw]
Subject: Re: [PATCH] UVC: use GFP_ATOMIC under spin lock.



Am 19.11.2012 22:34, schrieb Cyril Roelandt:
> Found using the following semantic patch:
> <spml>
> @@
> @@
> spin_lock_irqsave(...);
> ... when != spin_unlock_irqrestore(...);
> * GFP_KERNEL
> </spml>
>
> Signed-off-by: Cyril Roelandt <[email protected]>
> ---
> drivers/usb/gadget/uvc_video.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
> index b0e53a8..79b4132 100644
> --- a/drivers/usb/gadget/uvc_video.c
> +++ b/drivers/usb/gadget/uvc_video.c
> @@ -309,7 +309,7 @@ uvc_video_pump(struct uvc_video *video)
> video->encode(req, video, buf);
>
> /* Queue the USB request */
> - if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
> + if ((ret = usb_ep_queue(video->ep, req, GFP_ATOMIC)) < 0) {
> printk(KERN_INFO "Failed to queue request (%d)\n", ret);
> usb_ep_set_halt(video->ep);
> spin_unlock_irqrestore(&video->queue.irqlock, flags);


IMHO, this should be two lines, aka:

ret = usb_ep_queue(video->ep, req, GFP_KERNEL);
if (ret<0)

just my two cents,

re,
wh

2012-11-25 02:04:58

by Cyril Roelandt

[permalink] [raw]
Subject: [PATCH v2] UVC: use GFP_ATOMIC under spin lock.

Found using the following semantic patch:
<spml>
@@
@@
spin_lock_irqsave(...);
... when != spin_unlock_irqrestore(...);
* GFP_KERNEL
</spml>

Signed-off-by: Cyril Roelandt <[email protected]>
---
drivers/usb/gadget/uvc_video.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
index b0e53a8..cd067a6 100644
--- a/drivers/usb/gadget/uvc_video.c
+++ b/drivers/usb/gadget/uvc_video.c
@@ -309,7 +309,8 @@ uvc_video_pump(struct uvc_video *video)
video->encode(req, video, buf);

/* Queue the USB request */
- if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
+ ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
+ if (ret < 0) {
printk(KERN_INFO "Failed to queue request (%d)\n", ret);
usb_ep_set_halt(video->ep);
spin_unlock_irqrestore(&video->queue.irqlock, flags);
--
1.7.10.4

2012-11-27 13:13:14

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v2] UVC: use GFP_ATOMIC under spin lock.

Hi Cyril,

Thank you for the patch.

On Sunday 25 November 2012 02:58:19 Cyril Roelandt wrote:
> Found using the following semantic patch:
> <spml>
> @@
> @@
> spin_lock_irqsave(...);
> ... when != spin_unlock_irqrestore(...);
> * GFP_KERNEL
> </spml>
>
> Signed-off-by: Cyril Roelandt <[email protected]>

Acked-by: Laurent Pinchart <[email protected]>

and applied to my tree

> ---
> drivers/usb/gadget/uvc_video.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/uvc_video.c b/drivers/usb/gadget/uvc_video.c
> index b0e53a8..cd067a6 100644
> --- a/drivers/usb/gadget/uvc_video.c
> +++ b/drivers/usb/gadget/uvc_video.c
> @@ -309,7 +309,8 @@ uvc_video_pump(struct uvc_video *video)
> video->encode(req, video, buf);
>
> /* Queue the USB request */
> - if ((ret = usb_ep_queue(video->ep, req, GFP_KERNEL)) < 0) {
> + ret = usb_ep_queue(video->ep, req, GFP_ATOMIC);
> + if (ret < 0) {
> printk(KERN_INFO "Failed to queue request (%d)\n", ret);
> usb_ep_set_halt(video->ep);
> spin_unlock_irqrestore(&video->queue.irqlock, flags);
--
Regards,

Laurent Pinchart