title: How to find dma_request_chan() failure reason details?
body: <p>In an external kernel module, using DMA Engine, when calling <code>dma_request_chan()</code> returns an error pointer of value -19, i.e. <em>ENODEV</em> or "No such device".
  Now, in the active device tree, I do find a <strong>dma-names</strong> 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.</p>
  
  <p><strong>How do I find out what's wrong?</strong></p>
  
  <p>Background:</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>This is depicted, and they have an example here: <a href="https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842418/Linux+DMA+From+User+Space" rel="nofollow noreferrer">Section "4 DMA Proxy Design"</a>. I modified the code in the <em>dma-proxy.c</em> of the zip file linked there such that it uses only the RX channel, i.e. also only tries to request it.</p>
  
  <p>The code for that is here, to not make this post huge:
  <a href="https://onlinegdb.com/Hy8VL2-9I" rel="nofollow noreferrer">Modified <em>dma-proxy.c</em> at onlinegdb.com</a></p>
  
  <ul>
  <li>Line 407 has the function <code>create_channel()</code>, which used to use <code>dma_request_slave_channel()</code> which ditches the error code of the function it wraps, so to see the error, I am using that one instead: <code>dma_request_chan()</code>.</li>
  <li>The function <code>create_channel()</code> is called in function <code>dma_proxy_probe()</code> @ line 470 (the occurences before that are deactivated by compile switch).</li>
  <li><p>So by way of this call, <code>dma_request_chan()</code> will be called with the parameters:</p>
  
  <ul>
  <li><code>create_channel(pdev, &amp;channels[RX_CHANNEL], "dma_proxy_rx", DMA_DEV_TO_MEM);</code></li>
  </ul></li>
  </ul>
  
  <p>The <em>Device Tree</em> for my board has an added node for dma-proxy driver as is shown at the top of the <em>dma-proxy.c</em></p>
  
  <pre class="lang-dts prettyprint-override"><code>dma_proxy {
    compatible ="xlnx,dma_proxy";
    dmas = &lt;&amp;axi_dma_0 0&gt;;
    dma-names = "dma_proxy_rx";
  };
  </code></pre>
  
  <p>The name "axi_dma_0" matches with the name in the axi DMA device tree node:</p>
  
  <pre class="lang-dts prettyprint-override"><code>axi_dma_0: dma@a0000000 {
      #dma-cells = &lt;0x1&gt;;
      clock-names = "s_axi_lite_aclk", "m_axi_s2mm_aclk";
      clocks = &lt;0x3 0x47 0x3 0x47&gt;;
      compatible = "xlnx,axi-dma-7.1", "xlnx,axi-dma-1.00.a";
      interrupt-names = "s2mm_introut";
      interrupt-parent = &lt;0x1d&gt;;
      interrupts = &lt;0x0 0x2&gt;;
      reg = &lt;0x0 0xa0000000 0x0 0x1000&gt;;
      xlnx,addrwidth = &lt;0x28&gt;;
      xlnx,sg-length-width = &lt;0x1a&gt;;
      phandle = &lt;0x1e&gt;;
  
      dma-channel@a0000030 {
          compatible = "xlnx,axi-dma-s2mm-channel";
          dma-channels = &lt;0x1&gt;;
          interrupts = &lt;0x0 0x2&gt;;
          xlnx,datawidth = &lt;0x40&gt;;
          xlnx,device-id = &lt;0x0&gt;;
      };
  </code></pre>
  
  <p>If I now look here:</p>
  
  <pre class="lang-sh prettyprint-override"><code>% cat /proc/device-tree/dma_proxy/dma-names
  dma_proxy_rx
  </code></pre>
  
  <p>Looks like my <em>dma_proxy_rx</em>, that I'm trying to request the channel for, is in there.</p>
  
  <p>Edit:
  In the boot log, I see this:</p>
  
  <pre><code>xilinx-vdma a0000000.dma: Please ensure that IP supports buffer length &gt; 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!!
  </code></pre>
  
  <p>There are warnings - but in the end, the Xilinx AXI DMA Engine got "probed", meaning the lowest level driver loaded and is ready, right?</p>
  
  <p>So it looks to me like there should be my device, but the kernel disagrees.</p>