mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-12 10:24:21 +00:00
This commit cleans up the irq APIs which are a bit confusing. - pri_register_handler(), normal_register_handler() and common_register_handler() into request_irq(), and removed the unnecessary struct irq_request_info; - rename the unregister_common_handler() to free_irq(); After the revision, the common irq APIs becomes: - int32_t request_irq(uint32_t irq, irq_action_t action_fn, void *action_data, const char *name) - void free_irq(uint32_t irq) Signed-off-by: Yan, Like <like.yan@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
/*
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <hypervisor.h>
|
|
|
|
static uint32_t notification_irq = IRQ_INVALID;
|
|
|
|
/* run in interrupt context */
|
|
static int kick_notification(__unused uint32_t irq, __unused void *data)
|
|
{
|
|
/* Notification vector does not require handling here, it's just used
|
|
* to kick taget cpu out of non-root mode.
|
|
*/
|
|
return 0;
|
|
}
|
|
|
|
static int request_notification_irq(irq_action_t func, void *data,
|
|
const char *name)
|
|
{
|
|
int32_t retval;
|
|
|
|
if (notification_irq != IRQ_INVALID) {
|
|
pr_info("%s, Notification vector already allocated on this CPU",
|
|
__func__);
|
|
return -EBUSY;
|
|
}
|
|
|
|
/* all cpu register the same notification vector */
|
|
retval = request_irq(NOTIFY_IRQ, func, data, name);
|
|
if (retval < 0) {
|
|
pr_err("Failed to add notify isr");
|
|
return -ENODEV;
|
|
}
|
|
|
|
notification_irq = (uint32_t)retval;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void setup_notification(void)
|
|
{
|
|
uint16_t cpu;
|
|
char name[32] = {0};
|
|
|
|
cpu = get_cpu_id();
|
|
if (cpu > 0U) {
|
|
return;
|
|
}
|
|
|
|
/* support IPI notification, VM0 will register all CPU */
|
|
snprintf(name, 32, "NOTIFY_ISR%d", cpu);
|
|
if (request_notification_irq(kick_notification, NULL, name) < 0) {
|
|
pr_err("Failed to setup notification");
|
|
return;
|
|
}
|
|
|
|
dev_dbg(ACRN_DBG_PTIRQ, "NOTIFY: irq[%d] setup vector %x",
|
|
notification_irq, irq_to_vector(notification_irq));
|
|
}
|
|
|
|
static void cleanup_notification(void)
|
|
{
|
|
if (notification_irq != IRQ_INVALID) {
|
|
free_irq(notification_irq);
|
|
}
|
|
notification_irq = IRQ_INVALID;
|
|
}
|