kni: fix build with Linux 5.9

Message ID 1599652785-42385-1-git-send-email-humin29@huawei.com (mailing list archive)
State Rejected, archived
Headers
Series kni: fix build with Linux 5.9 |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK

Commit Message

humin (Q) Sept. 9, 2020, 11:59 a.m. UTC
  Build error seen with Linux kernel 5.9.

Build error:
kernel/linux/kni/kni_dev.h:104:30:
	error: passing argument 1 of ‘get_user_pages_remote’ from
	incompatible pointer type [-Werror=incompatible-pointer-types]
	ret = get_user_pages_remote(tsk, tsk->mm, iova, 1,

get_user_pages_remote() is changed in Linux kernel version 5.9 and
remove a parameter, struct task_struct *tsk:
Linux Commit 64019a2e467a ("mm/gup: remove task_struct pointer
for all gup code")

get_user_pages_remote() parameter updated with compile time Linux
kernel version check.

Cc: stable@dpdk.org

Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
---
 kernel/linux/kni/kni_dev.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Ferruh Yigit Sept. 9, 2020, 12:53 p.m. UTC | #1
On 9/9/2020 12:59 PM, Min Hu (Connor) wrote:
> Build error seen with Linux kernel 5.9.
> 
> Build error:
> kernel/linux/kni/kni_dev.h:104:30:
> 	error: passing argument 1 of ‘get_user_pages_remote’ from
> 	incompatible pointer type [-Werror=incompatible-pointer-types]
> 	ret = get_user_pages_remote(tsk, tsk->mm, iova, 1,
> 
> get_user_pages_remote() is changed in Linux kernel version 5.9 and
> remove a parameter, struct task_struct *tsk:
> Linux Commit 64019a2e467a ("mm/gup: remove task_struct pointer
> for all gup code")
> 
> get_user_pages_remote() parameter updated with compile time Linux
> kernel version check.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> Reviewed-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> ---
>  kernel/linux/kni/kni_dev.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h
> index ca5f92a..192c3d9 100644
> --- a/kernel/linux/kni/kni_dev.h
> +++ b/kernel/linux/kni/kni_dev.h
> @@ -101,8 +101,13 @@ static inline phys_addr_t iova_to_phys(struct task_struct *tsk,
>  	offset = iova & (PAGE_SIZE - 1);
>  
>  	/* Read one page struct info */
> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
> +	ret = get_user_pages_remote(tsk->mm, iova, 1,
> +				    FOLL_TOUCH, &page, NULL, NULL);
> +#else
>  	ret = get_user_pages_remote(tsk, tsk->mm, iova, 1,
>  				    FOLL_TOUCH, &page, NULL, NULL);
> +#endif /* >= 5.9.0 */
>  	if (ret < 0)
>  		return 0;
>  
> 

The patch is already out, please check: https://patches.dpdk.org/patch/75577/

If you are already on it, an ack or review tag would be good. Thanks.
  

Patch

diff --git a/kernel/linux/kni/kni_dev.h b/kernel/linux/kni/kni_dev.h
index ca5f92a..192c3d9 100644
--- a/kernel/linux/kni/kni_dev.h
+++ b/kernel/linux/kni/kni_dev.h
@@ -101,8 +101,13 @@  static inline phys_addr_t iova_to_phys(struct task_struct *tsk,
 	offset = iova & (PAGE_SIZE - 1);
 
 	/* Read one page struct info */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
+	ret = get_user_pages_remote(tsk->mm, iova, 1,
+				    FOLL_TOUCH, &page, NULL, NULL);
+#else
 	ret = get_user_pages_remote(tsk, tsk->mm, iova, 1,
 				    FOLL_TOUCH, &page, NULL, NULL);
+#endif /* >= 5.9.0 */
 	if (ret < 0)
 		return 0;