Xilinx / dma_ip_drivers

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

And here is complete guide for repaire the issue: #265

Closed mayureshw closed 6 months ago

mayureshw commented 6 months ago
          And here is complete guide for repaire the issue:
  1. File cdev_sgdma.c, function bodies for cdev_write_iter and cdev_read_iter, need to change io->iov to io->__iov;
  2. File xdma_cdev.c, line 606, change call of class_create(THIS_MODULE, XDMA_NODE_NAME) to class_create(XDMA_NODE_NAME);
  3. File cdev_ctrl.c, line 236. Need to add conversion of vma->vm_flags to vm_area_struct *. For example, you could write a function to write a flag into vm_flags field of vma (now is const):
// Source cpied from another devforum 
void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) {
    vma->vm_flags |= flags;
}

Usage:

// ... bridge mmap function body
vm_flags_set(vma, VMEM_FLAGS)
// ... 

With this changes, driver completly builds, again :)

_Originally posted by @MADMechaniculus in https://github.com/Xilinx/dma_ip_drivers/issues/253#issuecomment-1897509289_

For the 3rd point I get the following errors:

Makefile:17: XVC_FLAGS: . make -C /lib/modules/6.6.21_1/build M=/home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma modules make[1]: Entering directory '/usr/src/kernel-headers-6.6.21_1' /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/Makefile:17: XVC_FLAGS: . CC [M] /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/cdev_ctrl.o /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/cdev_ctrl.c:191:6: error: redefinition of 'vm_flags_set' 191 | void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) { | ^~~~~~~~~~~~ In file included from ./include/linux/scatterlist.h:8, from ./include/linux/dma-mapping.h:11, from /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/xdma_mod.h:26, from /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/xdma_cdev.h:27, from /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/cdev_ctrl.c:24: ./include/linux/mm.h:840:20: note: previous definition of 'vm_flags_set' with type 'void(struct vm_area_struct *, vm_flags_t)' {aka 'void(struct vm_area_struct *, long unsigned int)'} 840 | static inline void vm_flags_set(struct vm_area_struct *vma, | ^~~~~~~~~~~~ /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/cdev_ctrl.c: In function 'vm_flags_set': /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/cdev_ctrl.c:192:27: error: assignment of read-only member 'vm_flags' 192 | vma->vm_flags |= flags; | ^~ make[3]: *** [scripts/Makefile.build:243: /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma/cdev_ctrl.o] Error 1 make[2]: *** [/usr/src/kernel-headers-6.6.21_1/Makefile:1913: /home/guest/programs/xilinx/dma_ip_drivers/XDMA/linux-kernel/xdma] Error 2 make[1]: *** [Makefile:234: __sub-make] Error 2 make[1]: Leaving directory '/usr/src/kernel-headers-6.6.21_1' make: *** [Makefile:39: all] Error 2

j-bo commented 6 months ago

Seems that vm_flags_set has been included elsewhere thus causing your error.

Remove the vm_flags_set() definition you added and simply call existing vm_flags_set(vma, VMEM_FLAGS); (do not forget the ';')

Works on my setup (Ubuntu22.04 kernel 6.5.0-1018-oem)

mayureshw commented 6 months ago

Right. Thanks.