Changeset 1372

Show
Ignore:
Timestamp:
10/23/08 10:02:34 (12 years ago)
Author:
ppalmers
Message:

Host controller reliability changes:

  • make receive DMA mode selectable (but still hardcoded ATM). Some controllers seem to work better in bufferfill mode.
  • introduce a maximum number of ISO buffers for receive, lower the max nb of ISO buffers for xmit
  • make the number of buffers for receive and transmit a power of two
  • ensure at least two hardware interrupts per complete ISO buffer wraparound
Files:

Legend:

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

    r1371 r1372  
    133133// due to weirdness in the kernel layer 
    134134#define MAX_XMIT_PACKET_SIZE                         (2048-16) 
    135 #define MAX_XMIT_NB_BUFFERS                                200 
     135#define MAX_XMIT_NB_BUFFERS                                128 
     136#define MAX_RECV_NB_BUFFERS                                128 
    136137 
    137138// should be PAGE_SIZE (4096) for unpatched kernels 
  • branches/libffado-2.0/src/libieee1394/ieee1394service.cpp

    r1371 r1372  
    292292        } 
    293293    } 
    294      
    295     // check state 
     294 
     295    // init helpers 
    296296    if(!m_pCTRHelper) { 
    297297        debugFatal("No CycleTimerHelper available, bad!\n"); 
     
    309309    } 
    310310    m_pIsoManager->setVerboseLevel(getDebugLevel()); 
     311 
     312    m_pIsoManager->setReceiveMode(RAW1394_DMA_PACKET_PER_BUFFER); 
     313 
    311314    if(!m_pIsoManager->init()) { 
    312315        debugFatal("Could not initialize IsoHandlerManager\n"); 
  • branches/libffado-2.0/src/libieee1394/IsoHandler.cpp

    r1345 r1372  
    8181   , m_last_now( 0xFFFFFFFF ) 
    8282   , m_last_packet_handled_at( 0xFFFFFFFF ) 
     83   , m_receive_mode ( RAW1394_DMA_PACKET_PER_BUFFER ) 
    8384   , m_Client( 0 ) 
    8485   , m_speed( RAW1394_ISO_SPEED_400 ) 
     
    106107   , m_last_now( 0xFFFFFFFF ) 
    107108   , m_last_packet_handled_at( 0xFFFFFFFF ) 
     109   , m_receive_mode ( RAW1394_DMA_PACKET_PER_BUFFER ) 
    108110   , m_Client( 0 ) 
    109111   , m_speed( RAW1394_ISO_SPEED_400 ) 
     
    131133   , m_last_now( 0xFFFFFFFF ) 
    132134   , m_last_packet_handled_at( 0xFFFFFFFF ) 
     135   , m_receive_mode ( RAW1394_DMA_PACKET_PER_BUFFER ) 
    133136   , m_Client( 0 ) 
    134137   , m_speed( speed ) 
     
    675678                                m_max_packet_size, 
    676679                                m_Client->getChannel(), 
    677                                 RAW1394_DMA_PACKET_PER_BUFFER
     680                                m_receive_mode
    678681                                m_irq_interval)) { 
    679             debugFatal("Could not do receive initialisation (DMA_BUFFERFILL)!\n" ); 
     682            debugFatal("Could not do receive initialisation!\n" ); 
    680683            debugFatal("  %s\n",strerror(errno)); 
    681684            return false; 
  • branches/libffado-2.0/src/libieee1394/IsoHandler.h

    r1343 r1372  
    168168    uint32_t getLastPacketTime() {return m_last_packet_handled_at;}; 
    169169 
     170    /** 
     171     * @brief set iso receive mode. doesn't have any effect if the stream is running 
     172     * @param m receive mode 
     173     */ 
     174    void setReceiveMode(enum raw1394_iso_dma_recv_mode m) 
     175        {m_receive_mode = m;} 
     176 
    170177    void notifyOfDeath(); 
    171178    bool handleBusReset(); 
     
    181188    uint32_t        m_last_now; 
    182189    uint32_t        m_last_packet_handled_at; 
     190    enum raw1394_iso_dma_recv_mode m_receive_mode; 
    183191 
    184192    Streaming::StreamProcessor *m_Client; // FIXME: implement with functors 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.cpp

    r1345 r1372  
    459459   , m_IsoThreadReceive ( NULL ) 
    460460   , m_IsoTaskReceive ( NULL ) 
     461   , m_receive_mode( RAW1394_DMA_PACKET_PER_BUFFER ) 
    461462{ 
    462463} 
     
    470471   , m_IsoThreadReceive ( NULL ) 
    471472   , m_IsoTaskReceive ( NULL ) 
     473   , m_receive_mode( RAW1394_DMA_PACKET_PER_BUFFER ) 
    472474{ 
    473475} 
     
    777779        // the receive buffer size doesn't matter for the latency, 
    778780        // but it has a minimal value in order for libraw to operate correctly (300) 
    779         int buffers=400; 
     781        int buffers=1; 
     782        while(buffers < (int)packets_per_period && buffers < MAX_RECV_NB_BUFFERS) { 
     783            buffers *= 2; 
     784        } 
     785 
     786        // ensure at least 2 hardware interrupts per ISO buffer wraparound 
     787        if(irq_interval > buffers/2) { 
     788            irq_interval = buffers/2; 
     789        } 
    780790 
    781791        // create the actual handler 
     792        debugOutput( DEBUG_LEVEL_VERBOSE, " creating IsoRecvHandler\n"); 
    782793        h = new IsoHandler(*this, IsoHandler::eHT_Receive, 
    783794                           buffers, max_packet_size, irq_interval); 
    784  
    785         debugOutput( DEBUG_LEVEL_VERBOSE, " creating IsoRecvHandler\n"); 
    786795 
    787796        if(!h) { 
     
    790799        } 
    791800 
     801        h->setReceiveMode(m_receive_mode); 
     802 
    792803    } else if (stream->getType()==StreamProcessor::ePT_Transmit) { 
    793804        // setup the optimal parameters for the raw1394 ISO buffering 
    794 //        unsigned int packets_per_period = stream->getPacketsPerPeriod(); 
    795805        unsigned int max_packet_size = stream->getMaxPacketSize(); 
    796 //         unsigned int page_size = getpagesize(); 
    797  
    798         // Ensure we don't request a packet size bigger than the 
    799         // kernel-enforced maximum which is currently 1 page. 
    800 //         if (max_packet_size > page_size) { 
    801 //             debugError("max packet size (%u) > page size (%u)\n", max_packet_size, page_size); 
    802 //             return false; 
    803 //         } 
     806 
    804807        if (max_packet_size > MAX_XMIT_PACKET_SIZE) { 
    805808            debugError("max packet size (%u) > MAX_XMIT_PACKET_SIZE (%u)\n", 
     
    809812 
    810813        // the SP specifies how many packets to ISO-buffer 
    811         int buffers = stream->getNbPacketsIsoXmitBuffer(); 
    812         if (buffers > MAX_XMIT_NB_BUFFERS) { 
    813             debugOutput(DEBUG_LEVEL_VERBOSE, 
    814                         "nb buffers (%u) > MAX_XMIT_NB_BUFFERS (%u)\n", 
    815                         buffers, MAX_XMIT_NB_BUFFERS); 
    816             buffers = MAX_XMIT_NB_BUFFERS; 
    817         } 
    818         unsigned int irq_interval = buffers / MINIMUM_INTERRUPTS_PER_PERIOD; 
    819         if(irq_interval <= 0) irq_interval=1; 
     814        int req_buffers = stream->getNbPacketsIsoXmitBuffer(); 
     815        int buffers=1;  
     816        while(buffers < (int)req_buffers && buffers < MAX_RECV_NB_BUFFERS) { 
     817            buffers *= 2; 
     818        } 
     819 
     820        int irq_interval = req_buffers / MINIMUM_INTERRUPTS_PER_PERIOD; 
     821        if(irq_interval <= 0) irq_interval = 1; 
     822        // ensure at least 2 hardware interrupts per ISO buffer wraparound 
     823        if(irq_interval > buffers/2) irq_interval = buffers/2; 
    820824 
    821825        debugOutput( DEBUG_LEVEL_VERBOSE, " creating IsoXmitHandler\n"); 
  • branches/libffado-2.0/src/libieee1394/IsoHandlerManager.h

    r1292 r1372  
    197197         */ 
    198198        bool handleBusReset(); 
     199 
     200        /** 
     201         * @brief set iso receive mode. doesn't have any effect if the stream is running 
     202         * @param m receive mode 
     203         */ 
     204        void setReceiveMode(enum raw1394_iso_dma_recv_mode m) 
     205            {m_receive_mode = m;} 
     206 
    199207    // the state machine 
    200208    private: 
     
    236244        Util::Thread *  m_IsoThreadReceive; 
    237245        IsoTask *       m_IsoTaskReceive; 
     246        enum raw1394_iso_dma_recv_mode m_receive_mode; 
    238247 
    239248        // debug stuff