Page 1 of 1

add checks for DMA cache synchronisation function

Posted: Wed Apr 24, 2019 4:09 pm
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 -

Re: add checks for DMA cache synchronisation function

Posted: Wed Apr 24, 2019 6:04 pm
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!

Re: add checks for DMA cache synchronisation function

Posted: Wed Apr 24, 2019 11:17 pm
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