Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/userptr: Fix an incorrect assert
@ 2025-03-07 10:01 Thomas Hellström
  2025-03-07 10:07 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Thomas Hellström @ 2025-03-07 10:01 UTC (permalink / raw)
  To: intel-xe; +Cc: Thomas Hellström, Matthew Auld, Matthew Brost

The assert incorrectly checks the total length processed which
can in fact be greater than the number of pages. Fix.

Fixes: 0a98219bcc96 ("drm/xe/hmm: Don't dereference struct page pointers without notifier lock")
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/xe/xe_hmm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_hmm.c b/drivers/gpu/drm/xe/xe_hmm.c
index 392102515f3d..c3cc0fa105e8 100644
--- a/drivers/gpu/drm/xe/xe_hmm.c
+++ b/drivers/gpu/drm/xe/xe_hmm.c
@@ -138,13 +138,17 @@ static int xe_build_sg(struct xe_device *xe, struct hmm_range *range,
 		i += size;
 
 		if (unlikely(j == st->nents - 1)) {
+			xe_assert(xe, i >= npages);
 			if (i > npages)
 				size -= (i - npages);
+
 			sg_mark_end(sgl);
+		} else {
+			xe_assert(xe, i < npages);
 		}
+
 		sg_set_page(sgl, page, size << PAGE_SHIFT, 0);
 	}
-	xe_assert(xe, i == npages);
 
 	return dma_map_sgtable(dev, st, write ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE,
 			       DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_NO_KERNEL_MAPPING);
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-03-08 11:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07 10:01 [PATCH] drm/xe/userptr: Fix an incorrect assert Thomas Hellström
2025-03-07 10:07 ` ✓ CI.Patch_applied: success for " Patchwork
2025-03-07 10:07 ` ✓ CI.checkpatch: " Patchwork
2025-03-07 10:09 ` ✓ CI.KUnit: " Patchwork
2025-03-07 10:38 ` ✓ CI.Build: " Patchwork
2025-03-07 10:40 ` ✓ CI.Hooks: " Patchwork
2025-03-07 10:42 ` ✓ CI.checksparse: " Patchwork
2025-03-07 11:02 ` ✓ Xe.CI.BAT: " Patchwork
2025-03-07 13:19 ` [PATCH] " Matthew Auld
2025-03-07 14:57   ` Thomas Hellström
2025-03-08  2:09 ` ✗ Xe.CI.Full: failure for " Patchwork
2025-03-08 11:16   ` Thomas Hellström

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox