From: "Sven Püschel" <s.pueschel@pengutronix.de>
To: Jacob Chen <jacob-chen@iotwrt.com>,
Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel@pengutronix.de,
"Detlev Casanova" <detlev.casanova@collabora.com>,
"Michael Tretter" <m.tretter@pengutronix.de>,
"Guangshuo Li" <lgs201920130244@gmail.com>,
"Sven Püschel" <s.pueschel@pengutronix.de>
Subject: [PATCH v2 13/17] media: rockchip: rga: move core initialization from bind to probe
Date: Wed, 16 Sep 2026 17:09:54 +0200 [thread overview]
Message-ID: <20260916-spu-rga3multicore-v2-13-23aa2cb74e61@pengutronix.de> (raw)
In-Reply-To: <20260916-spu-rga3multicore-v2-0-23aa2cb74e61@pengutronix.de>
Move the core initialization from the core binding function to the core
probing function. This better matches the actual sequence, where the
core probe initializes most things and the bind function just binds the
core to the actual rga struct from the master device.
As the probe has no rockchip_rga struct, it has to get the
rga_hw struct from the of match data to determine if the given core has
an iommu.
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
---
v2
- indirectly fixed component_add error path not using goto err_put_clk
by using devres version for pm (pointed out by Sashiko and Nicolas)
- reordered commit for a better diff
- Avoid NULL pointer deref when interrupt fires on an unbound core
---
drivers/media/platform/rockchip/rga/rga.c | 97 ++++++++++++++++++-------------
1 file changed, 55 insertions(+), 42 deletions(-)
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index 37ccac5b406a4..fa34b93b1b7a5 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -72,6 +72,10 @@ static irqreturn_t rga_isr(int irq, void *prv)
struct rga_core *core = prv;
struct rockchip_rga *rga = core->rga;
+ /* ignore interrupt on an unbound core */
+ if (!rga)
+ return IRQ_HANDLED;
+
if (rga->hw->handle_irq(core)) {
struct vb2_v4l2_buffer *src, *dst;
struct rga_ctx *ctx = core->curr;
@@ -740,55 +744,16 @@ static int rga_parse_dt(struct rga_core *core)
static int rga_core_bind(struct device *dev, struct device *master, void *data)
{
- struct platform_device *pdev = to_platform_device(dev);
struct rockchip_rga *rga = data;
- struct rga_core *core;
+ struct rga_core *core = dev_get_drvdata(dev);
struct video_device *vfd;
int ret = 0;
- int irq;
-
- if (!pdev->dev.of_node)
- return -ENODEV;
-
- core = devm_kzalloc(&pdev->dev, sizeof(*core), GFP_KERNEL);
- if (!core)
- return -ENOMEM;
core->rga = rga;
- core->dev = &pdev->dev;
rga->cores[0] = core;
- ret = rga_parse_dt(core);
- if (ret)
- return dev_err_probe(&pdev->dev, ret, "Unable to parse OF data\n");
-
- ret = devm_pm_runtime_enable(core->dev);
- if (ret)
- return ret;
-
- pm_runtime_set_autosuspend_delay(core->dev, 50);
- pm_runtime_use_autosuspend(core->dev);
-
- core->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(core->regs))
- return PTR_ERR(core->regs);
-
- irq = platform_get_irq(pdev, 0);
- if (irq < 0)
- return irq;
-
- ret = devm_request_irq(core->dev, irq, rga_isr,
- rga_has_internal_iommu(rga) ? 0 : IRQF_SHARED,
- dev_name(core->dev), core);
- if (ret < 0)
- return dev_err_probe(core->dev, ret, "failed to request irq\n");
-
- ret = dma_set_mask_and_coherent(core->dev, DMA_BIT_MASK(32));
- if (ret)
- dev_err_probe(core->dev, ret, "32-bit DMA not supported");
-
- ret = v4l2_device_register(&pdev->dev, &rga->v4l2_dev);
+ ret = v4l2_device_register(dev, &rga->v4l2_dev);
if (ret)
return ret;
vfd = video_device_alloc();
@@ -804,7 +769,6 @@ static int rga_core_bind(struct device *dev, struct device *master, void *data)
video_set_drvdata(vfd, rga);
rga->vfd = vfd;
- platform_set_drvdata(pdev, core);
rga->m2m_dev = v4l2_m2m_init(&rga_m2m_ops);
if (IS_ERR(rga->m2m_dev)) {
v4l2_err(&rga->v4l2_dev, "Failed to init mem2mem device\n");
@@ -855,6 +819,8 @@ static void rga_core_unbind(struct device *dev, struct device *master,
v4l2_m2m_release(rga->m2m_dev);
video_unregister_device(rga->vfd);
v4l2_device_unregister(&rga->v4l2_dev);
+
+ core->rga = NULL;
}
static const struct component_ops rga_core_ops = {
@@ -864,7 +830,54 @@ static const struct component_ops rga_core_ops = {
static int rga_core_probe(struct platform_device *pdev)
{
+ struct rga_core *core;
+ const struct rga_hw *hw;
int ret = 0;
+ int irq;
+
+ if (!pdev->dev.of_node)
+ return -ENODEV;
+
+ hw = of_device_get_match_data(&pdev->dev);
+ if (!hw)
+ return dev_err_probe(&pdev->dev, -ENODEV, "failed to get match data\n");
+
+ core = devm_kzalloc(&pdev->dev, sizeof(*core), GFP_KERNEL);
+ if (!core)
+ return -ENOMEM;
+
+ core->dev = &pdev->dev;
+
+ ret = rga_parse_dt(core);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Unable to parse OF data\n");
+
+ ret = devm_pm_runtime_enable(core->dev);
+ if (ret)
+ return ret;
+
+ pm_runtime_set_autosuspend_delay(core->dev, 50);
+ pm_runtime_use_autosuspend(core->dev);
+
+ core->regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(core->regs))
+ return PTR_ERR(core->regs);
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ ret = devm_request_irq(core->dev, irq, rga_isr,
+ hw->has_internal_iommu ? 0 : IRQF_SHARED,
+ dev_name(core->dev), core);
+ if (ret < 0)
+ return dev_err_probe(core->dev, ret, "failed to request irq\n");
+
+ ret = dma_set_mask_and_coherent(core->dev, DMA_BIT_MASK(32));
+ if (ret)
+ dev_err_probe(core->dev, ret, "32-bit DMA not supported");
+
+ platform_set_drvdata(pdev, core);
ret = component_add(&pdev->dev, &rga_core_ops);
if (ret < 0)
--
2.55.0
next prev parent reply other threads:[~2026-09-16 15:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 15:09 [PATCH v2 00/17] media: rockchip: rga: Add multi-core support Sven Püschel
2026-09-16 15:09 ` [PATCH v2 01/17] media: rockchip: rga: zero cmdbuf in shared code Sven Püschel
2026-09-16 15:09 ` [PATCH v2 02/17] media: rockchip: rga: add comment about pixel alignment for YUV formats Sven Püschel
2026-09-16 15:09 ` [PATCH v2 03/17] media: rockchip: rga: move early return into if condition in vidioc_enum_fmt Sven Püschel
2026-09-16 15:09 ` [PATCH v2 04/17] media: rockchip: rga: removed unused regmap member Sven Püschel
2026-09-16 15:09 ` [PATCH v2 05/17] media: rockchip: rga: use devres version of pm_runtime_enable Sven Püschel
2026-09-16 15:09 ` [PATCH v2 06/17] media: v4l2-mem2mem: drop curr_ctx member from v4l2_m2m_dev struct Sven Püschel
2026-09-16 15:09 ` [PATCH v2 07/17] media: v4l2-mem2mem: support running multiple jobs in parallel Sven Püschel
2026-09-16 15:09 ` [PATCH v2 08/17] media: rockchip: rga: move power handling to device_run Sven Püschel
2026-09-16 15:09 ` [PATCH v2 09/17] media: rockchip: rga: adjust get_version to return the version Sven Püschel
2026-09-16 15:09 ` [PATCH v2 10/17] media: rockchip: rga: add rga_core structure Sven Püschel
2026-09-16 15:09 ` [PATCH v2 11/17] media: rockchip: rga: use components to manage multiple cores Sven Püschel
2026-09-16 15:09 ` [PATCH v2 12/17] media: rockchip: rga: move rockchip_rga allocation to master probe Sven Püschel
2026-09-16 15:09 ` Sven Püschel [this message]
2026-09-16 15:09 ` [PATCH v2 14/17] media: rockchip: rga: move video device to the master Sven Püschel
2026-09-16 15:09 ` [PATCH v2 15/17] media: rockchip: rga: bind all cores " Sven Püschel
2026-09-16 15:09 ` [PATCH v2 16/17] media: rockchip: rga: put all cores into first core iommu domain Sven Püschel
2026-09-16 15:09 ` [PATCH v2 17/17] media: rockchip: rga: schedule jobs to multiple cores Sven Püschel
2026-11-14 4:50 ` [PATCH v2 00/17] media: rockchip: rga: Add multi-core support Arun Iyengar
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=20260916-spu-rga3multicore-v2-13-23aa2cb74e61@pengutronix.de \
--to=s.pueschel@pengutronix.de \
--cc=detlev.casanova@collabora.com \
--cc=ezequiel@vanguardiasur.com.ar \
--cc=heiko@sntech.de \
--cc=jacob-chen@iotwrt.com \
--cc=kernel@pengutronix.de \
--cc=lgs201920130244@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=m.tretter@pengutronix.de \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
/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
all inboxes | Powered by JetHome®