All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jayant Shekhar" <jayant.shekhar@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org
Subject: Re: [PATCH v3 09/21] drm/msm/dcp: Add HFI DSI and panel commands
Date: Thu, 26 Nov 2026 06:54:24 +0000	[thread overview]
Message-ID: <sashiko-outbox-234915@kernel.org> (raw)
In-Reply-To: <20261126-jshekhar-v3-dcp-v3-9-f1e9d7505039@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] drm/msm/dcp: off-by-one DSC chroma_format and color_space in
  dcp_hfi_dsi_configure()
- [High] drm/msm/dcp: stack completion use-after-free on timeout in
  dcp_hfi_dsi_wait()
- [High] drm/msm/dcp: dcp_hfi_dcs_transfer() returns tx_len instead of
  rx_len on read
- [Medium] drm/msm/dcp: dcp_hfi_dsi_configure() omits packing
  cfg->dma_sched_line
- [Medium] drm/msm/dcp: hardcoded 8-bit panel mode in
  dcp_hfi_dsi_configure()
- [Low] drm/msm/dcp: undocumented struct members in dcp_dsi_hfi_config
  kernel-doc
--

commit 681ba5bae7f7207050885a01cedbdb43a05a6eb8
Author: Jayant Shekhar <jayant.shekhar@oss.qualcomm.com>

drm/msm/dcp: Add HFI DSI and panel commands

This commit adds HFI commands for DSI mode validation, display session and
power management, panel initialization, and DCS command transfers.

> diff --git a/drivers/gpu/drm/msm/dcp/dcp_dsi_config.h b/drivers/gpu/drm/msm/dcp/dcp_dsi_config.h
> new file mode 100644
> index 0000000000000..5f2013739edf1
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/dcp/dcp_dsi_config.h
> @@ -0,0 +1,67 @@

[ ... ]

> +/**
> + * struct dcp_dsi_hfi_config - DSI configuration passed to HFI.
> + *
> + * This contains the DSI output configuration plus mode-dependent values
> + * assembled before the HFI configuration commands are sent.
> + */
> +struct dcp_dsi_hfi_config {
> +	u32 display_type;

[Severity: Low]
This comment uses the /** kernel-doc marker without documenting the members
of struct dcp_dsi_hfi_config, which triggers kernel-doc warnings under W=1.

[ ... ]

> diff --git a/drivers/gpu/drm/msm/dcp/dcp_hfi_dsi_config.c b/drivers/gpu/drm/msm/dcp/dcp_hfi_dsi_config.c
> new file mode 100644
> index 0000000000000..8c4855334caac
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/dcp/dcp_hfi_dsi_config.c
> @@ -0,0 +1,597 @@

[ ... ]

> +static bool dcp_hfi_dsi_wait(struct dcp_hfi *hfi,
> +			     struct dcp_hfi_completion *comp)
> +{
> +	unsigned long flags;
> +
> +	if (wait_for_completion_timeout(&comp->done,
> +					msecs_to_jiffies(DCP_HFI_TIMEOUT_DISPLAY_MS)))
> +		return false;
> +
> +	/* Serialize removal with response dispatch before the stack object dies. */
> +	spin_lock_irqsave(&hfi->resp_drain_lock, flags);
> +	dcp_hfi_pending_find(hfi, comp->packet_id);
> +	spin_unlock_irqrestore(&hfi->resp_drain_lock, flags);
> +	return true;
> +}

[Severity: High]
Can dcp_hfi_dsi_wait() return on timeout while dcp_hfi_complete_pending() is
still accessing the stack-allocated completion?

dcp_hfi_resp_callback() drops hfi->resp_drain_lock right after
virtqueue_get_buf(), before unpacking packets and calling
dcp_hfi_complete_pending().  Inside dcp_hfi_complete_pending(),
dcp_hfi_pending_find() erases comp from hfi->pending_xa under
hfi->pending_lock and returns it before writing comp->status and calling
complete(&comp->done) without holding either lock:

CPU0                                  CPU1
dcp_hfi_dsi_configure()
  dcp_hfi_dsi_wait(&comp1)
    wait_for_completion_timeout()
      -> 0 (timed out)
                                      dcp_hfi_resp_callback()
                                        unlock(&hfi->resp_drain_lock)
                                        ...
                                        dcp_hfi_complete_pending()
                                          comp = dcp_hfi_pending_find()
    lock(&hfi->resp_drain_lock)
    dcp_hfi_pending_find() -> NULL
    unlock(&hfi->resp_drain_lock)
  return -ETIMEDOUT;
                                          comp->status = status;
                                          complete(&comp->done);
                                            <-- stack use-after-free

If dcp_hfi_pending_find() returns NULL in dcp_hfi_dsi_wait(), the response
handler has already claimed comp and is about to complete it, so
dcp_hfi_dsi_wait() needs to wait_for_completion(&comp->done) before allowing
dcp_hfi_dsi_configure() to unwind its stack frame.

[ ... ]

> +	num_props++;
> +	p += HFI_PACK(p, HFI_PROPERTY_PANEL_BPP, dcp_bpp_to_hfi(bpp));
> +	num_props++;
> +	p += HFI_PACK(p, HFI_PROPERTY_PANEL_LANES_STATE,
> +		       dcp_lanes_to_hfi(num_lanes));
> +	num_props++;
> +	p += HFI_PACK(p, HFI_PROPERTY_PANEL_OPERATING_MODE,
> +		       is_cmd_mode ? HFI_PANEL_CMD_MODE_8_BIT :
> +		       HFI_PANEL_VIDEO_MODE_8_BIT);

[Severity: Medium]
Should HFI_PROPERTY_PANEL_OPERATING_MODE select HFI_PANEL_CMD_MODE_10_BIT or
HFI_PANEL_VIDEO_MODE_10_BIT for 10-bpc panels?

dcp_bpp_to_hfi() maps 30-bpp panels (MIPI_DSI_FMT_RGB101010) to
HFI_PANEL_BPP_30, and HFI_PROPERTY_PANEL_COMPRESSION_DATA passes
cfg->dsc->bits_per_component, but HFI_PROPERTY_PANEL_OPERATING_MODE always
packs an 8-bit mode.

[ ... ]

> +	num_props++;
> +	*p++ = HFI_PACK_KEY(HFI_PROPERTY_PANEL_PHY_NUM, 0, 1 + num_phys);
> +	*p++ = num_phys;
> +	memcpy(p, cfg->phy_indices, num_phys * sizeof(*p));
> +	p += num_phys;
> +
> +	num_props++;
> +	p += HFI_PACK(p, HFI_PROPERTY_PANEL_DMA_SCHEDULE_WINDOW, dma_win);
> +	payload[0] = num_props;

[Severity: Medium]
Should dcp_hfi_dsi_configure() also pack cfg->dma_sched_line as
HFI_PROPERTY_PANEL_DMA_SCHEDULE_LINE?

struct dcp_dsi_hfi_config defines dma_sched_line alongside dma_sched_window,
and hfi_properties_panel.h defines HFI_PROPERTY_PANEL_DMA_SCHEDULE_LINE, but
cfg->dma_sched_line is never sent to firmware.

[ ... ]

> +	if (cfg->dsc) {
> +		u32 chroma_format = 0;
> +		u32 color_space = 0;
> +
> +		if (cfg->dsc->native_422)
> +			chroma_format = 1;
> +		else if (cfg->dsc->native_420)
> +			chroma_format = 2;
> +		if (cfg->dsc->native_422 || cfg->dsc->native_420)
> +			color_space = 1;
> +
> +		*p++ = HFI_PACK_KEY(HFI_PROPERTY_PANEL_COMPRESSION_DATA, 0, 12);
> +		*p++ = HFI_PANEL_COMPRESSION_DSC;
> +		*p++ = (cfg->dsc->dsc_version_major << 4) |
> +			cfg->dsc->dsc_version_minor;
> +		*p++ = 0; /* scr_version is not set by DRM DSC config. */
> +		*p++ = cfg->dsc->slice_height;
> +		*p++ = cfg->dsc->slice_width;
> +		*p++ = 1; /* one slice per packet */
> +		*p++ = cfg->dsc->bits_per_component;
> +		*p++ = 0; /* no post-PPS delay */
> +		*p++ = cfg->dsc->bits_per_pixel;
> +		*p++ = chroma_format;
> +		*p++ = color_space;
> +		*p++ = cfg->dsc->block_pred_enable;
> +	}

[Severity: High]
Are chroma_format and color_space off by one against the HFI panel protocol
enums?

In drivers/gpu/drm/msm/dcp/hfi/hfi_defs_panel.h, both enums are 1-based:

drivers/gpu/drm/msm/dcp/hfi/hfi_defs_panel.h:
enum hfi_panel_chroma_format_type {
	HFI_PANEL_CHROMA_FORMAT_444     = 1,
	HFI_PANEL_CHROMA_FORMAT_422     = 2,
	HFI_PANEL_CHROMA_FORMAT_420     = 3,
};

enum hfi_panel_color_space_type {
	HFI_PANEL_COLOR_SPACE_RGB     = 1,
	HFI_PANEL_COLOR_SPACE_YUV     = 2,
};

Packing 0/1/2 for chroma_format and 0/1 for color_space sends invalid 0
values for RGB 4:4:4 DSC panels and the wrong format/color space for native
4:2:2 and 4:2:0 panels.

[ ... ]

> +ssize_t dcp_hfi_dcs_transfer(struct dcp_hfi *hfi, u32 session_id,
> +			     const struct mipi_dsi_msg *msg,
> +			     void *tx_buf, dma_addr_t tx_iova,
> +			     void *rx_buf, dma_addr_t rx_iova,
> +			     u32 post_wait_ms, u32 ctrl_idx)
> +{
> +	struct hfi_dsi_cmd_desc cmd_desc = {};
> +	static atomic_t seq_no = ATOMIC_INIT(0);
> +	int ret;
> +
> +	if (!msg || !msg->tx_buf || !msg->tx_len)
> +		return -EINVAL;

[ ... ]

> +	if (msg->rx_len > 0)
> +		memcpy(msg->rx_buf, rx_buf, msg->rx_len);
> +
> +	return msg->tx_len;
> +}

[Severity: High]
Should dcp_hfi_dcs_transfer() return msg->rx_len on read transfers instead of
msg->tx_len?

struct mipi_dsi_host_ops.transfer expects the number of bytes received for
read packets, so returning msg->tx_len causes multi-byte DSI reads (where
tx_len != rx_len) to fail as short reads in callers such as
mipi_dsi_dcs_read().  Also, rejecting !msg->tx_len || !msg->tx_buf at entry
rejects valid 0-parameter generic transfers
(MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM and
MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM) where tx_len is 0.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-jshekhar-v3-dcp-v3-0-f1e9d7505039@oss.qualcomm.com?part=9

  reply	other threads:[~2026-11-26  6:54 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  6:29 [PATCH v3 00/21] drm/msm/dcp: Add Qualcomm DCP display support Jayant Shekhar
2026-11-26  6:29 ` [PATCH v3 01/21] dt-bindings: display: msm: Add Qualcomm DCP Jayant Shekhar
2026-11-26  6:44   ` sashiko-bot
2026-11-30 13:59   ` Rob Herring (Arm)
2026-11-30 14:33     ` Rob Herring
2026-11-26  6:29 ` [PATCH v3 02/21] drm/msm/dcp: Add HFI packet helpers Jayant Shekhar
2026-11-26  6:52   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 03/21] drm/msm/dcp: Add HFI device definitions Jayant Shekhar
2026-11-26  6:29 ` [PATCH v3 04/21] drm/msm/dcp: Add HFI display definitions Jayant Shekhar
2026-11-26  6:29 ` [PATCH v3 05/21] drm/msm/dcp: Add HFI panel definitions Jayant Shekhar
2026-11-26  6:40   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 06/21] drm/msm/dcp: Add HFI VirtIO transport Jayant Shekhar
2026-11-26  6:51   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 07/21] drm/msm/dcp: Handle asynchronous HFI responses Jayant Shekhar
2026-11-26  6:49   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 08/21] drm/msm/dcp: Add generic HFI display commands Jayant Shekhar
2026-11-26  6:45   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 09/21] drm/msm/dcp: Add HFI DSI and panel commands Jayant Shekhar
2026-11-26  6:54   ` sashiko-bot [this message]
2026-11-26  6:29 ` [PATCH v3 10/21] drm/msm/dcp: Add DCP CRTCs Jayant Shekhar
2026-11-26  6:58   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 11/21] drm/msm/dcp: Add DCP planes Jayant Shekhar
2026-11-26  7:02   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 12/21] drm/msm/dcp: Route HFI display events Jayant Shekhar
2026-11-26  6:50   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 13/21] drm/msm/dcp: Add DCP encoder Jayant Shekhar
2026-11-26  6:42   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 14/21] drm/msm/dcp: Add DCP DSI host and panel support Jayant Shekhar
2026-11-26  7:06   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 15/21] drm/msm/dcp: Integrate the DSI bridge with KMS Jayant Shekhar
2026-11-26  6:53   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 16/21] drm/msm/dcp: Register DCP display pipeline Jayant Shekhar
2026-11-26  7:03   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 17/21] drm/msm: Export GPU component matching helper Jayant Shekhar
2026-11-26  6:29 ` [PATCH v3 18/21] drm/msm/dcp: Add DCP VirtIO driver Jayant Shekhar
2026-11-26  7:07   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 19/21] drm/msm: Support KMS backends without a display IRQ Jayant Shekhar
2026-11-26  6:29 ` [PATCH v3 20/21] drm/msm: Register the DCP backend Jayant Shekhar
2026-11-26  7:00   ` sashiko-bot
2026-11-26  6:29 ` [PATCH v3 21/21] arm64: dts: qcom: hawi: Add DCP support Jayant Shekhar
2026-11-26  7:10   ` sashiko-bot

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-234915@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jayant.shekhar@oss.qualcomm.com \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.