Re: [PATCH v3 1/4] usb: gadget: f_midi: free usb request when done
From: Clemens Ladisch
Date: Mon Oct 12 2015 - 08:10:29 EST
Felipe Tonello wrote:
> On Mon, Oct 12, 2015 at 11:16 AM, Clemens Ladisch <clemens@xxxxxxxxxx> wrote:
>> Felipe Tonello wrote:
>>> I believe that is the best way to implement. Create multiple requests
>>> until the ALSA substreams buffer are empty and free the request on
>>> completion.
>>
>> I believe a better way to implement this is to allocate a fixed number
>> of requests, and to always reuse them.
>
> How many?
Enough to get proper pipelining. At least two, maybe not more.
(Depends on how fast those tiny CPUs can queue the next request.)
>>> The problem of having requests when host isn't listening will happen
>>> anyway because there is no way to know that until completion.
>>
>> But if you have no upper limit on the number of queues requests, you
>> will eventually run out of (DMA) memory.
>
> And that's what happening at the moment. One of my patches are to fix
> a memory leak when that happens.
>
> But it would be ideal to have a FIFO of requests and perhaps ignore
> new requests if the FIFO is full.
>
> So, allocate (pre-allocate?) new requests until the FIFO is full. Upon
> completion, remove the request from FIFO, but still reuse it on
> f_midi_transmit() and queue it on the FIFO again if there is still
> data from ALSA, otherwise just free the request.
Yes, that's exactly what I'm proposing.
Regards,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/