Xilinx / dma_ip_drivers

Xilinx QDMA IP Drivers
https://xilinx.github.io/dma_ip_drivers/
578 stars 420 forks source link

Support for Ubuntu 22.04 #191

Closed juan-escobedo closed 1 year ago

juan-escobedo commented 1 year ago

Hello,

I am trying to build the driver on a computer running Ubuntu 22.04 but when trying to run "make install" from the xdma folder, I get the following errors related to undefined functions:

/home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c: In function ‘transfer_destroy’: /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c:2911:25: error: implicit declaration of function ‘pci_unmap_sg’; did you mean ‘pci_unmap_rom’? [-Werror=implicit-function-declaration] 2911 | pci_unmap_sg(xdev->pdev, sgt->sgl, sgt->nents, | ^~~~ | pci_unmap_rom /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c: In function ‘xdma_xfer_aperture’: /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c:3195:30: error: implicit declaration of function ‘pci_map_sg’; did you mean ‘pci_map_rom’? [-Werror=implicit-function-declaration] 3195 | sgt->nents = pci_map_sg(xdev->pdev, sgt->sgl, sgt->orig_nents, | ^~~~~~ | pci_map_rom /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c: In function ‘set_dma_mask’: /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c:4194:14: error: implicit declaration of function ‘pci_set_dma_mask’; did you mean ‘set_dma_mask’? [-Werror=implicit-function-declaration] 4194 | if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { | ^~~~ | set_dma_mask /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.c:4200:17: error: implicit declaration of function ‘pci_set_consistent_dma_mask’ [-Werror=implicit-function-declaration] 4200 | pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)); | ^~~~~~~ cc1: some warnings being treated as errors make[2]: [scripts/Makefile.build:257: /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma/libxdma.o] Error 1 make[1]: [Makefile:1850: /home/user1/repos/dma_ip_drivers/XDMA/linux-kernel/xdma] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-5.19.0-32-generic' make: *** [Makefile:39: all] Error 2

The contents of /proc/version:

Linux version 5.19.0-32-generic (buildd@lcy02-amd64-026) (x86_64-linux-gnu-gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2

Thanks beforehand,

Juan

gnodipac886 commented 1 year ago

Same here! Any help would be great!

juan-escobedo commented 1 year ago

At the bottom of this article, you can the instructions to update the c source to make it compile. It replaces the pcimap/unmap functions with the dma version and updates how to dereference the caio pointer.

I am copying the plain text of the changes here for future reference in case the link dies.

diff --git a/XDMA/linux-kernel/xdma/cdev_sgdma.c b/XDMA/linux-kernel/xdma/cdev_sgdma.c
index 2b13000..c17145f 100644
--- a/XDMA/linux-kernel/xdma/cdev_sgdma.c
+++ b/XDMA/linux-kernel/xdma/cdev_sgdma.c
@@ -105,7 +105,11 @@ static void async_io_handler(unsigned long  cb_hndl, int err)
                res = caio->res;
                res2 = caio->res2;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
+  #if 0
                caio->iocb->ki_complete(caio->iocb, res, res2);
+  #else
+               caio->iocb->ki_complete(caio->iocb, res);
+  #endif
 #else
                aio_complete(caio->iocb, res, res2);
 #endif
@@ -120,7 +124,11 @@ skip_tran:

 skip_dev_lock:
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
+  #if 0
        caio->iocb->ki_complete(caio->iocb, numbytes, -EBUSY);
+  #else
+       caio->iocb->ki_complete(caio->iocb, numbytes);
+  #endif
 #else
        aio_complete(caio->iocb, numbytes, -EBUSY);
 #endif
diff --git a/XDMA/linux-kernel/xdma/libxdma.c b/XDMA/linux-kernel/xdma/libxdma.c
index 4342b79..f009207 100644
--- a/XDMA/linux-kernel/xdma/libxdma.c
+++ b/XDMA/linux-kernel/xdma/libxdma.c
@@ -2908,7 +2908,11 @@ static void transfer_destroy(struct xdma_dev *xdev, struct xdma_transfer *xfer)
                struct sg_table *sgt = xfer->sgt;

                if (sgt->nents) {
+#if 0
                        pci_unmap_sg(xdev->pdev, sgt->sgl, sgt->nents,
+#else
+                        dma_unmap_sg(&xdev->pdev->dev, sgt->sgl, sgt->nents,
+#endif
                                     xfer->dir);
                        sgt->nents = 0;
                }
@@ -3192,7 +3196,11 @@ ssize_t xdma_xfer_aperture(struct xdma_engine *engine, bool write, u64 ep_addr,
        }

        if (!dma_mapped) {
+#if 0
                sgt->nents = pci_map_sg(xdev->pdev, sgt->sgl, sgt->orig_nents,
+#else
+               sgt->nents = dma_map_sg(&xdev->pdev->dev, sgt->sgl, sgt->orig_nents,
+#endif
                                        dir);
                if (!sgt->nents) {
                        pr_info("map sgl failed, sgt 0x%p.\n", sgt);
@@ -3434,7 +3442,11 @@ ssize_t xdma_xfer_aperture(struct xdma_engine *engine, bool write, u64 ep_addr,

 unmap_sgl:
        if (!dma_mapped && sgt->nents) {
+#if 0
                pci_unmap_sg(xdev->pdev, sgt->sgl, sgt->orig_nents, dir);
+#else
+                dma_unmap_sg(&xdev->pdev->dev, sgt->sgl, sgt->orig_nents, dir);
+#endif
                sgt->nents = 0;
        }

@@ -3504,7 +3516,11 @@ ssize_t xdma_xfer_submit(void *dev_hndl, int channel, bool write, u64 ep_addr,
        }

        if (!dma_mapped) {
+#if 0
                nents = pci_map_sg(xdev->pdev, sg, sgt->orig_nents, dir);
+#else
+                nents = dma_map_sg(&xdev->pdev->dev, sg, sgt->orig_nents, dir);
+#endif
                if (!nents) {
                        pr_info("map sgl failed, sgt 0x%p.\n", sgt);
                        return -EIO;
@@ -3660,8 +3676,12 @@ ssize_t xdma_xfer_submit(void *dev_hndl, int channel, bool write, u64 ep_addr,

 unmap_sgl:
        if (!dma_mapped && sgt->nents) {
+#if 0
                pci_unmap_sg(xdev->pdev, sgt->sgl, sgt->orig_nents, dir);
-               sgt->nents = 0;
+#else
+               dma_unmap_sg(&xdev->pdev->dev, sgt->sgl, sgt->orig_nents, dir);
+#endif
+                sgt->nents = 0;
        }

        if (req)
@@ -3781,7 +3801,11 @@ ssize_t xdma_xfer_completion(void *cb_hndl, void *dev_hndl, int channel,

 unmap_sgl:
        if (!dma_mapped && sgt->nents) {
+#if 0
                pci_unmap_sg(xdev->pdev, sgt->sgl, sgt->orig_nents, dir);
+#else
+               dma_unmap_sg(&xdev->pdev->dev, sgt->sgl, sgt->orig_nents, dir);
+#endif
                sgt->nents = 0;
        }

@@ -3855,7 +3879,11 @@ ssize_t xdma_xfer_submit_nowait(void *cb_hndl, void *dev_hndl, int channel,
        }

        if (!dma_mapped) {
+#if 0
                nents = pci_map_sg(xdev->pdev, sg, sgt->orig_nents, dir);
+#else
+                nents = dma_map_sg(&xdev->pdev->dev, sg, sgt->orig_nents, dir);
+#endif
                if (!nents) {
                        pr_info("map sgl failed, sgt 0x%p.\n", sgt);
                        return -EIO;
@@ -3895,7 +3923,11 @@ ssize_t xdma_xfer_submit_nowait(void *cb_hndl, void *dev_hndl, int channel,
                        pr_info("transfer_init failed\n");

                        if (!dma_mapped && sgt->nents) {
+#if 0
                                pci_unmap_sg(xdev->pdev, sgt->sgl,
+#else
+                               dma_unmap_sg(&xdev->pdev->dev, sgt->sgl,
+#endif
                                                sgt->orig_nents, dir);
                                sgt->nents = 0;
                        }
@@ -3943,7 +3975,11 @@ ssize_t xdma_xfer_submit_nowait(void *cb_hndl, void *dev_hndl, int channel,

 unmap_sgl:
        if (!dma_mapped && sgt->nents) {
+#if 0
                pci_unmap_sg(xdev->pdev, sgt->sgl, sgt->orig_nents, dir);
+#else
+               dma_unmap_sg(&xdev->pdev->dev, sgt->sgl, sgt->orig_nents, dir);
+#endif
                sgt->nents = 0;
        }

@@ -4191,16 +4227,32 @@ static int set_dma_mask(struct pci_dev *pdev)

        dbg_init("sizeof(dma_addr_t) == %ld\n", sizeof(dma_addr_t));
        /* 64-bit addressing capability for XDMA? */
-       if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
+#if 0
+        if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) {
+#else
+        if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) {
+#endif
                /* query for DMA transfer */
                /* @see Documentation/DMA-mapping.txt */
                dbg_init("pci_set_dma_mask()\n");
                /* use 64-bit DMA */
                dbg_init("Using a 64-bit DMA mask.\n");
+#if 0
                pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64));
+#else
+               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
+#endif
+#if 0
        } else if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
+#else
+       } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
+#endif
                dbg_init("Could not set 64-bit DMA mask.\n");
+#if 0
                pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+#else
+               dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
+#endif
                /* use 32-bit DMA */
                dbg_init("Using a 32-bit DMA mask.\n");
        } else {
juan-escobedo commented 1 year ago

This pull request this repo aims to solve this issue but is still not merged as of writing this.

gnodipac886 commented 1 year ago

Thank you!