Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE
Can anyone confirm my understanding of this example code in C2000Ware version 3.01.00.00?
In f2838xif.c, in the routine f2838xif_transmit() the descriptor data pointer is set to the pbuf data pointer:
pktDescPtr->dataBuffer = q->payload;
The caller of f2838xif_transmit() subsequently calls pbuf_free() as the call stack unwinds.
This is a bug, because there is no synchronization between these two events:
1) copying of the memory by the DMA engine
2) freeing of the pbuf, and subsequent reuse by some other code
What should be done, if I understand LWIP's pbuf model correctly, is that the f2838xif interface layer increments the reference count using pbuf_ref() and then somehow saves the pbuf pointer, and then when TX completion happens in f2338xif_process_transmit(), recovers the pbuf pointer, and calls pbuf_free(). The result is that whichever pbuf_free() happens last will cause the memory to actually be freed, and the DMA access is guaranteed to precede it.
Thank you for your attention and advice.
Regards,
Nik