mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-28 16:27:01 +00:00
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 <like.yan@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
8fda0d8c5f
commit
08dd698d99
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -826,7 +826,7 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint)
|
||||
return 0;
|
||||
}
|
||||
|
||||
retval = normal_register_handler(IRQ_INVALID,
|
||||
retval = request_irq(IRQ_INVALID,
|
||||
dmar_fault_handler,
|
||||
dmar_uint,
|
||||
"dmar_fault_event");
|
||||
|
@ -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 */
|
||||
|
@ -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,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user