From nobody Tue Feb 10 05:45:09 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7121335D5F8 for ; Tue, 27 Jan 2026 14:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524830; cv=none; b=S6Yo8FFO3LON0+LN2xkKi4dYxn0R6MMhk/L65IH96bGOD0fZNeZFq5oHvepLtE8rD6YtAuKhL0QOAQ9wfzegbxrdTAYWJ9d9dOXWpy8fMZUxj2qb6X0//tY+eV07ExxGu/x1oXBWRFwMid2bhfXhiTjqbWCGDjm/DCVnRWIJqkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769524830; c=relaxed/simple; bh=iDSo3xKVQDr0j+iq/VfyVGqXilMDTdQkkmmxSDyozRY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CjRJM3EmomGqJWYUVENg8QfcKPIu40lwPpZNJRibMvGleEvEzALfcab4wXd9e2ZlfuahW4Vs4udp5Xt9Dd1mjnnja6ui/qHO3hAGV1k5vSoPSr5SjD0pLMDgRdAFfyoi+BcLJbJ84X610hoJUBQ4lRduMmH8MfL57Uz/v1Ejscs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=peter.mobile.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1vkkF0-0007YT-38; Tue, 27 Jan 2026 15:40:26 +0100 From: =?utf-8?q?Sven_P=C3=BCschel?= Date: Tue, 27 Jan 2026 15:39:24 +0100 Subject: [PATCH v3 15/27] media: rockchip: rga: prepare cmdbuf on streamon Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260127-spu-rga3-v3-15-77b273067beb@pengutronix.de> References: <20260127-spu-rga3-v3-0-77b273067beb@pengutronix.de> In-Reply-To: <20260127-spu-rga3-v3-0-77b273067beb@pengutronix.de> To: Jacob Chen , Ezequiel Garcia , Mauro Carvalho Chehab , Heiko Stuebner , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel@pengutronix.de, =?utf-8?q?Sven_P=C3=BCschel?= , Nicolas Dufresne X-Mailer: b4 0.14.3 X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: s.pueschel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Prepare the command buffer on streamon to reuse it's contents instead of completely writing it for every frame. Due to the stream settings being fixed after a streamon we only need to replace the source and destination addresses for each frame. This reduces the amount of CPU and memory operations done in each frame. Reviewed-by: Nicolas Dufresne Signed-off-by: Sven P=C3=BCschel --- drivers/media/platform/rockchip/rga/rga-hw.c | 13 +++++++++---- drivers/media/platform/rockchip/rga/rga.c | 13 ++++++++++++- drivers/media/platform/rockchip/rga/rga.h | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga-hw.c b/drivers/media/p= latform/rockchip/rga/rga-hw.c index 16380be598e4a..dcd540ed3fd5b 100644 --- a/drivers/media/platform/rockchip/rga/rga-hw.c +++ b/drivers/media/platform/rockchip/rga/rga-hw.c @@ -417,8 +417,6 @@ static void rga_cmd_set(struct rga_ctx *ctx, { struct rockchip_rga *rga =3D ctx->rga; =20 - memset(ctx->cmdbuf_virt, 0, RGA_CMDBUF_SIZE * 4); - rga_cmd_set_src_addr(ctx, src->dma_desc_pa); /* * Due to hardware bug, @@ -427,11 +425,9 @@ static void rga_cmd_set(struct rga_ctx *ctx, rga_cmd_set_src1_addr(ctx, dst->dma_desc_pa); =20 rga_cmd_set_dst_addr(ctx, dst->dma_desc_pa); - rga_cmd_set_mode(ctx); =20 rga_cmd_set_src_info(ctx, &src->offset); rga_cmd_set_dst_info(ctx, &dst->offset); - rga_cmd_set_trans_info(ctx); =20 rga_write(rga, RGA_CMD_BASE, ctx->cmdbuf_phy); =20 @@ -440,6 +436,14 @@ static void rga_cmd_set(struct rga_ctx *ctx, PAGE_SIZE, DMA_BIDIRECTIONAL); } =20 +static void rga_hw_setup_cmdbuf(struct rga_ctx *ctx) +{ + memset(ctx->cmdbuf_virt, 0, RGA_CMDBUF_SIZE * 4); + + rga_cmd_set_mode(ctx); + rga_cmd_set_trans_info(ctx); +} + static void rga_hw_start(struct rockchip_rga *rga, struct rga_vb_buffer *src, struct rga_vb_buffer *dst) { @@ -582,6 +586,7 @@ const struct rga_hw rga2_hw =3D { .max_height =3D MAX_HEIGHT, .stride_alignment =3D 4, =20 + .setup_cmdbuf =3D rga_hw_setup_cmdbuf, .start =3D rga_hw_start, .handle_irq =3D rga_handle_irq, .get_version =3D rga_get_version, diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/plat= form/rockchip/rga/rga.c index 2920efe65082a..6947c472a8b01 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -568,6 +568,17 @@ static int vidioc_s_selection(struct file *file, void = *priv, return ret; } =20 +static int vidioc_streamon(struct file *file, void *priv, + enum v4l2_buf_type type) +{ + struct rga_ctx *ctx =3D file_to_rga_ctx(file); + const struct rga_hw *hw =3D ctx->rga->hw; + + hw->setup_cmdbuf(ctx); + + return v4l2_m2m_streamon(file, ctx->fh.m2m_ctx, type); +} + static const struct v4l2_ioctl_ops rga_ioctl_ops =3D { .vidioc_querycap =3D vidioc_querycap, =20 @@ -592,7 +603,7 @@ static const struct v4l2_ioctl_ops rga_ioctl_ops =3D { .vidioc_subscribe_event =3D v4l2_ctrl_subscribe_event, .vidioc_unsubscribe_event =3D v4l2_event_unsubscribe, =20 - .vidioc_streamon =3D v4l2_m2m_ioctl_streamon, + .vidioc_streamon =3D vidioc_streamon, .vidioc_streamoff =3D v4l2_m2m_ioctl_streamoff, =20 .vidioc_g_selection =3D vidioc_g_selection, diff --git a/drivers/media/platform/rockchip/rga/rga.h b/drivers/media/plat= form/rockchip/rga/rga.h index 38518146910a6..c741213710b32 100644 --- a/drivers/media/platform/rockchip/rga/rga.h +++ b/drivers/media/platform/rockchip/rga/rga.h @@ -152,6 +152,7 @@ struct rga_hw { u32 max_width, max_height; u8 stride_alignment; =20 + void (*setup_cmdbuf)(struct rga_ctx *ctx); void (*start)(struct rockchip_rga *rga, struct rga_vb_buffer *src, struct rga_vb_buffer *dst); bool (*handle_irq)(struct rockchip_rga *rga); --=20 2.52.0