public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] irqchip: armada-370-xp: fix MSI race condition
Date: Mon, 25 Nov 2013 17:26:45 +0100	[thread overview]
Message-ID: <1385396807-19027-3-git-send-email-thomas.petazzoni@free-electrons.com> (raw)
In-Reply-To: <1385396807-19027-1-git-send-email-thomas.petazzoni@free-electrons.com>

From: Lior Amsalem <alior@marvell.com>

In the Armada 370/XP driver, when we receive an IRQ 1, we read the
list of doorbells that caused the interrupt from register
ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS. This gives the list of MSIs that
were generated. However, instead of acknowledging only the MSIs that
were generated, we acknowledge *all* the MSIs, by writing
~MSI_DOORBELL_MASK in the ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS register.

This creates a race condition: if a new MSI that isn't part of the
ones read into the temporary "msimask" variable is fired before we
acknowledge all MSIs, then we will simply loose it.

It is important to mention that this ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS
register has the following behavior: "A CPU write of 0 clears the bits
in this field. A CPU write of 1 has no effect". This is what allows us
to simply write ~msimask to acknoledge the handled MSIs.

Notice that the same problem is present in the IPI implementation, but
it is fixed as a separate patch, so that this IPI fix can be pushed to
older stable versions as appropriate (all the way to 3.8), while the
MSI code only appeared in 3.13.

Signed-off-by: Lior Amsalem <alior@marvell.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
This is only needed for 3.13, since the MSI support didn't exist in
earlier kernel versions.
---
 drivers/irqchip/irq-armada-370-xp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index f5e49a2..3fac063 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -381,7 +381,7 @@ armada_370_xp_handle_irq(struct pt_regs *regs)
 						ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS)
 				& PCI_MSI_DOORBELL_MASK;
 
-			writel(~PCI_MSI_DOORBELL_MASK, per_cpu_int_base +
+			writel(~msimask, per_cpu_int_base +
 			       ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS);
 
 			for (msinr = PCI_MSI_DOORBELL_START;
-- 
1.8.1.2

  parent reply	other threads:[~2013-11-25 16:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 16:26 [PATCH 0/4] ARM: mvebu: misc important fixes Thomas Petazzoni
2013-11-25 16:26 ` [PATCH 1/4] irqchip: armada-370-xp: fix IPI race condition Thomas Petazzoni
2013-11-25 18:17   ` Jason Cooper
2013-12-12 22:23   ` Thomas Petazzoni
2013-12-13 16:38     ` Jason Cooper
2013-12-14 17:35       ` Thomas Petazzoni
2013-11-25 16:26 ` Thomas Petazzoni [this message]
2013-11-25 18:18   ` [PATCH 2/4] irqchip: armada-370-xp: fix MSI " Jason Cooper
2013-11-25 16:26 ` [PATCH 3/4] ARM: mvebu: use the virtual CPU registers to access coherency registers Thomas Petazzoni
2013-11-25 18:23   ` Jason Cooper
2013-11-25 16:26 ` [PATCH 4/4] ARM: mvebu: re-enable PCIe on Armada 370 DB Thomas Petazzoni
2013-11-25 18:25   ` Jason Cooper

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=1385396807-19027-3-git-send-email-thomas.petazzoni@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.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