diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2017-06-14 03:33:43 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2017-06-14 03:33:43 +0200 |
commit | a92e1d1a8d9a4dcaff3c6dc3d6b47d4b2e341155 (patch) | |
tree | d94fb21e165f7a10cbdebbaebb81d68991294464 | |
parent | 4b969ccd377f8cc643738135efacebe6761a1068 (diff) | |
download | pcitool-a92e1d1a8d9a4dcaff3c6dc3d6b47d4b2e341155.tar.gz pcitool-a92e1d1a8d9a4dcaff3c6dc3d6b47d4b2e341155.tar.bz2 pcitool-a92e1d1a8d9a4dcaff3c6dc3d6b47d4b2e341155.tar.xz pcitool-a92e1d1a8d9a4dcaff3c6dc3d6b47d4b2e341155.zip |
Support kernels up to 4.9 (patch provided by Timo)
-rw-r--r-- | driver/compat.h | 9 | ||||
-rw-r--r-- | driver/umem.c | 22 |
2 files changed, 16 insertions, 15 deletions
diff --git a/driver/compat.h b/driver/compat.h index 24cc5a9..ba9d15a 100644 --- a/driver/compat.h +++ b/driver/compat.h @@ -37,4 +37,13 @@ # define __devinitdata #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0) +# define get_user_pages_compat(vma, nr, pages) get_user_pages(vma, nr, FOLL_WRITE, pages, NULL) +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0) +# define get_user_pages_compat(vma, nr, pages) get_user_pages(vma, nr, 1, 0, pages, NULL) +#else +# define get_user_pages_compat(vma, nr, pages) get_user_pages(current, current->mm, vma, nr, 1, 0, pages, NULL) +#endif + + #endif diff --git a/driver/umem.c b/driver/umem.c index 8d73207..e643102 100644 --- a/driver/umem.c +++ b/driver/umem.c @@ -81,15 +81,7 @@ int pcidriver_umem_sgmap(pcidriver_privdata_t *privdata, umem_handle_t *umem_han /* Get the page information */ down_read(¤t->mm->mmap_sem); - res = get_user_pages( - current, - current->mm, - umem_handle->vma, - nr_pages, - 1, - 0, /* do not force, FIXME: shall I? */ - pages, - NULL ); + res = get_user_pages_compat(umem_handle->vma, nr_pages, pages); up_read(¤t->mm->mmap_sem); /* Error, not all pages mapped */ @@ -106,7 +98,7 @@ int pcidriver_umem_sgmap(pcidriver_privdata_t *privdata, umem_handle_t *umem_han /* Lock the pages, then populate the SG list with the pages */ /* page0 is different */ if ( !PageReserved(pages[0]) ) - __set_page_locked(pages[0]); + lock_page(pages[0]); offset = (umem_handle->vma & ~PAGE_MASK); length = (umem_handle->size > (PAGE_SIZE-offset) ? (PAGE_SIZE-offset) : umem_handle->size); @@ -117,7 +109,7 @@ int pcidriver_umem_sgmap(pcidriver_privdata_t *privdata, umem_handle_t *umem_han for(i=1; i<nr_pages; i++) { /* Lock page first */ if ( !PageReserved(pages[i]) ) - __set_page_locked(pages[i]); + lock_page(pages[i]); /* Populate the list */ sg_set_page(&sg[i], pages[i], ((count > PAGE_SIZE) ? PAGE_SIZE : count), 0); @@ -166,10 +158,10 @@ umem_sgmap_unmap: if (nr_pages > 0) { for(i=0; i<nr_pages; i++) { if (PageLocked(pages[i])) - __clear_page_locked(pages[i]); + unlock_page(pages[i]); if (!PageReserved(pages[i])) set_page_dirty(pages[i]); - page_cache_release(pages[i]); + put_page(pages[i]); } } vfree(sg); @@ -198,10 +190,10 @@ int pcidriver_umem_sgunmap(pcidriver_privdata_t *privdata, pcidriver_umem_entry_ /* Mark pages as Dirty and unlock it */ if ( !PageReserved( umem_entry->pages[i] )) { SetPageDirty( umem_entry->pages[i] ); - __clear_page_locked(umem_entry->pages[i]); + unlock_page(umem_entry->pages[i]); } /* and release it from the cache */ - page_cache_release( umem_entry->pages[i] ); + put_page( umem_entry->pages[i] ); } } |