Port-xen archive

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

Re: interrupt cleanup #2



Cherry G.Mathew <cherry%zyx.in@localhost> writes:


[...]

>
> More patches coming soon.
>

Here is the next patch, verbatim from the first series. It seems to
survive atf-run in /usr/tests

The next one will be a bit intrusive.

-- 
~cherry

# HG changeset patch
# User Cherry G. Mathew <cherry%NetBSD.org@localhost>
# Date 1535431400 0
#      Tue Aug 28 04:43:20 2018 +0000
# Branch cherry-xen
# Node ID 2e41d4c73ec0a65fe1c9c1a7f11a4f5b50b1be58
# Parent  6ae998799191511838071e5c522750d2643bf622
[mq]: 0002-introduce-hypervisor_prime_pirq_event

diff -r 6ae998799191 -r 2e41d4c73ec0 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c	Mon Aug 27 10:24:53 2018 +0000
+++ b/sys/arch/x86/x86/intr.c	Tue Aug 28 04:43:20 2018 +0000
@@ -1291,9 +1291,29 @@
 	    sizeof(intrstr_buf));
 
 	evtchn = xen_pirq_alloc(&irq, type);
-	pih = pirq_establish(irq & 0xff, evtchn, handler, arg, level,
-	    intrstr, xname);
+	pih = kmem_zalloc(sizeof(struct pintrhand),
+	    cold ? KM_NOSLEEP : KM_SLEEP);
+	if (pih == NULL) {
+		printf("%s: can't allocate handler info\n", __func__);
+		return NULL;
+	}
+
 	pih->pic_type = pic->pic_type;
+	pih->pirq = irq & 0xff; /* This is just a handle that xen gives us */	
+	pih->evtch = evtchn;
+	pih->func = handler;
+	pih->arg = arg;
+
+	extern int pirq_interrupt(void *);
+	if (event_set_handler(evtchn, pirq_interrupt, pih, level,
+		intrstr, xname) != 0) {
+		kmem_free(pih, sizeof(struct pintrhand));
+		return NULL;
+	}
+
+	hypervisor_prime_pirq_event(irq & 0xff,evtchn);
+	hypervisor_enable_event(evtchn);
+
 	return pih;
 #endif /* NPCI > 0 || NISA > 0 */
 
diff -r 6ae998799191 -r 2e41d4c73ec0 sys/arch/xen/include/hypervisor.h
--- a/sys/arch/xen/include/hypervisor.h	Mon Aug 27 10:24:53 2018 +0000
+++ b/sys/arch/xen/include/hypervisor.h	Tue Aug 28 04:43:20 2018 +0000
@@ -130,6 +130,7 @@
 struct intrframe;
 struct cpu_info;
 void do_hypervisor_callback(struct intrframe *regs);
+void hypervisor_prime_pirq_event(int, unsigned int);
 void hypervisor_enable_event(unsigned int);
 
 extern int xen_version;
diff -r 6ae998799191 -r 2e41d4c73ec0 sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c	Mon Aug 27 10:24:53 2018 +0000
+++ b/sys/arch/xen/xen/evtchn.c	Tue Aug 28 04:43:20 2018 +0000
@@ -1006,6 +1006,25 @@
 }
 
 void
+hypervisor_prime_pirq_event(int pirq, unsigned int evtch)
+{
+#if NPCI > 0 || NISA > 0
+	physdev_op_t physdev_op;
+	physdev_op.cmd = PHYSDEVOP_IRQ_STATUS_QUERY;
+	physdev_op.u.irq_status_query.irq = pirq;
+	if (HYPERVISOR_physdev_op(&physdev_op) < 0)
+		panic("HYPERVISOR_physdev_op(PHYSDEVOP_IRQ_STATUS_QUERY)");
+	if (physdev_op.u.irq_status_query.flags &
+	    PHYSDEVOP_IRQ_NEEDS_UNMASK_NOTIFY) {
+		pirq_needs_unmask_notify[evtch >> 5] |= (1 << (evtch & 0x1f));
+#ifdef IRQ_DEBUG
+		printf("pirq %d needs notify\n", pirq);
+#endif
+	}
+#endif /* NPCI > 0 || NISA > 0 */
+}
+
+void
 hypervisor_enable_event(unsigned int evtch)
 {
 #ifdef IRQ_DEBUG


Home | Main Index | Thread Index | Old Index