From 08dd698d9927a20bc9e7e570dd56205c9694b4c9 Mon Sep 17 00:00:00 2001 From: "Yan, Like" Date: Sun, 5 Aug 2018 23:29:02 +0800 Subject: [PATCH] hv: pirq: rename common irq APIs 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 Reviewed-by: Li, Fei1 Acked-by: Anthony Xu --- hypervisor/arch/x86/irq.c | 57 +++++++-------------------------- hypervisor/arch/x86/notify.c | 4 +-- hypervisor/arch/x86/timer.c | 4 +-- hypervisor/arch/x86/vtd.c | 8 ++--- hypervisor/common/ptdev.c | 4 +-- hypervisor/include/common/irq.h | 25 ++++----------- 6 files changed, 27 insertions(+), 75 deletions(-) diff --git a/hypervisor/arch/x86/irq.c b/hypervisor/arch/x86/irq.c index c0de5beee..3d9c55748 100644 --- a/hypervisor/arch/x86/irq.c +++ b/hypervisor/arch/x86/irq.c @@ -166,8 +166,10 @@ static void disable_pic_irq(void) pio_write8(0xffU, 0x21U); } -static int32_t common_register_handler(uint32_t irq_arg, - struct irq_request_info *info) +int32_t request_irq(uint32_t irq_arg, + irq_action_t action_fn, + void *priv_data, + const char *name) { struct irq_desc *desc; uint32_t irq = irq_arg, vector; @@ -200,7 +202,6 @@ static int32_t common_register_handler(uint32_t irq_arg, * * ===================================================== */ - ASSERT(info != NULL, "Invalid param"); /* HV select a irq for device if irq < 0 * this vector/irq match to APCI DSDT or PCI INTx/MSI @@ -237,24 +238,25 @@ static int32_t common_register_handler(uint32_t irq_arg, if (desc->action == NULL) { spinlock_irqsave_obtain(&desc->irq_lock); - desc->priv_data = info->priv_data; - desc->action = info->func; + desc->priv_data = priv_data; + desc->action = action_fn; /* we are okay using strcpy_s here even with spinlock * since no #PG in HV right now */ - (void)strcpy_s(desc->name, 32U, info->name); + (void)strcpy_s(desc->name, 32U, name); spinlock_irqrestore_release(&desc->irq_lock); } else { pr_err("%s: request irq(%u) vr(%u) for %s failed,\ already requested", __func__, - irq, irq_to_vector(irq), info->name); + irq, irq_to_vector(irq), name); return -EBUSY; } dev_dbg(ACRN_DBG_IRQ, "[%s] %s irq%d vr:0x%x", - __func__, info->name, irq, desc->vector); + __func__, desc->name, irq, desc->vector); + return (int32_t)irq; } @@ -556,7 +558,7 @@ void update_irq_handler(uint32_t irq, irq_handler_t func) spinlock_irqrestore_release(&desc->irq_lock); } -void unregister_handler_common(uint32_t irq) +void free_irq(uint32_t irq) { struct irq_desc *desc; @@ -580,43 +582,6 @@ void unregister_handler_common(uint32_t irq) irq_desc_try_free_vector(desc->irq); } -/* - * Allocate IRQ with Vector from VECTOR_DYNAMIC_START ~ VECTOR_DYNAMIC_END - */ -int32_t normal_register_handler(uint32_t irq, - irq_action_t func, - void *priv_data, - const char *name) -{ - struct irq_request_info info; - - info.func = func; - info.priv_data = priv_data; - info.name = (char *)name; - - return common_register_handler(irq, &info); -} - -/* - * Allocate IRQ with vector from VECTOR_FIXED_START ~ VECTOR_FIXED_END - * Allocate a IRQ and install isr on that specific cpu - * User can install same irq/isr on different CPU by call this function multiple - * times - */ -int32_t pri_register_handler(uint32_t irq, - irq_action_t func, - void *priv_data, - const char *name) -{ - struct irq_request_info info; - - info.func = func; - info.priv_data = priv_data; - info.name = (char *)name; - - return common_register_handler(irq, &info); -} - #ifdef HV_DEBUG void get_cpu_interrupt_info(char *str_arg, int str_max) { diff --git a/hypervisor/arch/x86/notify.c b/hypervisor/arch/x86/notify.c index c7cf62f11..77351ae95 100644 --- a/hypervisor/arch/x86/notify.c +++ b/hypervisor/arch/x86/notify.c @@ -29,7 +29,7 @@ static int request_notification_irq(irq_action_t func, void *data, } /* all cpu register the same notification vector */ - retval = pri_register_handler(NOTIFY_IRQ, func, data, name); + retval = request_irq(NOTIFY_IRQ, func, data, name); if (retval < 0) { pr_err("Failed to add notify isr"); return -ENODEV; @@ -64,7 +64,7 @@ void setup_notification(void) static void cleanup_notification(void) { if (notification_irq != IRQ_INVALID) { - unregister_handler_common(notification_irq); + free_irq(notification_irq); } notification_irq = IRQ_INVALID; } diff --git a/hypervisor/arch/x86/timer.c b/hypervisor/arch/x86/timer.c index 110e791cb..ce2347909 100644 --- a/hypervisor/arch/x86/timer.c +++ b/hypervisor/arch/x86/timer.c @@ -111,7 +111,7 @@ static int request_timer_irq(irq_action_t func, const char *name) { int32_t retval; - retval = pri_register_handler(TIMER_IRQ, func, NULL, name); + retval = request_irq(TIMER_IRQ, func, NULL, name); if (retval >= 0) { update_irq_handler(TIMER_IRQ, quick_handler_nolock); } else { @@ -208,7 +208,7 @@ void timer_cleanup(void) uint16_t pcpu_id = get_cpu_id(); if (pcpu_id == BOOT_CPU_ID) { - unregister_handler_common(TIMER_IRQ); + free_irq(TIMER_IRQ); } } diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 6b29912d8..414d400d3 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -826,10 +826,10 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint) return 0; } - retval = normal_register_handler(IRQ_INVALID, - dmar_fault_handler, - dmar_uint, - "dmar_fault_event"); + retval = request_irq(IRQ_INVALID, + dmar_fault_handler, + dmar_uint, + "dmar_fault_event"); if (retval < 0 ) { pr_err("%s: fail to setup interrupt", __func__); diff --git a/hypervisor/common/ptdev.c b/hypervisor/common/ptdev.c index 7ab4639f8..ef12ce0b7 100644 --- a/hypervisor/common/ptdev.c +++ b/hypervisor/common/ptdev.c @@ -134,7 +134,7 @@ ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq) int32_t retval; /* register and allocate host vector/irq */ - retval = normal_register_handler(phys_irq, ptdev_interrupt_handler, + retval = request_irq(phys_irq, ptdev_interrupt_handler, (void *)entry, "dev assign"); ASSERT(retval >= 0, "dev register failed"); @@ -150,7 +150,7 @@ ptdev_deactivate_entry(struct ptdev_remapping_info *entry) atomic_clear32(&entry->active, ACTIVE_FLAG); - unregister_handler_common(entry->allocated_pirq); + free_irq(entry->allocated_pirq); entry->allocated_pirq = IRQ_INVALID; /* remove from softirq list if added */ diff --git a/hypervisor/include/common/irq.h b/hypervisor/include/common/irq.h index 04c855f92..627b31dc5 100644 --- a/hypervisor/include/common/irq.h +++ b/hypervisor/include/common/irq.h @@ -23,15 +23,7 @@ enum irq_desc_state { IRQ_DESC_IN_PROCESS, }; -typedef int (*irq_action_t)(uint32_t irq, void *dev_data); -struct irq_request_info { - /* vector set to 0xE0 ~ 0xFF for pri_register_handler - * and set to VECTOR_INVALID for normal_register_handler - */ - irq_action_t func; - void *priv_data; - char *name; -}; +typedef int (*irq_action_t)(uint32_t irq, void *priv_data); /* any field change in below required irq_lock protection with irqsave */ struct irq_desc { @@ -58,17 +50,12 @@ void irq_desc_try_free_vector(uint32_t irq); uint32_t irq_to_vector(uint32_t irq); -int32_t pri_register_handler(uint32_t irq, - irq_action_t func, - void *priv_data, - const char *name); +int32_t request_irq(uint32_t irq, + irq_action_t action_fn, + void *priv_data, + const char *name); -int32_t normal_register_handler(uint32_t irq, - irq_action_t func, - void *priv_data, - const char *name); - -void unregister_handler_common(uint32_t irq); +void free_irq(uint32_t irq); typedef int (*irq_handler_t)(struct irq_desc *desc, void *handler_data); void update_irq_handler(uint32_t irq, irq_handler_t func);