* [PATCH v3] media: ti: cal: drain WDMA IRQ before freeing contexts
@ 2026-09-25 19:19 Myeonghun Pak
2026-10-01 18:07 ` [PATCH v4] " Myeonghun Pak
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-09-25 19:19 UTC (permalink / raw)
To: Yemike Abhilash Chandra, Mauro Carvalho Chehab
Cc: Myeonghun Pak, linux-media, linux-kernel, stable, Ijae Kim
cal_remove() unregisters the video devices but does not release their vb2
queues. An active stream can therefore keep WDMA IRQs enabled while the
contexts are freed. The managed IRQ is released only after .remove()
returns, so a handler already in flight can access a freed context through
cal->ctx[i].
Use vb2_video_unregister_device() to release each queue and stop any active
stream while the IRQ is still available for DMA stop completion. Then
release the managed IRQ explicitly before destroying the contexts, which
synchronizes any in-flight handler before the context memory is freed.
Drain the IRQ on the probe error path before destroying partially created
contexts too.
Fixes: 343e89a792a5 ("[media] media: ti-vpe: Add CAL v4l2 camera capture driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Changes in v3:
- Resend the unchanged patch with intact diff headers.
Changes in v2:
- Rebuilt the mail-ready message; no code changes.
drivers/media/platform/ti/cal/cal-video.c | 2 +-
drivers/media/platform/ti/cal/cal.c | 11 +++++++----
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c
index d40e24ab1127..0310dba0c810 100644
--- a/drivers/media/platform/ti/cal/cal-video.c
+++ b/drivers/media/platform/ti/cal/cal-video.c
@@ -1036,7 +1036,7 @@ void cal_ctx_v4l2_unregister(struct cal_ctx *ctx)
ctx_dbg(1, ctx, "unregistering %s\n",
video_device_node_name(&ctx->vdev));
- video_unregister_device(&ctx->vdev);
+ vb2_video_unregister_device(&ctx->vdev);
}
int cal_ctx_v4l2_init(struct cal_ctx *ctx)
diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/ti/cal/cal.c
index b7e77b6b8950..d332a05facce 100644
--- a/drivers/media/platform/ti/cal/cal.c
+++ b/drivers/media/platform/ti/cal/cal.c
@@ -1151,7 +1151,6 @@ static int cal_probe(struct platform_device *pdev)
bool connected = false;
unsigned int i;
int ret;
- int irq;
cal = devm_kzalloc(&pdev->dev, sizeof(*cal), GFP_KERNEL);
if (!cal)
@@ -1186,9 +1185,9 @@ static int cal_probe(struct platform_device *pdev)
cal_dbg(1, cal, "ioresource %s at %pa - %pa\n",
cal->res->name, &cal->res->start, &cal->res->end);
- irq = platform_get_irq(pdev, 0);
- cal_dbg(1, cal, "got irq# %d\n", irq);
- ret = devm_request_irq(&pdev->dev, irq, cal_irq, 0, CAL_MODULE_NAME,
+ cal->irq = platform_get_irq(pdev, 0);
+ cal_dbg(1, cal, "got irq# %d\n", cal->irq);
+ ret = devm_request_irq(&pdev->dev, cal->irq, cal_irq, 0, CAL_MODULE_NAME,
cal);
if (ret)
return ret;
@@ -1268,6 +1267,8 @@ static int cal_probe(struct platform_device *pdev)
return 0;
error_context:
+ devm_free_irq(&pdev->dev, cal->irq, cal);
+
for (i = 0; i < cal->num_contexts; i++)
cal_ctx_destroy(cal->ctx[i]);
@@ -1298,6 +1299,8 @@ static void cal_remove(struct platform_device *pdev)
for (i = 0; i < cal->data->num_csi2_phy; i++)
cal_camerarx_disable(cal->phy[i]);
+ devm_free_irq(&pdev->dev, cal->irq, cal);
+
for (i = 0; i < cal->num_contexts; i++)
cal_ctx_destroy(cal->ctx[i]);
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v4] media: ti: cal: drain WDMA IRQ before freeing contexts
2026-09-25 19:19 [PATCH v3] media: ti: cal: drain WDMA IRQ before freeing contexts Myeonghun Pak
@ 2026-10-01 18:07 ` Myeonghun Pak
0 siblings, 0 replies; 2+ messages in thread
From: Myeonghun Pak @ 2026-10-01 18:07 UTC (permalink / raw)
To: Yemike Abhilash Chandra, Mauro Carvalho Chehab
Cc: linux-media, linux-kernel, stable, Ijae Kim, Benoit Parrot,
Hans Verkuil
cal_remove() unregisters the video devices but does not release their vb2
queues. An active stream can therefore keep WDMA IRQs enabled while the
contexts are freed. The managed IRQ is released only after .remove()
returns, so a handler already in flight can access a freed context through
cal->ctx[i].
Use vb2_video_unregister_device() to release each queue and stop any active
stream while the IRQ is still available for DMA stop completion. Then
release the managed IRQ explicitly before destroying the contexts, which
synchronizes any in-flight handler before the context memory is freed.
Drain the IRQ on the probe error path before destroying partially created
contexts too.
Fixes: 343e89a792a5 ("[media] media: ti-vpe: Add CAL v4l2 camera capture driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
Changes in v4:
- Rebase onto the latest media-committers next branch.
- Rewrap devm_request_irq() to stay within 80 columns; no functional changes.
- Compile-test the CAL driver with x86_64 COMPILE_TEST and W=1.
Changes in v3:
- Resend the unchanged patch with intact diff headers.
Changes in v2:
- Rebuilt the mail-ready message; no code changes.
drivers/media/platform/ti/cal/cal-video.c | 2 +-
drivers/media/platform/ti/cal/cal.c | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/media/platform/ti/cal/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c
index 1990cab77344..fdf0b2f2a310 100644
--- a/drivers/media/platform/ti/cal/cal-video.c
+++ b/drivers/media/platform/ti/cal/cal-video.c
@@ -1051,7 +1051,7 @@ void cal_ctx_v4l2_unregister(struct cal_ctx *ctx)
ctx_dbg(1, ctx, "unregistering %s\n",
video_device_node_name(&ctx->vdev));
- video_unregister_device(&ctx->vdev);
+ vb2_video_unregister_device(&ctx->vdev);
}
int cal_ctx_v4l2_init(struct cal_ctx *ctx)
diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/ti/cal/cal.c
index 5c82378d1eee..0340e19fe8cb 100644
--- a/drivers/media/platform/ti/cal/cal.c
+++ b/drivers/media/platform/ti/cal/cal.c
@@ -1145,7 +1145,6 @@ static int cal_probe(struct platform_device *pdev)
bool connected = false;
unsigned int i;
int ret;
- int irq;
cal = devm_kzalloc(&pdev->dev, sizeof(*cal), GFP_KERNEL);
if (!cal)
@@ -1180,10 +1179,10 @@ static int cal_probe(struct platform_device *pdev)
cal_dbg(1, cal, "ioresource %s at %pa - %pa\n",
cal->res->name, &cal->res->start, &cal->res->end);
- irq = platform_get_irq(pdev, 0);
- cal_dbg(1, cal, "got irq# %d\n", irq);
- ret = devm_request_irq(&pdev->dev, irq, cal_irq, 0, CAL_MODULE_NAME,
- cal);
+ cal->irq = platform_get_irq(pdev, 0);
+ cal_dbg(1, cal, "got irq# %d\n", cal->irq);
+ ret = devm_request_irq(&pdev->dev, cal->irq, cal_irq, 0,
+ CAL_MODULE_NAME, cal);
if (ret)
return ret;
@@ -1264,6 +1263,8 @@ static int cal_probe(struct platform_device *pdev)
return 0;
error_context:
+ devm_free_irq(&pdev->dev, cal->irq, cal);
+
for (i = 0; i < cal->num_contexts; i++)
cal_ctx_destroy(cal->ctx[i]);
@@ -1294,6 +1295,8 @@ static void cal_remove(struct platform_device *pdev)
for (i = 0; i < cal->data->num_csi2_phy; i++)
cal_camerarx_disable(cal->phy[i]);
+ devm_free_irq(&pdev->dev, cal->irq, cal);
+
for (i = 0; i < cal->num_contexts; i++)
cal_ctx_destroy(cal->ctx[i]);
base-commit: 4a069a763e8a86821edac4159f7c59a20015631b
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-01 18:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25 19:19 [PATCH v3] media: ti: cal: drain WDMA IRQ before freeing contexts Myeonghun Pak
2026-10-01 18:07 ` [PATCH v4] " Myeonghun Pak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox