On Thu, Sep 03, 2015 at 09:52:57AM +0200, Martin Pieuchot wrote:
> On 01/09/15(Tue) 22:26, Grant Czajkowski wrote:
> > In ugen(4), bulk reads of length > UGEN_BBSIZE are split into
> > multiple transfers. This patch instead sends a single
> > transfer utilizing USBD_NO_COPY.
>
> Committed with one tweak below. Do not hesitate to elaborate *why*
> you'd like to see such change committed, it might not be obvious to
> all the tech@ readers ;)
Thanks Martin, I will keep that in mind in the future. The
intent of this change is to reduce the amount of copying
done by using the DMA buffer directly and simplify the code
by removing the while loop.
> > @@ -541,14 +541,19 @@ ugen_do_read(struct ugen_softc *sc, int
> > xfer = usbd_alloc_xfer(sc->sc_udev);
> > if (xfer == 0)
> > return (ENOMEM);
> > - flags = USBD_SYNCHRONOUS;
> > + flags = USBD_SYNCHRONOUS | USBD_NO_COPY;
> > if (sce->state & UGEN_SHORT_OK)
> > flags |= USBD_SHORT_XFER_OK;
> > if (sce->timeout == 0)
> > flags |= USBD_CATCH;
> > - while ((n = min(UGEN_BBSIZE, uio->uio_resid)) != 0) {
> > + if ((n = uio->uio_resid) != 0) {
> > + buf = usbd_alloc_buffer(xfer, n);
> > + if (buf == 0) {
> ^^^^
> I changed this into "if (buff == NULL)" since we compare pointers to
> NULL. I know that ugen(4) needs a bit of cleanup in this regard, feel
> free to convert them if you wish :)
>