Devicetree
 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 08/21] drm/msm/dcp: Add generic HFI display commands
Date: Thu, 26 Nov 2026 06:45:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-234899@kernel.org> (raw)
In-Reply-To: <20261126-jshekhar-v3-dcp-v3-8-f1e9d7505039@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/msm/dcp: completion zeroing and unlocked caps_cache in
  dcp_hfi_kms.c
- [High] drm/msm/dcp: pipe count clobbering in
  dcp_hfi_parse_init_caps_kv()
- [Low] drm/msm/dcp: uninitialized stack buffer in
  dcp_hfi_log_pipe_ids()
--

commit 493628efb4ff9c95ef6c5374bcbb496f98a1b513
Author: Jayant Shekhar <jayant.shekhar@oss.qualcomm.com>

drm/msm/dcp: Add generic HFI display commands

This commit adds HFI display command helpers for CRTCs, planes, encoders,
device initialization, and capability parsing in the DCP driver.

> diff --git a/drivers/gpu/drm/msm/dcp/dcp_hfi_kms.c b/drivers/gpu/drm/msm/dcp/dcp_hfi_kms.c
> new file mode 100644
> index 0000000000000..82a7fb420e650
> --- /dev/null
> +++ b/drivers/gpu/drm/msm/dcp/dcp_hfi_kms.c
> @@ -0,0 +1,325 @@

[ ... ]

> +static void dcp_hfi_caps_cache_init(struct dcp_hfi_caps_cache *cache)
> +{
> +	init_completion(&cache->device_done);
> +	init_completion(&cache->display_done);
> +}
> +
> +static void dcp_hfi_caps_cache_start(struct dcp_hfi *hfi)
> +{
> +	memset(&hfi->caps_cache, 0, sizeof(hfi->caps_cache));
> +	dcp_hfi_caps_cache_init(&hfi->caps_cache);
> +}
> +
> +static void dcp_hfi_caps_cache_stop(struct dcp_hfi *hfi)
> +{
> +	memset(&hfi->caps_cache, 0, sizeof(hfi->caps_cache));
> +}

[Severity: High]
Can dcp_hfi_caps_cache_stop() corrupt cache->device_done and
cache->display_done while capability events are still arriving on resp_vq?

memset() zeroes the whole struct dcp_hfi_caps_cache, including both struct
completion objects, setting their wait.task_list pointers to NULL and
zeroing wait.lock without holding hfi->caps_lock.  In
dcp_hfi_get_capabilities(), a timeout on cache->display_done only logs a
warning before jumping to out_free_cache and calling
dcp_hfi_caps_cache_stop() (and timeouts in dcp_hfi_send_device_init() or on
cache->device_done do the same):

CPU0                              CPU1 (resp_vq callback)
dcp_hfi_get_capabilities()
  wait_for_completion_timeout(
    &cache->display_done, ...)
    -> times out
  ...
  dcp_hfi_caps_cache_stop(hfi)
    memset(&hfi->caps_cache, 0, ...)
                                  dcp_hfi_dispatch_event()
                                    spin_lock_irqsave(&hfi->caps_lock)
                                    dcp_hfi_store_caps_payload(...,
                                      &hfi->caps_cache.display_done, ...)
                                      complete(&cache->display_done)
                                        swake_up_locked()
                                          <-- NULL pointer dereference

In swake_up_locked(), list_empty(&q->task_list) evaluates NULL ==
&q->task_list as false and dereferences NULL when waking the first entry.

In addition, dcp_hfi_dispatch_event() updates hfi->caps_cache under
hfi->caps_lock, whereas dcp_hfi_caps_cache_start(),
dcp_hfi_caps_cache_stop(), and dcp_hfi_get_capabilities() only hold
hfi->caps_cache_lock.  Because VIG_CAPS, DMA_CAPS, VIG_R1_CAPS, and
DMA_R1_CAPS do not signal a completion, dcp_hfi_get_capabilities() can read
and zero those buffers concurrently with dcp_hfi_store_caps_payload().

[ ... ]

> +static void dcp_hfi_parse_init_caps_kv(struct dcp_caps *caps,
> +				       u32 prop_key,
> +				       const u32 *payload,
> +				       u32 max_words)
> +{
> +	u32 prop_id = HFI_PROP_ID(prop_key);
> +	u32 count, i;
> +
> +	if (!payload || !max_words)
> +		return;
> +
> +	switch (prop_id) {

[ ... ]

> +	case HFI_PROPERTY_DEVICE_INIT_VIG_INDICES:
> +		if (max_words < 1)
> +			break;
> +		count = payload[0];
> +		if (count > max_words - 1)
> +			count = max_words - 1;
> +		caps->num_vig_pipes = 0;
> +		caps->virt_vig_count = 0;
> +		for (i = 0; i < count; i++) {
> +			u32 idx = payload[1 + i];
> +
> +			if (DCP_REC_ID(idx) == 0) {
> +				if (caps->num_vig_pipes < DCP_MAX_SSPP_COUNT)
> +					caps->vig_pipe_ids[caps->num_vig_pipes++] = idx;
> +			} else {
> +				if (caps->virt_vig_count < DCP_MAX_SSPP_COUNT)
> +					caps->vig_r1_indices[caps->virt_vig_count++] = idx;
> +			}
> +		}
> +		break;
> +	case HFI_PROPERTY_DEVICE_INIT_DMA_INDICES:
> +		if (max_words < 1)
> +			break;
> +		count = payload[0];
> +		if (count > max_words - 1)
> +			count = max_words - 1;
> +		caps->num_dma_pipes = 0;
> +		caps->virt_dma_count = 0;
> +		for (i = 0; i < count; i++) {
> +			u32 idx = payload[1 + i];
> +
> +			if (DCP_REC_ID(idx) == 0) {
> +				if (caps->num_dma_pipes < DCP_MAX_SSPP_COUNT)
> +					caps->dma_pipe_ids[caps->num_dma_pipes++] = idx;
> +			} else {
> +				if (caps->virt_dma_count < DCP_MAX_SSPP_COUNT)
> +					caps->dma_r1_indices[caps->virt_dma_count++] = idx;
> +			}
> +		}
> +		break;

[Severity: High]
Does parsing cache->vig_r1_buf and cache->dma_r1_buf in
dcp_hfi_get_capabilities() wipe out caps->num_vig_pipes and
caps->num_dma_pipes?

Both primary (DCP_REC_ID(idx) == 0) and rect-1 (DCP_REC_ID(idx) != 0) pipe
lists use HFI_PROPERTY_DEVICE_INIT_VIG_INDICES and
HFI_PROPERTY_DEVICE_INIT_DMA_INDICES.  Because dcp_hfi_parse_init_caps_kv()
unconditionally zeroes both primary and virtual counts before looping,
parsing vig_r1_buf and dma_r1_buf after vig_buf and dma_buf resets
caps->num_vig_pipes and caps->num_dma_pipes to 0, causing caps->max_planes
to become 0 and dcp_hfi_get_capabilities() to fail with -EINVAL.

[ ... ]

> +static void dcp_hfi_log_pipe_ids(struct device *dev, const char *label,
> +				 const u32 *ids, u32 count)
> +{
> +	char buf[128];
> +	int pos = 0;
> +	u32 i;
> +
> +	for (i = 0; i < count && pos < (int)sizeof(buf) - 8; i++)
> +		pos += scnprintf(buf + pos, sizeof(buf) - pos,
> +				  "%s0x%x", i ? "," : "", ids[i]);
> +
> +	dev_dbg(dev, "%s: count=%u ids=[%s]\n", label, count, buf);
> +}

[Severity: Low]
If count is 0, the loop does not run and dev_dbg() prints buf uninitialized
from the stack.

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

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

Thread overview: 39+ 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-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 [this message]
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
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-234899@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox