mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 23:13:26 +00:00
hv: timer: request timer irq once only
Since global vector table is being used on all pcpus, it's not necessary to request timer irq at each cpu init. With this change, per_cpu timer nodes are removed, and only BSP registers and unregisters timer irq. Signed-off-by: Yan, Like <like.yan@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
b4a2ff5022
commit
c663267b03
@ -13,7 +13,7 @@
|
|||||||
#define MIN_TIMER_PERIOD_US 500U
|
#define MIN_TIMER_PERIOD_US 500U
|
||||||
|
|
||||||
uint32_t tsc_khz = 0U;
|
uint32_t tsc_khz = 0U;
|
||||||
|
static struct dev_handler_node *timer_node;
|
||||||
static void run_timer(struct hv_timer *timer)
|
static void run_timer(struct hv_timer *timer)
|
||||||
{
|
{
|
||||||
/* deadline = 0 means stop timer, we should skip */
|
/* deadline = 0 means stop timer, we should skip */
|
||||||
@ -108,20 +108,16 @@ void del_timer(struct hv_timer *timer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int request_timer_irq(uint16_t pcpu_id,
|
static int request_timer_irq(dev_handler_t func, const char *name)
|
||||||
dev_handler_t func, void *data,
|
|
||||||
const char *name)
|
|
||||||
{
|
{
|
||||||
struct dev_handler_node *node = NULL;
|
if (timer_node != NULL) {
|
||||||
|
pr_err("Timer isr already added");
|
||||||
if (per_cpu(timer_node, pcpu_id) != NULL) {
|
unregister_handler_common(timer_node);
|
||||||
pr_err("CPU%d timer isr already added", pcpu_id);
|
|
||||||
unregister_handler_common(per_cpu(timer_node, pcpu_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node = pri_register_handler(TIMER_IRQ, VECTOR_TIMER, func, data, name);
|
timer_node = pri_register_handler(TIMER_IRQ, VECTOR_TIMER,
|
||||||
if (node != NULL) {
|
func, NULL, name);
|
||||||
per_cpu(timer_node, pcpu_id) = node;
|
if (timer_node != NULL) {
|
||||||
update_irq_handler(TIMER_IRQ, quick_handler_nolock);
|
update_irq_handler(TIMER_IRQ, quick_handler_nolock);
|
||||||
} else {
|
} else {
|
||||||
pr_err("Failed to add timer isr");
|
pr_err("Failed to add timer isr");
|
||||||
@ -198,12 +194,15 @@ void timer_init(void)
|
|||||||
uint16_t pcpu_id = get_cpu_id();
|
uint16_t pcpu_id = get_cpu_id();
|
||||||
|
|
||||||
init_percpu_timer(pcpu_id);
|
init_percpu_timer(pcpu_id);
|
||||||
register_softirq(SOFTIRQ_TIMER, timer_softirq);
|
|
||||||
|
|
||||||
snprintf(name, 32, "timer_tick[%hu]", pcpu_id);
|
snprintf(name, 32, "timer_tick[%hu]", pcpu_id);
|
||||||
if (request_timer_irq(pcpu_id, tsc_deadline_handler, NULL, name) < 0) {
|
if (pcpu_id == BOOT_CPU_ID) {
|
||||||
pr_err("Timer setup failed");
|
register_softirq(SOFTIRQ_TIMER, timer_softirq);
|
||||||
return;
|
|
||||||
|
if (request_timer_irq(tsc_deadline_handler, name) < 0) {
|
||||||
|
pr_err("Timer setup failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init_tsc_deadline_timer();
|
init_tsc_deadline_timer();
|
||||||
@ -213,11 +212,10 @@ void timer_cleanup(void)
|
|||||||
{
|
{
|
||||||
uint16_t pcpu_id = get_cpu_id();
|
uint16_t pcpu_id = get_cpu_id();
|
||||||
|
|
||||||
if (per_cpu(timer_node, pcpu_id) != NULL) {
|
if (pcpu_id == BOOT_CPU_ID && timer_node != NULL) {
|
||||||
unregister_handler_common(per_cpu(timer_node, pcpu_id));
|
unregister_handler_common(timer_node);
|
||||||
|
timer_node = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
per_cpu(timer_node, pcpu_id) = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_tsc(void)
|
void check_tsc(void)
|
||||||
|
@ -26,7 +26,6 @@ struct per_cpu_region {
|
|||||||
uint64_t softirq_pending;
|
uint64_t softirq_pending;
|
||||||
uint64_t spurious;
|
uint64_t spurious;
|
||||||
uint64_t vmxon_region_pa;
|
uint64_t vmxon_region_pa;
|
||||||
struct dev_handler_node *timer_node;
|
|
||||||
struct shared_buf *earlylog_sbuf;
|
struct shared_buf *earlylog_sbuf;
|
||||||
void *vcpu;
|
void *vcpu;
|
||||||
void *ever_run_vcpu;
|
void *ever_run_vcpu;
|
||||||
|
Loading…
Reference in New Issue
Block a user