All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sven Püschel" <s.pueschel@pengutronix.de>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v6 27/28] media: rockchip: rga: add rga3 support
Date: Fri, 15 May 2026 16:34:43 +0000	[thread overview]
Message-ID: <20260515163443.B73A0C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260515-spu-rga3-v6-27-e547152eb9c9@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Kernel Panic on Shared IRQ due to missing PM Runtime active check
- [High] DMA API Violation and Out-of-bounds Cache Sync on Coherent Memory
- [High] Silent API Failure of Crop Coordinates
- [Medium] Hardware Error Interrupts Masked
--

commit 71c16e32b64b60b7b83f81a3d0e8a736dfa30182
Author: Sven Püschel <s.pueschel@pengutronix.de>
Subject: media: rockchip: rga: add rga3 support

Add support for the RGA3 unit contained in the RK3588. Only a basic
feature set consisting of scaling and color conversion is implemented.

> diff --git a/drivers/media/platform/rockchip/rga/rga3-hw.c b/drivers/media/platform/rockchip/rga/rga3-hw.c
> new file mode 100644
> index 0000000000000..ca1c268303dd4
> --- /dev/null
> +++ b/drivers/media/platform/rockchip/rga/rga3-hw.c

[ ... ]

> +static void rga3_cmd_set_win0_addr(struct rga_ctx *ctx,
> +				   const struct rga_addrs *addrs)
> +{
> +	u32 *cmd = ctx->cmdbuf_virt;
> +	unsigned int reg;
> +
> +	reg = RGA3_WIN0_Y_BASE - RGA3_FIRST_CMD_REG;
> +	cmd[reg >> 2] = addrs->y_addr;
> +	reg = RGA3_WIN0_U_BASE - RGA3_FIRST_CMD_REG;
> +	cmd[reg >> 2] = addrs->u_addr;
> +}

Does this code ignore the crop coordinates (ctx->in.crop.top and
ctx->in.crop.left)?

In the existing RGA2 implementation, offsets are applied using
rga_get_corner_addrs(). Here, the unadjusted buffer base addresses are
used. If userspace sets a crop selection with non-zero top/left offsets,
the API call will succeed but the hardware will process the image starting
from (0, 0).

[ ... ]

> +static void rga3_hw_start(struct rockchip_rga *rga,
> +			  struct rga_vb_buffer *src, struct rga_vb_buffer *dst)
> +{
> +	struct rga_ctx *ctx = rga->curr;
> +
> +	rga3_cmd_set_win0_addr(ctx, &src->dma_addrs);
> +	rga3_cmd_set_wr_addr(ctx, &dst->dma_addrs);
> +
> +	rga_write(rga, RGA3_CMD_ADDR, ctx->cmdbuf_phy);
> +
> +	/* sync CMD buf for RGA */
> +	dma_sync_single_for_device(rga->dev, ctx->cmdbuf_phy,
> +				   PAGE_SIZE, DMA_BIDIRECTIONAL);

Is it safe to use dma_sync_single_for_device() on ctx->cmdbuf_phy?

The command buffer is allocated via dma_alloc_attrs() with
DMA_ATTR_WRITE_COMBINE, which provides coherent memory. The DMA API strictly
forbids using streaming sync functions on coherent or write-combined memory,
which can cause kernel panics or warnings when CONFIG_DMA_API_DEBUG is enabled.

Additionally, the sync size is hardcoded to PAGE_SIZE (4096 bytes), but
RGA3_CMDBUF_SIZE is only 184 bytes. Could this cause an out-of-bounds cache
sync and corrupt memory if SWIOTLB bounce buffers are used? Should a standard
memory write barrier (wmb()) be used instead?

> +	/* set to master mode and start the conversion */
> +	rga_write(rga, RGA3_SYS_CTRL,
> +		  FIELD_PREP(RGA3_CMD_MODE, RGA3_CMD_MODE_MASTER));
> +	rga_write(rga, RGA3_INT_EN, FIELD_PREP(RGA3_INT_FRM_DONE, 1));

Are hardware error interrupts masked here?

RGA3_INT_EN is programmed with only RGA3_INT_FRM_DONE. If the hardware
encounters an error (like RGA3_INT_WR_BUS_ERR), it will halt but fail to
assert the interrupt. This would leave the V4L2 m2m framework waiting
indefinitely for buffer completion.

> +	rga_write(rga, RGA3_CMD_CTRL,
> +		  FIELD_PREP(RGA3_CMD_LINE_START_PULSE, 1));
> +}
> +
> +static bool rga3_handle_irq(struct rockchip_rga *rga)
> +{
> +	u32 intr;
> +
> +	intr = rga_read(rga, RGA3_INT_RAW);

Is it possible for this register read to occur while the device is
runtime-suspended?

Since RGA3 sets .has_internal_iommu to false, the interrupt is requested with
IRQF_SHARED. If another device on the shared line triggers an interrupt while
the RGA3 clocks are disabled, this register read may return 0xffffffff.

Since FIELD_GET(RGA3_INT_FRM_DONE, 0xffffffff) is true, the ISR would process
a spurious frame. When no job is active, rga->curr is NULL, which could lead
to a crash when dereferencing the context.

To comply with PM Runtime guidelines, should the IRQ handler use
pm_runtime_get_if_active() before accessing registers, and should the driver
call synchronize_irq() in the runtime suspend callback?

> +	/* clear all interrupts */
> +	rga_write(rga, RGA3_INT_CLR, intr);
> +
> +	return FIELD_GET(RGA3_INT_FRM_DONE, intr);
> +}

If error interrupts are enabled to prevent job hangs, would returning false
here cause the core ISR to ignore the error interrupt instead of aborting the
job?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-spu-rga3-v6-0-e547152eb9c9@pengutronix.de?part=27

  reply	other threads:[~2026-05-15 16:34 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 15:32 [PATCH v6 00/28] media: platform: rga: Add RGA3 support Sven Püschel
2026-05-15 15:32 ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 01/28] media: dt-bindings: media: rockchip-rga: add rockchip,rk3588-rga3 Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 02/28] media: v4l2-common: sort RGB formats in v4l2_format_info Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 03/28] media: v4l2-common: add missing 1 and 2 byte RGB formats to v4l2_format_info Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 04/28] media: v4l2-common: add has_alpha " Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 05/28] media: v4l2-common: add v4l2_fill_pixfmt_mp_aligned helper Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:58   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 06/28] media: rockchip: rga: fix too small buffer size Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 07/28] media: rockchip: rga: use clk_bulk api Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:54   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 08/28] media: rockchip: rga: use stride for offset calculation Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 09/28] media: rockchip: rga: remove redundant rga_frame variables Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 10/28] media: rockchip: rga: announce and sync colorimetry Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:14   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 11/28] media: rockchip: rga: move hw specific parts to a dedicated struct Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:05   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 12/28] media: rockchip: rga: avoid odd frame sizes for YUV formats Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 13/28] media: rockchip: rga: calculate x_div/y_div using v4l2_format_info Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 14/28] media: rockchip: rga: move cmdbuf to rga_ctx Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:12   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 15/28] media: rockchip: rga: align stride to 4 bytes Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:17   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 16/28] media: rockchip: rga: reuse cmdbuf contents Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:59   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 17/28] media: rockchip: rga: check scaling factor Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:54   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 18/28] media: rockchip: rga: use card type to specify rga type Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:00   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 19/28] media: rockchip: rga: change offset to dma_addresses Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:59   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 20/28] media: rockchip: rga: support external iommus Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:08   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 21/28] media: rockchip: rga: share the interrupt when an external iommu is used Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:11   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 22/28] media: rockchip: rga: remove size from rga_frame Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:21   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 23/28] media: rockchip: rga: remove stride " Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 24/28] media: rockchip: rga: move rga_fmt to rga-hw.h Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 25/28] media: rockchip: rga: add feature flags Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:22   ` sashiko-bot
2026-05-15 15:32 ` [PATCH v6 26/28] media: rockchip: rga: disable multi-core support Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 15:32 ` [PATCH v6 27/28] media: rockchip: rga: add rga3 support Sven Püschel
2026-05-15 15:32   ` Sven Püschel
2026-05-15 16:34   ` sashiko-bot [this message]
2026-05-15 15:32 ` [PATCH v6 28/28] arm64: dts: rockchip: add rga3 dt nodes Sven Püschel
2026-05-15 15:32   ` Sven Püschel

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=20260515163443.B73A0C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=s.pueschel@pengutronix.de \
    --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.