Skip to content

Commit f90daa9

Browse files
matt-auldtursulin
authored andcommitted
drm/i915/dmabuf: fix sg_table handling in map_dma_buf
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]>
1 parent f0c4d9f commit f90daa9

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
@@ -40,13 +40,13 @@ static struct sg_table *i915_gem_map_dma_buf(struct dma_buf_attachment *attachme
4040
goto err;
4141
}
4242

43-
ret = sg_alloc_table(st, obj->mm.pages->nents, GFP_KERNEL);
43+
ret = sg_alloc_table(st, obj->mm.pages->orig_nents, GFP_KERNEL);
4444
if (ret)
4545
goto err_free;
4646

4747
src = obj->mm.pages->sgl;
4848
dst = st->sgl;
49-
for (i = 0; i < obj->mm.pages->nents; i++) {
49+
for (i = 0; i < obj->mm.pages->orig_nents; i++) {
5050
sg_set_page(dst, sg_page(src), src->length, 0);
5151
dst = sg_next(dst);
5252
src = sg_next(src);

0 commit comments

Comments
 (0)