|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [[UNIKRAFT PATCH] v4 2/4] plat/kvm: Made _ukplat_irq_handle interrupt-context-safe
From: Cristian Vijelie <cristianvijelie@xxxxxxxxx>
I moved the interrupt request handler for the KVM platform into a separate
source file, isr.c, that is built using the 'isr' flag. Also, I have moved
the definitions needed by both irq.c and isr.c into an internal header,
'internal/irq.h'
Signed-off-by: Cristian Vijelie <cristianvijelie@xxxxxxxxx>
---
plat/kvm/Makefile.uk | 1 +
plat/kvm/internal/irq.h | 13 ++++++++
plat/kvm/irq.c | 51 +---------------------------
plat/kvm/isr.c | 73 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 88 insertions(+), 50 deletions(-)
create mode 100644 plat/kvm/internal/irq.h
create mode 100644 plat/kvm/isr.c
diff --git a/plat/kvm/Makefile.uk b/plat/kvm/Makefile.uk
index 94321e0..ec079dd 100644
--- a/plat/kvm/Makefile.uk
+++ b/plat/kvm/Makefile.uk
@@ -100,6 +100,7 @@ LIBKVMPLAT_SRCS-$(CONFIG_ARCH_ARM_64) +=
$(LIBKVMPLAT_BASE)/arm/intctrl.c
LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/shutdown.c
LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/memory.c
LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/irq.c
+LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/isr.c|isr
LIBKVMPLAT_SRCS-y += $(LIBKVMPLAT_BASE)/io.c
LIBKVMPLAT_SRCS-y += $(UK_PLAT_COMMON_BASE)/lcpu.c|common
LIBKVMPLAT_SRCS-y += $(UK_PLAT_COMMON_BASE)/memory.c|common
diff --git a/plat/kvm/internal/irq.h b/plat/kvm/internal/irq.h
new file mode 100644
index 0000000..2fd6b6d
--- /dev/null
+++ b/plat/kvm/internal/irq.h
@@ -0,0 +1,13 @@
+#include <uk/plat/irq.h>
+#include <uk/compat_list.h>
+#include <uk/plat/common/irq.h>
+
+struct irq_handler {
+ irq_handler_func_t func;
+ void *arg;
+
+ UK_SLIST_ENTRY(struct irq_handler) entries;
+};
+
+UK_SLIST_HEAD(irq_handler_head, struct irq_handler);
+static struct irq_handler_head irq_handlers[__MAX_IRQ];
\ No newline at end of file
diff --git a/plat/kvm/irq.c b/plat/kvm/irq.c
index 8f43aa6..87301a2 100644
--- a/plat/kvm/irq.c
+++ b/plat/kvm/irq.c
@@ -36,19 +36,10 @@
#include <uk/assert.h>
#include <errno.h>
#include <uk/bitops.h>
+#include "internal/irq.h"
static struct uk_alloc *allocator;
-struct irq_handler {
- irq_handler_func_t func;
- void *arg;
-
- UK_SLIST_ENTRY(struct irq_handler) entries;
-};
-
-UK_SLIST_HEAD(irq_handler_head, struct irq_handler);
-static struct irq_handler_head irq_handlers[__MAX_IRQ];
-
int ukplat_irq_register(unsigned long irq, irq_handler_func_t func, void *arg)
{
struct irq_handler *h;
@@ -72,46 +63,6 @@ int ukplat_irq_register(unsigned long irq,
irq_handler_func_t func, void *arg)
return 0;
}
-/*
- * TODO: This is a temporary solution used to identify non TSC clock
- * interrupts in order to stop waiting for interrupts with deadline.
- */
-extern unsigned long sched_have_pending_events;
-
-void _ukplat_irq_handle(unsigned long irq)
-{
- struct irq_handler *h;
-
- UK_SLIST_FOREACH(h, &irq_handlers[irq], entries) {
- /* TODO define platform wise macro for timer IRQ number */
- if (irq != 0)
- /* IRQ 0 is reserved for a timer, responsible to
- * wake up cpu from halt, so it can check if
- * it has something to do. Effectively it is OS ticks.
- *
- * If interrupt comes not from the timer, the
- * chances are some work have just
- * arrived. Let's kick the scheduler out of
- * the halting loop, and let it take care of
- * that work.
- */
- __uk_test_and_set_bit(0, &sched_have_pending_events);
-
- if (h->func(h->arg) == 1)
- goto exit_ack;
- }
- /*
- * Acknowledge interrupts even in the case when there was no handler for
- * it. We do this to (1) compensate potential spurious interrupts of
- * devices, and (2) to minimize impact on drivers that share one
- * interrupt line that would then stay disabled.
- */
- uk_pr_crit("Unhandled irq=%lu\n", irq);
-
-exit_ack:
- intctrl_ack_irq(irq);
-}
-
int ukplat_irq_init(struct uk_alloc *a)
{
UK_ASSERT(allocator == NULL);
diff --git a/plat/kvm/isr.c b/plat/kvm/isr.c
new file mode 100644
index 0000000..f0ea3d3
--- /dev/null
+++ b/plat/kvm/isr.c
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: ISC */
+/*
+ * Authors: Dan Williams
+ * Martin Lucina
+ * Ricardo Koller
+ * Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * Copyright (c) 2015-2017 IBM
+ * Copyright (c) 2016-2017 Docker, Inc.
+ * Copyright (c) 2018, NEC Europe Ltd., NEC Corporation
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+/* Taken from solo5 intr.c */
+
+#include <kvm/irq.h>
+#include "internal/irq.h"
+#include <uk/bitops.h>
+#include <kvm/intctrl.h>
+#include <uk/assert.h>
+
+extern unsigned long sched_have_pending_events;
+
+/*
+ * TODO: This is a temporary solution used to identify non TSC clock
+ * interrupts in order to stop waiting for interrupts with deadline.
+ */
+
+void _ukplat_irq_handle(unsigned long irq)
+{
+ struct irq_handler *h;
+
+ UK_SLIST_FOREACH(h, &irq_handlers[irq], entries) {
+ /* TODO define platform wise macro for timer IRQ number */
+ if (irq != 0)
+ /* IRQ 0 is reserved for a timer, responsible to
+ * wake up cpu from halt, so it can check if
+ * it has something to do. Effectively it is OS ticks.
+ *
+ * If interrupt comes not from the timer, the
+ * chances are some work have just
+ * arrived. Let's kick the scheduler out of
+ * the halting loop, and let it take care of
+ * that work.
+ */
+ __uk_test_and_set_bit(0, &sched_have_pending_events);
+
+ if (h->func(h->arg) == 1)
+ goto exit_ack;
+ }
+ /*
+ * Acknowledge interrupts even in the case when there was no handler for
+ * it. We do this to (1) compensate potential spurious interrupts of
+ * devices, and (2) to minimize impact on drivers that share one
+ * interrupt line that would then stay disabled.
+ */
+ uk_pr_crit("Unhandled irq=%lu\n", irq);
+
+exit_ack:
+ intctrl_ack_irq(irq);
+}
\ No newline at end of file
--
2.25.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |