mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 14:33:38 +00:00
cleanup spin lock in irq.c
-- move exception_lock to dump.c -- optimize the lock usage in request_irq Tracked-On: #4958 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
This commit is contained in:
parent
d0a4052518
commit
67a7c355ec
@ -20,7 +20,6 @@
|
|||||||
#include <logmsg.h>
|
#include <logmsg.h>
|
||||||
#include <vmx.h>
|
#include <vmx.h>
|
||||||
|
|
||||||
static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, };
|
|
||||||
static spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, };
|
static spinlock_t irq_alloc_spinlock = { .head = 0U, .tail = 0U, };
|
||||||
|
|
||||||
uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE];
|
uint64_t irq_alloc_bitmap[IRQ_ALLOC_BITMAP_SIZE];
|
||||||
@ -214,8 +213,8 @@ int32_t request_irq(uint32_t req_irq, irq_action_t action_fn, void *priv_data,
|
|||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
} else {
|
} else {
|
||||||
desc = &irq_desc_array[irq];
|
desc = &irq_desc_array[irq];
|
||||||
spinlock_irqsave_obtain(&desc->lock, &rflags);
|
|
||||||
if (desc->action == NULL) {
|
if (desc->action == NULL) {
|
||||||
|
spinlock_irqsave_obtain(&desc->lock, &rflags);
|
||||||
desc->flags = flags;
|
desc->flags = flags;
|
||||||
desc->priv_data = priv_data;
|
desc->priv_data = priv_data;
|
||||||
desc->action = action_fn;
|
desc->action = action_fn;
|
||||||
@ -224,8 +223,6 @@ int32_t request_irq(uint32_t req_irq, irq_action_t action_fn, void *priv_data,
|
|||||||
ret = (int32_t)irq;
|
ret = (int32_t)irq;
|
||||||
dev_dbg(DBG_LEVEL_IRQ, "[%s] irq%d vr:0x%x", __func__, irq, desc->vector);
|
dev_dbg(DBG_LEVEL_IRQ, "[%s] irq%d vr:0x%x", __func__, irq, desc->vector);
|
||||||
} else {
|
} else {
|
||||||
spinlock_irqrestore_release(&desc->lock, rflags);
|
|
||||||
|
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
pr_err("%s: request irq(%u) vr(%u) failed, already requested", __func__,
|
pr_err("%s: request irq(%u) vr(%u) failed, already requested", __func__,
|
||||||
irq, irq_to_vector(irq));
|
irq, irq_to_vector(irq));
|
||||||
@ -372,15 +369,9 @@ void dispatch_exception(struct intr_excp_ctx *ctx)
|
|||||||
{
|
{
|
||||||
uint16_t pcpu_id = get_pcpu_id();
|
uint16_t pcpu_id = get_pcpu_id();
|
||||||
|
|
||||||
/* Obtain lock to ensure exception dump doesn't get corrupted */
|
|
||||||
spinlock_obtain(&exception_spinlock);
|
|
||||||
|
|
||||||
/* Dump exception context */
|
/* Dump exception context */
|
||||||
dump_exception(ctx, pcpu_id);
|
dump_exception(ctx, pcpu_id);
|
||||||
|
|
||||||
/* Release lock to let other CPUs handle exception */
|
|
||||||
spinlock_release(&exception_spinlock);
|
|
||||||
|
|
||||||
/* Halt the CPU */
|
/* Halt the CPU */
|
||||||
cpu_dead();
|
cpu_dead();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define CALL_TRACE_HIERARCHY_MAX 20U
|
#define CALL_TRACE_HIERARCHY_MAX 20U
|
||||||
#define DUMP_STACK_SIZE 0x200U
|
#define DUMP_STACK_SIZE 0x200U
|
||||||
|
|
||||||
|
static spinlock_t exception_spinlock = { .head = 0U, .tail = 0U, };
|
||||||
/*
|
/*
|
||||||
* readable exception descriptors.
|
* readable exception descriptors.
|
||||||
*/
|
*/
|
||||||
@ -242,6 +243,9 @@ void dump_intr_excp_frame(const struct intr_excp_ctx *ctx)
|
|||||||
|
|
||||||
void dump_exception(struct intr_excp_ctx *ctx, uint16_t pcpu_id)
|
void dump_exception(struct intr_excp_ctx *ctx, uint16_t pcpu_id)
|
||||||
{
|
{
|
||||||
|
/* Obtain lock to ensure exception dump doesn't get corrupted */
|
||||||
|
spinlock_obtain(&exception_spinlock);
|
||||||
|
|
||||||
/* Dump host context */
|
/* Dump host context */
|
||||||
dump_intr_excp_frame(ctx);
|
dump_intr_excp_frame(ctx);
|
||||||
/* Show host stack */
|
/* Show host stack */
|
||||||
@ -252,4 +256,7 @@ void dump_exception(struct intr_excp_ctx *ctx, uint16_t pcpu_id)
|
|||||||
/* Save registers*/
|
/* Save registers*/
|
||||||
crash_ctx = ctx;
|
crash_ctx = ctx;
|
||||||
cache_flush_invalidate_all();
|
cache_flush_invalidate_all();
|
||||||
|
|
||||||
|
/* Release lock to let other CPUs handle exception */
|
||||||
|
spinlock_release(&exception_spinlock);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user