All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] media: qcom: camss: fix VFE/CSID/video error handling and register bugs
@ 2026-11-22 13:35 ` Robert Ijtsma
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma via B4 Relay @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

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().

Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
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,
--  
Robert Ijtsma <robertijtsma@gmail.com>



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 0/5] media: qcom: camss: fix VFE/CSID/video error handling and register bugs
@ 2026-11-22 13:35 ` Robert Ijtsma
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

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().

Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
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,
--  
Robert Ijtsma <robertijtsma@gmail.com>


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
  2026-11-22 13:35 ` Robert Ijtsma
@ 2026-11-22 13:35   ` Robert Ijtsma
  -1 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma via B4 Relay @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

From: Robert Ijtsma <robertijtsma@gmail.com>

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.

Fixes: 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
index 62c2405..502a0d4 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
@@ -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



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
@ 2026-11-22 13:35   ` Robert Ijtsma
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

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.

Fixes: 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
index 62c2405..502a0d4 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
@@ -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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
  2026-11-22 13:35 ` Robert Ijtsma
@ 2026-11-22 13:35   ` Robert Ijtsma
  -1 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma via B4 Relay @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

From: Robert Ijtsma <robertijtsma@gmail.com>

In __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.

Fixes: 729fc005c8e2 ("media: qcom: camss: Split testgen, RDI and RX for CSID 170")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
index eadcb2f..804c8fe 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
@@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8
 	writel_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));
 }
 

-- 
2.56.0



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
@ 2026-11-22 13:35   ` Robert Ijtsma
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

In __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.

Fixes: 729fc005c8e2 ("media: qcom: camss: Split testgen, RDI and RX for CSID 170")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
index eadcb2f..804c8fe 100644
--- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
+++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
@@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8
 	writel_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));
 }
 

-- 
2.56.0


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
  2026-11-22 13:35 ` Robert Ijtsma
@ 2026-11-22 13:35   ` Robert Ijtsma
  -1 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma via B4 Relay @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

From: Robert Ijtsma <robertijtsma@gmail.com>

csid_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.

Fixes: c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++++--------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 51f2090..e67edc3 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -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



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
@ 2026-11-22 13:35   ` Robert Ijtsma
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

csid_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.

Fixes: c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++++--------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
index 51f2090..e67edc3 100644
--- a/drivers/media/platform/qcom/camss/camss-csid.c
+++ b/drivers/media/platform/qcom/camss/camss-csid.c
@@ -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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities
  2026-11-22 13:35 ` Robert Ijtsma
@ 2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  -1 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

msm_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.

Fixes: 4c98a5f57f90 ("media: camss: Add VFE files")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-vfe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index ad09593..fe6b7ef 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities
@ 2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma via B4 Relay @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

From: Robert Ijtsma <robertijtsma@gmail.com>

msm_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.

Fixes: 4c98a5f57f90 ("media: camss: Add VFE files")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-vfe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
index ad09593..fe6b7ef 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -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



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
  2026-11-22 13:35 ` Robert Ijtsma
@ 2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  -1 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

If 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.

Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-video.c | 27 ++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 0852eb6..6f7b9f3 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -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


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
@ 2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  0 siblings, 0 replies; 23+ messages in thread
From: Robert Ijtsma via B4 Relay @ 2026-11-22 13:35 UTC (permalink / raw)
  To: Bryan O'Donoghue, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm, Robert Ijtsma

From: Robert Ijtsma <robertijtsma@gmail.com>

If 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.

Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
---
 drivers/media/platform/qcom/camss/camss-video.c | 27 ++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index 0852eb6..6f7b9f3 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -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



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
  2026-11-22 13:35   ` Robert Ijtsma
  (?)
@ 2026-11-23  9:48   ` Loic Poulain
  -1 siblings, 0 replies; 23+ messages in thread
From: Loic Poulain @ 2026-11-23  9:48 UTC (permalink / raw)
  To: robertijtsma
  Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm

On Sun, Nov 22, 2026 at 2:35 PM Robert Ijtsma via B4 Relay
<devnull+robertijtsma.gmail.com@kernel.org> wrote:
>
> From: Robert Ijtsma <robertijtsma@gmail.com>
>
> In __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.
>
> Fixes: 729fc005c8e2 ("media: qcom: camss: Split testgen, RDI and RX for CSID 170")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
> ---
>  drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
> index eadcb2f..804c8fe 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
> @@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8
>         writel_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.

> +       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
>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
  2026-11-22 13:35   ` Robert Ijtsma
  (?)
@ 2026-11-23  9:53   ` Loic Poulain
  -1 siblings, 0 replies; 23+ messages in thread
From: Loic Poulain @ 2026-11-23  9:53 UTC (permalink / raw)
  To: robertijtsma
  Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm

On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay
<devnull+robertijtsma.gmail.com@kernel.org> wrote:
>
> From: Robert Ijtsma <robertijtsma@gmail.com>
>
> csid_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.
>
> Fixes: c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>

Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>

> ---
>  drivers/media/platform/qcom/camss/camss-csid.c | 48 ++++++++++++--------------
>  1 file changed, 22 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-csid.c b/drivers/media/platform/qcom/camss/camss-csid.c
> index 51f2090..e67edc3 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid.c
> @@ -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
>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
  2026-11-22 13:35   ` Robert Ijtsma
  (?)
@ 2026-11-23  9:58   ` Loic Poulain
  -1 siblings, 0 replies; 23+ messages in thread
From: Loic Poulain @ 2026-11-23  9:58 UTC (permalink / raw)
  To: robertijtsma
  Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm

On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay
<devnull+robertijtsma.gmail.com@kernel.org> wrote:
>
> From: Robert Ijtsma <robertijtsma@gmail.com>
>
> 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.
> Fixes: 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>

The related 'sof' callback is a no-op for vfe_170. Bryan, I guess it's
ok to not consider it for stable/fix.

Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>

> ---
>  drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> index 62c2405..502a0d4 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> @@ -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
>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities
  2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  (?)
@ 2026-11-23 10:00   ` Loic Poulain
  -1 siblings, 0 replies; 23+ messages in thread
From: Loic Poulain @ 2026-11-23 10:00 UTC (permalink / raw)
  To: robertijtsma
  Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm

On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay
<devnull+robertijtsma.gmail.com@kernel.org> wrote:
>
> From: Robert Ijtsma <robertijtsma@gmail.com>
>
> msm_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.
>
> Fixes: 4c98a5f57f90 ("media: camss: Add VFE files")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>

Reviewed-by: Loic Poulain <loic.poulain@oss.qualcomm.com>

> ---
>  drivers/media/platform/qcom/camss/camss-vfe.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c
> index ad09593..fe6b7ef 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c
> @@ -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
>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
  2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  (?)
@ 2026-11-23 10:04   ` Loic Poulain
  -1 siblings, 0 replies; 23+ messages in thread
From: Loic Poulain @ 2026-11-23 10:04 UTC (permalink / raw)
  To: robertijtsma
  Cc: Bryan O'Donoghue, Vladimir Zapolskiy, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm

On Sun, Nov 22, 2026 at 2:36 PM Robert Ijtsma via B4 Relay
<devnull+robertijtsma.gmail.com@kernel.org> wrote:
>
> From: Robert Ijtsma <robertijtsma@gmail.com>
>
> If 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.

I saw at least three similar patches recently, can you look at this one:
https://lore.kernel.org/all/20261031041154.308030-3-xiaqinghuan@mail.ustc.edu.cn/

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.

>
> Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
> ---
>  drivers/media/platform/qcom/camss/camss-video.c | 27 ++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index 0852eb6..6f7b9f3 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -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
>
>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts
  2026-11-22 13:35   ` Robert Ijtsma
  (?)
  (?)
@ 2026-11-23 13:46   ` Bryan O'Donoghue
  -1 siblings, 0 replies; 23+ messages in thread
From: Bryan O'Donoghue @ 2026-11-23 13:46 UTC (permalink / raw)
  To: robertijtsma, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm

On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
> From: Robert Ijtsma <robertijtsma@gmail.com>
> 
> 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.
> 
> Fixes: 7319cdf189bb ("media: camss: Add support for VFE hardware version Titan 170")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
> ---
>   drivers/media/platform/qcom/camss/camss-vfe-17x.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> index 62c2405..502a0d4 100644
> --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c
> @@ -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++)
> 
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation
  2026-11-22 13:35   ` Robert Ijtsma
  (?)
  (?)
@ 2026-11-23 14:40   ` Bryan O'Donoghue
  -1 siblings, 0 replies; 23+ messages in thread
From: Bryan O'Donoghue @ 2026-11-23 14:40 UTC (permalink / raw)
  To: robertijtsma, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm

On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
> From: Robert Ijtsma <robertijtsma@gmail.com>
> 
> In __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.

Sign bit is irrelevant to this patch please drop from the commit log.

> Use BIT(RDI_CFG0_ENABLE) to explicitly set or clear the bit depending
> on `enable`, matching camss-csid-680.c.
> 
> Fixes: 729fc005c8e2 ("media: qcom: camss: Split testgen, RDI and RX for CSID 170")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
> ---
>   drivers/media/platform/qcom/camss/camss-csid-gen2.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/qcom/camss/camss-csid-gen2.c b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
> index eadcb2f..804c8fe 100644
> --- a/drivers/media/platform/qcom/camss/camss-csid-gen2.c
> +++ b/drivers/media/platform/qcom/camss/camss-csid-gen2.c
> @@ -318,7 +318,10 @@ static void __csid_configure_rdi_stream(struct csid_device *csid, u8 enable, u8
>   	writel_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));
>   }
>   
> 

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

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

---
bod

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure
  2026-11-22 13:35   ` Robert Ijtsma
  (?)
  (?)
@ 2026-11-23 14:42   ` Bryan O'Donoghue
  -1 siblings, 0 replies; 23+ messages in thread
From: Bryan O'Donoghue @ 2026-11-23 14:42 UTC (permalink / raw)
  To: robertijtsma, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm

On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
> From: Robert Ijtsma <robertijtsma@gmail.com>
> 
> csid_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.
> 
> Fixes: c5af8db84c01 ("media: camss: Do vfe_get/vfe_put for csid on sm8250")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
> ---

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities
  2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  (?)
  (?)
@ 2026-11-23 14:53   ` Bryan O'Donoghue
  -1 siblings, 0 replies; 23+ messages in thread
From: Bryan O'Donoghue @ 2026-11-23 14:53 UTC (permalink / raw)
  To: robertijtsma, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm

On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
> From: Robert Ijtsma <robertijtsma@gmail.com>
> 
> msm_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.
> 
> Fixes: 4c98a5f57f90 ("media: camss: Add VFE files")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
> ---
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
  2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
  (?)
  (?)
@ 2026-11-23 14:57   ` Bryan O'Donoghue
  2026-11-23 15:11     ` Loic Poulain
  -1 siblings, 1 reply; 23+ messages in thread
From: Bryan O'Donoghue @ 2026-11-23 14:57 UTC (permalink / raw)
  To: robertijtsma, Vladimir Zapolskiy, Loic Poulain,
	Mauro Carvalho Chehab
  Cc: linux-media, linux-arm-msm

On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
> From: Robert Ijtsma <robertijtsma@gmail.com>
> 
> If 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.
> 
> Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
> Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>

I'm 90% sure someone has already submitted a change for this.

Anyway

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure
  2026-11-23 14:57   ` Bryan O'Donoghue
@ 2026-11-23 15:11     ` Loic Poulain
  0 siblings, 0 replies; 23+ messages in thread
From: Loic Poulain @ 2026-11-23 15:11 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: robertijtsma, Vladimir Zapolskiy, Mauro Carvalho Chehab,
	linux-media, linux-arm-msm

On Mon, Nov 23, 2026 at 3:57 PM Bryan O'Donoghue
<bryan.odonoghue@linaro.org> wrote:
>
> On 22/11/2026 13:35, Robert Ijtsma via B4 Relay wrote:
> > From: Robert Ijtsma <robertijtsma@gmail.com>
> >
> > If 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.
> >
> > Fixes: 0ac2586c410f ("media: camss: Add files which handle the video device nodes")
> > Signed-off-by: Robert Ijtsma <robertijtsma@gmail.com>
>
> I'm 90% sure someone has already submitted a change for this.

Yes, it was already submitted, refer to my previous reply.

>
> Anyway
>
> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2026-11-23 15:11 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 13:35 [PATCH 0/5] media: qcom: camss: fix VFE/CSID/video error handling and register bugs Robert Ijtsma via B4 Relay
2026-11-22 13:35 ` Robert Ijtsma
2026-11-22 13:35 ` [PATCH 1/5] media: qcom: camss: vfe-17x: check status1 for RDI SOF interrupts Robert Ijtsma via B4 Relay
2026-11-22 13:35   ` Robert Ijtsma
2026-11-23  9:58   ` Loic Poulain
2026-11-23 13:46   ` Bryan O'Donoghue
2026-11-22 13:35 ` [PATCH 2/5] media: qcom: camss: csid-gen2: fix RDI enable bit manipulation Robert Ijtsma via B4 Relay
2026-11-22 13:35   ` Robert Ijtsma
2026-11-23  9:48   ` Loic Poulain
2026-11-23 14:40   ` Bryan O'Donoghue
2026-11-22 13:35 ` [PATCH 3/5] media: qcom: camss: csid: release parent device on power-on failure Robert Ijtsma via B4 Relay
2026-11-22 13:35   ` Robert Ijtsma
2026-11-23  9:53   ` Loic Poulain
2026-11-23 14:42   ` Bryan O'Donoghue
2026-11-22 13:35 ` [PATCH 4/5] media: qcom: camss: vfe: destroy mutexes after unregistering entities Robert Ijtsma
2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
2026-11-23 10:00   ` Loic Poulain
2026-11-23 14:53   ` Bryan O'Donoghue
2026-11-22 13:35 ` [PATCH 5/5] media: qcom: camss: video: stop started subdevs on start_streaming failure Robert Ijtsma
2026-11-22 13:35   ` Robert Ijtsma via B4 Relay
2026-11-23 10:04   ` Loic Poulain
2026-11-23 14:57   ` Bryan O'Donoghue
2026-11-23 15:11     ` Loic Poulain

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.