Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/pic Fix lost interrupt. (2/2)



details:   https://anonhg.NetBSD.org/src/rev/47cf023a7328
branches:  trunk
changeset: 757471:47cf023a7328
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Tue Aug 31 14:33:41 2010 +0000

description:
Fix lost interrupt. (2/2)
  + It is likely to lose sight of interrupt when the interrupt of irq_base
    that is smaller than the same at the level is generated if PIC_MAXSOURCES
    is 33 or more.

diffstat:

 sys/arch/arm/pic/pic.c |  30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diffs (67 lines):

diff -r 7c15f799ea76 -r 47cf023a7328 sys/arch/arm/pic/pic.c
--- a/sys/arch/arm/pic/pic.c    Tue Aug 31 14:23:27 2010 +0000
+++ b/sys/arch/arm/pic/pic.c    Tue Aug 31 14:33:41 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic.c,v 1.5 2010/08/31 14:23:27 kiyohara Exp $ */
+/*     $NetBSD: pic.c,v 1.6 2010/08/31 14:33:41 kiyohara Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.5 2010/08/31 14:23:27 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic.c,v 1.6 2010/08/31 14:33:41 kiyohara Exp $");
 
 #define _INTR_PRIVATE
 #include <sys/param.h>
@@ -193,6 +193,7 @@
        size_t irq_base;
 #if PIC_MAXSOURCES > 32
        size_t irq_count;
+       int poi = 0;            /* Possibility of interrupting */
 #endif
        uint32_t pending_irqs;
        uint32_t blocked_irqs;
@@ -214,14 +215,20 @@
                if (pending_irqs == 0) {
 #if PIC_MAXSOURCES > 32
                        irq_count += 32;
-                       if (__predict_true(irq_count >= pic->pic_maxsources))
-                               break;
-                       irq_base += 32;
-                       ipending++;
-                       iblocked++;
-                       if (irq_base >= pic->pic_maxsources) {
+                       if (__predict_true(irq_count >= pic->pic_maxsources)) {
+                               if (!poi)
+                                       /*Interrupt at this level was handled.*/
+                                       break;
+                               irq_base = 0;
+                               irq_count = 0;
+                               poi = 0;
                                ipending = pic->pic_pending_irqs;
                                iblocked = pic->pic_blocked_irqs;
+                       } else {
+                               irq_base += 32;
+                               ipending++;
+                               iblocked++;
+                               KASSERT(irq_base <= pic->pic_maxsources);
                        }
                        continue;
 #else
@@ -240,6 +247,13 @@
                                cpsie(I32_bit);
                                pic_dispatch(is, frame);
                                cpsid(I32_bit);
+#if PIC_MAXSOURCES > 32
+                               /*
+                                * There is a possibility of interrupting
+                                * from cpsie() to cpsid().
+                                */
+                               poi = 1;
+#endif
                                blocked_irqs |= __BIT(irq);
                        } else {
                                KASSERT(0);



Home | Main Index | Thread Index | Old Index