lkml.org 
[lkml]   [2016]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 28/31] cpia2_usb: don't use stack for DMA
Em Tue, 11 Oct 2016 22:56:06 +0000
Kosuke Tatsukawa <tatsu@ab.jp.nec.com> escreveu:

> Hi,
>
> > The USB control messages require DMA to work. We cannot pass
> > a stack-allocated buffer, as it is not warranted that the
> > stack would be into a DMA enabled area.
> >
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
> > Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
> > ---
> > drivers/media/usb/cpia2/cpia2_usb.c | 32 +++++++++++++++++++++++++++++---
> > 1 file changed, 29 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
> > index 13620cdf0599..417d683b237d 100644
> > --- a/drivers/media/usb/cpia2/cpia2_usb.c
> > +++ b/drivers/media/usb/cpia2/cpia2_usb.c
> > @@ -545,10 +545,19 @@ static void free_sbufs(struct camera_data *cam)
> > static int write_packet(struct usb_device *udev,
> > u8 request, u8 * registers, u16 start, size_t size)
> > {
> > + unsigned char *buf;
> > + int ret;
> > +
> > if (!registers || size <= 0)
> > return -EINVAL;
> >
> > - return usb_control_msg(udev,
> > + buf = kmalloc(size, GFP_KERNEL);
> > + if (!buf)
> > + return -ENOMEM;
> > +
> > + memcpy(buf, registers, size);
> > +
> > + ret = usb_control_msg(udev,
> > usb_sndctrlpipe(udev, 0),
> > request,
> > USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> > @@ -557,6 +566,9 @@ static int write_packet(struct usb_device *udev,
> > registers, /* buffer */
> =========
>
> I think you also want to change the argument to usb_control_msg() from
> "registers" to "buf" in write_packet().

True!

Thanks for pointing it! Just sent a version of the patch with this fixed.

Regards,
Mauro

\
 
 \ /
  Last update: 2016-10-12 04:20    [W:0.048 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site