enable_irq() and disable_irq() are reference counted, so we must make sure
that each enable_irq() is always paired with a single disable_irq(). If we
call disable_irq() twice followed by just a single enable_irq(), the IRQ
will remain disabled forever.
For the error handling path in qcom_q6v5_wait_for_start(), disable_irq()
will end up being called twice, because disable_irq() also happens in
qcom_q6v5_unprepare() when rolling back the call to qcom_q6v5_prepare().
Fix this by dropping disable_irq() in qcom_q6v5_wait_for_start(). Since
qcom_q6v5_prepare() is the function that calls enable_irq(), it makes more
sense to have the rollback handled always by qcom_q6v5_unprepare().
Fixes: 3b415c8fb263 ("remoteproc: q6v5: Extract common resource handling")
Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
---
drivers/remoteproc/qcom_q6v5.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c
index 4ee5e67a9f03f5f766f04396b9a3e45f77293764..769c6d6d6a731672eca9f960b05c68f6d4d77af2 100644
--- a/drivers/remoteproc/qcom_q6v5.c
+++ b/drivers/remoteproc/qcom_q6v5.c
@@ -156,9 +156,6 @@ int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout)
int ret;
ret = wait_for_completion_timeout(&q6v5->start_done, timeout);
- if (!ret)
- disable_irq(q6v5->handover_irq);
-
return !ret ? -ETIMEDOUT : 0;
}
EXPORT_SYMBOL_GPL(qcom_q6v5_wait_for_start);
--
2.50.1
On Tue, Aug 19, 2025 at 01:08:02PM +0200, Stephan Gerhold wrote: > enable_irq() and disable_irq() are reference counted, so we must make sure > that each enable_irq() is always paired with a single disable_irq(). If we > call disable_irq() twice followed by just a single enable_irq(), the IRQ > will remain disabled forever. > > For the error handling path in qcom_q6v5_wait_for_start(), disable_irq() > will end up being called twice, because disable_irq() also happens in > qcom_q6v5_unprepare() when rolling back the call to qcom_q6v5_prepare(). > > Fix this by dropping disable_irq() in qcom_q6v5_wait_for_start(). Since > qcom_q6v5_prepare() is the function that calls enable_irq(), it makes more > sense to have the rollback handled always by qcom_q6v5_unprepare(). > > Fixes: 3b415c8fb263 ("remoteproc: q6v5: Extract common resource handling") Didn't earlier versions also have the same behaviour? > Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org> > --- > drivers/remoteproc/qcom_q6v5.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c > index 4ee5e67a9f03f5f766f04396b9a3e45f77293764..769c6d6d6a731672eca9f960b05c68f6d4d77af2 100644 > --- a/drivers/remoteproc/qcom_q6v5.c > +++ b/drivers/remoteproc/qcom_q6v5.c > @@ -156,9 +156,6 @@ int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout) > int ret; > > ret = wait_for_completion_timeout(&q6v5->start_done, timeout); > - if (!ret) > - disable_irq(q6v5->handover_irq); > - > return !ret ? -ETIMEDOUT : 0; > } > EXPORT_SYMBOL_GPL(qcom_q6v5_wait_for_start); > > -- > 2.50.1 > -- With best wishes Dmitry
On Tue, Aug 19, 2025 at 02:44:26PM +0300, Dmitry Baryshkov wrote: > On Tue, Aug 19, 2025 at 01:08:02PM +0200, Stephan Gerhold wrote: > > enable_irq() and disable_irq() are reference counted, so we must make sure > > that each enable_irq() is always paired with a single disable_irq(). If we > > call disable_irq() twice followed by just a single enable_irq(), the IRQ > > will remain disabled forever. > > > > For the error handling path in qcom_q6v5_wait_for_start(), disable_irq() > > will end up being called twice, because disable_irq() also happens in > > qcom_q6v5_unprepare() when rolling back the call to qcom_q6v5_prepare(). > > > > Fix this by dropping disable_irq() in qcom_q6v5_wait_for_start(). Since > > qcom_q6v5_prepare() is the function that calls enable_irq(), it makes more > > sense to have the rollback handled always by qcom_q6v5_unprepare(). > > > > Fixes: 3b415c8fb263 ("remoteproc: q6v5: Extract common resource handling") > > Didn't earlier versions also have the same behaviour? > I don't think so. The "extracted common resource handling" came from qcom_q6v5_pil.c, but q6v5_start() just had most of this code inline in a single function [1]. The handling of enable_irq()/disable_irq() through the goto labels looks correct there. Thanks, Stephan [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/remoteproc/qcom_q6v5_pil.c?id=0e622e80191e75c99b6ecc265c140a37d81e7a63#n795
On Tue, Aug 19, 2025 at 04:55:09PM +0200, Stephan Gerhold wrote: > On Tue, Aug 19, 2025 at 02:44:26PM +0300, Dmitry Baryshkov wrote: > > On Tue, Aug 19, 2025 at 01:08:02PM +0200, Stephan Gerhold wrote: > > > enable_irq() and disable_irq() are reference counted, so we must make sure > > > that each enable_irq() is always paired with a single disable_irq(). If we > > > call disable_irq() twice followed by just a single enable_irq(), the IRQ > > > will remain disabled forever. > > > > > > For the error handling path in qcom_q6v5_wait_for_start(), disable_irq() > > > will end up being called twice, because disable_irq() also happens in > > > qcom_q6v5_unprepare() when rolling back the call to qcom_q6v5_prepare(). > > > > > > Fix this by dropping disable_irq() in qcom_q6v5_wait_for_start(). Since > > > qcom_q6v5_prepare() is the function that calls enable_irq(), it makes more > > > sense to have the rollback handled always by qcom_q6v5_unprepare(). > > > > > > Fixes: 3b415c8fb263 ("remoteproc: q6v5: Extract common resource handling") > > > > Didn't earlier versions also have the same behaviour? > > > > I don't think so. The "extracted common resource handling" came from > qcom_q6v5_pil.c, but q6v5_start() just had most of this code inline in a > single function [1]. The handling of enable_irq()/disable_irq() through > the goto labels looks correct there. Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> -- With best wishes Dmitry
© 2016 - 2025 Red Hat, Inc.