[Muscle] reducing polling inside pcsc-lite (libusb issue)

Todd Denniston Todd.Denniston at ssa.crane.navy.mil
Thu Feb 14 10:03:46 PST 2008


Ludovic Rousseau wrote, On 02/14/2008 11:27 AM:
> Hello,
> 
> Up to now pcscd is polling the card driver every 400ms
> (PCSCLITE_STATUS_POLL_RATE) to detect a card movement. This will wake
> up the CPU constantly and consume power.
> 
> Many CCID readers (but not all) can use an asynchronous message to
> send a card movement event to the host. This is supported in the CCID
> driver [1] version 1.3.3 with support of TAG_IFD_POLLING_THREAD.
> You need to use a snapshot of pcsc-lite [2] to use this feature.
> 
> My problem is that the libusb function usb_interrupt_read() is not
> efficient and will poll using a 1ms timeout.
> So instead of a polling every 400ms by pcscd we have a polling every
> 1ms by libusb. The situation is worse regarding CPU usage :-(
> 
> The problem in libusb has been discovered thanks to powertop [3] and
> be corrected in the subversion revision 657 [4] of
> /trunk/libusb/linux.c [5]. I backported the patch (attached) for
> libusb 0.1.12.
> But I have no idea when a new stable version of libusb (with the
> correction) will be available.
> 
> So what should I do?
> I plan to disable TAG_IFD_POLLING_THREAD in the CCID driver by default
> and allow a way to activate it using the driver Info.plist file.
> Other ideas? proposals? comments?
> 

Proposals/ideas:
A) in ./configure test for a libusb/OpenUSB version that you know does/will 
have the fix, and then disable TAG_IFD_POLLING_THREAD if that version is found 
and the person configuring has not given an option to force 
TAG_IFD_POLLING_THREAD.
B) in ./configure test for current and older libusb/OpenUSB versions that you 
know do not have the fix, and then enable TAG_IFD_POLLING_THREAD unless the 
person configuring has given an option to force no TAG_IFD_POLLING_THREAD.

Both of which are hoping that when ever a new version of either come out they 
will have the fix.
or
C)  in ./configure test for current and older libusb/OpenUSB versions that you 
know do not have the fix, if there is a newer version found drop a note to to 
the user indicating that if the polling issue was fixed in the libusb they are 
using they may wish to give a configure option to force no 
TAG_IFD_POLLING_THREAD.  And when you know a fixed version is out, you update 
the configure script next ccid release to test and do (A) appropriately.


> 
> libusb 0.1.x will not evolve much. libusb 1.0 [6] is on its way and is
> in competition with OpenUSB [7]. libusb 1.0 or OpenUSB have no stable
> release yet.
> 
> Regards,
> 
> [1] http://pcsclite.alioth.debian.org/ccid.html
> [2] http://ludovic.rousseau.free.fr/softwares/pcsc-lite/
> [3] http://www.lesswatts.org/projects/powertop/
> [4] http://libusb.svn.sourceforge.net/viewvc/libusb/trunk/libusb/linux.c?r1=597&r2=657
> [5] http://libusb.svn.sourceforge.net/viewvc/libusb/trunk/libusb/linux.c?view=log
> |6] http://libusb.wiki.sourceforge.net/Libusb1.0
> [7] http://openusb.sourceforge.net/
> 
> 

-- 
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter


More information about the Muscle mailing list