All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/msm/dsi: Fix TX buffer pin leak on command transfers
@ 2026-11-26 14:19 Vladimir Zapolskiy
  2026-11-27 20:29 ` Dmitry Baryshkov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Zapolskiy @ 2026-11-26 14:19 UTC (permalink / raw)
  To: Rob Clark, Dmitry Baryshkov
  Cc: Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
	David Airlie, Simona Vetter, Konrad Dybcio, Pengyu Luo,
	Alexander Koskovich, Abel Vesa, Kavan Smith, Jonathan Marek,
	Jordan Crouse, linux-arm-msm, dri-devel, freedreno

The DSI 6G TX buffer is allocated by msm_gem_kernel_new(), which pins
the buffer object in the KMS address space and returns its IOVA, but the
returned IOVA is ignored. Instead dsi_dma_base_get_6g() calls
msm_gem_get_and_pin_iova() on every DSI command transfer to get the TX
buffer address, and the buffer is never unpinned after the transfer.

As a result the pin count of the TX buffer object grows with every
transmitted DSI command, and when the buffer is freed by
msm_gem_kernel_put(), which drops only the pin taken on allocation,
the object is freed while still pinned:

  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
   msm_gem_kernel_put+0xa4/0xb8
   msm_dsi_tx_buf_free+0x2c/0x64
   dsi_unbind+0x20/0x40

Save the IOVA returned on the TX buffer allocation and use it as the DMA
base of command transfers without pinning the buffer again.

Fixes: 9fe041f6fdfe ("drm/msm: Add msm_gem_get_and_pin_iova()")
Signed-off-by: Vladimir Zapolskiy <vz@kernel.org>
---
 drivers/gpu/drm/msm/dsi/dsi_host.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 78f0fd259421..5a6fb1a5a890 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -153,6 +153,7 @@ struct msm_dsi_host {
 	/* DSI 6G TX buffer*/
 	struct drm_gem_object *tx_gem_obj;
 	struct drm_gpuvm *vm;
+	u64 tx_iova;
 
 	/* DSI v2 TX buffer */
 	void *tx_buf;
@@ -1261,6 +1262,7 @@ int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size)
 
 	msm_gem_object_set_name(msm_host->tx_gem_obj, "tx_gem");
 
+	msm_host->tx_iova = iova;
 	msm_host->tx_size = msm_host->tx_gem_obj->size;
 
 	return 0;
@@ -1422,14 +1424,13 @@ static int dsi_long_read_resp(u8 *buf, const struct mipi_dsi_msg *msg)
 
 int dsi_dma_base_get_6g(struct msm_dsi_host *msm_host, uint64_t *dma_base)
 {
-	struct drm_device *dev = msm_host->dev;
-	struct msm_drm_private *priv = dev->dev_private;
-
 	if (!dma_base)
 		return -EINVAL;
 
-	return msm_gem_get_and_pin_iova(msm_host->tx_gem_obj,
-				priv->kms->vm, dma_base);
+	/* The TX buffer is pinned on allocation by msm_gem_kernel_new() */
+	*dma_base = msm_host->tx_iova;
+
+	return 0;
 }
 
 int dsi_dma_base_get_v2(struct msm_dsi_host *msm_host, uint64_t *dma_base)
-- 
2.51.0


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

end of thread, other threads:[~2026-11-27 20:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 14:19 [PATCH] drm/msm/dsi: Fix TX buffer pin leak on command transfers Vladimir Zapolskiy
2026-11-27 20:29 ` Dmitry Baryshkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.