Skip to content

Commit dc066a7

Browse files
matt-auldgregkh
authored andcommitted
drm/i915/dmabuf: fix sg_table handling in map_dma_buf
commit f90daa9 upstream. We need to iterate over the original entries here for the sg_table, pulling out the struct page for each one, to be remapped. However currently this incorrectly iterates over the final dma mapped entries, which is likely just one gigantic sg entry if the iommu is enabled, leading to us only mapping the first struct page (and any physically contiguous pages following it), even if there is potentially lots more data to follow. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/7306 Fixes: 1286ff7 ("i915: add dmabuf/prime buffer sharing support.") Signed-off-by: Matthew Auld <[email protected]> Cc: Lionel Landwerlin <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: Ville Syrjälä <[email protected]> Cc: Michael J. Ruhl <[email protected]> Cc: <[email protected]> # v3.5+ Reviewed-by: Michael J. Ruhl <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 28d52f9) Signed-off-by: Tvrtko Ursulin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent afbd118 commit dc066a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ static struct sg_table *i915_gem_map_dma_buf(struct dma_buf_attachment *attachme
3434
goto err;
3535
}
3636

37-
ret = sg_alloc_table(st, obj->mm.pages->nents, GFP_KERNEL);
37+
ret = sg_alloc_table(st, obj->mm.pages->orig_nents, GFP_KERNEL);
3838
if (ret)
3939
goto err_free;
4040

4141
src = obj->mm.pages->sgl;
4242
dst = st->sgl;
43-
for (i = 0; i < obj->mm.pages->nents; i++) {
43+
for (i = 0; i < obj->mm.pages->orig_nents; i++) {
4444
sg_set_page(dst, sg_page(src), src->length, 0);
4545
dst = sg_next(dst);
4646
src = sg_next(src);

0 commit comments

Comments
 (0)