Skip to content

Commit c59fca1

Browse files
committed
Support kernel 4.17+ with new mm interface
1 parent 2256279 commit c59fca1

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

patches/linux_uio/uio_pci_dma.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,25 +1068,45 @@ uio_pci_dma_free_kernel_memory(struct uio_pci_dma_private *priv)
10681068

10691069

10701070
#ifdef UIO_PDA_USE_PAGEFAULT_HANDLER
1071+
#ifdef PDA_VMF_T
1072+
static vm_fault_t
1073+
#else
10711074
static int
1075+
#endif
10721076
page_fault_handler
10731077
(
1078+
#ifndef PDA_VMF_T
10741079
struct vm_area_struct *vma,
1080+
#endif
10751081
struct vm_fault *vmf
10761082
)
10771083
{
10781084
UIO_DEBUG_ENTER();
10791085

1086+
#ifdef PDA_VMF_T
1087+
struct vm_area_struct *vma = vmf->vma;
1088+
#endif
10801089
struct uio_pci_dma_private *priv = vma->vm_private_data;
10811090

10821091
#ifdef PDA_PFN_T_PAGES
1092+
#ifdef PDA_VMF_T
1093+
return vmf_insert_mixed(vma, (unsigned long)vmf->address,
1094+
pfn_to_pfn_t(priv->pfn_list[vmf->pgoff % priv->pages]));
1095+
#else
10831096
int ret = vm_insert_mixed(vma, (unsigned long)vmf->virtual_address,
10841097
pfn_to_pfn_t(priv->pfn_list[vmf->pgoff % priv->pages]));
1098+
#endif
1099+
#else
1100+
#ifdef PDA_VMF_T
1101+
return vmf_insert_mixed(vma, (unsigned long)vmf->address,
1102+
priv->pfn_list[vmf->pgoff % priv->pages]);
10851103
#else
10861104
int ret = vm_insert_mixed(vma, (unsigned long)vmf->virtual_address,
10871105
priv->pfn_list[vmf->pgoff % priv->pages]);
10881106
#endif
1107+
#endif
10891108

1109+
#ifndef PDA_VMF_T
10901110
switch(ret)
10911111
{
10921112
case 0:
@@ -1095,6 +1115,7 @@ page_fault_handler
10951115
case -ENOMEM : { UIO_DEBUG_RETURN(VM_FAULT_OOM); }
10961116
default : { UIO_DEBUG_RETURN(VM_FAULT_SIGBUS); }
10971117
}
1118+
#endif
10981119

10991120
}
11001121

patches/linux_uio/uio_pci_dma.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,16 @@ BIN_ATTR_MAP_CALLBACK( map_sg );
327327
#define PDA_SIXARG_GUP
328328
#endif
329329

330+
/**
331+
* Kernel 4.17 joins struct fault_env and vm_fault:
332+
* https://github.com/torvalds/linux/commit/82b0f8c39a3869b6fd2a10e180a862248736ec6f
333+
* It also introduces vmf_insert_page() of vm_fault_t return type, replacing vm_insert_page()
334+
* https://github.com/torvalds/linux/commit/1c8f422059ae5da07db7406ab916203f9417e396
335+
**/
336+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
337+
#define PDA_VMF_T
338+
#endif
339+
330340
#endif /** __KERNEL__ */
331341

332342
#endif /** UIO_PCI_DMA_H */

0 commit comments

Comments
 (0)