DRM commit e3c92eb causes OpenChrome DRM to crash during boot
Subsystems (3)
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
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
@@ -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
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 onttm_resourceto usesize_ttype) reworked ttm_resource{} to usesize_ttype size instead of unsigned long typenum_pages. In that commit, whenttm_move_memcpy()is being called fromttm_bo_move_memcpy(), the code was changed to specify the page size fromttm->num_pagesinstead of the original code'sdst_mem->num_pages. Since the commit is about reworking ttm_resource{} to usesize_ttype size instead of unsigned long typenum_pages, the commit should have specified page size converted version ofdst_mem->size. UsePFN_UPmacro to convertdst_mem->sizeto page size.
Zack already came up with the same patch, please review that one instead.
Thanks,
Christian.
Quoted 19 lines
Signed-off-by Kevin Brace <[email protected]>--- 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@@ -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);