[lkml]   [2009]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 5/5] usb_debug: EXPERIMENTAL - poll hcd device to force writes
Am Mittwoch, 6. Mai 2009 21:24:56 schrieb Alan Stern:
> On Wed, 6 May 2009, Oliver Neukum wrote:

> A little thought yielded the following algorithm. It assumes there is
> a fixed set of URBs allocated, unlike what you have done. Does it make

No, it does not ;-) Your approach is more general than you think.
The only important constraint is that the number of URBs in flight
be limited. It doesn't matter when they are allocated.

> sense to take this approach?


> Let N be the total number of URBs allocated, each capable of holding up
> to B bytes. Let NIF be the number of URBs in flight at any time, so
> the number of available URBs is N - NIF. The number of available bytes
> might be < (N - NIF)*B because the next URB might be partially full.
> P is an adjustable parameter of the algorithm. For simplicity you can
> take P = 1, but increasing P (any value below N is okay) would yield
> reduced latency at the cost of more partially-filled URB submissions
> (so possibly reduced throughput).
> Write routine:
> Copy bytes into the available URB buffers, submitting URBs as
> they get filled. At the end, if the next URB is partially full
> then submit it only if NIF < P.

I did so. In principle. I am leaving the iteration to the tty layer.

> Completion routine:
> If the next URB to send is partially filled, submit it.

Much easier if P = N - 1

> write_room routine:
> Return the actual number of bytes remaining in the available
> URBs, but no more than (N-P)*B.


> How does that sound? Converting \n to \r\n will add some complication
> but not too much.
> Allocating URBs on the fly adds a lot of complication. There has to be
> a minimum number of pre-allocated URBs; otherwise write_room could

Why? You can always calculate with the number of URBs you'd
allocate as a maximum.

> never return a positive value. If you allocate additional URBs
> later on, when would you free them?

Like you free all URBs, on completion.


 \ /
  Last update: 2009-05-06 22:05    [W:0.067 / U:16.068 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site