Skip to contentSkip to conversation

DRM commit e3c92eb causes OpenChrome DRM to crash during boot

PATCH In review Kevin Brace 2 participants 3 messages Jan 11, 2023 – Jan 12, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover DRM commit e3c92eb causes OpenChrome DRM to crash during boot

From: Kevin Brace <[email protected]>

Hi,

I work on an out of the kernel tree DRM module for VIA Technologies Chrome integrated graphics (https://cgit.freedesktop.org/openchrome/drm-openchrome/),
and DRM commit e3c92eb4a84fb0f00442e6b5cabf4f11b0eaaf41 (drm/ttm: rework on ttm_resource to use size_t type) definitely breaks my code.
The bug is 100% reproducible.
It took me about 2 1/2 weeks to track down the bad commit due to the general difficulty of debugging DRM code since it gets loaded by the OS way before sysklogd service is even up and running to record a crash.
For this bug, bug check did not come on, so this made it very hard to track down the bad commit.
After reversing many commits, I was able to see a difference in the behavior of the code if this particular commit was reversed.
I am including a patch that I think correctly fixes the erroneous code, and OpenChrome DRM works correctly (i.e., OS now boots properly) if the patch is applied.
Please be more careful tinkering with TTM in the future since it tends to be very fragile.

--
Kevin Brace (1):
drm/ttm: Fix of rework on ttm_resource to use size_t type commit

 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.38.2
#1 lore raw

PATCH 1/1 drm/ttm: Fix of rework on ttm_resource to use size_t type commit

From: Kevin Brace <[email protected]>

Commit e3c92eb4a84fb0f00442e6b5cabf4f11b0eaaf41 (drm/ttm: rework on ttm_resource to use size_t type) reworked ttm_resource{} to use size_t type size instead of unsigned long type num_pages. In that commit, when ttm_move_memcpy() is being called from ttm_bo_move_memcpy(), the code was changed to specify the page size from ttm->num_pages instead of the original code's dst_mem->num_pages. Since the commit is about reworking ttm_resource{} to use size_t type size instead of unsigned long type num_pages, the commit should have specified page size converted version of dst_mem->size. Use PFN_UP macro to convert dst_mem->size to page size.

---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -1
index ba3aa0a0fc43..da5493f789df 100644
@@ -173,7 +173,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 
 	clear = src_iter->ops->maps_tt && (!ttm || !ttm_tt_is_populated(ttm));
 	if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC)))
-		ttm_move_memcpy(clear, ttm->num_pages, dst_iter, src_iter);
+		ttm_move_memcpy(clear, PFN_UP(dst_mem->size), dst_iter, src_iter);
 
 	if (!src_iter->ops->maps_tt)
 		ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, src_mem);
Signature · 1 line
2.38.2
#2 lore raw

Re: [PATCH 1/1] drm/ttm: Fix of rework on ttm_resource to use size_t type commit

Am 11.01.23 um 23:45 schrieb Kevin Brace:

Quoted 12 lines

From: Kevin Brace <[email protected]>

Commit e3c92eb4a84fb0f00442e6b5cabf4f11b0eaaf41 (drm/ttm: rework on ttm_resource to use size_t type) reworked ttm_resource{} to use size_t type size instead of unsigned long type num_pages. In that commit, when ttm_move_memcpy() is being called from ttm_bo_move_memcpy(), the code was changed to specify the page size from ttm->num_pages instead of the original code's dst_mem->num_pages. Since the commit is about reworking ttm_resource{} to use size_t type size instead of unsigned long type num_pages, the commit should have specified page size converted version of dst_mem->size. Use PFN_UP macro to convert dst_mem->size to page size.

Zack already came up with the same patch, please review that one instead.

Thanks,
Christian.

Quoted 19 lines
---
  drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -1
index ba3aa0a0fc43..da5493f789df 100644
@@ -173,7 +173,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 
  	clear = src_iter->ops->maps_tt && (!ttm || !ttm_tt_is_populated(ttm));
  	if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC)))
-		ttm_move_memcpy(clear, ttm->num_pages, dst_iter, src_iter);
+		ttm_move_memcpy(clear, PFN_UP(dst_mem->size), dst_iter, src_iter);
 
  	if (!src_iter->ops->maps_tt)
  		ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, src_mem);