myriadrf / xtrx_linux_pcie_drv

XTRX PCI driver for linux
Apache License 2.0
16 stars 22 forks source link

Compilation fails with the kernel versions 4.11 and later #1

Closed chemeris closed 6 years ago

chemeris commented 6 years ago

Build fails on Ubuntu 17.04 x64.

Output of the build:

make -C /lib/modules/4.12.8-041208-generic/build M=/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv modules
make[1]: Entering directory '/usr/src/linux-headers-4.12.8-041208-generic'
  CC [M]  /home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv/xtrx.o
/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv/xtrx.c: In function ‘xtrx_probe’:
/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv/xtrx.c:1061:8: error: implicit declaration of function ‘pci_enable_msi_range’ [-Werror=implicit-function-declaration]
  err = pci_enable_msi_range(pdev, XTRX_MSI_COUNT, XTRX_MSI_COUNT);
        ^~~~~~~~~~~~~~~~~~~~
At top level:
/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv/xtrx.c:702:20: warning: ‘xtrx_msi_irq_single’ defined but not used [-Wunused-function]
 static irqreturn_t xtrx_msi_irq_single(int irq, void *data)
                    ^~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
scripts/Makefile.build:308: recipe for target '/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv/xtrx.o' failed
make[2]: *** [/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv/xtrx.o] Error 1
Makefile:1515: recipe for target '_module_/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv' failed
make[1]: *** [_module_/home/ipse/work/xtrx/images.git/sources/xtrx_linux_pcie_drv] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.12.8-041208-generic'
Makefile:10: recipe for target 'modules' failed
make: *** [modules] Error 2
chemeris commented 6 years ago

Kernel patch with the change: https://patchwork.kernel.org/patch/9505893/ An example of how to migrate to the new API: https://patchwork.kernel.org/patch/9505891/

smunaut commented 6 years ago

This is a patch attempt :

diff --git a/xtrx.c b/xtrx.c
index ba0ec9a..b09972c 100644
--- a/xtrx.c
+++ b/xtrx.c
@@ -1058,7 +1058,7 @@ static int xtrx_probe(struct pci_dev *pdev,
        init_waitqueue_head(&xtrxdev->queue_other);
        init_waitqueue_head(&xtrxdev->onepps_ctrl);

-       err = pci_enable_msi_range(pdev, XTRX_MSI_COUNT, XTRX_MSI_COUNT);
+       err = pci_alloc_irq_vectors(pdev, XTRX_MSI_COUNT, XTRX_MSI_COUNT, PCI_IRQ_MSI);
        if (err == XTRX_MSI_COUNT) {
                xtrxdev->inttype = XTRX_MSI_4;

It builds fine, but until I actually verified it works I won't do a pull request.

smunaut commented 6 years ago

Seems to work fine, feel free to apply :)

smunaut commented 6 years ago
diff --git a/xtrx.c b/xtrx.c
index ba0ec9a..01215a2 100644
--- a/xtrx.c
+++ b/xtrx.c
@@ -38,6 +38,7 @@
 #include <linux/device.h>
 #include <linux/time.h>
 #include <linux/pps_kernel.h>
+#include <linux/version.h>
 #include <asm/page.h>
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -1058,7 +1059,11 @@ static int xtrx_probe(struct pci_dev *pdev,
        init_waitqueue_head(&xtrxdev->queue_other);
        init_waitqueue_head(&xtrxdev->onepps_ctrl);

+#if LINUX_VERSION_CODE <= KERNEL_VERSION(4,11,0)
        err = pci_enable_msi_range(pdev, XTRX_MSI_COUNT, XTRX_MSI_COUNT);
+#else
+       err = pci_alloc_irq_vectors(pdev, XTRX_MSI_COUNT, XTRX_MSI_COUNT, PCI_IRQ_MSI);
+#endif
        if (err == XTRX_MSI_COUNT) {
                xtrxdev->inttype = XTRX_MSI_4;
chemeris commented 6 years ago

Nice, thank you!

sergforce commented 6 years ago

Merged