Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C633E606A329 for ; Sun, 29 Nov 2026 13:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aNcYdlkz Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3570510E853; Sun, 29 Nov 2026 13:08:05 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id DCDCF10E853 for ; Sun, 29 Nov 2026 13:07:58 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 90BF943EC3; Sun, 29 Nov 2026 13:07:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E3471F00897; Sun, 29 Nov 2026 13:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795957678; bh=I7Ge2JICR3e9MTUpZY1E1srX3SroDhVKZxwm25FCTxA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=aNcYdlkzgxr+DOhClNfh3dXxaOQ1pd1byc3iSLEUO63ZQbskry4wxH+d7bIXIPzKh teFvh8llOny+e1LRhfkUyeL2WaZMJAjI0eOjsDb9TWW6jairaUZQzLL8/aIohYNjql GOKoecze/rCO3+Ih0sgoCqCTCFSeZLq9y2K8yUcMDTmpt0fYzL0BUhZXKRs/HHaMum +wPfIP6+3PUCLy/ulcYeGIMGcyzNNQImDfS7qEaSxtujCmr/XmStbxZtgNMi/2hvDx 4mdyQTW2sgXm20Rp3Pwncp6c1QkNrK8QjF2idfa2mkCKVx8fwZ6opuno5sVCn/yKxK x6Yihuu+gLkbw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/5] drm/msm/dsi: implement transfer_batch using multi-packet CMD DMA To: "Vladimir Bely" Cc: dri-devel@lists.freedesktop.org In-Reply-To: <20261129130026.581466-3-vlwwwwww@gmail.com> References: <20261129130026.581466-1-vlwwwwww@gmail.com> <20261129130026.581466-3-vlwwwwww@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 13:07:56 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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 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 *ms= m_host, > return len; > } > =20 > +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 =3D msm_host->cfg_hnd; > + int max_len =3D msm_host->tx_size; > + int offset =3D 0, last_offset =3D 0; > + u8 *data =3D NULL; > + size_t i; > + int ret; > + > + if ((msm_host->mode_flags & MIPI_DSI_MODE_VIDEO) && msm_host->mode) { > + int bllp_len =3D msm_host->mode->hdisplay * > + mipi_dsi_pixel_format_to_bpp(msm_host->format) / 8; > + > + max_len =3D min(max_len, bllp_len); > + } > + > + for (i =3D 0; i < count; i++) { > + struct mipi_dsi_packet packet; > + int pkt_len; > + > + ret =3D mipi_dsi_create_packet(&packet, &msgs[i]); > + if (ret) { > + pr_err("%s: create packet failed, %d\n", __func__, ret); > + goto err_put; > + } > + pkt_len =3D (packet.size + 3) & (~0x3); > + if (pkt_len > max_len) { > + pr_err("%s: cmd cannot fit into transfer buffer, len=3D%d\n", > + __func__, pkt_len); > + ret =3D -EINVAL; > + goto err_put; > + } > + > + if (offset > 0 && offset + pkt_len > max_len) { > + data[last_offset + 3] |=3D BIT(7); /* Last packet */ > + if (cfg_hnd->ops->tx_buf_put) > + cfg_hnd->ops->tx_buf_put(msm_host); > + data =3D NULL; > + > + ret =3D 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 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129130026.5814= 66-1-vlwwwwww@gmail.com?part=3D2