ikwzm / udmabuf

User space mappable dma buffer device driver for Linux.
BSD 2-Clause "Simplified" License
569 stars 171 forks source link

Unable to compile on 5.14 #125

Open aminems opened 3 weeks ago

aminems commented 3 weeks ago

I'm using Oracle Linux 9 with kernel 5.14.0-427.13.1.el9_4.x86_64 I'm not able to compile the latest version of udmabuf

/u-dma-buf.c:2494:22: error: implicit declaration of function ‘device_add_properties’; did you mean ‘device_add_groups’? [-Werror=implicit-function-declaration] 2494 | retval = device_add_properties(dev, props);

./include/linux/export.h:17:22: error: passing argument 1 of ‘class_create’ from incompatible pointer type [-Werror=incompatible-pointer-types] 17 #define THIS_MODULE (&__this_module) ~^~~~~~~
struct module *

/u-dma-buf.c:3658:25: error: too many arguments to function ‘class_create’ 3658 | udmabuf_sys_class = class_create(THIS_MODULE, DRIVER_NAME);

The first two errors could be resolved by ignoring the warning, but the last one is a real one.

Any advice?

ikwzm commented 3 weeks ago

Thank you for the issue.

However, I don't have arch=x86_64, linux kernel 5.14 environment, so I couldn't reproduce it. Instead, I tried with arch=arm64, linux kernel 5.15 and got the following

shell$ make ARCH=arm64 KERNEL_SRC_DIR=/usr/src/linux-5.15.108-zynqmp-fpga-generic
make -C /usr/src/linux-5.15.108-zynqmp-fpga-generic ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- M=/home/ichiro/work/udmabuf CONFIG_U_DMA_BUF=m U_DMA_BUF_CONFIG=1 U_DMA_BUF_DEBUG=1 U_DMA_BUF_QUIRK_MMAP=1 U_DMA_BUF_IN_KERNEL_FUNCTIONS=1 U_DMA_BUF_IOCTL=2 U_DMA_BUF_EXPORT=1 modules
make[1]: Entering directory '/usr/src/linux-5.15.108-zynqmp-fpga-generic'
warning: the compiler differs from the one used to build the kernel
  CC [M]  /home/ichiro/work/udmabuf/u-dma-buf.o
aarch64-linux-gnu-gcc: warning: switch ‘-msign-return-address=all’ is no longer supported
  MODPOST /home/ichiro/work/udmabuf/Module.symvers
  CC [M]  /home/ichiro/work/udmabuf/u-dma-buf.mod.o
aarch64-linux-gnu-gcc: warning: switch ‘-msign-return-address=all’ is no longer supported
  LD [M]  /home/ichiro/work/udmabuf/u-dma-buf.ko
make[1]: Leaving directory '/usr/src/linux-5.15.108-zynqmp-fpga-generic'

As shown above, the build was successful.

The prototype declaration for device_add_properties() is in include/linux/property.h. And u-dma-buf.c includes this header file. Please check include/linux/property.h in your environment.

aminems commented 1 week ago

On 5.14 it doesn't work, all the pre-requisites are there but it looks like there was changes on the kernel regarding this two issues.

janitza-nihe commented 5 days ago

In later kernel versions, i just had the same problem with kernel 6.6, class_create only takes 1 argument - the name. You can just remove the "THIS_MODULE" argument from the class_create call. The corresponding kernel commit says that the first argument has never been used, so it has been removed.

janitza-nihe commented 5 days ago

See https://lore.kernel.org/all/20230313181843.1207845-4-gregkh@linuxfoundation.org/

ikwzm commented 5 days ago

Thanks for the information. However, the issue has already been fixed by @bcattle's PR #113 in u-dma-buf v4.5.2 as follows

#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
    udmabuf_sys_class = class_create(THIS_MODULE, DRIVER_NAME);
#else
    udmabuf_sys_class = class_create(DRIVER_NAME);
#endif