Index: sys/compat/linuxkpi/common/include/linux/scatterlist.h =================================================================== --- sys/compat/linuxkpi/common/include/linux/scatterlist.h +++ sys/compat/linuxkpi/common/include/linux/scatterlist.h @@ -327,18 +327,26 @@ return (ret); } -static inline int +static inline struct scatterlist * __sg_alloc_table_from_pages(struct sg_table *sgt, struct page **pages, unsigned int count, unsigned long off, unsigned long size, - unsigned int max_segment, gfp_t gfp_mask) + unsigned int max_segment, + struct scatterlist *prv, unsigned int left_pages __unused, + gfp_t gfp_mask) { unsigned int i, segs, cur, len; int rc; struct scatterlist *s; + if (prv != NULL) { + panic( + "Support for prv != NULL not implemented in " + "__sg_alloc_table_from_pages()"); + } + if (__predict_false(!max_segment || offset_in_page(max_segment))) - return (-EINVAL); + return (ERR_PTR(-EINVAL)); len = 0; for (segs = i = 1; i < count; ++i) { @@ -350,13 +358,15 @@ } } if (__predict_false((rc = sg_alloc_table(sgt, segs, gfp_mask)))) - return (rc); + return (ERR_PTR(rc)); cur = 0; - for_each_sg(sgt->sgl, s, sgt->orig_nents, i) { + for (i = 0, s = sgt->sgl; i < sgt->orig_nents; i++) { unsigned long seg_size; unsigned int j; + s = sg_next(s); + len = 0; for (j = cur + 1; j < count; ++j) { len += PAGE_SIZE; @@ -371,7 +381,12 @@ off = 0; cur = j; } - return (0); + KASSERT(s != NULL, ("s is NULL after loop in __sg_alloc_table_from_pages()")); + + if (left_pages == 0) + sg_mark_end(s); + + return (s); } static inline int @@ -381,8 +396,8 @@ gfp_t gfp_mask) { - return (__sg_alloc_table_from_pages(sgt, pages, count, off, size, - SCATTERLIST_MAX_SEGMENT, gfp_mask)); + return PTR_ERR_OR_ZERO(__sg_alloc_table_from_pages(sgt, pages, count, off, size, + SCATTERLIST_MAX_SEGMENT, NULL, 0, gfp_mask)); } static inline int Index: sys/ofed/drivers/infiniband/core/ib_umem_odp.c =================================================================== --- sys/ofed/drivers/infiniband/core/ib_umem_odp.c +++ sys/ofed/drivers/infiniband/core/ib_umem_odp.c @@ -576,7 +576,7 @@ * complex (and doesn't gain us much performance in most use * cases). */ - npages = get_user_pages_remote(owning_process, owning_mm, + npages = get_user_pages_remote(owning_mm, user_virt, gup_num_pages, flags, local_page_list, NULL); up_read(&owning_mm->mmap_sem);