public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Parlane <andrewp@carallon.com>
To: ecos-devel@ecos.sourceware.org
Subject: Nested interrupts on ARM
Date: Fri, 18 Oct 2013 15:00:00 -0000	[thread overview]
Message-ID: <52614D10.1040801@carallon.com> (raw)

I found a bug with our product which boils down to a high priority 
interrupt not being called fast enough sometimes because we are in a 
different ISR (lower priority).  We have 
CYGSEM_HAL_COMMON_INTERRUPTS_ALLOW_NESTING on, but looking through the 
code this does very little on ARM chips (just sets the min stack size).

Looking at packages/hal/arm/arch/current/src/vectors.S it looks like the 
framework for nested interrupts is in place, but during an interrupt the 
IRQ bit in the CPSR register is never cleared. I wrote the following 
patch, which enables IRQs runs the ISR and disables IRQs again. This 
works, and I can now see nested interrupts working, however I'm now 
seeing it take 30us to get into my high priority ISR when I'm already in 
an ISR, rather than the 7us when I'm not already in an ISR.

So my questions:
1) Does my patch make sense?
2) Any idea why this wasn't already in place? It seems like something so 
simple must have been left out for a reason.
3) Any idea on the 30us to get into my ISR? This may be the first ISR 
disabling IRQs for a bit, I need to look more into this area.

Thanks,
Andrew Parlane
Carallon Ltd.


--- a/packages/hal/arm/arch/current/src/vectors.S
+++ b/packages/hal/arm/arch/current/src/vectors.S
@@ -914,7 +914,14 @@ IRQ:
  #endif // CYGIMP_HAL_COMMON_INTERRUPTS_IGNORE_SPURIOUS
          b       spurious_IRQ

-10:     ldr     r1,.hal_interrupt_data
+10:
+        // re-enable IRQs so we can have nested interrutps
+        ARM_MODE(r1,10)
+        mrs     r1,cpsr
+        bic     r1,r1,#CPSR_IRQ_DISABLE
+        msr     cpsr, r1
+
+        ldr     r1,.hal_interrupt_data
          ldr     r1,[r1,v1,lsl #2]       // handler data
          ldr     r2,.hal_interrupt_handlers
          ldr     v3,[r2,v1,lsl #2]       // handler (indexed by vector #)
@@ -926,6 +933,11 @@ IRQ:
          mov     lr,pc                   // invoke handler (call indirect
          bx      v3                      // thru v3)

+        // disable IRQs
+        mrs     r1,cpsr
+        orr     r1,r1,#CPSR_IRQ_DISABLE
+        msr     cpsr, r1
+
  spurious_IRQ:

                 reply	other threads:[~2013-10-18 15:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=52614D10.1040801@carallon.com \
    --to=andrewp@carallon.com \
    --cc=ecos-devel@ecos.sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).