From: sashiko-bot@kernel.org
To: "Vladimir Bely" <vlwwwwww@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/5] drm/msm/dsi: implement transfer_batch using multi-packet CMD DMA
Date: Sun, 29 Nov 2026 13:07:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-239623@kernel.org> (raw)
In-Reply-To: <20261129130026.581466-3-vlwwwwww@gmail.com>
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/dsi: pin count leak in dsi_dma_base_get_6g() [1]
--
commit d8fea90d2c8669ea251b525d2dbbf6c4872f4096
Author: Vladimir Bely <vlwwwwww@gmail.com>
drm/msm/dsi: implement transfer_batch using multi-packet CMD DMA
This commit implements mipi_dsi_host_ops.transfer_batch() by packing
contiguous write-only DSI messages that share the same LPM flag into a
single command DMA buffer.
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 78f0fd2594216..6e1630edc1caa 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
[ ... ]
> @@ -1568,6 +1578,90 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host,
> return len;
> }
>
> +static int dsi_cmds2buf_tx_batch(struct msm_dsi_host *msm_host,
> + const struct mipi_dsi_msg *msgs, size_t count)
> +{
> + const struct msm_dsi_cfg_handler *cfg_hnd = msm_host->cfg_hnd;
> + int max_len = msm_host->tx_size;
> + int offset = 0, last_offset = 0;
> + u8 *data = NULL;
> + size_t i;
> + int ret;
> +
> + if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && msm_host->mode) {
> + int bllp_len = msm_host->mode->hdisplay *
> + mipi_dsi_pixel_format_to_bpp(msm_host->format) / 8;
> +
> + max_len = min(max_len, bllp_len);
> + }
> +
> + for (i = 0; i < count; i++) {
> + struct mipi_dsi_packet packet;
> + int pkt_len;
> +
> + ret = mipi_dsi_create_packet(&packet, &msgs[i]);
> + if (ret) {
> + pr_err("%s: create packet failed, %d\n", __func__, ret);
> + goto err_put;
> + }
> + pkt_len = (packet.size + 3) & (~0x3);
> + if (pkt_len > max_len) {
> + pr_err("%s: cmd cannot fit into transfer buffer, len=%d\n",
> + __func__, pkt_len);
> + ret = -EINVAL;
> + goto err_put;
> + }
> +
> + if (offset > 0 && offset + pkt_len > max_len) {
> + data[last_offset + 3] |= BIT(7); /* Last packet */
> + if (cfg_hnd->ops->tx_buf_put)
> + cfg_hnd->ops->tx_buf_put(msm_host);
> + data = NULL;
> +
> + ret = dsi_cmd_dma_tx(msm_host, offset);
[Severity: High]
This problem wasn't introduced by this patch, but does dsi_cmd_dma_tx()
leak the pin count on msm_host->tx_gem_obj [1]?
On DSI 6G, dsi_cmd_dma_tx() calls cfg_hnd->ops->dma_base_get(), which
resolves to dsi_dma_base_get_6g():
drivers/gpu/drm/msm/dsi/dsi_host.c:dsi_dma_base_get_6g() {
...
return msm_gem_get_and_pin_iova(msm_host->tx_gem_obj,
priv->kms->vm, dma_base);
}
Nothing unpins msm_host->tx_gem_obj after the DMA transfer finishes, so
every command transmission increments pin_count. Over repeated command
transfers such as brightness updates, the 32-bit pin_count can eventually
overflow, risking premature unpinning and a use-after-free during DMA.
[1] https://sashiko.dev/#/bug/linux-e5a035ef-dc12-4992-93df-f5006f073546
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129130026.581466-1-vlwwwwww@gmail.com?part=2
next prev parent reply other threads:[~2026-11-29 13:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:00 [PATCH 0/5] drm: mipi-dsi/msm/panel: add DSI batch transfer and s6e88a0-ams452ef01 backlight Vladimir Bely
2026-11-29 13:00 ` [PATCH 1/5] drm/mipi-dsi: add multi-message batch transfer support Vladimir Bely
2026-11-29 13:00 ` [PATCH 2/5] drm/msm/dsi: implement transfer_batch using multi-packet CMD DMA Vladimir Bely
2026-11-29 13:07 ` sashiko-bot [this message]
2026-11-29 13:00 ` [PATCH 3/5] drm/panel: s6e88a0-ams452ef01: set prepare_prev_first Vladimir Bely
2026-11-29 13:00 ` [PATCH 4/5] drm/panel: s6e88a0-ams452ef01: move display off to disable callback Vladimir Bely
2026-11-29 13:00 ` [PATCH 5/5] drm/panel: s6e88a0-ams452ef01: add backlight support Vladimir Bely
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=sashiko-outbox-239623@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vlwwwwww@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox