Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and write the address off mistakes #6

Open
nick1chao opened this issue Mar 21, 2017 · 7 comments
Open

Read and write the address off mistakes #6

nick1chao opened this issue Mar 21, 2017 · 7 comments

Comments

@nick1chao
Copy link

Hi Gianluca
I'm trying to use your driver on a zedboard, petalinux system.The kernel version is 4.6.0.When i run the applicatio,the error in the title comes up.

The driver is loaded successfully. I debug driver found problem here:

iowrite32(1, obj_dev->virt_bus_addr + MM2S_DMACR);
iowrite32(obj_dev->ds_axidma_handle, obj_dev->virt_bus_addr + MM2S_SA);
iowrite32(len, obj_dev->virt_bus_addr + MM2S_LENGTH);

Thanks for any help you can offer.

@durellinux
Copy link
Owner

durellinux commented Mar 21, 2017 via email

@nick1chao
Copy link
Author

Thank you for your answer.
The addresses used in the Vivado project is:

axi_dma_0 0x40400000
axi_dma_1 0x40410000
axi_dma_2 0x40420000
axi_dma_3 0x40430000

And here is my device tree:
amba_pl: amba_pl {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges ;
axi_dma_0: dma@40400000 {
#dma-cells = <1>;
clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = "xlnx,axi-dma-1.00.a";
interrupt-parent = <&intc>;
interrupts = <0 29 4 0 30 4>;
reg = <0x40400000 0x10000>;
xlnx,addrwidth = <0x20>;
dma-channel@40400000 {
compatible = "xlnx,axi-dma-mm2s-channel";
dma-channels = <0x1>;
interrupts = <0 29 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
};
dma-channel@40400030 {
compatible = "xlnx,axi-dma-s2mm-channel";
dma-channels = <0x1>;
interrupts = <0 30 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
};
};
axi_dma_1: dma@40410000 {
#dma-cells = <1>;
clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = "xlnx,axi-dma-1.00.a";
interrupt-parent = <&intc>;
interrupts = <0 31 4 0 32 4>;
reg = <0x40410000 0x10000>;
xlnx,addrwidth = <0x20>;
dma-channel@40410000 {
compatible = "xlnx,axi-dma-mm2s-channel";
dma-channels = <0x1>;
interrupts = <0 31 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x1>;
};
dma-channel@40410030 {
compatible = "xlnx,axi-dma-s2mm-channel";
dma-channels = <0x1>;
interrupts = <0 32 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x1>;
};
};
axi_dma_2: dma@40420000 {
#dma-cells = <1>;
clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = "xlnx,axi-dma-1.00.a";
interrupt-parent = <&intc>;
interrupts = <0 33 4 0 34 4>;
reg = <0x40420000 0x10000>;
xlnx,addrwidth = <0x20>;
dma-channel@40420000 {
compatible = "xlnx,axi-dma-mm2s-channel";
dma-channels = <0x1>;
interrupts = <0 33 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x2>;
};
dma-channel@40420030 {
compatible = "xlnx,axi-dma-s2mm-channel";
dma-channels = <0x1>;
interrupts = <0 34 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x2>;
};
};
axi_dma_3: dma@40430000 {
#dma-cells = <1>;
clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = "xlnx,axi-dma-1.00.a";
interrupt-parent = <&intc>;
interrupts = <0 35 4 0 36 4>;
reg = <0x40430000 0x10000>;
xlnx,addrwidth = <0x20>;
dma-channel@40430000 {
compatible = "xlnx,axi-dma-mm2s-channel";
dma-channels = <0x1>;
interrupts = <0 35 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x3>;
};
dma-channel@40430030 {
compatible = "xlnx,axi-dma-s2mm-channel";
dma-channels = <0x1>;
interrupts = <0 36 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x3>;
};
};
};

The addresses is same.
Where there is a problem?

@fspada
Copy link
Collaborator

fspada commented Mar 21, 2017

Hi,
it seems there are 2 errors here:
1 - the compatible string doesn't match with the driver: To correctly use the driver change the compatible attribute in:
compatible = "ds_axidma";
2 - in the dts change the description of the device from

axi_dma_0: dma@4040000 {
#dma-cells = <1>;
clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
compatible = "xlnx,axi-dma-1.00.a";
interrupt-parent = <&intc>;
interrupts = <0 29 4 0 30 4>;
reg = <0x40400000 0x10000>;
xlnx,addrwidth = <0x20>;
dma-channel@4040000 {
compatible = "xlnx,axi-dma-mm2s-channel";
dma-channels = <0x1>;
interrupts = <0 29 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
};
dma-channel@4040003 {
compatible = "xlnx,axi-dma-s2mm-channel";
dma-channels = <0x1>;
interrupts = <0 30 4>;
xlnx,datawidth = <0x20>;
xlnx,device-id = <0x0>;
};
};

to
axi_dma_1: axi-dma1@4040000 {
compatible = "ds_axidma";
reg = <0x40400000 0x10000>;
} ;
also for axi_dma_1 axi_dma_2 and axi_dma_3.
The driver only needs the compatible and reg attributes. All the rest (interrupts, dual channel) is not supported.

@fspada
Copy link
Collaborator

fspada commented Mar 21, 2017

@nick1chao
Copy link
Author

Hi
I have already changed the device tree,the compatible is same with the driver.But the error is still on.
Here is my device tree:

           axi-dma1@40400000 {
                    compatible = "ds_axidma";
                    reg = <0x40400000 0x10000>;
            };

            axi-dma2@40410000 {
                    compatible = "ds_axidma";
                    reg = <0x40410000 0x10000>;
            };

            axi-dma3@40420000 {
                    compatible = "ds_axidma";
                    reg = <0x40420000 0x10000>;
            };

            axi-dma4@40430000 {
                    compatible = "ds_axidma";
                    reg = <0x40430000 0x10000>;
            };

The insmod command is ok:
root@dmaRegister:/lib/modules/4.6.0-xilinx/extra# insmod dmatest.ko
init: registered
DMA_LENGTH = 32768
init: registered
DMA_LENGTH = 32768
init: registered
DMA_LENGTH = 32768
init: registered
DMA_LENGTH = 32768

But run the application,the error log:

ARM 1 3 0.333333 0
Unhandled fault: page domain fault (0x01b) at 0x00022008
pgd = de5e4000
[00022008] *pgd=1e4d5831, *pte=00ae375f, *ppte=00ae3c7f
Internal error: Oops - BUG: 1b [#2] PREEMPT SMP ARM
Modules linked in: dmatest(O) ipv6 [last unloaded: dmatest]
CPU: 1 PID: 1039 Comm: dmaapp Tainted: G D O 4.6.0-xilinx #4
Hardware name: Xilinx Zynq Platform
task: de5f85c0 ti: ddcba000 task.ti: ddcba000
PC is at memcpy+0xc0/0x330
LR is at ds_axidma_write+0x30/0xa4 [dmatest]
pc : [] lr : [] psr: 800c0013
sp : ddcbbedc ip : 0f400000 fp : 00000003
r10: 00000000 r9 : ddcba000 r8 : c0107084
r7 : 00022008 r6 : 00022008 r5 : de428080 r4 : 00000001
r3 : de4280d8 r2 : 80000000 r1 : 00022008 r0 : df048000
Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 18c5387d Table: 1e5e404a DAC: 00000051
Process dmaapp (pid: 1039, stack limit = 0xddcba210)
Stack: (0xddcbbedc to 0xddcbc000)
bec0: df048000
bee0: 00000001 bf061408 00000001 bf0613d8 ddcbbf88 00022008 c0107084 c01c5ff0
bf00: 00000000 00000000 00000000 ddcbbf10 00000000 00000000 00000400 de48e000
bf20: 00000006 de63bb18 00000006 de63bb40 00000002 de63bb00 00000001 de594600
bf40: ddcbbf88 00000001 de594600 00000001 de594600 ddcbbf88 00022008 c01c6c0c
bf60: de594600 00022008 00000001 de594600 de594600 00022008 00000001 c0107084
bf80: ddcba000 c01c775c 00000000 00000000 00000001 00000000 00000001 00000001
bfa0: 00000004 c0106ec0 00000000 00000001 00000003 00022008 00000001 00022008
bfc0: 00000000 00000001 00000001 00000004 00000006 00000005 00000004 00000003
bfe0: 00000000 befd9c2c 00010b40 b6f308e0 600c0010 00000003 4241403f 46454443
[] (memcpy) from [] (ds_axidma_write+0x30/0xa4 [dmatest])
[] (ds_axidma_write [dmatest]) from [] (__vfs_write+0x1c/0x)
[] (__vfs_write) from [] (vfs_write+0xa8/0x130)
[] (vfs_write) from [] (SyS_write+0x40/0x80)
[] (SyS_write) from [] (ret_fast_syscall+0x0/0x3c)
Code: e4808004 e480e004 e8bd01e0 e1b02f82 (14d13001)
---[ end trace ec921171af79cdd8 ]---
Segmentation fault

I use the petalinux 2016.3,kernel version is 4.6.0 and the board is zedboard.
Where is the problem may occur.

@fspada
Copy link
Collaborator

fspada commented Mar 22, 2017

It seems that the page fault is generated by the memcpy.
In the ds_axidma_write function substitute the memcpy with copy_from_user function, here the signature:
static inline long copy_from_user(void *to, const void __user * from, unsigned long n)

also in ds_axidma_read substitute memcpy with copy_to_user function, here the signature:
static inline long copy_to_user(void __user *to, const void *from, unsigned long n)

I think we have to fix the driver.

@fspada
Copy link
Collaborator

fspada commented Mar 22, 2017

Let me know if this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants