add checks for DMA cache synchronisation function

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

add checks for DMA cache synchronisation function

Post by alex31 »

Hello,

More than one, I have been trapped by calling cacheBufferInvalidate or cacheBufferFlush with an unproperly aligned address. Is it possible to add an chDbgAssert in these 2 functions, that check that the 5 LSB of address are clear ?

The effects of passing unaligned address can go from subtle bug to hard hardware fault with smashed stack where debugger is of no help.

Alexandre -
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: add checks for DMA cache synchronisation function

Post by steved »

Not used the cacheBufferInvalidate or cacheBufferFlush functions yet, I don't think. But the earlier dmaBufferFlush() would accept and apparently work OK with any address. (I had a situation where a 3rd-party-created buffer was definitely not 32-byte aligned; I had to flush one more cache line than the minimum, to make sure the whole buffer was flushed).
So enforcing 32-byte boundaries could cause a different set of problems!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: add checks for DMA cache synchronisation function

Post by Giovanni »

Invalidating non aligned objects (address AND size) is a very bad idea, this would mean corrupting adjacent data. Flushing is not a problem.

Giovanni
Post Reply