Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen Restore de EOI mechanism for pirq, using the ne...
details: https://anonhg.NetBSD.org/src/rev/9e5b39926f0a
branches: trunk
changeset: 366227:9e5b39926f0a
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu May 19 09:54:27 2022 +0000
description:
Restore de EOI mechanism for pirq, using the newer hypervisor interface.
It is needed.
Hopefully fixes kern/56291, kern/56793, kern/55667
diffstat:
sys/arch/xen/include/hypervisor.h | 6 ++-
sys/arch/xen/x86/hypervisor_machdep.c | 7 ++-
sys/arch/xen/xen/evtchn.c | 61 ++++++++++++++++++++++++++++++----
3 files changed, 63 insertions(+), 11 deletions(-)
diffs (179 lines):
diff -r fe43f9f47180 -r 9e5b39926f0a sys/arch/xen/include/hypervisor.h
--- a/sys/arch/xen/include/hypervisor.h Thu May 19 07:41:26 2022 +0000
+++ b/sys/arch/xen/include/hypervisor.h Thu May 19 09:54:27 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor.h,v 1.52 2020/05/02 16:44:36 bouyer Exp $ */
+/* $NetBSD: hypervisor.h,v 1.53 2022/05/19 09:54:27 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -159,6 +159,10 @@
struct intrframe;
struct cpu_info;
void do_hypervisor_callback(struct intrframe *regs);
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+void hypervisor_prime_pirq_event(int, unsigned int);
+void hypervisor_ack_pirq_event(unsigned int);
+#endif /* XENPV && ( NPCI > 0 || NISA > 0 ) */
extern int xen_version;
#define XEN_MAJOR(x) (((x) & 0xffff0000) >> 16)
diff -r fe43f9f47180 -r 9e5b39926f0a sys/arch/xen/x86/hypervisor_machdep.c
--- a/sys/arch/xen/x86/hypervisor_machdep.c Thu May 19 07:41:26 2022 +0000
+++ b/sys/arch/xen/x86/hypervisor_machdep.c Thu May 19 09:54:27 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hypervisor_machdep.c,v 1.39 2020/05/02 16:44:36 bouyer Exp $ */
+/* $NetBSD: hypervisor_machdep.c,v 1.40 2022/05/19 09:54:27 bouyer Exp $ */
/*
*
@@ -54,7 +54,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.39 2020/05/02 16:44:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hypervisor_machdep.c,v 1.40 2022/05/19 09:54:27 bouyer Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -388,6 +388,9 @@
{
KASSERT(args == NULL);
hypervisor_unmask_event(port);
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+ hypervisor_ack_pirq_event(port);
+#endif /* NPCI > 0 || NISA > 0 */
}
void
diff -r fe43f9f47180 -r 9e5b39926f0a sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Thu May 19 07:41:26 2022 +0000
+++ b/sys/arch/xen/xen/evtchn.c Thu May 19 09:54:27 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: evtchn.c,v 1.96 2020/11/15 14:01:06 bouyer Exp $ */
+/* $NetBSD: evtchn.c,v 1.97 2022/05/19 09:54:27 bouyer Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.96 2020/11/15 14:01:06 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.97 2022/05/19 09:54:27 bouyer Exp $");
#include "opt_xen.h"
#include "isa.h"
@@ -105,11 +105,13 @@
static int virq_to_evtch[NR_VIRQS];
-#if NPCI > 0 || NISA > 0
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
/* event-channel <-> PIRQ mapping */
static int pirq_to_evtch[NR_PIRQS];
+/* PIRQ needing notify */
+static int evtch_to_pirq_eoi[NR_EVENT_CHANNELS];
int pirq_interrupt(void *);
-#endif
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
static void xen_evtchn_mask(struct pic *, int);
static void xen_evtchn_unmask(struct pic *, int);
@@ -235,11 +237,13 @@
for (i = 0; i < NR_VIRQS; i++)
virq_to_evtch[i] = -1;
-#if NPCI > 0 || NISA > 0
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
/* No PIRQ -> event mappings. */
for (i = 0; i < NR_PIRQS; i++)
pirq_to_evtch[i] = -1;
-#endif
+ for (i = 0; i < NR_EVENT_CHANNELS; i++)
+ evtch_to_pirq_eoi[i] = -1;
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
/* No event-channel are 'live' right now. */
for (i = 0; i < NR_EVENT_CHANNELS; i++) {
@@ -388,6 +392,9 @@
}
x86_disable_intr();
hypervisor_unmask_event(evtch);
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+ hypervisor_ack_pirq_event(evtch);
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
splx:
ci->ci_ilevel = ilevel;
@@ -621,7 +628,7 @@
return evtchn;
}
-#if NPCI > 0 || NISA > 0
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
int
get_pirq_to_evtch(int pirq)
{
@@ -725,7 +732,9 @@
return NULL;
}
+ hypervisor_prime_pirq_event(pirq, evtch);
hypervisor_unmask_event(evtch);
+ hypervisor_ack_pirq_event(evtch);
return ih;
}
@@ -754,7 +763,7 @@
return ret;
}
-#endif /* NPCI > 0 || NISA > 0 */
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
/*
@@ -1067,6 +1076,42 @@
return 0;
}
+#if defined(XENPV) && (NPCI > 0 || NISA > 0)
+void
+hypervisor_prime_pirq_event(int pirq, unsigned int evtch)
+{
+ struct physdev_irq_status_query irq_status;
+ irq_status.irq = pirq;
+ if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status) < 0)
+ panic("HYPERVISOR_physdev_op(PHYSDEVOP_IRQ_STATUS_QUERY)");
+ if (irq_status.flags & XENIRQSTAT_needs_eoi) {
+ evtch_to_pirq_eoi[evtch] = pirq;
+#ifdef IRQ_DEBUG
+ printf("pirq %d needs notify\n", pirq);
+#endif
+ }
+}
+
+void
+hypervisor_ack_pirq_event(unsigned int evtch)
+{
+#ifdef IRQ_DEBUG
+ if (evtch == IRQ_DEBUG)
+ printf("%s: evtch %d\n", __func__, evtch);
+#endif
+
+ if (evtch_to_pirq_eoi[evtch] > 0) {
+ struct physdev_eoi eoi;
+ eoi.irq = evtch_to_pirq_eoi[evtch];
+#ifdef IRQ_DEBUG
+ if (evtch == IRQ_DEBUG)
+ printf("pirq_notify(%d)\n", evtch);
+#endif
+ (void)HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi);
+ }
+}
+#endif /* defined(XENPV) && (NPCI > 0 || NISA > 0) */
+
int
xen_debug_handler(void *arg)
{
Home |
Main Index |
Thread Index |
Old Index