cancel
Showing results for 
Search instead for 
Did you mean: 

PC Drivers & Software

ilvsusie
Journeyman III

xrt installation error - build failed - implicit declaration of function ‘pci_unmap_page’;

having following error while installing xrt

root cause:

pci_dma_mapping_error was in pci-dma-compat.h

static inline int

pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)

{

        return dma_mapping_error(&pdev->dev, dma_addr);

}

https://coral.googlesource.com/linux-imx/+/refs/heads/alpha/include/linux/pci-dma-compat.h

but looks like pci-dma-compat.h is deprecated.

In the following link, I see this sentence ---> Now that all usages of the functions defined in "pci-dma-compat.h" have been removed, it is time to remove this file as well.

https://lore.kernel.org/all/20220310170445.GA163749@bhelgaas/T/

 

 

reproduction:

sudo apt install ./xrt_202220.2.14.354_22.04-amd64-xrt.deb

Error! Build of xocl.ko failed for: 5.19.0-43-generic (x86_64)
Make sure the name of the generated module is correct and at the root of the
build directory, or consult make.log in the build directory
/var/lib/dkms/xrt/2.14.354/build/ for more information.
****************************************************************
* DKMS failed to install XRT drivers.
* Please check if kernel development headers are installed for OS variant used.
*
* Check build logs in /var/lib/dkms/xrt/2.14.354
****************************************************************

 

 

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

 

 

$ uname -r
5.19.0-43-generic

 

 

error message : 

CC [M] /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.o
/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c: In function ‘sgl_unmap’:
/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c:2305:25: error: implicit declaration of function ‘pci_unmap_page’; did you mean ‘dma_unmap_page’? [-Werror=implicit-function-declaration]
2305 | pci_unmap_page(pdev, sg->dma_addr - sg->offset,
| ^~~~~~~~~~~~~~
| dma_unmap_page
/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c: In function ‘sgl_map’:
/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c:2337:32: error: implicit declaration of function ‘pci_map_page’; did you mean ‘dma_map_page’? [-Werror=implicit-function-declaration]
2337 | sg->dma_addr = pci_map_page(pdev, sg->pg, 0, PAGE_SIZE, dir);
| ^~~~~~~~~~~~
| dma_map_page
In file included from ./include/linux/export.h:33,
from ./include/linux/linkage.h:7,
from ./include/linux/kernel.h:17,
from ./include/linux/interrupt.h:6,
from /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.h:39,
from /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c:27:
/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c:2338:30: error: implicit declaration of function ‘pci_dma_mapping_error’; did you mean ‘dma_mapping_error’? [-Werror=implicit-function-declaration]
2338 | if (unlikely(pci_dma_mapping_error(pdev, sg->dma_addr))) {
| ^~~~~~~~~~~~~~~~~~~~~
./include/linux/compiler.h:78:45: note: in definition of macro ‘unlikely’
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:257: /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.o] Error 1
make[2]: *** [Makefile:1850: /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf] Error 2
make[2]: Leaving directory '/usr/src/linux-headers-5.19.0-43-generic'
make[1]: *** [Makefile:135: all] Error 2
make[1]: Leaving directory '/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf'
make: *** [Makefile:2: all] Error 2

0 Likes
1 Reply
ilvsusie
Journeyman III

Here is a solution to the problem. 

Add following inline functions at the beginning of /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/libqdma_export.c

 

static inline dma_addr_t

pci_map_page(struct pci_dev *hwdev, struct page *page,

             unsigned long offset, size_t size, int direction)

{

        return dma_map_page(hwdev == NULL ? NULL : &hwdev->dev, page, offset, size, (enum dma_data_direction)direction);

}

 

static inline void

pci_unmap_page(struct pci_dev *hwdev, dma_addr_t dma_address,

               size_t size, int direction)

{

        dma_unmap_page(hwdev == NULL ? NULL : &hwdev->dev, dma_address, size, (enum dma_data_direction)direction);

}

 

static inline int

pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t dma_addr)

{

        return dma_mapping_error(&pdev->dev, dma_addr);

}

 

For /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/qdma_st_c2h.c

 

PCI_DMA_FROMDEVICE -> DMA_FROM_DEVICE

 

/var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/../lib/libqdma/QDMA/linux-kernel/driver/libqdma/xdev.c

 

static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)

{

        return dma_set_mask(&dev->dev, mask);

}

 

static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)

{

        return dma_set_coherent_mask(&dev->dev, mask);

}

 

Skipping BTF generation for /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf/xocl.ko due to unavailability of vmlinux

 

To fix above error, need to run the following two commands:

sudo apt install dwarves

sudo cp /sys/kernel/btf/vmlinux /usr/lib/modules/`uname -r`/build/



https://askubuntu.com/questions/1348250/skipping-btf-generation-xxx-due-to-unavailability-of-vmlinux...

 

Next, build in the userpf folder

sudo chown -R kmkim:kmkim /var/lib/dkms/xrt

cd /var/lib/dkms/xrt/2.14.354/build/driver/xocl/userpf

make

 

Finally, install the kernel module.

cd /var/lib/dkms/xrt/2.14.354/build/driver/xocl

make 

sudo make install

 

0 Likes