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.
User avatar
Posts: 299
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 26 times
Been thanked: 37 times

add checks for DMA cache synchronisation function

Postby alex31 » Wed Apr 24, 2019 4:09 pm


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 -

Posts: 731
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 10 times
Been thanked: 106 times

Re: add checks for DMA cache synchronisation function

Postby steved » Wed Apr 24, 2019 6:04 pm

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
Site Admin
Posts: 13063
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 757 times
Been thanked: 636 times

Re: add checks for DMA cache synchronisation function

Postby Giovanni » Wed Apr 24, 2019 11:17 pm

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


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 1 guest