Module Name: src Committed By: cherry Date: Sat Oct 6 16:44:55 UTC 2018
Modified Files: src/sys/arch/x86/x86: intr.c src/sys/arch/xen/x86: pintr.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.130 -r1.131 src/sys/arch/x86/x86/intr.c cvs rdiff -u -r1.4 -r1.5 src/sys/arch/xen/x86/pintr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.130 src/sys/arch/x86/x86/intr.c:1.131 --- src/sys/arch/x86/x86/intr.c:1.130 Thu Sep 20 05:08:45 2018 +++ src/sys/arch/x86/x86/intr.c Sat Oct 6 16:44:55 2018 @@ -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 @@ intr_establish_xname(int legacy_irq, str #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 @@ intr_establish_xname(int legacy_irq, str 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 */ Index: src/sys/arch/xen/x86/pintr.c diff -u src/sys/arch/xen/x86/pintr.c:1.4 src/sys/arch/xen/x86/pintr.c:1.5 --- src/sys/arch/xen/x86/pintr.c:1.4 Sat Oct 6 16:37:11 2018 +++ src/sys/arch/xen/x86/pintr.c Sat Oct 6 16:44:55 2018 @@ -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 @@ xen_pirq_alloc(intr_handle_t *pirq, int 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 @@ xen_pirq_alloc(intr_handle_t *pirq, int */ 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 @@ retry: (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 @@ retry: irq2port[irq] = bind_pirq_to_evtch(irq) + 1; } } - KASSERT(irq2port[irq] > 0); - return (irq2port[irq] - 1); + return (irq2vect[irq]); } #endif /* defined(DOM0OPS) || NPCI > 0 */