[PATCH master 1/2] net: fsl-fman: fix alignment of RX buffer

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jan 8 02:14:18 PST 2024


The receive buffer needs to be cacheline aligned for cache maintenance
to avoid invalidating unrelated malloc memory. This was so far not the
case due to malloc's minimum alignment of 8-byte (with TLSF), so switch
to dma_alloc instead.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/net/fsl-fman.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c
index ff32fa8fc753..baafe027c079 100644
--- a/drivers/net/fsl-fman.c
+++ b/drivers/net/fsl-fman.c
@@ -620,9 +620,7 @@ static int fm_eth_rx_port_parameter_init(struct fm_eth *fm_eth)
 			* RX_BD_RING_SIZE);
 
 	/* alloc Rx buffer from main memory */
-	rx_buf_pool = malloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE);
-	if (!rx_buf_pool)
-		return -ENOMEM;
+	rx_buf_pool = dma_alloc(MAX_RXBUF_LEN * RX_BD_RING_SIZE);
 
 	memset(rx_buf_pool, 0, MAX_RXBUF_LEN * RX_BD_RING_SIZE);
 
-- 
2.39.2




More information about the barebox mailing list