On 30/08/15(Sun) 09:31, John L. Scarfone wrote:
> On Sun, Aug 30, 2015 at 12:32:24PM +0200, Martin Pieuchot stated:
> > That's good but the original design of allocating an xfer for every
> > usbd_transfer(9) call does not make much sense.  
> > 
> > You could allocate two xfers (one for read and one for write) at the
> > same time the pipes are opened and free them when they're closed.
> > 
> > You could even allocate the DMA buffer with usb_alloc_buffer() and pass
> > the USBD_NO_COPY flag to usbd_transfer(9) to avoid a supplementary copy.
> 
> Thanks for the feedback, Martin. I've been running with your first
> suggestion for a bit with no issues. I wonder though if the xfer can't
> just be shared for rx and tx?

You cannot easily do that because the CPU executing usbd_transfer(9)
with a USBD_SYNCHRONOUS flag might sleep.  So if you try to submit
another transfer at this moment using the same "xfer" descriptor bad
things will happen ;)

>                               I also NULLed out the pipes on failure
> since it looks like otherwise they'd be re-closed on detach. I'll look
> into the usbd_alloc_buffer() idea.

That'd great, thanks.

I've just committed your diff, good work.

Reply via email to