@@ -1295,6 +1295,11 @@ const static struct ipc_service_backend backend_ops = {
12951295 .release_rx_buffer = release_rx_buffer ,
12961296};
12971297
1298+ /**
1299+ * Required block alignment.
1300+ */
1301+ #define BLOCK_ALIGNMENT sizeof(uint32_t)
1302+
12981303/**
12991304 * Number of bytes per each ICMsg message. It is used to calculate size of ICMsg area.
13001305 */
@@ -1308,28 +1313,28 @@ const static struct ipc_service_backend backend_ops = {
13081313 (PBUF_HEADER_OVERHEAD(GET_CACHE_ALIGNMENT(i)) + 2 * BYTES_PER_ICMSG_MESSAGE)
13091314
13101315/**
1311- * Returns required block alignment for instance "i".
1316+ * Returns required data cache alignment for instance "i".
13121317 */
13131318#define GET_CACHE_ALIGNMENT (i ) \
1314- MAX(sizeof(uint32_t) , DT_INST_PROP_OR(i, dcache_alignment, 0))
1319+ MAX(BLOCK_ALIGNMENT , DT_INST_PROP_OR(i, dcache_alignment, 0))
13151320
13161321/**
13171322 * Calculates minimum size required for ICMsg region for specific number of local
13181323 * and remote blocks. The minimum size ensures that ICMsg queue is will never overflow
13191324 * because it can hold data message for each local block and release message
13201325 * for each remote block.
13211326 */
1322- #define GET_ICMSG_MIN_SIZE (i , local_blocks , remote_blocks ) \
1327+ #define GET_ICMSG_MIN_SIZE (i , local_blocks , remote_blocks ) ROUND_UP( \
13231328 (ICMSG_BUFFER_OVERHEAD(i) + BYTES_PER_ICMSG_MESSAGE * \
1324- (local_blocks + remote_blocks))
1329+ (local_blocks + remote_blocks)), GET_CACHE_ALIGNMENT(i))
13251330
13261331/**
13271332 * Calculate aligned block size by evenly dividing remaining space after removing
13281333 * the space for ICMsg.
13291334 */
13301335#define GET_BLOCK_SIZE (i , total_size , local_blocks , remote_blocks ) ROUND_DOWN( \
13311336 ((total_size) - GET_ICMSG_MIN_SIZE(i, (local_blocks), (remote_blocks))) / \
1332- (local_blocks), GET_CACHE_ALIGNMENT(i) )
1337+ (local_blocks), BLOCK_ALIGNMENT )
13331338
13341339/**
13351340 * Calculate offset where area for blocks starts which is just after the ICMsg.
@@ -1434,11 +1439,11 @@ const static struct ipc_service_backend backend_ops = {
14341439 }; \
14351440 BUILD_ASSERT(IS_POWER_OF_TWO(GET_CACHE_ALIGNMENT(i)), \
14361441 "This module supports only power of two cache alignment"); \
1437- BUILD_ASSERT((GET_BLOCK_SIZE_INST(i, tx, rx) >= GET_CACHE_ALIGNMENT(i)) && \
1442+ BUILD_ASSERT((GET_BLOCK_SIZE_INST(i, tx, rx) >= BLOCK_ALIGNMENT) && \
14381443 (GET_BLOCK_SIZE_INST(i, tx, rx) < \
14391444 GET_MEM_SIZE_INST(i, tx)), \
14401445 "TX region is too small for provided number of blocks"); \
1441- BUILD_ASSERT((GET_BLOCK_SIZE_INST(i, rx, tx) >= GET_CACHE_ALIGNMENT(i)) && \
1446+ BUILD_ASSERT((GET_BLOCK_SIZE_INST(i, rx, tx) >= BLOCK_ALIGNMENT) && \
14421447 (GET_BLOCK_SIZE_INST(i, rx, tx) < \
14431448 GET_MEM_SIZE_INST(i, rx)), \
14441449 "RX region is too small for provided number of blocks"); \
0 commit comments