Xilinx / dma_ip_drivers

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

Why reserving extra 4 bytes in mmap_bar()? #187

Closed yu-zou closed 1 year ago

yu-zou commented 1 year ago

In reg_read_mmap function defined in linux-kernel/apps/dma-utils/dmactl_regs.c mmap_bar(fname, xcmd->req.reg.reg+4, PROT_READ) reserves extra 4 bytes in addition to the register length. What's the point of this reservation?

I tried removing this extra reservation, and the code does not work correctly. Originally, I thought it was used for address alignment, but it seems this extra 4 bytes have to be there.

Thank you.

hmaarrfk commented 1 year ago

The integer before the +4 likely refers to its address. You thus need to map not only the address, but also the size of the address you want to read.

yu-zou commented 1 year ago

@hmaarrfk Thanks for the reply. I see how it works. If I want to access a register at 4K address, then I should map 0~(4K+4), otherwise when I access the register at 4K, it will exceed boundary.