Changeset 1342

Show
Ignore:
Timestamp:
09/24/08 05:45:25 (12 years ago)
Author:
ppalmers
Message:

improve interrupt scheduling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/config.h.in

    r1299 r1342  
    128128#define MAX_XMIT_PACKET_SIZE                         (2048-16) 
    129129#define MAX_XMIT_NB_BUFFERS                                200 
     130 
     131// should be PAGE_SIZE (4096) for unpatched kernels 
     132#define RAW1394_RCV_MIN_BUF_STRIDE                        4096 
    130133 
    131134#define ISOHANDLER_FLUSH_BEFORE_ITERATE                      0 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.cpp

    r1292 r1342  
    352352        #ifdef DEBUG 
    353353        if(m_poll_fds_shadow[i].revents) { 
    354             debugOutput(DEBUG_LEVEL_ULTRA_VERBOSE, 
     354            debugOutputExtreme(DEBUG_LEVEL_VERBOSE, 
    355355                        "(%p, %s) received events: %08X for (%d/%d, %p, %s)\n", 
    356356                        this, (m_handlerType == IsoHandler::eHT_Transmit? "Transmit": "Receive"), 
     
    760760        // setup the optimal parameters for the raw1394 ISO buffering 
    761761        unsigned int packets_per_period = stream->getPacketsPerPeriod(); 
    762         unsigned int max_packet_size = stream->getMaxPacketSize(); 
    763         unsigned int page_size = getpagesize() - 2; // for one reason or another this is necessary 
     762        unsigned int max_packet_size = stream->getMaxPacketSize() + 8; // bufferfill takes another 8 bytes for headers 
     763        unsigned int page_size = getpagesize(); 
    764764 
    765765        // Ensure we don't request a packet size bigger than the 
    766766        // kernel-enforced maximum which is currently 1 page. 
     767        // NOTE: PP: this is not really true AFAICT 
    767768        if (max_packet_size > page_size) { 
    768769            debugError("max packet size (%u) > page size (%u)\n", max_packet_size, page_size); 
     
    770771        } 
    771772 
    772         unsigned int irq_interval = packets_per_period / MINIMUM_INTERRUPTS_PER_PERIOD; 
    773         if(irq_interval <= 0) irq_interval=1; 
    774          
     773        // the interrupt/wakeup interval prediction of raw1394 is a mess... 
     774        int wanted_irq_interval = (packets_per_period-1) / MINIMUM_INTERRUPTS_PER_PERIOD; 
     775        if(wanted_irq_interval <= 0) wanted_irq_interval=1; 
     776 
     777        // mimic kernel initialization 
     778        unsigned int kern_buff_stride = RAW1394_RCV_MIN_BUF_STRIDE; 
     779        for (; kern_buff_stride < max_packet_size; kern_buff_stride *= 2); 
     780        if (kern_buff_stride > page_size) kern_buff_stride = page_size; 
     781        // kern_buff_stride is the minimal granularity of interrupts 
     782        // therefore the following will result in on-average correct interrupt timing 
     783        int irq_interval = (wanted_irq_interval * max_packet_size) / kern_buff_stride; 
     784 
    775785        // the receive buffer size doesn't matter for the latency, 
    776786        // but it has a minimal value in order for libraw to operate correctly (300)