linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: fsl: qbman: avoid race in clearing QMan interrupt
@ 2018-12-21 14:41 Madalin Bucur
  2019-01-18 22:56 ` Li Yang
  0 siblings, 1 reply; 2+ messages in thread
From: Madalin Bucur @ 2018-12-21 14:41 UTC (permalink / raw)
  To: leoyang.li, linux-arm-kernel
  Cc: Madalin Bucur, netdev, roy.pledge, linux-kernel, linuxppc-dev, davem

By clearing all interrupt sources, not only those that
already occurred, the existing code may acknowledge by
mistake interrupts that occurred after the code checks
for them.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
---
 drivers/soc/fsl/qbman/qman.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 52c153cd795a..636f83f781f5 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1143,18 +1143,19 @@ static void qm_mr_process_task(struct work_struct *work);
 static irqreturn_t portal_isr(int irq, void *ptr)
 {
 	struct qman_portal *p = ptr;
-
-	u32 clear = QM_DQAVAIL_MASK | p->irq_sources;
 	u32 is = qm_in(&p->p, QM_REG_ISR) & p->irq_sources;
+	u32 clear = 0;
 
 	if (unlikely(!is))
 		return IRQ_NONE;
 
 	/* DQRR-handling if it's interrupt-driven */
-	if (is & QM_PIRQ_DQRI)
+	if (is & QM_PIRQ_DQRI) {
 		__poll_portal_fast(p, QMAN_POLL_LIMIT);
+		clear = QM_DQAVAIL_MASK | QM_PIRQ_DQRI;
+	}
 	/* Handling of anything else that's interrupt-driven */
-	clear |= __poll_portal_slow(p, is);
+	clear |= __poll_portal_slow(p, is) & QM_PIRQ_SLOW;
 	qm_out(&p->p, QM_REG_ISR, clear);
 	return IRQ_HANDLED;
 }
-- 
2.1.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] soc: fsl: qbman: avoid race in clearing QMan interrupt
  2018-12-21 14:41 [PATCH] soc: fsl: qbman: avoid race in clearing QMan interrupt Madalin Bucur
@ 2019-01-18 22:56 ` Li Yang
  0 siblings, 0 replies; 2+ messages in thread
From: Li Yang @ 2019-01-18 22:56 UTC (permalink / raw)
  To: madalin.bucur
  Cc: Netdev, Roy Pledge, lkml, linuxppc-dev, David Miller,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Fri, Dec 21, 2018 at 8:43 AM Madalin Bucur <madalin.bucur@nxp.com> wrote:
>
> By clearing all interrupt sources, not only those that
> already occurred, the existing code may acknowledge by
> mistake interrupts that occurred after the code checks
> for them.
>
> Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
> Signed-off-by: Roy Pledge <roy.pledge@nxp.com>

Applied for fix.  Thanks.  Suggest to forward it to
stable@vger.kernel.org after merged into Linus' tree.  It would be
better to add "Cc: stable@vger.kernel.org" in the commit message for
similar patches next time.

Regards,
Leo

> ---
>  drivers/soc/fsl/qbman/qman.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
> index 52c153cd795a..636f83f781f5 100644
> --- a/drivers/soc/fsl/qbman/qman.c
> +++ b/drivers/soc/fsl/qbman/qman.c
> @@ -1143,18 +1143,19 @@ static void qm_mr_process_task(struct work_struct *work);
>  static irqreturn_t portal_isr(int irq, void *ptr)
>  {
>         struct qman_portal *p = ptr;
> -
> -       u32 clear = QM_DQAVAIL_MASK | p->irq_sources;
>         u32 is = qm_in(&p->p, QM_REG_ISR) & p->irq_sources;
> +       u32 clear = 0;
>
>         if (unlikely(!is))
>                 return IRQ_NONE;
>
>         /* DQRR-handling if it's interrupt-driven */
> -       if (is & QM_PIRQ_DQRI)
> +       if (is & QM_PIRQ_DQRI) {
>                 __poll_portal_fast(p, QMAN_POLL_LIMIT);
> +               clear = QM_DQAVAIL_MASK | QM_PIRQ_DQRI;
> +       }
>         /* Handling of anything else that's interrupt-driven */
> -       clear |= __poll_portal_slow(p, is);
> +       clear |= __poll_portal_slow(p, is) & QM_PIRQ_SLOW;
>         qm_out(&p->p, QM_REG_ISR, clear);
>         return IRQ_HANDLED;
>  }
> --
> 2.1.0
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-01-18 22:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-21 14:41 [PATCH] soc: fsl: qbman: avoid race in clearing QMan interrupt Madalin Bucur
2019-01-18 22:56 ` Li Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).