Re: [PATCH] vmwgfx: Create debugfs ttm_resource_manager entry only if needed
I just pushed it to drm-misc-fixes. Thanks for your reviews, -- Jocelyn On 14/03/2024 09:14, Jocelyn Falempe wrote: On 13/03/2024 18:57, Zack Rusin wrote: On Tue, Mar 12, 2024 at 5:36 AM Jocelyn Falempe wrote: [...] Thanks! That looks great. I can push it through drm-misc-fixes. Thanks, I think I only forget the "drm/" in the commit title, but yes you can push it with this small correction. Reviewed-by: Zack Rusin z Best regards,
Re: [PATCH] vmwgfx: Create debugfs ttm_resource_manager entry only if needed
On 13/03/2024 18:57, Zack Rusin wrote: On Tue, Mar 12, 2024 at 5:36 AM Jocelyn Falempe wrote: [...] Thanks! That looks great. I can push it through drm-misc-fixes. Thanks, I think I only forget the "drm/" in the commit title, but yes you can push it with this small correction. Reviewed-by: Zack Rusin z Best regards, -- Jocelyn
Re: [PATCH] vmwgfx: Create debugfs ttm_resource_manager entry only if needed
On Tue, Mar 12, 2024 at 5:36 AM Jocelyn Falempe wrote: > > The driver creates /sys/kernel/debug/dri/0/mob_ttm even when the > corresponding ttm_resource_manager is not allocated. > This leads to a crash when trying to read from this file. > > Add a check to create mob_ttm, system_mob_ttm, and gmr_ttm debug file > only when the corresponding ttm_resource_manager is allocated. > > crash> bt > PID: 3133409 TASK: 8fe4834a5000 CPU: 3COMMAND: "grep" > #0 [b954506b3b20] machine_kexec at b2a6bec3 > #1 [b954506b3b78] __crash_kexec at b2bb598a > #2 [b954506b3c38] crash_kexec at b2bb68c1 > #3 [b954506b3c50] oops_end at b2a2a9b1 > #4 [b954506b3c70] no_context at b2a7e913 > #5 [b954506b3cc8] __bad_area_nosemaphore at b2a7ec8c > #6 [b954506b3d10] do_page_fault at b2a7f887 > #7 [b954506b3d40] page_fault at b360116e > [exception RIP: ttm_resource_manager_debug+0x11] > RIP: c04afd11 RSP: b954506b3df0 RFLAGS: 00010246 > RAX: 8fe41a6d1200 RBX: RCX: 0940 > RDX: RSI: c04b4338 RDI: > RBP: b954506b3e08 R8: 8fee3ffad000 R9: > R10: 8fe41a76a000 R11: 0001 R12: > R13: 0001 R14: 8fe5bb6f3900 R15: 8fe41a6d1200 > ORIG_RAX: CS: 0010 SS: 0018 > #8 [b954506b3e00] ttm_resource_manager_show at c04afde7 [ttm] > #9 [b954506b3e30] seq_read at b2d8f9f3 > RIP: 7f4c4eda8985 RSP: 7ffdbba9e9f8 RFLAGS: 0246 > RAX: ffda RBX: 0037e000 RCX: 7f4c4eda8985 > RDX: 0037e000 RSI: 7f4c41573000 RDI: 0003 > RBP: 0037e000 R8: R9: 0037fe30 > R10: R11: 0246 R12: 7f4c41573000 > R13: 0003 R14: 7f4c41572010 R15: 0003 > ORIG_RAX: CS: 0033 SS: 002b > > Signed-off-by: Jocelyn Falempe > Fixes: af4a25bbe5e7 ("drm/vmwgfx: Add debugfs entries for various ttm > resource managers") > Cc: > --- > drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 15 +-- > 1 file changed, 9 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c > b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c > index d3e308fdfd5b..c7d90f96d16a 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c > @@ -1444,12 +1444,15 @@ static void vmw_debugfs_resource_managers_init(struct > vmw_private *vmw) > root, "system_ttm"); > ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, > TTM_PL_VRAM), > root, "vram_ttm"); > - ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, > VMW_PL_GMR), > - root, "gmr_ttm"); > - ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, > VMW_PL_MOB), > - root, "mob_ttm"); > - ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, > VMW_PL_SYSTEM), > - root, "system_mob_ttm"); > + if (vmw->has_gmr) > + > ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_GMR), > + root, "gmr_ttm"); > + if (vmw->has_mob) { > + > ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_MOB), > + root, "mob_ttm"); > + > ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, > VMW_PL_SYSTEM), > + root, "system_mob_ttm"); > + } > } > > static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val, > > base-commit: b33651a5c98dbd5a919219d8c129d0674ef74299 > -- > 2.44.0 > Thanks! That looks great. I can push it through drm-misc-fixes. Reviewed-by: Zack Rusin z
[PATCH] vmwgfx: Create debugfs ttm_resource_manager entry only if needed
The driver creates /sys/kernel/debug/dri/0/mob_ttm even when the corresponding ttm_resource_manager is not allocated. This leads to a crash when trying to read from this file. Add a check to create mob_ttm, system_mob_ttm, and gmr_ttm debug file only when the corresponding ttm_resource_manager is allocated. crash> bt PID: 3133409 TASK: 8fe4834a5000 CPU: 3COMMAND: "grep" #0 [b954506b3b20] machine_kexec at b2a6bec3 #1 [b954506b3b78] __crash_kexec at b2bb598a #2 [b954506b3c38] crash_kexec at b2bb68c1 #3 [b954506b3c50] oops_end at b2a2a9b1 #4 [b954506b3c70] no_context at b2a7e913 #5 [b954506b3cc8] __bad_area_nosemaphore at b2a7ec8c #6 [b954506b3d10] do_page_fault at b2a7f887 #7 [b954506b3d40] page_fault at b360116e [exception RIP: ttm_resource_manager_debug+0x11] RIP: c04afd11 RSP: b954506b3df0 RFLAGS: 00010246 RAX: 8fe41a6d1200 RBX: RCX: 0940 RDX: RSI: c04b4338 RDI: RBP: b954506b3e08 R8: 8fee3ffad000 R9: R10: 8fe41a76a000 R11: 0001 R12: R13: 0001 R14: 8fe5bb6f3900 R15: 8fe41a6d1200 ORIG_RAX: CS: 0010 SS: 0018 #8 [b954506b3e00] ttm_resource_manager_show at c04afde7 [ttm] #9 [b954506b3e30] seq_read at b2d8f9f3 RIP: 7f4c4eda8985 RSP: 7ffdbba9e9f8 RFLAGS: 0246 RAX: ffda RBX: 0037e000 RCX: 7f4c4eda8985 RDX: 0037e000 RSI: 7f4c41573000 RDI: 0003 RBP: 0037e000 R8: R9: 0037fe30 R10: R11: 0246 R12: 7f4c41573000 R13: 0003 R14: 7f4c41572010 R15: 0003 ORIG_RAX: CS: 0033 SS: 002b Signed-off-by: Jocelyn Falempe Fixes: af4a25bbe5e7 ("drm/vmwgfx: Add debugfs entries for various ttm resource managers") Cc: --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 15 +-- 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index d3e308fdfd5b..c7d90f96d16a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1444,12 +1444,15 @@ static void vmw_debugfs_resource_managers_init(struct vmw_private *vmw) root, "system_ttm"); ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, TTM_PL_VRAM), root, "vram_ttm"); - ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_GMR), - root, "gmr_ttm"); - ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_MOB), - root, "mob_ttm"); - ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_SYSTEM), - root, "system_mob_ttm"); + if (vmw->has_gmr) + ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_GMR), + root, "gmr_ttm"); + if (vmw->has_mob) { + ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_MOB), + root, "mob_ttm"); + ttm_resource_manager_create_debugfs(ttm_manager_type(>bdev, VMW_PL_SYSTEM), + root, "system_mob_ttm"); + } } static int vmwgfx_pm_notifier(struct notifier_block *nb, unsigned long val, base-commit: b33651a5c98dbd5a919219d8c129d0674ef74299 -- 2.44.0