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:
Yan, Like 2018-08-05 23:29:02 +08:00 committed by lijinxia
parent 8fda0d8c5f
commit 08dd698d99
6 changed files with 27 additions and 75 deletions

View File

@ -166,8 +166,10 @@ static void disable_pic_irq(void)
pio_write8(0xffU, 0x21U); pio_write8(0xffU, 0x21U);
} }
static int32_t common_register_handler(uint32_t irq_arg, int32_t request_irq(uint32_t irq_arg,
struct irq_request_info *info) irq_action_t action_fn,
void *priv_data,
const char *name)
{ {
struct irq_desc *desc; struct irq_desc *desc;
uint32_t irq = irq_arg, vector; 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 /* HV select a irq for device if irq < 0
* this vector/irq match to APCI DSDT or PCI INTx/MSI * 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) { if (desc->action == NULL) {
spinlock_irqsave_obtain(&desc->irq_lock); spinlock_irqsave_obtain(&desc->irq_lock);
desc->priv_data = info->priv_data; desc->priv_data = priv_data;
desc->action = info->func; desc->action = action_fn;
/* we are okay using strcpy_s here even with spinlock /* we are okay using strcpy_s here even with spinlock
* since no #PG in HV right now * 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); spinlock_irqrestore_release(&desc->irq_lock);
} else { } else {
pr_err("%s: request irq(%u) vr(%u) for %s failed,\ pr_err("%s: request irq(%u) vr(%u) for %s failed,\
already requested", __func__, already requested", __func__,
irq, irq_to_vector(irq), info->name); irq, irq_to_vector(irq), name);
return -EBUSY; return -EBUSY;
} }
dev_dbg(ACRN_DBG_IRQ, "[%s] %s irq%d vr:0x%x", 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; 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); spinlock_irqrestore_release(&desc->irq_lock);
} }
void unregister_handler_common(uint32_t irq) void free_irq(uint32_t irq)
{ {
struct irq_desc *desc; struct irq_desc *desc;
@ -580,43 +582,6 @@ void unregister_handler_common(uint32_t irq)
irq_desc_try_free_vector(desc->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 #ifdef HV_DEBUG
void get_cpu_interrupt_info(char *str_arg, int str_max) void get_cpu_interrupt_info(char *str_arg, int str_max)
{ {

View File

@ -29,7 +29,7 @@ static int request_notification_irq(irq_action_t func, void *data,
} }
/* all cpu register the same notification vector */ /* 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) { if (retval < 0) {
pr_err("Failed to add notify isr"); pr_err("Failed to add notify isr");
return -ENODEV; return -ENODEV;
@ -64,7 +64,7 @@ void setup_notification(void)
static void cleanup_notification(void) static void cleanup_notification(void)
{ {
if (notification_irq != IRQ_INVALID) { if (notification_irq != IRQ_INVALID) {
unregister_handler_common(notification_irq); free_irq(notification_irq);
} }
notification_irq = IRQ_INVALID; notification_irq = IRQ_INVALID;
} }

View File

@ -111,7 +111,7 @@ static int request_timer_irq(irq_action_t func, const char *name)
{ {
int32_t retval; int32_t retval;
retval = pri_register_handler(TIMER_IRQ, func, NULL, name); retval = request_irq(TIMER_IRQ, func, NULL, name);
if (retval >= 0) { if (retval >= 0) {
update_irq_handler(TIMER_IRQ, quick_handler_nolock); update_irq_handler(TIMER_IRQ, quick_handler_nolock);
} else { } else {
@ -208,7 +208,7 @@ void timer_cleanup(void)
uint16_t pcpu_id = get_cpu_id(); uint16_t pcpu_id = get_cpu_id();
if (pcpu_id == BOOT_CPU_ID) { if (pcpu_id == BOOT_CPU_ID) {
unregister_handler_common(TIMER_IRQ); free_irq(TIMER_IRQ);
} }
} }

View File

@ -826,7 +826,7 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint)
return 0; return 0;
} }
retval = normal_register_handler(IRQ_INVALID, retval = request_irq(IRQ_INVALID,
dmar_fault_handler, dmar_fault_handler,
dmar_uint, dmar_uint,
"dmar_fault_event"); "dmar_fault_event");

View File

@ -134,7 +134,7 @@ ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq)
int32_t retval; int32_t retval;
/* register and allocate host vector/irq */ /* 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"); (void *)entry, "dev assign");
ASSERT(retval >= 0, "dev register failed"); ASSERT(retval >= 0, "dev register failed");
@ -150,7 +150,7 @@ ptdev_deactivate_entry(struct ptdev_remapping_info *entry)
atomic_clear32(&entry->active, ACTIVE_FLAG); atomic_clear32(&entry->active, ACTIVE_FLAG);
unregister_handler_common(entry->allocated_pirq); free_irq(entry->allocated_pirq);
entry->allocated_pirq = IRQ_INVALID; entry->allocated_pirq = IRQ_INVALID;
/* remove from softirq list if added */ /* remove from softirq list if added */

View File

@ -23,15 +23,7 @@ enum irq_desc_state {
IRQ_DESC_IN_PROCESS, IRQ_DESC_IN_PROCESS,
}; };
typedef int (*irq_action_t)(uint32_t irq, void *dev_data); typedef int (*irq_action_t)(uint32_t irq, void *priv_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;
};
/* any field change in below required irq_lock protection with irqsave */ /* any field change in below required irq_lock protection with irqsave */
struct irq_desc { struct irq_desc {
@ -58,17 +50,12 @@ void irq_desc_try_free_vector(uint32_t irq);
uint32_t irq_to_vector(uint32_t irq); uint32_t irq_to_vector(uint32_t irq);
int32_t pri_register_handler(uint32_t irq, int32_t request_irq(uint32_t irq,
irq_action_t func, irq_action_t action_fn,
void *priv_data, void *priv_data,
const char *name); const char *name);
int32_t normal_register_handler(uint32_t irq, void free_irq(uint32_t irq);
irq_action_t func,
void *priv_data,
const char *name);
void unregister_handler_common(uint32_t irq);
typedef int (*irq_handler_t)(struct irq_desc *desc, void *handler_data); typedef int (*irq_handler_t)(struct irq_desc *desc, void *handler_data);
void update_irq_handler(uint32_t irq, irq_handler_t func); void update_irq_handler(uint32_t irq, irq_handler_t func);