How to find dma_request_chan() failure reason details?

2.4k Views Asked by At

In an external kernel module, using DMA Engine, when calling dma_request_chan() returns an error pointer of value -19, i.e. ENODEV or "No such device". Now, in the active device tree, I do find a dma-names entry with what I'm trying to get a channel for, so my suspicion is that something else deeper in the forest is already not found.

How do I find out what's wrong?

Background:

I have a Zynq MP Ultrascale+ board here, with an FPGA design which uses AXI VDMA block to provide one channel of data to be received on the Cortex A's Linux, where the data is written to DDR4 by the FPGA and to be read from Linux.

I found that there is a Xilinx DMA driver included in the kernel, in the Xilinx source repo anyway, currently kernel version 5.6.0. And that that driver has no user space interface, such that an intermediate kernel driver is needed.

This is depicted, and they have an example here: Section "4 DMA Proxy Design". I modified the code in the dma-proxy.c of the zip file linked there such that it uses only the RX channel, i.e. also only tries to request it.

The code for that is here, to not make this post huge: Modified dma-proxy.c at onlinegdb.com

  • Line 407 has the function create_channel(), which used to use dma_request_slave_channel() which ditches the error code of the function it wraps, so to see the error, I am using that one instead: dma_request_chan().
  • The function create_channel() is called in function dma_proxy_probe() @ line 470 (the occurences before that are deactivated by compile switch).
  • So by way of this call, dma_request_chan() will be called with the parameters:

    • create_channel(pdev, &channels[RX_CHANNEL], "dma_proxy_rx", DMA_DEV_TO_MEM);

The Device Tree for my board has an added node for dma-proxy driver as is shown at the top of the dma-proxy.c

dma_proxy {
  compatible ="xlnx,dma_proxy";
  dmas = <&axi_dma_0 0>;
  dma-names = "dma_proxy_rx";
};

The name "axi_dma_0" matches with the name in the axi DMA device tree node:

axi_dma_0: dma@a0000000 {
    #dma-cells = <0x1>;
    clock-names = "s_axi_lite_aclk", "m_axi_s2mm_aclk";
    clocks = <0x3 0x47 0x3 0x47>;
    compatible = "xlnx,axi-dma-7.1", "xlnx,axi-dma-1.00.a";
    interrupt-names = "s2mm_introut";
    interrupt-parent = <0x1d>;
    interrupts = <0x0 0x2>;
    reg = <0x0 0xa0000000 0x0 0x1000>;
    xlnx,addrwidth = <0x28>;
    xlnx,sg-length-width = <0x1a>;
    phandle = <0x1e>;

    dma-channel@a0000030 {
        compatible = "xlnx,axi-dma-s2mm-channel";
        dma-channels = <0x1>;
        interrupts = <0x0 0x2>;
        xlnx,datawidth = <0x40>;
        xlnx,device-id = <0x0>;
    };

If I now look here:

% cat /proc/device-tree/dma_proxy/dma-names
dma_proxy_rx

Looks like my dma_proxy_rx, that I'm trying to request the channel for, is in there.

Edit: In the boot log, I see this:

xilinx-vdma a0000000.dma: Please ensure that IP supports buffer length > 23 bits
irq: no irq domain found for interrupt-controller@a0010000 !
xilinx-vdma a0000000.dma: unable to request IRQ 0
xilinx-vdma a0000000.dma: WARN: Device release is not defined so it is not safe to unbind this driver while in use
xilinx-vdma a0000000.dma: Xilinx AXI DMA Engine Driver Probed!!

There are warnings - but in the end, the Xilinx AXI DMA Engine got "probed", meaning the lowest level driver loaded and is ready, right?

So it looks to me like there should be my device, but the kernel disagrees.

1

There are 1 best solutions below

1
On BEST ANSWER

I've got the same problem with similar configuration. After digging a lot of kernel source code (especially drivers/dma/xilinx/xilinx_dma.c) I've solved this problem by changing channel number in dmas parameter from 0 to 1 in dma-proxy device tree entry like this:

dma_proxy {
  compatible ="xlnx,dma_proxy";
  dmas = <&axi_dma_0 1>;
  dma-names = "dma_proxy_rx";
};

It seems that dma-proxy example is written for AXI DMA block with both mm2s (channel #0) and s2mm (channel #1) channels. And if we remove mm2s channel from AXI DMA block, the s2mm channel stays #1.