[PATCH 6/6] drm/i915: Fix DMA mapped scatterlist iteration
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Wed Sep 9 11:19:06 UTC 2020
From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
When walking DMA mapped scatterlists sg_dma_len has to be used since it
can be different (coalesced) from the backing store entry.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Fixes: 85d1225ec066 ("drm/i915: Introduce & use new lightweight SGL iterators")
Reported-by: Tom Murphy <murphyt7 at tcd.ie>
Suggested-by: Logan Gunthorpe <logang at deltatee.com>
---
drivers/gpu/drm/i915/i915_scatterlist.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_scatterlist.h b/drivers/gpu/drm/i915/i915_scatterlist.h
index b7b59328cb76..510856887628 100644
--- a/drivers/gpu/drm/i915/i915_scatterlist.h
+++ b/drivers/gpu/drm/i915/i915_scatterlist.h
@@ -27,13 +27,17 @@ static __always_inline struct sgt_iter {
} __sgt_iter(struct scatterlist *sgl, bool dma) {
struct sgt_iter s = { .sgp = sgl };
- if (s.sgp) {
+ if (dma && s.sgp && sg_dma_len(s.sgp) == 0) {
+ s.sgp = NULL;
+ } else if (s.sgp) {
s.max = s.curr = s.sgp->offset;
- s.max += s.sgp->length;
- if (dma)
+ if (dma) {
s.dma = sg_dma_address(s.sgp);
- else
+ s.max += sg_dma_len(s.sgp);
+ } else {
s.pfn = page_to_pfn(sg_page(s.sgp));
+ s.max += s.sgp->length;
+ }
}
return s;
--
2.25.1
More information about the Intel-gfx-trybot
mailing list