cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vconst89
Adventurer
Adventurer
264 Views
Registered: ‎09-10-2020

U50, XDMA driver problem

Hi,

 

I'm using XDMA driver from this repo, compiled and inserted the module

https://github.com/Xilinx/dma_ip_drivers/tree/master/XDMA/linux-kernel

 

 

$ ls /dev/ | grep xdma
xdma
xdma0_bypass
xdma0_bypass_c2h_0
xdma0_bypass_c2h_1
xdma0_bypass_h2c_0
xdma0_bypass_h2c_1
xdma0_c2h_0
xdma0_c2h_1
xdma0_control
xdma0_events_0
..........
xdma0_events_15
xdma0_h2c_0
xdma0_h2c_1
xdma0_user
xdma0_xvc

$ lspci -v -nn -s 17:00
17:00.1 Processing accelerators [1200]: Xilinx Corporation Device [10ee:5021]
        Subsystem: Xilinx Corporation Device [10ee:000e]
        Flags: bus master, fast devsel, latency 0, IRQ 67, NUMA node 0
        Memory at 380070000000 (64-bit, prefetchable) [size=32M]
        Memory at 380074000000 (64-bit, prefetchable) [size=128K]
        Memory at 380060000000 (64-bit, prefetchable) [size=256M]
        Capabilities: [40] Power Management version 3
        Capabilities: [60] MSI-X: Enable+ Count=32 Masked-
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [e00] Access Control Services
        Capabilities: [e10] #15
        Capabilities: [e80] Vendor Specific Information: ID=0020 Rev=0 Len=010 <?>
        Kernel driver in use: xdma
        Kernel modules: xocl

 

 

 

But dma tests are failing and the problem is in return code from read/write operations

 

$ ./dma_from_device 
/dev/xdma0_c2h_0, read 0x20 @ 0x0 failed -1.
read file: Unknown error 512

$ ./dma_to_device 
write buffer to AXI MM address using SGDMA
write file: Unknown error 512

And the kernel messages

$ dmesg -k
[325109.621423] xdma:xdma_xfer_submit: xfer 0x0000000084cb9289,32, s 0x1 timed out, ep 0x20.
[325109.621429] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x0000000064c9537e) = 0x1fc10006 (id).
[325109.621432] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x00000000f72be762) = 0x00000000 (status).
[325109.621434] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x00000000257b98ea) = 0x00f83e1e (control)
[325109.621437] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x000000009ac4f85f) = 0x3f8a0200 (first_desc_lo)
[325109.621439] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x000000009b7498e7) = 0x00000000 (first_desc_hi)
[325109.621442] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x00000000635f9235) = 0x00000000 (first_desc_adjacent).
[325109.621444] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x000000007bbe953f) = 0x00000000 (completed_desc_count).
[325109.621447] xdma:engine_reg_dump: 0-C2H0-MM: ioread32(0x00000000cc6f05a3) = 0x00f83e5e (interrupt_enable_mask)
[325109.621451] xdma:engine_status_dump: SG engine 0-C2H0-MM status: 0x00000000:
[325109.621454] xdma:transfer_abort: abort transfer 0x0000000084cb9289, desc 1, engine desc queued 0.

Here's some basic test, that tries to read and write all 4 DMA-channel-files

 

https://pastebin.com/FpKet2A6

	char xdma_devices[][20] = {"/dev/xdma0_h2c_0",
								"/dev/xdma0_h2c_1",
								"/dev/xdma0_c2h_0",
								"/dev/xdma0_c2h_1"};

	size_t i = 0;
	int fpga_fd =-100;
	int rcw,rcr = -100;
	signed char wr_buf[ 4]  = {11 , 22, 33, 44};
	signed char rd_buf[20] = {0};
	 
	for( i = 0; i < sizeof(xdma_devices) / sizeof(xdma_devices[0]); i++)
	{	
		fpga_fd = open(xdma_devices[i], O_RDWR);
	    rcr =  read( fpga_fd, rd_buf, 1);
	    rcw = write( fpga_fd, wr_buf, 1);
	    fprintf(stdout,"Device  %s \t code  %d \t  Write %d \t Read %d\n",xdma_devices[i],fpga_fd,rcw,rcr);
	    close(fpga_fd);
	}

 

And all 4 files can be opened, but all of them are not available neither for reading nor for writing, return code is always -1

Device  /dev/xdma0_h2c_0         code  3          Write -1       Read -1
Device  /dev/xdma0_h2c_1         code  3          Write -1       Read -1
Device  /dev/xdma0_c2h_0         code  3          Write -1       Read -1
Device  /dev/xdma0_c2h_1         code  3          Write -1       Read -1

All 4 leads to similar errors in the kernel log

What can be the reasons for this problem? 

0 Kudos
Reply
2 Replies
vconst89
Adventurer
Adventurer
246 Views
Registered: ‎09-10-2020

 

https://github.com/Xilinx/dma_ip_drivers/blob/master/XDMA/linux-kernel/xdma/cdev_sgdma.c#L372 

	if ((write && engine->dir != DMA_TO_DEVICE) ||
	    (!write && engine->dir != DMA_FROM_DEVICE)) {
		pr_err("r/w mismatch. W %d, dir %d.\n",
			write, engine->dir);
		return -EINVAL;
	}
[324871.541874] xdma:char_sgdma_read_write: r/w mismatch. W 1, dir 2.
0 Kudos
Reply
vconst89
Adventurer
Adventurer
181 Views
Registered: ‎09-10-2020

Any thoughts or suggestions?

0 Kudos
Reply