Xilinx / dma_ip_drivers

Xilinx QDMA IP Drivers
https://xilinx.github.io/dma_ip_drivers/
581 stars 421 forks source link

suspicious code xdma write_from_buffer #153

Open vissermc opened 2 years ago

vissermc commented 2 years ago

This function only does an lseek when the offset is non-zero, but in practice, offset can be zero, and in that case it will continue from writing from previous call. Same applies to read_to_buffer if (offset) { rc = lseek(fd, offset, SEEK_SET);

byzantic commented 1 year ago

Yes, this gave me a lot of problems.

I was using write_from_buffer, but the source buffer on the FPGA was a ring buffer, so offsets cycled back to 0, but used the previous address! This led me to weeks of frustrating debug.

I removed the if (offset) and always performed the lseek.

In fairness to the original author the kernel module, this issue only exists in the example test code, but of course we all copy that into our working code, don't we?