lkml.org 
[lkml]   [2021]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v7 17/19] staging: r8188eu: shorten calls chain of rtw_read{8,16,32}()
On Fri, Sep 17, 2021 at 03:01:27PM +0000, David Laight wrote:
> From: Greg Kroah-Hartman
> > Sent: 17 September 2021 15:50
> ...
> > > +static int usb_read(struct intf_hdl *intfhdl, u16 addr, void *data, u8 size)
> > > +{
> > > + struct adapter *adapt = intfhdl->padapter;
> > > + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt);
> > > + struct usb_device *udev = dvobjpriv->pusbdev;
> > > + int status;
> > > + u8 *io_buf; /* Pointer to I/O buffer */
> >
> > As you "know" size is not going to be larger than 4 (hint, you should
> > prboably check it), just use bytes off of the stack here, and you can
> > ignore this buffer entirely. That will hopefully allow you in the
> > future to get rid of that buffer as odds are it will not be needed
> > anymore.
>
> Isn't that likely to be the buffer that gets dma'd to/from?
> In which case it can't be on-stack.
> Certainly that is a common problem with usb drivers.

Yes it was a problem, which is why the USB core function called here
does not require that and makes sure to allocate the buffer itself so
that all will be fine.

> Give the size of the urb? structure allocated for each transfer
> adding a bounce buffer area in it for short transfers would
> surely be sane.

USB speeds are slow you will never notice the difference for control
messages.

thanks,

greg k-h

\
 
 \ /
  Last update: 2021-09-17 17:22    [W:0.043 / U:1.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site