From: Vladimir Zapolskiy <vz@kernel.org>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
Dmitry Baryshkov <lumag@kernel.org>
Cc: Abhinav Kumar <abhinav.kumar@linux.dev>,
Jessica Zhang <jesszhan0024@gmail.com>,
Sean Paul <sean@poorly.run>,
Marijn Suijten <marijn.suijten@somainline.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Pengyu Luo <mitltlatltl@gmail.com>,
Alexander Koskovich <akoskovich@pm.me>,
Abel Vesa <abel.vesa@oss.qualcomm.com>,
Kavan Smith <kavansmith82@gmail.com>,
Jonathan Marek <jonathan@marek.ca>,
Jordan Crouse <jordan@cosmicpenguin.net>,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
freedreno@lists.freedesktop.org
Subject: [PATCH] drm/msm/dsi: Fix TX buffer pin leak on command transfers
Date: Thu, 26 Nov 2026 16:19:42 +0200 [thread overview]
Message-ID: <20261126141942.335280-1-vz@kernel.org> (raw)
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
next reply other threads:[~2026-11-26 14:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:19 Vladimir Zapolskiy [this message]
2026-11-27 20:29 ` [PATCH] drm/msm/dsi: Fix TX buffer pin leak on command transfers Dmitry Baryshkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126141942.335280-1-vz@kernel.org \
--to=vz@kernel.org \
--cc=abel.vesa@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=airlied@gmail.com \
--cc=akoskovich@pm.me \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=jesszhan0024@gmail.com \
--cc=jonathan@marek.ca \
--cc=jordan@cosmicpenguin.net \
--cc=kavansmith82@gmail.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=mitltlatltl@gmail.com \
--cc=robin.clark@oss.qualcomm.com \
--cc=sean@poorly.run \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.