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

Added 6.6 kernel support for zocl #7868

Merged
merged 1 commit into from
Jan 3, 2024
Merged
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
9 changes: 7 additions & 2 deletions src/runtime_src/core/edge/drm/zocl/common/zocl_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,13 @@ int zocl_iommu_map_bo(struct drm_device *dev, struct drm_zocl_bo *bo)
}

/* MAP user's VA to pages table into IOMMU */
err = iommu_map_sg(zdev->domain, bo->uaddr, bo->sgt->sgl,
bo->sgt->nents, prot);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
err = iommu_map_sg(zdev->domain, bo->uaddr, bo->sgt->sgl,
bo->sgt->nents, prot, GFP_KERNEL);
#else
err = iommu_map_sg(zdev->domain, bo->uaddr, bo->sgt->sgl,
bo->sgt->nents, prot);
#endif
if (err < 0) {
/* If IOMMU map failed forget user's VA */
bo->uaddr = 0;
Expand Down
28 changes: 21 additions & 7 deletions src/runtime_src/core/edge/drm/zocl/common/zocl_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,11 @@ zocl_gem_mmap(struct file *filp, struct vm_area_struct *vma)
* and set the vm_pgoff (used as a fake buffer offset by DRM)
* to 0 as we want to map the whole buffer.
*/
vma->vm_flags &= ~VM_PFNMAP;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
vma->vm_flags &= ~VM_PFNMAP;
#else
vm_flags_clear(vma, VM_PFNMAP);
#endif
vma->vm_pgoff = 0;

gem_obj = vma->vm_private_data;
Expand Down Expand Up @@ -781,8 +785,13 @@ static int zocl_mmap(struct file *filp, struct vm_area_struct *vma)
rc = zocl_iommu_map_bo(dev, bo);
if (rc)
return rc;
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
#else
vm_flags_clear(vma, VM_PFNMAP);
vm_flags_set(vma, VM_MIXEDMAP);
#endif
/* Reset the fake offset used to identify the BO */
vma->vm_pgoff = 0;
return 0;
Expand All @@ -805,9 +814,12 @@ static int zocl_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL;

vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_flags |= VM_IO;
vma->vm_flags |= VM_RESERVED;

#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
vma->vm_flags |= VM_IO;
vma->vm_flags |= VM_RESERVED;
#else
vm_flags_set(vma, VM_IO | VM_RESERVED);
#endif
vma->vm_ops = &reg_physical_vm_ops;
rc = io_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
vsize, vma->vm_page_prot);
Expand Down Expand Up @@ -1020,15 +1032,17 @@ static struct drm_driver zocl_driver = {
#endif

.gem_create_object = zocl_gem_create_object,
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_mmap = drm_gem_prime_mmap,
#endif
.gem_prime_import = zocl_gem_import,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
.gem_prime_import_sg_table = drm_gem_dma_prime_import_sg_table,
#else
.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
#endif
.gem_prime_mmap = drm_gem_prime_mmap,
.ioctls = zocl_ioctls,
.num_ioctls = ARRAY_SIZE(zocl_ioctls),
.fops = &zocl_driver_fops,
Expand Down
6 changes: 5 additions & 1 deletion src/runtime_src/core/edge/drm/zocl/common/zocl_xclbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,11 @@ zocl_load_sect(struct drm_zocl_dev *zdev, struct axlf *axlf, char __user *xclbin
flags = zdev->fpga_mgr->flags;
zdev->fpga_mgr->flags |= FPGA_MGR_CONFIG_DMA_BUF;
zdev->fpga_mgr->dmabuf = drm_gem_prime_export(&bo->gem_base, 0);
err = of_overlay_fdt_apply((void *)section_buffer, size, &id);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
err = of_overlay_fdt_apply((void *)section_buffer, size, &id, NULL);
#else
err = of_overlay_fdt_apply((void *)section_buffer, size, &id);
#endif
if (err < 0) {
DRM_WARN("Failed to create overlay (err=%d)\n", err);
zdev->fpga_mgr->flags = flags;
Expand Down
Loading