intel / ipu6-drivers

152 stars 50 forks source link

ipu-psys: Fix compilation with kernels >= 6.5.0 #174

Closed jwrdegoede closed 10 months ago

jwrdegoede commented 10 months ago

Kernel 6.5 has removed the last parameter from get_user_pages(). Adjust the code accordingly.

hao-yao commented 10 months ago

Thank you. I also changed here internally but a little different, because the style of this block is confusing. I changed it like this:

    } else {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
        nr = get_user_pages(current, current->mm, start & PAGE_MASK,
                    npages, 1, 0, pages, NULL);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
        nr = get_user_pages(start & PAGE_MASK, npages,
                    1, 0, pages, NULL);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
        nr = get_user_pages(start & PAGE_MASK, npages,
                    FOLL_WRITE, pages, NULL);
#else
        nr = get_user_pages(start & PAGE_MASK, npages,
                    FOLL_WRITE, pages);
#endif
        if (nr < npages)
            goto error_up_read;
    }

Diff here:

diff --git a/drivers/media/pci/intel/ipu-psys.c b/drivers/media/pci/intel/ipu-psys.c
index 5e2b37046..cefa60e67 100644
--- a/drivers/media/pci/intel/ipu-psys.c
+++ b/drivers/media/pci/intel/ipu-psys.c
@@ -214,17 +214,18 @@ static int ipu_psys_get_userpages(struct ipu_dma_buf_attach *attach)
                }
        } else {
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
-               nr = get_user_pages(current, current->mm,
-                                   start & PAGE_MASK, npages,
-#else
+               nr = get_user_pages(current, current->mm, start & PAGE_MASK,
+                                   npages, 1, 0, pages, NULL);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
                nr = get_user_pages(start & PAGE_MASK, npages,
-#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
-                                   1, 0,
+                                   1, 0, pages, NULL);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
+               nr = get_user_pages(start & PAGE_MASK, npages,
+                                   FOLL_WRITE, pages, NULL);
 #else
-                                   FOLL_WRITE,
+               nr = get_user_pages(start & PAGE_MASK, npages,
+                                   FOLL_WRITE, pages);
 #endif
-                                   pages, NULL);
                if (nr < npages)
                        goto error_up_read;
        }

If you feel OK could you change to this version?

jwrdegoede commented 10 months ago

I agree that your solution is better. I've just pushed out an update using your solution.

hao-yao commented 10 months ago

Thank you @jwrdegoede .