mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-02 21:46:58 +00:00
1. add register_softirq to register a softirq handler 2. rename exec_softirq to do_softirq; raise_softirq to fire_softirq. 3. in do_softirq call registered softirq handler not call the device softirq handle function directly 4. enable irq after vm exit and disable irq after the first call do_softirq before vm enter. 5. call do_softirq again when irq disabled to handle the risk unhandled softirq. 6. rename SOFTIRQ_DEV_ASSIGN to SOFTIRQ_PTDEV 7. remove SOFTIRQ_ATOMIC Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
49 lines
897 B
C
49 lines
897 B
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <hypervisor.h>
|
|
#include <softirq.h>
|
|
|
|
|
|
static softirq_handler softirq_handlers[NR_SOFTIRQS];
|
|
|
|
void init_softirq(void)
|
|
{
|
|
}
|
|
|
|
/*
|
|
* @pre: nr will not equal or large than NR_SOFTIRQS
|
|
*/
|
|
void register_softirq(uint16_t nr, softirq_handler handler)
|
|
{
|
|
softirq_handlers[nr] = handler;
|
|
}
|
|
|
|
/*
|
|
* @pre: nr will not equal or large than NR_SOFTIRQS
|
|
*/
|
|
void fire_softirq(uint16_t nr)
|
|
{
|
|
bitmap_set_lock(nr, &per_cpu(softirq_pending, get_cpu_id()));
|
|
}
|
|
|
|
void do_softirq(void)
|
|
{
|
|
uint16_t nr;
|
|
uint16_t cpu_id = get_cpu_id();
|
|
volatile uint64_t *softirq_pending_bitmap =
|
|
&per_cpu(softirq_pending, cpu_id);
|
|
|
|
while (true) {
|
|
nr = ffs64(*softirq_pending_bitmap);
|
|
if (nr >= NR_SOFTIRQS)
|
|
break;
|
|
|
|
bitmap_clear_lock(nr, softirq_pending_bitmap);
|
|
(*softirq_handlers[nr])(cpu_id);
|
|
}
|
|
}
|