udmabuf: udmabuf of_reserved_mem_device failed

Hello,

I’m trying to set up a udmabuf on a memory device inside the PL side of a ZynqMP at address 0x4_0000_0000. I’m using the Petalinux kernel version 4.19.0-xilinx-v2019.1 with a Debian Stretch rootfs. I’m running into an issue though, of_reserved_mem_device_init is failing, returning -22. Here is the section of my device tree for the reserved memory region and udmabuf:

amba_pl@0 {
                #address-cells = <0x2>;
                #size-cells = <0x2>;
                compatible = "simple-bus";
                ranges;

                reserved-memory {
                        #address-cells = <2>;
                        #size-cells = <2>;
                        ranges;
                        image_buf0: image_buf@0 {
                                compatible = "shared-dma-pool";
                                reusable;
                                reg = <0x4 0x0 0x0 0x400000>;
                                label = "image_buf0";
                        };
                };

                udmabuf@0 {
                        compatible = "ikwzm,udmabuf-0.10.a";
                        device-name = "udmabuf0";
                        size = <0x0 0x400000>;
                        memory-region = <&image_buf0>;
                };
        };

Here’s what happens when I try to load udmabuf:

rocky@zynq:~/repos/udmabuf$ sudo insmod udmabuf.ko 
[ 1076.852053] udmabuf amba_pl@0:udmabuf@0: of_reserved_mem_device_init failed. return=-22
[ 1076.860210] udmabuf amba_pl@0:udmabuf@0: driver installed.
[ 1076.865730] udmabuf: probe of amba_pl@0:udmabuf@0 failed with error -22

I’ve attached the full kernel log as well. Can you help me find where it is going wrong?

dmesg.txt

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (10 by maintainers)

Most upvoted comments

u-dma-buf v3.2.0-rc.3 has been experimentally released.

Please try specifying dma-mask=<64> or dma-mask=<40> in the device tree.

       udmabuf@400000000 {
                compatible = "ikwzm,u-dma-buf";
                device-name = "udmabuf0";
                size = <0x400000>;
                dma-mask = <64>;
                memory-region = <&image_buf0>;
        };

If you do not specify the dma-mask, the dma area is limited to the 32-bit address. Therefore, the buffer may not be allocated from the memory area specified by memory-region. This is my guess. I don’t have your environment, so I can’t confirm. If it doesn’t bother you, please try.

I think this did it! I see this when I load the kernel module:

root@zynq:/mnt/foo# insmod u-dma-buf.ko 
[   25.048672] u_dma_buf: loading out-of-tree module taints kernel.
[   25.055924] u-dma-buf udmabuf@400000000: assigned reserved memory node image_buf@400000000
[   25.175385] u-dma-buf udmabuf0: driver version = 3.2.0-rc.3
[   25.180958] u-dma-buf udmabuf0: major number   = 243
[   25.185923] u-dma-buf udmabuf0: minor number   = 0
[   25.190708] u-dma-buf udmabuf0: phys address   = 0x0000000400000000
[   25.196967] u-dma-buf udmabuf0: buffer size    = 268435456
[   25.202452] u-dma-buf udmabuf@400000000: driver installed.

I see lots of cacheline fills to the memory on HPM0 on my ILA. I tested this on both kernel 4.19 and 5.4, both seemed to work correctly.

Thank you so much for your help. I couldn’t have gotten this working on my own.

https://github.com/ikwzm/udmabuf/issues/33

I posted there my working device tree.

You can look at that… I was struggling with similar problem. Check first your compatibility nose if you are using udmabuf or the other one u-dma-buf.

If I remember correctly I had the reserved memory node outside of the amba section, only the udma bug inside