Xilinx / dma_ip_drivers

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

reg_rw program only reads registers that are 1kB aligned #155

Open lenazh opened 2 years ago

lenazh commented 2 years ago

reg_rw fails to read registers that are not 1kB aligned. This is caused by the mmap call on line 98 failing. I am using Versal CPM example.

For example:

[root@localhost tools]# ./reg_rw /dev/xdma0_control 0x0000
device: /dev/xdma0_control, address: 0x00000000, access read.
access width: word (32-bits)
character device /dev/xdma0_control opened.
Memory 0x0 mapped at address 0x7fed00edc000.
Read 32-bit value at address 0x00000000 (0x7fed00edc000): 0x1fc00001

[root@localhost tools]# ./reg_rw /dev/xdma0_control 0x0004
device: /dev/xdma0_control, address: 0x00000004, access read.
access width: word (32-bits)
character device /dev/xdma0_control opened.
Error at line 91, file reg_rw.c (22) [Invalid argument]

[root@localhost tools]# ./reg_rw /dev/xdma0_control 0x0010
device: /dev/xdma0_control, address: 0x00000010, access read.
access width: word (32-bits)
character device /dev/xdma0_control opened.
Error at line 91, file reg_rw.c (22) [Invalid argument]

[root@localhost tools]# ./reg_rw /dev/xdma0_control 0x0100
device: /dev/xdma0_control, address: 0x00000100, access read.
access width: word (32-bits)
character device /dev/xdma0_control opened.
Error at line 91, file reg_rw.c (22) [Invalid argument]

[root@localhost tools]# ./reg_rw /dev/xdma0_control 0x1000
device: /dev/xdma0_control, address: 0x00001000, access read.
access width: word (32-bits)
character device /dev/xdma0_control opened.
Memory 0x1000 mapped at address 0x7f356672e000.
Read 32-bit value at address 0x00001000 (0x7f356672e000): 0x1fc10001

[root@localhost tools]# uname -a
Linux localhost.localdomain 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost tools]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
JamieLuo commented 2 years ago

I have experienced this issue as well, on my machine the page size is 4KB. So I have no idea how to read the register that does not in a 4KB alignment. Anybody know is there any other way to access all the registers in the bar?