linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: vic: re-read status register before dispatching each IRQ handler
Date: Thu, 5 Apr 2012 10:23:54 +0100	[thread overview]
Message-ID: <20120405092354.GA22446@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <ADE657CA350FB648AAC2C43247A983F002069840A167@AUSP01VMBX24.collaborationhost.net>

On Wed, Apr 04, 2012 at 08:07:34PM +0100, H Hartley Sweeten wrote:
> On Wednesday, April 04, 2012 3:05 AM, Will Deacon wrote:
> > diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
> > index 7a66311..6b1de5d 100644
> > --- a/arch/arm/common/vic.c
> > +++ b/arch/arm/common/vic.c
> > @@ -435,11 +435,9 @@ static int handle_one_vic(struct vic_device *vic, struct pt_regs *regs)
> >  	u32 stat, irq;
> >  	int handled = 0;
> >  
> > -	stat = readl_relaxed(vic->base + VIC_IRQ_STATUS);
> > -	while (stat) {
> > +	while ((stat = readl_relaxed(vic->base + VIC_IRQ_STATUS))) {
> >  		irq = ffs(stat) - 1;
> >  		handle_IRQ(irq_find_mapping(vic->domain, irq), regs);
> > -		stat &= ~(1 << irq);
> >  		handled = 1;
> >  	}
> 
> You probably should fix the comment above the function:

Sorry, missed that. v2 below.

Thanks,

Will


Author: Will Deacon <will.deacon@arm.com>
Date:   Wed Apr 4 10:13:49 2012 +0100

    ARM: vic: re-read status register before dispatching each IRQ handler
    
    handle_IRQ may briefly cause interrupts to be re-enabled during soft IRQ
    processing on the exit path, leading to nested handling of VIC interrupts.
    
    Since the current code does not re-read the VIC_IRQ_STATUS register, this
    can lead to multiple invocations of the same interrupt handler and
    spurious interrupts to be reported.
    
    This patch changes the VIC interrupt dispatching code to re-read the
    status register each time, avoiding duplicate invocations of the same
    handler.
    
    Acked-and-tested-by: H Hartley Sweeten <hsweeten@visionengravers.com>
    Reviewed-by: Jamie Iles <jamie@jamieiles.com>
    Signed-off-by: Will Deacon <will.deacon@arm.com>

diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index 7a66311..7e288f9 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -427,19 +427,18 @@ int __init vic_of_init(struct device_node *node, struct device_node *parent)
 
 /*
  * Handle each interrupt in a single VIC.  Returns non-zero if we've
- * handled at least one interrupt.  This does a single read of the
- * status register and handles all interrupts in order from LSB first.
+ * handled at least one interrupt.  This reads the status register
+ * before handling each interrupt, which is necessary given that
+ * handle_IRQ may briefly re-enable interrupts for soft IRQ handling.
  */
 static int handle_one_vic(struct vic_device *vic, struct pt_regs *regs)
 {
        u32 stat, irq;
        int handled = 0;
 
-       stat = readl_relaxed(vic->base + VIC_IRQ_STATUS);
-       while (stat) {
+       while ((stat = readl_relaxed(vic->base + VIC_IRQ_STATUS))) {
                irq = ffs(stat) - 1;
                handle_IRQ(irq_find_mapping(vic->domain, irq), regs);
-               stat &= ~(1 << irq);
                handled = 1;
        }

      reply	other threads:[~2012-04-05  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-04 10:05 [PATCH] ARM: vic: re-read status register before dispatching each IRQ handler Will Deacon
2012-04-04 19:07 ` H Hartley Sweeten
2012-04-05  9:23   ` Will Deacon [this message]

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=20120405092354.GA22446@mudshark.cambridge.arm.com \
    --to=will.deacon@arm.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;
as well as URLs for NNTP newsgroup(s).