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

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

Merged
merged 1 commit into from
Aug 29, 2023

Conversation

jwrdegoede
Copy link
Contributor

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

@hao-yao
Copy link
Contributor

hao-yao commented Aug 29, 2023

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?

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

Suggested-by: Hao Yao <yao.hao@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
@jwrdegoede
Copy link
Contributor Author

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

@hao-yao
Copy link
Contributor

hao-yao commented Aug 29, 2023

Thank you @jwrdegoede .

@hao-yao hao-yao merged commit 7c3d6ab into intel:master Aug 29, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants