From: Bryan O'Donoghue <bod@kernel.org>
To: Hitesh Patel <hitesh@ebytelogic.com>, linux-media@vger.kernel.org
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
Loic Poulain <loic.poulain@oss.qualcomm.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Gjorgji Rosikopulos <gjorgji.rosikopulos@oss.qualcomm.com>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
ravi@ebytelogic.com
Subject: Re: [PATCH v3 3/5] media: qcom: camss: vfe: Fix VFE reset while another line is streaming
Date: Mon, 28 Sep 2026 09:49:20 +0100 [thread overview]
Message-ID: <cd778fa5-6382-4378-af18-1e19cf0d6c9b@kernel.org> (raw)
In-Reply-To: <20260928064336.272659-4-hitesh@ebytelogic.com>
On 28/09/2026 07:43, Hitesh Patel wrote:
> @@ -814,6 +814,7 @@ static int vfe_disable_output(struct vfe_line *line)
> struct vfe_output *output = &line->output;
> unsigned long flags;
> unsigned int i;
> + bool last;
>
> spin_lock_irqsave(&vfe->output_lock, flags);
> for (i = 0; i < output->wm_num; i++)
> @@ -821,6 +822,13 @@ static int vfe_disable_output(struct vfe_line *line)
> output->gen2.active_num = 0;
> spin_unlock_irqrestore(&vfe->output_lock, flags);
>
> + mutex_lock(&vfe->stream_lock);
> + last = vfe->stream_count == 1;
> + mutex_unlock(&vfe->stream_lock);
> +
> + if (!last)
> + return 0;
> +
NAK.
This can't be correct, in fact its very racy and will break. Here is the
existing code.
static int vfe_disable_output(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
struct vfe_output *output = &line->output;
unsigned long flags;
unsigned int i;
spin_lock_irqsave(&vfe->output_lock, flags);
for (i = 0; i < output->wm_num; i++)
vfe->res->hw_ops->vfe_wm_stop(vfe, output->wm_idx[i]);
output->gen2.active_num = 0;
spin_unlock_irqrestore(&vfe->output_lock, flags);
return vfe_reset(vfe);
}
/*
* vfe_disable - Disable streaming on VFE line
* @line: VFE line
*
* Return 0 on success or a negative error code otherwise
*/
int vfe_disable(struct vfe_line *line)
{
struct vfe_device *vfe = to_vfe(line);
int ret;
ret = vfe_disable_output(line);
if (ret)
goto error;
vfe_put_output(line);
mutex_lock(&vfe->stream_lock);
vfe->stream_count--;
mutex_unlock(&vfe->stream_lock);
error:
return ret;
}
Here's how
stream_count = 2;
thread0:
vfe_disable()
vfe_disable_output()
mutex_lock();
last = stream_count == 1; //false
mutex_unlock();
return;
thread1:
vfe_disable()
vfe_disable_output()
mutex_lock();
last = stream_count == 1; //false
mutex_unlock();
return;
thread0:
vfe_disable()
mutex_lock();
stream_count--; // => stream_count = 1;
mutex_unlock();
thread1:
vfe_disable()
mutex_lock();
stream_count--; // => stream_count = 0;
mutex_unlock();
vfe_reset() is never called.
this->
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c
b/drivers/media/platform/qcom/camss/camss-vfe.c
index 34e4319d8f80c..3dafd5d778630 100644
--- a/drivers/media/platform/qcom/camss/camss-vfe.c
+++ b/drivers/media/platform/qcom/camss/camss-vfe.c
@@ -828,7 +828,7 @@ static int vfe_disable_output(struct vfe_line *line)
output->gen2.active_num = 0;
spin_unlock_irqrestore(&vfe->output_lock, flags);
- return vfe_reset(vfe);
+ return 0;
}
/*
@@ -850,7 +850,8 @@ int vfe_disable(struct vfe_line *line)
mutex_lock(&vfe->stream_lock);
- vfe->stream_count--;
+ if (--vfe->stream_count == 0)
+ ret = vfe_reset(vfe);
mutex_unlock(&vfe->stream_lock);
---
bod
next prev parent reply other threads:[~2026-09-28 8:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 6:43 [PATCH v3 0/5] media: qcom: camss: fixes for several cameras behind a CSI-2 bridge Hitesh Patel
2026-09-28 6:43 ` [PATCH v3 1/5] media: qcom: camss: vfe-17x: Fix write master buffer done being dropped Hitesh Patel
2026-09-28 7:44 ` Loic Poulain
2026-09-28 8:27 ` Bryan O'Donoghue
2026-09-28 6:43 ` [PATCH v3 2/5] media: qcom: camss: vfe-17x: Fix write master selection for RDI lines Hitesh Patel
2026-09-28 7:50 ` Loic Poulain
2026-09-28 8:29 ` Bryan O'Donoghue
2026-09-28 6:43 ` [PATCH v3 3/5] media: qcom: camss: vfe: Fix VFE reset while another line is streaming Hitesh Patel
2026-09-28 7:55 ` Loic Poulain
2026-09-28 8:49 ` Bryan O'Donoghue [this message]
2026-09-28 10:21 ` Hitesh Patel
2026-09-28 6:43 ` [PATCH v3 4/5] media: qcom: camss: Take the link frequency from the CSI-2 transmitter Hitesh Patel
2026-09-28 8:06 ` Loic Poulain
2026-09-28 6:43 ` [PATCH v3 5/5] media: qcom: camss: Create the source to CSIPHY link per endpoint Hitesh Patel
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=cd778fa5-6382-4378-af18-1e19cf0d6c9b@kernel.org \
--to=bod@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=gjorgji.rosikopulos@oss.qualcomm.com \
--cc=hitesh@ebytelogic.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mchehab@kernel.org \
--cc=ravi@ebytelogic.com \
--cc=vladimir.zapolskiy@linaro.org \
/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®