media: qcom: camss: fix VFE/CSID/video error handling and register bugs
Subsystems (4)
cover media: qcom: camss: fix VFE/CSID/video error handling and register bugs
This series fixes five self-contained bugs in the Qualcomm CAMSS driver found during Titan 175 (SC8180X) camera bring-up and code review:
1. vfe-17x: Check VFE_IRQ_STATUS_1 (status1) rather than VFE_IRQ_STATUS_0 (status0) against STATUS_1_RDI_SOF(i) in vfe_isr().
2. csid-gen2: Use BIT(RDI_CFG0_ENABLE) to explicitly set or clear bit 31 in __csid_configure_rdi_stream(), avoiding signed int shift overflow and ensuring the enable bit is cleared when stopping a stream.
3. csid: Release the parent device reference via parent_dev_ops->put() on all csid_set_power() power-on failure paths.
4. vfe: Destroy power_lock and stream_lock after unregistering VFE subdevices and video nodes in msm_vfe_unregister_entities().
5. video: Roll back already-started upstream subdevices if s_stream(1) fails partway through video_start_streaming().
---
Robert Ijtsma (5):
media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
media: qcom: camss: csid: release parent device on power-on failure
media: qcom: camss: vfe: destroy mutexes after unregistering entities
media: qcom: camss: video: stop started subdevs on start_streaming failure
.../media/platform/qcom/camss/camss-csid-gen2.c | 5 ++- drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++------------ drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +- drivers/media/platform/qcom/camss/camss-vfe.c | 6 +-- drivers/media/platform/qcom/camss/camss-video.c | 27 ++++++++++-- 5 files changed, 54 insertions(+), 34 deletions(-)
---
base-commit: 4843f6873f7c4835e62f2c73ba0fd538e57a2f22
change-id: 20261122-camss-fixes-4a671ce21042
Best regards,
Signature · 1 line
Robert Ijtsma <[email protected]>
PATCH 1/5 media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
In vfe_isr(), STATUS_1_RDI_SOF(i) is a bitmask for VFE_IRQ_STATUS_1 (status1), not VFE_IRQ_STATUS_0 (status0). Checking status0 instead tests the unrelated STATUS_0_IMAGE_COMPOSITE_DONE bits (27..30).
Check status1 against STATUS_1_RDI_SOF(i) as intended.
--- drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-vfe-17x.c +1 -1
@@ -356,7 +356,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->isr_ops.reg_update (vfe, i);for (i =VFE_LINE_RDI0 ; i < vfe->res->line_num; i++) -if (status0 &STATUS_1_RDI_SOF (i)) +if (status1 &STATUS_1_RDI_SOF (i)) vfe->isr_ops.sof (vfe, i);for (i =0 ; i <MSM_VFE_COMPOSITE_IRQ_NUM ; i++)
Signature · 1 line
2.56.0
Re: [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
Quoted 10 lines · On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay…
From: Robert Ijtsma <[email protected]>
In
vfe_isr(),STATUS_1_RDI_SOF(i)is a bitmask forVFE_IRQ_STATUS_1(status1), notVFE_IRQ_STATUS_0(status0). Checking status0 instead tests the unrelatedSTATUS_0_IMAGE_COMPOSITE_DONEbits (27..30).Check status1 against
STATUS_1_RDI_SOF(i)as intended.Fixes 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170")Signed-off-by Robert Ijtsma <[email protected]>
The related 'sof' callback is a no-op for vfe_170. Bryan, I guess it's ok to not consider it for stable/fix.
Quoted 22 lines
--- drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/camss/camss-vfe-17x.c +1
-2@@ -356,7 +356,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->isr_ops.reg_update (vfe, i);for (i =VFE_LINE_RDI0 ; i < vfe->res->line_num; i++) -if (status0 &STATUS_1_RDI_SOF (i)) +if (status1 &STATUS_1_RDI_SOF (i)) vfe->isr_ops.sof (vfe, i);for (i =0 ; i <MSM_VFE_COMPOSITE_IRQ_NUM ; i++) --2.56.0
Re: [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
In reply to Robert IjtsmaQuoted 20 lines · On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
From: Robert Ijtsma <[email protected]>
In
vfe_isr(),STATUS_1_RDI_SOF(i)is a bitmask forVFE_IRQ_STATUS_1(status1), notVFE_IRQ_STATUS_0(status0). Checking status0 instead tests the unrelatedSTATUS_0_IMAGE_COMPOSITE_DONEbits (27..30).Check status1 against
STATUS_1_RDI_SOF(i)as intended.Fixes 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170")Signed-off-by Robert Ijtsma <[email protected]>--- drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/qcom/camss/camss-vfe-17x.c +0
-0
drivers/media/platform/qcom/camss/camss-vfe-17x.c static irqreturn_t vfe_isr(int irq, void *dev) · line 362
Quoted 8 lines
drivers/media/platform/qcom/camss/camss-vfe-17x.c +1
-1@@ -356,7 +356,7 @@ static irqreturn_t vfe_isr(int irq, void *dev) vfe->isr_ops.reg_update (vfe, i);for (i =VFE_LINE_RDI0 ; i < vfe->res->line_num; i++) -if (status0 &STATUS_1_RDI_SOF (i)) +if (status1 &STATUS_1_RDI_SOF (i)) vfe->isr_ops.sof (vfe, i);for (i =0 ; i <MSM_VFE_COMPOSITE_IRQ_NUM ; i++)
PATCH 2/5 media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
In reply to Robert IjtsmaIn __csid_configure_rdi_stream(), shifting the u8 parameter enable (promoted to signed int) left by RDI_CFG0_ENABLE (31) shifts into the sign bit, and bitwise ORing never explicitly clears the enable bit when enable is zero.
Use BIT(RDI_CFG0_ENABLE) to explicitly set or clear the bit depending on enable, matching camss-csid-680.c.
--- drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-csid-gen2.c +4 -1
@@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8writel_relaxed (val, csid->base +CSID_RDI_CTRL (port)); val =readl_relaxed (csid->base +CSID_RDI_CFG0 (port)); - val |= enable <<RDI_CFG0_ENABLE ; +if (enable) + val |=BIT (RDI_CFG0_ENABLE ); +else + val &= ~BIT (RDI_CFG0_ENABLE );writel_relaxed (val, csid->base +CSID_RDI_CFG0 (port)); }
Signature · 1 line
2.56.0
Loic Poulain
reviewerRe: [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
Quoted 22 lines · On Sun, Nov 22, 2026 at 2:35 PM Robert Ijtsma via B4 Relay…
From: Robert Ijtsma <[email protected]>
In
__csid_configure_rdi_stream(), shifting the u8 parameterenable(promoted to signed int) left byRDI_CFG0_ENABLE(31) shifts into the sign bit, and bitwise ORing never explicitly clears the enable bit whenenableis zero.Use
BIT(RDI_CFG0_ENABLE)to explicitly set or clear the bit depending onenable, matchingcamss-csid-680.c.Fixes 729fc005c8e2 ("media: qcom: camss: Split testgen, RDI and RX for CSID 170")Signed-off-by Robert Ijtsma <[email protected]>--- drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/media/platform/qcom/camss/camss-csid-gen2.c +0
-0
drivers/media/platform/qcom/camss/camss-csid-gen2.c static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8 · line 321
Quoted 4 lines
drivers/media/platform/qcom/camss/camss-csid-gen2.c +0
-1@@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8writel_relaxed (val, csid->base +CSID_RDI_CTRL (port)); val =readl_relaxed (csid->base +CSID_RDI_CFG0 (port)); - val |= enable <<RDI_CFG0_ENABLE ;
So, why not also making the enable parameter a bool.
Quoted 12 lines
drivers/media/platform/qcom/camss/camss-csid-gen2.c +4
-1+if (enable) + val |=BIT (RDI_CFG0_ENABLE ); +else + val &= ~BIT (RDI_CFG0_ENABLE );writel_relaxed (val, csid->base +CSID_RDI_CFG0 (port)); } --2.56.0
Re: [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
In reply to Robert IjtsmaQuoted 6 lines · On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
From: Robert Ijtsma <[email protected]>
In
__csid_configure_rdi_stream(), shifting the u8 parameterenable(promoted to signed int) left byRDI_CFG0_ENABLE(31) shifts into the sign bit, and bitwise ORing never explicitly clears the enable bit whenenableis zero.
Sign bit is irrelevant to this patch please drop from the commit log.
Quoted 16 lines
Use
BIT(RDI_CFG0_ENABLE)to explicitly set or clear the bit depending onenable, matchingcamss-csid-680.c.Fixes 729fc005c8e2 ("media: qcom: camss: Split testgen, RDI and RX for CSID 170")Signed-off-by Robert Ijtsma <[email protected]>--- drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/media/platform/qcom/camss/camss-csid-gen2.c +0
-0@@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8writel_relaxed (val, csid->base +CSID_RDI_CTRL (port));
drivers/media/platform/qcom/camss/camss-csid-gen2.c static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8 · line 327
Quoted 10 lines
drivers/media/platform/qcom/camss/camss-csid-gen2.c +4
-1val =readl_relaxed (csid->base +CSID_RDI_CFG0 (port)); - val |= enable <<RDI_CFG0_ENABLE ; +if (enable) + val |=BIT (RDI_CFG0_ENABLE ); +else + val &= ~BIT (RDI_CFG0_ENABLE );writel_relaxed (val, csid->base +CSID_RDI_CFG0 (port)); }
The bug is that val |= 0 does nothing, not that the sign bit matters
u32 val;
u8 enable = 0;
val |= (int)enable << 1;
enable is still zero => two's complement zero is still zero.
and
enable = 1;
val |= (int)enable << 31;
sets the sign bit but that's bit 31 => 0x80000000 which is what we want to set...
What's legitimate is
enable = 0;
val |= enable << ANY_INT;
will not twiddle any bit in val so please just stick to the bug description in the commit log.
Once fixed you can add my
---
bod
PATCH 3/5 media: qcom: camss: csid: release parent device on power-on failure
In reply to Robert Ijtsmacsid_set_power() acquires a reference on the parent device via parent_dev_ops->get() before resuming runtime PM, enabling regulators and clocks, and resetting the CSID hardware. If any of these subsequent steps fail, the function returns without calling parent_dev_ops->put(), leaking the parent VFE power reference.
Consolidate the power-on error paths using goto labels and release the parent device reference on all failure paths.
--- drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++++-------------- 1 file changed, 22 insertions(+), 26 deletions(-)
drivers/media/platform/qcom/camss/camss-csid.c +22 -26
@@ -682,7 +682,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)struct csid_device *csid =v4l2_get_subdevdata (sd);struct camss *camss = csid->camss;struct device *dev = camss->dev; -int ret =0 ; +int ret;if (on) {/*
@@ -696,44 +696,28 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ret =pm_runtime_resume_and_get (dev);if (ret <0 ) -return ret; + goto err_parent_put; ret =regulator_bulk_enable (csid->num_supplies, csid->supplies); -if (ret <0 ) { -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_pm_put; ret =csid_set_clock_rates (csid); -if (ret <0 ) { -regulator_bulk_disable (csid->num_supplies, - csid->supplies); -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_regulators_disable; ret =camss_enable_clocks (csid->nclocks, csid->clock, dev); -if (ret <0 ) { -regulator_bulk_disable (csid->num_supplies, - csid->supplies); -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_regulators_disable; csid->phy.need_vc_update = true;enable_irq (csid->irq); ret = csid->res->hw_ops->reset (csid); -if (ret <0 ) { -disable_irq (csid->irq); -camss_disable_clocks (csid->nclocks, csid->clock); -regulator_bulk_disable (csid->num_supplies, - csid->supplies); -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_reset; csid->res->hw_ops->hw_version (csid); }else {
@@ -745,6 +729,18 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) csid->res->parent_dev_ops->put (camss, csid->id); } +return 0 ; + +err_reset: +disable_irq (csid->irq); +camss_disable_clocks (csid->nclocks, csid->clock); +err_regulators_disable: +regulator_bulk_disable (csid->num_supplies, csid->supplies); +err_pm_put: +pm_runtime_put_sync (dev); +err_parent_put: + csid->res->parent_dev_ops->put (camss, csid->id); +return ret; }
Signature · 1 line
2.56.0
Re: [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
Quoted 9 lines · On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay…
From: Robert Ijtsma <[email protected]>
csid_set_power()acquires a reference on the parent device viaparent_dev_ops->get()before resuming runtime PM, enabling regulators and clocks, and resetting the CSID hardware. If any of these subsequent steps fail, the function returns without callingparent_dev_ops->put(), leaking the parent VFE power reference.
Quoted 5 lines
Consolidate the power-on error paths using goto labels and release the parent device reference on all failure paths.
Fixes c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")Signed-off-by Robert Ijtsma <[email protected]>
Quoted 95 lines
--- drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++++-------------- 1 file changed, 22 insertions(+), 26 deletions(-)drivers/media/platform/qcom/camss/camss-csid.c +22
-27@@ -682,7 +682,7 @@ static int csid_set_power(struct v4l2_subdev *sd, int on)struct csid_device *csid =v4l2_get_subdevdata (sd);struct camss *camss = csid->camss;struct device *dev = camss->dev; -int ret =0 ; +int ret;if (on) {/* @@ -696,44 +696,28 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) ret =pm_runtime_resume_and_get (dev);if (ret <0 ) -return ret; + goto err_parent_put; ret =regulator_bulk_enable (csid->num_supplies, csid->supplies); -if (ret <0 ) { -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_pm_put; ret =csid_set_clock_rates (csid); -if (ret <0 ) { -regulator_bulk_disable (csid->num_supplies, - csid->supplies); -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_regulators_disable; ret =camss_enable_clocks (csid->nclocks, csid->clock, dev); -if (ret <0 ) { -regulator_bulk_disable (csid->num_supplies, - csid->supplies); -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_regulators_disable; csid->phy.need_vc_update = true;enable_irq (csid->irq); ret = csid->res->hw_ops->reset (csid); -if (ret <0 ) { -disable_irq (csid->irq); -camss_disable_clocks (csid->nclocks, csid->clock); -regulator_bulk_disable (csid->num_supplies, - csid->supplies); -pm_runtime_put_sync (dev); -return ret; - } +if (ret <0 ) + goto err_reset; csid->res->hw_ops->hw_version (csid); }else {@@ -745,6 +729,18 @@ static int csid_set_power(struct v4l2_subdev *sd, int on) csid->res->parent_dev_ops->put (camss, csid->id); } +return 0 ; + +err_reset: +disable_irq (csid->irq); +camss_disable_clocks (csid->nclocks, csid->clock); +err_regulators_disable: +regulator_bulk_disable (csid->num_supplies, csid->supplies); +err_pm_put: +pm_runtime_put_sync (dev); +err_parent_put: + csid->res->parent_dev_ops->put (camss, csid->id); +return ret; } --2.56.0
Re: [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
In reply to Robert IjtsmaQuoted 8 lines · On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
From: Robert Ijtsma <[email protected]>
csid_set_power()acquires a reference on the parent device viaparent_dev_ops->get()before resuming runtime PM, enabling regulators and clocks, and resetting the CSID hardware. If any of these subsequent steps fail, the function returns without callingparent_dev_ops->put(), leaking the parent VFE power reference.
Quoted 6 lines
Consolidate the power-on error paths using goto labels and release the parent device reference on all failure paths.
Fixes c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")Signed-off-by Robert Ijtsma <[email protected]>---
PATCH 4/5 media: qcom: camss: vfe: destroy mutexes after unregistering entities
In reply to Robert Ijtsmamsm_vfe_unregister_entities() destroys vfe->power_lock and vfe->stream_lock before unregistering the VFE video devices and V4L2 subdevices. Active userspace handles or concurrent teardown callbacks can still acquire these mutexes until the entities are unregistered.
Destroy power_lock and stream_lock after all VFE entities have been unregistered and cleaned up.
--- drivers/media/platform/qcom/camss/camss-vfe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe.c +3 -3
@@ -2168,9 +2168,6 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe) {int i; -mutex_destroy (&vfe->power_lock); -mutex_destroy (&vfe->stream_lock); -for (i =0 ; i < vfe->res->line_num; i++) {struct v4l2_subdev *sd = &vfe->line[i].subdev;struct camss_video *video_out = &vfe->line[i].video_out;
@@ -2179,6 +2176,9 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe)v4l2_device_unregister_subdev (sd);media_entity_cleanup (&sd->entity); } + +mutex_destroy (&vfe->power_lock); +mutex_destroy (&vfe->stream_lock); }bool vfe_is_lite (struct vfe_device *vfe)
Signature · 1 line
2.56.0
Re: [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities
Quoted 8 lines · On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay…
From: Robert Ijtsma <[email protected]>
msm_vfe_unregister_entities()destroysvfe->power_lockandvfe->stream_lockbefore unregistering the VFE video devices and V4L2 subdevices. Active userspace handles or concurrent teardown callbacks can still acquire these mutexes until the entities are unregistered.
Quoted 5 lines
Destroy
power_lockandstream_lockafter all VFE entities have been unregistered and cleaned up.Fixes 4c98a5f57f90 ("media: camss: Add VFE files")Signed-off-by Robert Ijtsma <[email protected]>
Quoted 33 lines
--- drivers/media/platform/qcom/camss/camss-vfe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/media/platform/qcom/camss/camss-vfe.c +3
-4@@ -2168,9 +2168,6 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe) {int i; -mutex_destroy (&vfe->power_lock); -mutex_destroy (&vfe->stream_lock); -for (i =0 ; i < vfe->res->line_num; i++) {struct v4l2_subdev *sd = &vfe->line[i].subdev;struct camss_video *video_out = &vfe->line[i].video_out;@@ -2179,6 +2176,9 @@ void msm_vfe_unregister_entities(struct vfe_device *vfe)v4l2_device_unregister_subdev (sd);media_entity_cleanup (&sd->entity); } + +mutex_destroy (&vfe->power_lock); +mutex_destroy (&vfe->stream_lock); }bool vfe_is_lite (struct vfe_device *vfe) --2.56.0
Re: [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities
In reply to Robert IjtsmaQuoted 7 lines · On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
From: Robert Ijtsma <[email protected]>
msm_vfe_unregister_entities()destroysvfe->power_lockandvfe->stream_lockbefore unregistering the VFE video devices and V4L2 subdevices. Active userspace handles or concurrent teardown callbacks can still acquire these mutexes until the entities are unregistered.
Quoted 6 lines
Destroy
power_lockandstream_lockafter all VFE entities have been unregistered and cleaned up.Fixes 4c98a5f57f90 ("media: camss: Add VFE files")Signed-off-by Robert Ijtsma <[email protected]>---
PATCH 5/5 media: qcom: camss: video: stop started subdevs on start_streaming failure
In reply to Robert IjtsmaIf a subdevice fails s_stream(1) partway through video_start_streaming(), previously started subdevices earlier in the pipeline (such as the VFE and CSID) are never stopped. This leaks VFE stream counts and write master reservations, leaving the pipeline stuck on subsequent stream attempts.
Walk the pipeline from the video device up to the failing entity and call s_stream(0) on each already-started subdevice before stopping the media pipeline and flushing buffers.
--- drivers/media/platform/qcom/camss/camss-video.c | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/camss/camss-video.c +24 -3
@@ -253,7 +253,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) {struct camss_video *video =vb2_get_drv_priv (q);struct video_device *vdev = &video->vdev; -struct media_entity *entity; +struct media_entity *entity, *failed_entity;struct media_pad *pad;struct v4l2_subdev *subdev;int ret;
@@ -282,12 +282,33 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) subdev =media_entity_to_v4l2_subdev (entity); ret =v4l2_subdev_call (subdev, video, s_stream,1 ); -if (ret <0 && ret != -ENOIOCTLCMD ) - goto error; +if (ret <0 && ret != -ENOIOCTLCMD ) { + failed_entity = entity; + goto error_stop_subdevs; + } }return 0 ; +error_stop_subdevs: + entity = &vdev->entity; +while (1 ) { + pad = &entity->pads[0 ]; +if (!(pad->flags &MEDIA_PAD_FL_SINK )) +break ; + + pad =media_pad_remote_pad_first (pad); +if (!pad || !is_media_entity_v4l2_subdev (pad->entity)) +break ; + + entity = pad->entity; +if (entity == failed_entity) +break ; + + subdev =media_entity_to_v4l2_subdev (entity); +v4l2_subdev_call (subdev, video, s_stream,0 ); + } + error:video_device_pipeline_stop (vdev);
Signature · 1 line
2.56.0
Loic Poulain
reviewerRe: [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
Quoted 9 lines · On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay…
From: Robert Ijtsma <[email protected]>
If a subdevice fails
s_stream(1)partway throughvideo_start_streaming(), previously started subdevices earlier in the pipeline (such as the VFE and CSID) are never stopped. This leaks VFE stream counts and write master reservations, leaving the pipeline stuck on subsequent stream attempts.
Quoted 3 lines
Walk the pipeline from the video device up to the failing entity and call
s_stream(0)on each already-started subdevice before stopping the media pipeline and flushing buffers.
I saw at least three similar patches recently, can you look at this one:
https://lore.kernel.org/all/[email protected]/
What would be nice is to build on the above change and address the reported points/issues, as I haven't seen any follow-up from Qianhui.
Quoted 61 lines
Fixes 0ac2586c410f ("media: camss: Add files which handle the video device nodes")Signed-off-by Robert Ijtsma <[email protected]>--- drivers/media/platform/qcom/camss/camss-video.c | 27 ++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)drivers/media/platform/qcom/camss/camss-video.c +24
-4@@ -253,7 +253,7 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) {struct camss_video *video =vb2_get_drv_priv (q);struct video_device *vdev = &video->vdev; -struct media_entity *entity; +struct media_entity *entity, *failed_entity;struct media_pad *pad;struct v4l2_subdev *subdev;int ret;@@ -282,12 +282,33 @@ static int video_start_streaming(struct vb2_queue *q, unsigned int count) subdev =media_entity_to_v4l2_subdev (entity); ret =v4l2_subdev_call (subdev, video, s_stream,1 ); -if (ret <0 && ret != -ENOIOCTLCMD ) - goto error; +if (ret <0 && ret != -ENOIOCTLCMD ) { + failed_entity = entity; + goto error_stop_subdevs; + } }return 0 ; +error_stop_subdevs: + entity = &vdev->entity; +while (1 ) { + pad = &entity->pads[0 ]; +if (!(pad->flags &MEDIA_PAD_FL_SINK )) +break ; + + pad =media_pad_remote_pad_first (pad); +if (!pad || !is_media_entity_v4l2_subdev (pad->entity)) +break ; + + entity = pad->entity; +if (entity == failed_entity) +break ; + + subdev =media_entity_to_v4l2_subdev (entity); +v4l2_subdev_call (subdev, video, s_stream,0 ); + } + error:video_device_pipeline_stop (vdev); --2.56.0
Re: [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
In reply to Robert IjtsmaQuoted 8 lines · On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
From: Robert Ijtsma <[email protected]>
If a subdevice fails
s_stream(1)partway throughvideo_start_streaming(), previously started subdevices earlier in the pipeline (such as the VFE and CSID) are never stopped. This leaks VFE stream counts and write master reservations, leaving the pipeline stuck on subsequent stream attempts.
Quoted 6 lines
Walk the pipeline from the video device up to the failing entity and call
s_stream(0)on each already-started subdevice before stopping the media pipeline and flushing buffers.Fixes 0ac2586c410f ("media: camss: Add files which handle the video device nodes")Signed-off-by Robert Ijtsma <[email protected]>
I'm 90% sure someone has already submitted a change for this.
Anyway
Loic Poulain
reviewerRe: [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
Quoted 10 lines · Bryan O'Donoghue
Quoted 8 lines · On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
From: Robert Ijtsma <[email protected]>
If a subdevice fails
s_stream(1)partway throughvideo_start_streaming(), previously started subdevices earlier in the pipeline (such as the VFE and CSID) are never stopped. This leaks VFE stream counts and write master reservations, leaving the pipeline stuck on subsequent stream attempts.
Quoted 8 lines
Quoted 6 lines
Walk the pipeline from the video device up to the failing entity and call
s_stream(0)on each already-started subdevice before stopping the media pipeline and flushing buffers.Fixes 0ac2586c410f ("media: camss: Add files which handle the video device nodes")Signed-off-by Robert Ijtsma <[email protected]>I'm 90% sure someone has already submitted a change for this.
Yes, it was already submitted, refer to my previous reply.
Quoted 4 lines
Anyway
Reviewed-by Bryan O'Donoghue <[email protected]>