2009-07-13 03:10:55     DMA bug in bfin_sport.c

Document created by Aaronwu Employee on Aug 16, 2013
Version 1Show Document
  • View in full screen mode

2009-07-13 03:10:55     DMA bug in bfin_sport.c

Jeppe Ledet-Pedersen (DENMARK)

Message: 77102   

 

Hi

 

The bfin_sport.c driver seems to contain a bug in the sport_read (line 530-536) and sport_write (line 608-614) functions. I have checked out the newest svn revision. When using DMA for transfers of more than 0x8000 words, the 2D DMA is enabled in the following way:

 

xcount = count / word_bytes;

ycount = 0;

if (xcount > 0x8000) {

    ycount = xcount >> 15;

    xcount = 0x8000;

    dma_config |= DMA2D;

}

 

As both xcount and ycount are defined as uint16_t, xcount >> 15 can max be 1 thus transferring only 0x8000 words. We have fixed it in the following way:

 

xcount = count / word_bytes;

ycount = 0;

if ((count / word_bytes) > 0x8000) {

    ycount = (count/word_bytes) >> 15;

    xcount = 0x8000;

    dma_config |= DMA2D;

}

 

This will of course only allow 2D DMA transfers of a multiple of 0x8000 words. Another question is why the driver does not use 1D DMA for data less than 0x10000? A better solution could be to use the code from the bf53x_sport.c sound driver, which does not require the data to be a multiple of 0x8000 words and only uses 2D for data greater than 0x10000. Perhaps one of the developers can come up with a better solution.

 

Best regards,

 

Jeppe

QuoteReplyEditDelete

 

 

2009-07-13 03:12:31     Re: DMA bug in bfin_sport.c

Jeppe Ledet-Pedersen (DENMARK)

Message: 77103   

 

This thread   blackfin.uclinux.org/gf/project/uclinux-dist/forum/?action=ForumBrowse&forum_id=39&_forum_action=ForumMessageBrowse&thread_id=3145 seems to be about the same problem. I'm surprised that no one else have had the problem for almost 3 years.

QuoteReplyEditDelete

Attachments

    Outcomes