Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vishnu Reddy" <busanna.reddy@oss.qualcomm.com>
Cc: conor+dt@kernel.org, media-ci@linuxtv.org,
	devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 1/5] media: iris: Add dma sync calls for input and output buffers
Date: Tue, 18 Aug 2026 16:03:50 +0000	[thread overview]
Message-ID: <20260818160351.4E8F51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818-iris-fixes-dma-pseq-fint-v2-1-8dc8c4b3880e@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Calling `dma_sync_single_*` on an IOVA managed by videobuf2-dma-contig violates the DMA API and can cause severe memory corruption for non-contiguous DMA-BUF imports.
- [High] The DMA synchronization logic for output buffers is fundamentally broken: it synchronizes the CPU cache before the hardware writes, uses the wrong API direction, specifies a zero size, and omits the necessary sync upon completion.
--

--- Patch [1]: [PATCH v2 1/5] media: iris: Add dma sync calls for input and output buffers ---
commit ee7c5670aeeb217b4b298594d79282fac01b4135
Author: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>

media: iris: Add dma sync calls for input and output buffers

This commit adds DMA synchronization calls in iris_queue_buffer() to fix
data corruption and hardware faults. It uses dma_sync_single_for_device for
input buffers and dma_sync_single_for_cpu for output buffers.

> diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
> index eb8de60c1177f..c7a664426187d 100644
> --- a/drivers/media/platform/qcom/iris/iris_buffer.c
> +++ b/drivers/media/platform/qcom/iris/iris_buffer.c
> @@ -585,6 +585,13 @@ int iris_queue_buffer(struct iris_inst *inst, struct iris_buffer *buf)
>  	const struct iris_hfi_session_ops *hfi_ops = inst->hfi_session_ops;
>  	int ret;
>  
> +	if (buf->type == BUF_INPUT)
> +		dma_sync_single_for_device(inst->core->dev, buf->device_addr,
> +					   buf->data_size, DMA_TO_DEVICE);

[Severity: Critical]
Does this violate the DMA API by passing a videobuf2-managed IOVA to
dma_sync_single_for_device()?

For imported scatter-gather DMA-BUFs, the IOVA might be contiguous but backed
by physically discontiguous pages. Calling a single-mapped sync on the IOVA 
translates the start IOVA to a single physical address and performs cache 
maintenance on a linear physical address range. Can this corrupt arbitrary 
physical memory while leaving the actual backing pages unsynchronized?

> +	else if (buf->type == BUF_OUTPUT)
> +		dma_sync_single_for_cpu(inst->core->dev, buf->device_addr,
> +					buf->data_size, DMA_FROM_DEVICE);
> +

[Severity: High]
Is the synchronization direction correct for a queued capture buffer?

This calls dma_sync_single_for_cpu() before the hardware writes to the 
buffer, claiming CPU ownership instead of giving it to the device with 
dma_sync_single_for_device(..., DMA_FROM_DEVICE). 

Additionally, buf->data_size for a queued empty capture buffer is typically
zero. Does this result in syncing zero bytes?

Finally, is there a missing dma_sync_single_for_cpu() in the completion path
(such as iris_vb2_buffer_done()) after the hardware finishes writing and 
buf->data_size is populated? Without it, the CPU might read speculative or 
stale data.

>  	ret = hfi_ops->session_queue_buf(inst, buf);
>  	if (ret)
>  		return ret;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818-iris-fixes-dma-pseq-fint-v2-0-8dc8c4b3880e@oss.qualcomm.com?part=1

  reply	other threads:[~2026-08-18 16:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 15:54 [PATCH v2 0/5] media: iris: Fix DMA coherency, power-off ordering, and frame interval issues Vishnu Reddy
2026-08-18 15:54 ` [PATCH v2 1/5] media: iris: Add dma sync calls for input and output buffers Vishnu Reddy
2026-08-18 16:03   ` sashiko-bot [this message]
2026-08-18 15:54 ` [PATCH v2 2/5] dt-bindings: media: qcom,sc7280-venus: Add dma-coherent property Vishnu Reddy
2026-08-18 15:54 ` [PATCH v2 3/5] arm64: dts: qcom: sc7280: Add dma-coherent property into venus node Vishnu Reddy
2026-08-18 15:54 ` [PATCH v2 4/5] media: iris: Fix power-off ordering to disable power domain after clocks Vishnu Reddy
2026-08-18 16:05   ` sashiko-bot
2026-08-18 15:54 ` [PATCH v2 5/5] media: iris: Fix frame interval enumeration for non-divisor framerates Vishnu Reddy

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=20260818160351.4E8F51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=busanna.reddy@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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