* [PATCH 0/2] drm/msm: fbdev: Fix the framebuffer pin leak on destroy @ 2026-11-26 17:05 Vladimir Zapolskiy 2026-11-26 17:05 ` [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object " Vladimir Zapolskiy 2026-11-26 17:05 ` [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer Vladimir Zapolskiy 0 siblings, 2 replies; 6+ messages in thread From: Vladimir Zapolskiy @ 2026-11-26 17:05 UTC (permalink / raw) To: Rob Clark, Dmitry Baryshkov, Thomas Zimmermann Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno The fbdev emulation pins the framebuffer buffer object in the KMS address space on probe, but never unpins it, and the buffer object is freed while still pinned, which triggers a pin_count warning on unbind of the MSM DRM device, for instance on removal of a DSI panel driver module. Vladimir Zapolskiy (2): drm/msm: fbdev: Unpin the framebuffer buffer object on destroy drm/msm: fbdev: Add the missing VMA reference of the framebuffer drivers/gpu/drm/msm/msm_fbdev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.51.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object on destroy 2026-11-26 17:05 [PATCH 0/2] drm/msm: fbdev: Fix the framebuffer pin leak on destroy Vladimir Zapolskiy @ 2026-11-26 17:05 ` Vladimir Zapolskiy 2026-11-26 17:24 ` sashiko-bot 2026-11-27 20:43 ` Dmitry Baryshkov 2026-11-26 17:05 ` [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer Vladimir Zapolskiy 1 sibling, 2 replies; 6+ messages in thread From: Vladimir Zapolskiy @ 2026-11-26 17:05 UTC (permalink / raw) To: Rob Clark, Dmitry Baryshkov, Thomas Zimmermann Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno The fbdev emulation pins the framebuffer buffer object in the KMS address space and maps it on probe, however on fbdev destruction only the mapping is released, and the buffer object is freed while still pinned. For instance on removal of a DSI panel driver module, which unbinds the MSM DRM driver, the next warning message is displayed: msm_obj->pin_count WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x90/0x98 Call trace: update_lru_locked+0x90/0x98 (P) put_pages+0x8c/0x104 msm_gem_free_object+0x1bc/0x244 drm_gem_object_free+0x1c/0x30 drm_client_buffer_delete+0xd4/0xf8 msm_fbdev_fb_destroy+0x54/0x6c put_fb_info+0x48/0x84 unregister_framebuffer+0x88/0xf8 drm_fb_helper_unregister_info+0x14/0x20 drm_fbdev_client_unregister+0x18/0x34 drm_client_dev_unregister+0x80/0xfc drm_dev_unregister+0x24/0x98 msm_drm_uninit.isra.0+0x8c/0xcc Unpin the buffer object on fbdev destruction in the same way as it is done on the error path of the fbdev probe. Fixes: 940b869c2f2f ("drm/msm: Implement fbdev emulation as in-kernel client") Signed-off-by: Vladimir Zapolskiy <vz@kernel.org> --- drivers/gpu/drm/msm/msm_fbdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index f37cc3f97a21..25e55b5c5ecc 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -41,6 +41,7 @@ static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma) static void msm_fbdev_fb_destroy(struct fb_info *info) { struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; + struct msm_drm_private *priv = helper->dev->dev_private; struct drm_gem_object *bo = msm_framebuffer_bo(helper->fb, 0); DBG(); @@ -48,6 +49,7 @@ static void msm_fbdev_fb_destroy(struct fb_info *info) drm_fb_helper_fini(helper); msm_gem_put_vaddr(bo); + msm_gem_unpin_iova(bo, priv->kms->vm); drm_client_buffer_delete(helper->buffer); drm_client_release(&helper->client); -- 2.51.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object on destroy 2026-11-26 17:05 ` [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object " Vladimir Zapolskiy @ 2026-11-26 17:24 ` sashiko-bot 2026-11-27 20:43 ` Dmitry Baryshkov 1 sibling, 0 replies; 6+ messages in thread From: sashiko-bot @ 2026-11-26 17:24 UTC (permalink / raw) To: Vladimir Zapolskiy; +Cc: dri-devel Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/msm: missing msm_gem_vma_get() in msm_fbdev_driver_fbdev_probe() [1] -- commit f61acbf5c2e9c608df43ac6974e8470121d1679c Author: Vladimir Zapolskiy <vz@kernel.org> drm/msm: fbdev: Unpin the framebuffer buffer object on destroy This commit unpins the framebuffer GEM buffer object from the KMS address space in msm_fbdev_fb_destroy() before deleting the client buffer. > diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c > index f37cc3f97a21f..25e55b5c5ecc0 100644 > --- a/drivers/gpu/drm/msm/msm_fbdev.c > +++ b/drivers/gpu/drm/msm/msm_fbdev.c > @@ -41,6 +41,7 @@ static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma) > static void msm_fbdev_fb_destroy(struct fb_info *info) > { > struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; > + struct msm_drm_private *priv = helper->dev->dev_private; > struct drm_gem_object *bo = msm_framebuffer_bo(helper->fb, 0); > > DBG(); > @@ -48,6 +49,7 @@ static void msm_fbdev_fb_destroy(struct fb_info *info) > drm_fb_helper_fini(helper); > > msm_gem_put_vaddr(bo); > + msm_gem_unpin_iova(bo, priv->kms->vm); [Severity: High] This problem wasn't introduced by this patch, but does msm_fbdev_driver_fbdev_probe() need to call msm_gem_vma_get(bo) [1] when pinning the framebuffer in priv->kms->vm (paired with msm_gem_vma_put(bo) in msm_fbdev_fb_destroy())? drivers/gpu/drm/msm/msm_fbdev.c:msm_fbdev_driver_fbdev_probe() { ... ret = msm_gem_get_and_pin_iova(bo, priv->kms->vm, &paddr); ... drm_gem_handle_delete(file, handle); return 0; err_msm_gem_unpin: msm_gem_unpin_iova(bo, priv->kms->vm); msm_gem_vma_put(bo); err_drm_client_buffer_delete: drm_client_buffer_delete(buffer); err_drm_gem_handle_delete: drm_gem_handle_delete(file, handle); return ret; } The only VMA reference on bo comes from drm_gem_handle_create() -> msm_gem_open(). Deleting the temporary handle at the end of probe calls msm_gem_close() -> msm_gem_vma_put(), which drops vma_ref to zero and tears down the KMS VMA while fbi->fix.smem_start still holds the freed IOVA. If msm_gem_get_vaddr() fails instead, err_msm_gem_unpin calls msm_gem_vma_put() before falling through to drm_gem_handle_delete(), underflowing vma_ref to -1. [1] https://sashiko.dev/#/bug/linux-f430fb49-9db8-4da0-8b31-b9f1caff2095 -- Sashiko AI review · https://sashiko.dev/#/patchset/20261126170535.361985-1-vz@kernel.org?part=1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object on destroy 2026-11-26 17:05 ` [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object " Vladimir Zapolskiy 2026-11-26 17:24 ` sashiko-bot @ 2026-11-27 20:43 ` Dmitry Baryshkov 1 sibling, 0 replies; 6+ messages in thread From: Dmitry Baryshkov @ 2026-11-27 20:43 UTC (permalink / raw) To: Vladimir Zapolskiy Cc: Rob Clark, Dmitry Baryshkov, Thomas Zimmermann, Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno On Thu, Nov 26, 2026 at 07:05:34PM +0200, Vladimir Zapolskiy wrote: > The fbdev emulation pins the framebuffer buffer object in the KMS > address space and maps it on probe, however on fbdev destruction only > the mapping is released, and the buffer object is freed while still > pinned. For instance on removal of a DSI panel driver module, which > unbinds the MSM DRM driver, the next warning message is displayed: > > msm_obj->pin_count > WARNING: drivers/gpu/drm/msm/msm_gem.c:173 at update_lru_locked+0x90/0x98 > Call trace: > update_lru_locked+0x90/0x98 (P) > put_pages+0x8c/0x104 > msm_gem_free_object+0x1bc/0x244 > drm_gem_object_free+0x1c/0x30 > drm_client_buffer_delete+0xd4/0xf8 > msm_fbdev_fb_destroy+0x54/0x6c > put_fb_info+0x48/0x84 > unregister_framebuffer+0x88/0xf8 > drm_fb_helper_unregister_info+0x14/0x20 > drm_fbdev_client_unregister+0x18/0x34 > drm_client_dev_unregister+0x80/0xfc > drm_dev_unregister+0x24/0x98 > msm_drm_uninit.isra.0+0x8c/0xcc > > Unpin the buffer object on fbdev destruction in the same way as it is > done on the error path of the fbdev probe. > > Fixes: 940b869c2f2f ("drm/msm: Implement fbdev emulation as in-kernel client") > Signed-off-by: Vladimir Zapolskiy <vz@kernel.org> > --- > drivers/gpu/drm/msm/msm_fbdev.c | 2 ++ > 1 file changed, 2 insertions(+) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer 2026-11-26 17:05 [PATCH 0/2] drm/msm: fbdev: Fix the framebuffer pin leak on destroy Vladimir Zapolskiy 2026-11-26 17:05 ` [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object " Vladimir Zapolskiy @ 2026-11-26 17:05 ` Vladimir Zapolskiy 2026-11-27 20:43 ` Dmitry Baryshkov 1 sibling, 1 reply; 6+ messages in thread From: Vladimir Zapolskiy @ 2026-11-26 17:05 UTC (permalink / raw) To: Rob Clark, Dmitry Baryshkov, Thomas Zimmermann Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno A VMA reference of the framebuffer buffer object is dropped on the probe error path, like msm_framebuffer_cleanup() does, but the reference is never taken, and the VMA reference count underflows on the following deletion of the temporary GEM handle. The missing reference also affects a successful probe: the KMS VMA is torn down, when the VMA reference count drops to zero, which happens on deletion of the temporary GEM handle at the end of the probe. Then fbi->fix.smem_start points to an unmapped address, and on fbdev destruction msm_gem_unpin_iova() finds no VMA and does not drop the pin, unless the framebuffer is prepared for scanout at that time. Take a VMA reference before pinning the framebuffer on probe, like msm_framebuffer_prepare() does, and drop it after unpinning on fbdev destruction. Fixes: eb714953c441 ("drm/msm: fbdev: Use a DRM client buffer") Signed-off-by: Vladimir Zapolskiy <vz@kernel.org> --- drivers/gpu/drm/msm/msm_fbdev.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c index 25e55b5c5ecc..b5ced6ede19f 100644 --- a/drivers/gpu/drm/msm/msm_fbdev.c +++ b/drivers/gpu/drm/msm/msm_fbdev.c @@ -50,6 +50,7 @@ static void msm_fbdev_fb_destroy(struct fb_info *info) msm_gem_put_vaddr(bo); msm_gem_unpin_iova(bo, priv->kms->vm); + msm_gem_vma_put(bo); drm_client_buffer_delete(helper->buffer); drm_client_release(&helper->client); @@ -144,10 +145,11 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, * in panic (ie. lock-safe, etc) we could avoid pinning the * buffer now: */ + msm_gem_vma_get(bo); ret = msm_gem_get_and_pin_iova(bo, priv->kms->vm, &paddr); if (ret) { drm_err(dev, "failed to get buffer obj iova: %d\n", ret); - goto err_drm_client_buffer_delete; + goto err_msm_gem_vma_put; } DBG("fbi=%p, dev=%p", fbi, dev); @@ -183,8 +185,8 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, err_msm_gem_unpin: msm_gem_unpin_iova(bo, priv->kms->vm); +err_msm_gem_vma_put: msm_gem_vma_put(bo); -err_drm_client_buffer_delete: drm_client_buffer_delete(buffer); err_drm_gem_handle_delete: drm_gem_handle_delete(file, handle); -- 2.51.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer 2026-11-26 17:05 ` [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer Vladimir Zapolskiy @ 2026-11-27 20:43 ` Dmitry Baryshkov 0 siblings, 0 replies; 6+ messages in thread From: Dmitry Baryshkov @ 2026-11-27 20:43 UTC (permalink / raw) To: Vladimir Zapolskiy Cc: Rob Clark, Dmitry Baryshkov, Thomas Zimmermann, Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm, dri-devel, freedreno On Thu, Nov 26, 2026 at 07:05:35PM +0200, Vladimir Zapolskiy wrote: > A VMA reference of the framebuffer buffer object is dropped on the probe > error path, like msm_framebuffer_cleanup() does, but the reference is > never taken, and the VMA reference count underflows on the following > deletion of the temporary GEM handle. > > The missing reference also affects a successful probe: the KMS VMA is > torn down, when the VMA reference count drops to zero, which happens on > deletion of the temporary GEM handle at the end of the probe. Then > fbi->fix.smem_start points to an unmapped address, and on fbdev > destruction msm_gem_unpin_iova() finds no VMA and does not drop the pin, > unless the framebuffer is prepared for scanout at that time. > > Take a VMA reference before pinning the framebuffer on probe, like > msm_framebuffer_prepare() does, and drop it after unpinning on fbdev > destruction. > > Fixes: eb714953c441 ("drm/msm: fbdev: Use a DRM client buffer") > Signed-off-by: Vladimir Zapolskiy <vz@kernel.org> > --- > drivers/gpu/drm/msm/msm_fbdev.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> -- With best wishes Dmitry ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-27 20:44 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-26 17:05 [PATCH 0/2] drm/msm: fbdev: Fix the framebuffer pin leak on destroy Vladimir Zapolskiy 2026-11-26 17:05 ` [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object " Vladimir Zapolskiy 2026-11-26 17:24 ` sashiko-bot 2026-11-27 20:43 ` Dmitry Baryshkov 2026-11-26 17:05 ` [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer Vladimir Zapolskiy 2026-11-27 20:43 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox