[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libftdi
Subject:    Re: [libftdi-1.0] Limit read buffer chunksize to 16384 on Linux
From:       Jie Zhang <jie.zhang () analog ! com>
Date:       2010-02-15 9:59:57
Message-ID: 4B791B1D.8040808 () analog ! com
[Download RAW message or body]

On 02/15/2010 05:36 PM, Thomas Jarosch wrote:
> Hello Jie,
>
> On Sunday, 14. February 2010 12:17:58 Jie Zhang wrote:
>> On Sun, Feb 14, 2010 at 5:58 PM, Jim Paris<jim@jtan.com>  wrote:
>>>> +#ifdef __linux__
>>>> +    /* We can't set readbuffer_chunksize larger than
>>>> MAX_BULK_BUFFER_LENGTH, +       which is defined in libusb-1.0.
>>>>   Otherwise, each USB read request will +       be divided into
>>>> multiple URBs.  This will cause issues on Linux kernel +       older
>>>> than 2.6.32.  */
>>>> +    if (chunksize>  16384)
>>>> +        chunksize = 16384;
>>>
>>> Shouldn't this be
>>>
>>>> +    if (chunksize>  MAX_BULK_BUFFER_LENGTH)
>>>> +        chunksize = MAX_BULK_BUFFER_LENGTH;
>>
>> MAX_BULK_BUFFER_LENGTH is a macro defined in an internal header file
>> in libusb. So we can't use it here.
>
> Hmm, here's a comment from libusb 1.0:
>
> 	/* usbfs places a 16kb limit on bulk URBs. we divide up larger requests
> 	 * into smaller units to meet such restriction, then fire off all the
> 	 * units at once. it would be simpler if we just fired one unit at a time,
> 	 * but there is a big performance gain through doing it this way. */
> 	int num_urbs = transfer->length / MAX_BULK_BUFFER_LENGTH;
>
> Just guess what happens if the usbfs restriction is resolved
> and libusb adjusts the interface... this -will- break.
>
> Is there some data structure we could read out?

AFAIK, no.

> Or include the internal header file during the build
> stage of libftdi to determine the value?
>
But the internal header file is not installed. We can't require source 
code of libusb is available when building libftdi. But I think we can 
ask on libusb mailing list if it's OK to move the macro definition out 
to libusb.h. I will do that.


Jie

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@developer.intra2net.com   

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic