Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Move the pic->pic_addroute() call from within pintr...



details:   https://anonhg.NetBSD.org/src/rev/dcd828dcffff
branches:  trunk
changeset: 993878:dcd828dcffff
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sat Oct 06 16:44:55 2018 +0000

description:
Move the pic->pic_addroute() call from within pintr.c:xen_pirq_alloc() to
intr.c:intr_establish_xname()

xen_pirq_alloc() now returns a vector value, as is intended by
the semantics of the call to the hypervisor, PHYSDEVOP_ASSIGN_VECTOR.

This also brings our usage closer to native.

diffstat:

 sys/arch/x86/x86/intr.c  |  23 +++++++++++++++++------
 sys/arch/xen/x86/pintr.c |  10 +++-------
 2 files changed, 20 insertions(+), 13 deletions(-)

diffs (99 lines):

diff -r dfc2aa673946 -r dcd828dcffff sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sat Oct 06 16:37:11 2018 +0000
+++ b/sys/arch/x86/x86/intr.c   Sat Oct 06 16:44:55 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.130 2018/09/20 05:08:45 cherry Exp $        */
+/*     $NetBSD: intr.c,v 1.131 2018/10/06 16:44:55 cherry Exp $        */
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.130 2018/09/20 05:08:45 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.131 2018/10/06 16:44:55 cherry Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -1264,7 +1264,7 @@
 #if NPCI > 0 || NISA > 0
        struct pintrhand *pih;
        intr_handle_t irq;
-       int evtchn;
+       int vector, evtchn;
 
        KASSERTMSG(legacy_irq == -1 || (0 <= legacy_irq && legacy_irq < NUM_XEN_IRQS),
            "bad legacy IRQ value: %d", legacy_irq);
@@ -1290,10 +1290,21 @@
        intrstr = intr_create_intrid(irq, pic, pin, intrstr_buf,
            sizeof(intrstr_buf));
 
-       evtchn = xen_pirq_alloc(&irq, type);
-       irq = (legacy_irq == -1) ? irq : legacy_irq; /* ISA compat */   
+       vector = xen_pirq_alloc(&irq, type);
+       irq = (legacy_irq == -1) ? irq : legacy_irq; /* ISA compat */
+
+#if NIOAPIC > 0
+       extern struct cpu_info phycpu_info_primary; /* XXX */
+       struct cpu_info *ci = &phycpu_info_primary;
+       pic->pic_addroute(pic, ci, pin, vector, type);
+#else
+
+#endif /* NIOAPIC */
+       evtchn = irq2port[vect2irq[vector]];
+       KASSERT(evtchn > 0);
+
        pih = pirq_establish(irq & 0xff, evtchn, handler, arg, level,
-           intrstr, xname);
+                            intrstr, xname);
        pih->pic_type = pic->pic_type;
        return pih;
 #endif /* NPCI > 0 || NISA > 0 */
diff -r dfc2aa673946 -r dcd828dcffff sys/arch/xen/x86/pintr.c
--- a/sys/arch/xen/x86/pintr.c  Sat Oct 06 16:37:11 2018 +0000
+++ b/sys/arch/xen/x86/pintr.c  Sat Oct 06 16:44:55 2018 +0000
@@ -103,7 +103,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.4 2018/10/06 16:37:11 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pintr.c,v 1.5 2018/10/06 16:44:55 cherry Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_xen.h"
@@ -165,7 +165,7 @@
        physdev_op_t op;
        int irq = *pirq;
 #if NIOAPIC > 0
-       extern struct cpu_info phycpu_info_primary; /* XXX */
+
        /*
         * The hypervisor has already allocated vectors and IRQs for the
         * devices. Reusing the same IRQ doesn't work because as we bind
@@ -179,7 +179,6 @@
         */
        static int xen_next_irq = 200;
        struct ioapic_softc *ioapic = ioapic_find(APIC_IRQ_APIC(*pirq));
-       struct pic *pic = &ioapic->sc_pic;
        int pin = APIC_IRQ_PIN(*pirq);
 
        if (*pirq & APIC_INT_VIA_APIC) {
@@ -207,8 +206,6 @@
                                (irq > 0 && irq < 16 &&
                                 vect2irq[op.u.irq_op.vector] == irq));
                        vect2irq[op.u.irq_op.vector] = irq;
-                       pic->pic_addroute(pic, &phycpu_info_primary, pin,
-                           op.u.irq_op.vector, type);
                }
                *pirq &= ~0xff;
                *pirq |= irq;
@@ -229,7 +226,6 @@
                        irq2port[irq] = bind_pirq_to_evtch(irq) + 1;
                }
        }
-       KASSERT(irq2port[irq] > 0);
-       return (irq2port[irq] - 1);
+       return (irq2vect[irq]);
 }
 #endif /* defined(DOM0OPS) || NPCI > 0 */



Home | Main Index | Thread Index | Old Index