Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel 6.4 xdma compile fixes #238

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions XDMA/linux-kernel/xdma/cdev_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ int bridge_mmap(struct file *file, struct vm_area_struct *vma)
* prevent touching the pages (byte access) for swap-in,
* and prevent the pages from being swapped out
*/
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
vm_flags_set(vma, VMEM_FLAGS);
#else
vma->vm_flags |= VMEM_FLAGS;
#endif
/* make MMIO accessible to user space */
rv = io_remap_pfn_range(vma, vma->vm_start, phys >> PAGE_SHIFT,
vsize, vma->vm_page_prot);
Expand Down
18 changes: 13 additions & 5 deletions XDMA/linux-kernel/xdma/cdev_sgdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void async_io_handler(unsigned long cb_hndl, int err)
if (!err)
numbytes = xdma_xfer_completion((void *)cb, xdev,
engine->channel, cb->write, cb->ep_addr,
&cb->sgt, 0,
&cb->sgt, 0,
cb->write ? h2c_timeout * 1000 :
c2h_timeout * 1000);

Expand All @@ -109,14 +109,14 @@ static void async_io_handler(unsigned long cb_hndl, int err)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
caio->iocb->ki_complete(caio->iocb, res, res2);
#else
aio_complete(caio->iocb, res, res2);
aio_complete(caio->iocb, res, caio->res2);
#endif
skip_tran:
spin_unlock(&caio->lock);
kmem_cache_free(cdev_cache, caio);
kfree(cb);
return;
}
}
spin_unlock(&caio->lock);
return;

Expand Down Expand Up @@ -566,14 +566,22 @@ static ssize_t cdev_aio_read(struct kiocb *iocb, const struct iovec *io,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
static ssize_t cdev_write_iter(struct kiocb *iocb, struct iov_iter *io)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
return cdev_aio_write(iocb, io->__iov, io->nr_segs, io->iov_offset);
#else
return cdev_aio_write(iocb, io->iov, io->nr_segs, io->iov_offset);
#endif
}

static ssize_t cdev_read_iter(struct kiocb *iocb, struct iov_iter *io)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
return cdev_aio_read(iocb, io->__iov, io->nr_segs, io->iov_offset);
#else
return cdev_aio_read(iocb, io->iov, io->nr_segs, io->iov_offset);
}
#endif
}
#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)

static int ioctl_do_perf_start(struct xdma_engine *engine, unsigned long arg)
{
Expand Down Expand Up @@ -799,7 +807,7 @@ static int ioctl_do_aperture_dma(struct xdma_engine *engine, unsigned long arg,

return io.error;
}

static long char_sgdma_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
Expand Down
17 changes: 8 additions & 9 deletions XDMA/linux-kernel/xdma/libxdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -3269,7 +3269,7 @@ ssize_t xdma_xfer_aperture(struct xdma_engine *engine, bool write, u64 ep_addr,
sg = req->sg;
ep_addr = req->ep_addr + (req->offset & (aperture - 1));
i = req->sg_idx;

for (sg = req->sg; i < sg_max && desc_idx < desc_max;
i++, sg = sg_next(sg)) {
dma_addr_t addr = sg_dma_address(sg);
Expand Down Expand Up @@ -3302,7 +3302,7 @@ ssize_t xdma_xfer_aperture(struct xdma_engine *engine, bool write, u64 ep_addr,
ep_addr += len;
addr += len;
tlen -= len;

desc_idx++;
desc_cnt++;
if (desc_idx == desc_max)
Expand All @@ -3314,7 +3314,7 @@ ssize_t xdma_xfer_aperture(struct xdma_engine *engine, bool write, u64 ep_addr,
else
break;
}

req->sg_offset = sg_offset;
req->sg_idx = i;

Expand Down Expand Up @@ -3523,7 +3523,6 @@ ssize_t xdma_xfer_submit(void *dev_hndl, int channel, bool write, u64 ep_addr,
#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;
Expand Down Expand Up @@ -4232,9 +4231,9 @@ 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 LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
#else
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)))
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)))
#endif
{
/* query for DMA transfer */
Expand All @@ -4245,11 +4244,11 @@ static int set_dma_mask(struct pci_dev *pdev)
#endif
/* use 64-bit DMA */
dbg_init("Using a 64-bit DMA mask.\n");
} else
} else
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32)))
#else
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)))
#endif
{
dbg_init("Could not set 64-bit DMA mask.\n");
Expand Down
4 changes: 4 additions & 0 deletions XDMA/linux-kernel/xdma/xdma_cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,11 @@ int xpdev_create_interfaces(struct xdma_pci_dev *xpdev)

int xdma_cdev_init(void)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
g_xdma_class = class_create(THIS_MODULE, XDMA_NODE_NAME);
#else
g_xdma_class = class_create(XDMA_NODE_NAME);
#endif
if (IS_ERR(g_xdma_class)) {
dbg_init(XDMA_NODE_NAME ": failed to create class");
return -EINVAL;
Expand Down