embeddedsw icon indicating copy to clipboard operation
embeddedsw copied to clipboard

Reinitializing xemacpsif DMA on error case

Open juanriverafranceschi opened this issue 7 months ago • 1 comments

We were having some issues with an older version of xemacpsif and found some potential issues during code review. Most of them were already fixed in newer versions of the Xilinx release but there is one that is not.

The driver will call init_dma when an error callback occurs: https://github.com/Xilinx/embeddedsw/blob/master/ThirdParty/sw_services/lwip220/src/lwip-2.2.0/contrib/ports/xilinx/netif/xemacpsif.c#L471

init_dma increments the bd_space_index without resetting it to 0.
https://github.com/Xilinx/embeddedsw/blob/master/ThirdParty/sw_services/lwip220/src/lwip-2.2.0/contrib/ports/xilinx/netif/xemacpsif_dma.c#L660

If too many errors (~16) occur in the same power cycle it will eventually go past the end of the bd_space leading to overwriting whatever memory lives after. We have not seen that many errors occur in a single power cycle during our normal operation but noticed during code review that the risk is there. The fix would likely to set bd_space_index = 0 early in init_dma.

juanriverafranceschi avatar Jun 09 '25 19:06 juanriverafranceschi

@juanriverafranceschi : Noted, we will fix this.

venodela avatar Jun 15 '25 15:06 venodela