Skip to content

Commit 08dd698

Browse files
lyan3lijinxia
authored andcommitted
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>
1 parent 8fda0d8 commit 08dd698

File tree

6 files changed

+27
-75
lines changed

6 files changed

+27
-75
lines changed

hypervisor/arch/x86/irq.c

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ static void disable_pic_irq(void)
166166
pio_write8(0xffU, 0x21U);
167167
}
168168

169-
static int32_t common_register_handler(uint32_t irq_arg,
170-
struct irq_request_info *info)
169+
int32_t request_irq(uint32_t irq_arg,
170+
irq_action_t action_fn,
171+
void *priv_data,
172+
const char *name)
171173
{
172174
struct irq_desc *desc;
173175
uint32_t irq = irq_arg, vector;
@@ -200,7 +202,6 @@ static int32_t common_register_handler(uint32_t irq_arg,
200202
*
201203
* =====================================================
202204
*/
203-
ASSERT(info != NULL, "Invalid param");
204205

205206
/* HV select a irq for device if irq < 0
206207
* 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,
237238

238239
if (desc->action == NULL) {
239240
spinlock_irqsave_obtain(&desc->irq_lock);
240-
desc->priv_data = info->priv_data;
241-
desc->action = info->func;
241+
desc->priv_data = priv_data;
242+
desc->action = action_fn;
242243

243244
/* we are okay using strcpy_s here even with spinlock
244245
* since no #PG in HV right now
245246
*/
246-
(void)strcpy_s(desc->name, 32U, info->name);
247+
(void)strcpy_s(desc->name, 32U, name);
247248

248249
spinlock_irqrestore_release(&desc->irq_lock);
249250
} else {
250251
pr_err("%s: request irq(%u) vr(%u) for %s failed,\
251252
already requested", __func__,
252-
irq, irq_to_vector(irq), info->name);
253+
irq, irq_to_vector(irq), name);
253254
return -EBUSY;
254255
}
255256

256257
dev_dbg(ACRN_DBG_IRQ, "[%s] %s irq%d vr:0x%x",
257-
__func__, info->name, irq, desc->vector);
258+
__func__, desc->name, irq, desc->vector);
259+
258260
return (int32_t)irq;
259261
}
260262

@@ -556,7 +558,7 @@ void update_irq_handler(uint32_t irq, irq_handler_t func)
556558
spinlock_irqrestore_release(&desc->irq_lock);
557559
}
558560

559-
void unregister_handler_common(uint32_t irq)
561+
void free_irq(uint32_t irq)
560562
{
561563
struct irq_desc *desc;
562564

@@ -580,43 +582,6 @@ void unregister_handler_common(uint32_t irq)
580582
irq_desc_try_free_vector(desc->irq);
581583
}
582584

583-
/*
584-
* Allocate IRQ with Vector from VECTOR_DYNAMIC_START ~ VECTOR_DYNAMIC_END
585-
*/
586-
int32_t normal_register_handler(uint32_t irq,
587-
irq_action_t func,
588-
void *priv_data,
589-
const char *name)
590-
{
591-
struct irq_request_info info;
592-
593-
info.func = func;
594-
info.priv_data = priv_data;
595-
info.name = (char *)name;
596-
597-
return common_register_handler(irq, &info);
598-
}
599-
600-
/*
601-
* Allocate IRQ with vector from VECTOR_FIXED_START ~ VECTOR_FIXED_END
602-
* Allocate a IRQ and install isr on that specific cpu
603-
* User can install same irq/isr on different CPU by call this function multiple
604-
* times
605-
*/
606-
int32_t pri_register_handler(uint32_t irq,
607-
irq_action_t func,
608-
void *priv_data,
609-
const char *name)
610-
{
611-
struct irq_request_info info;
612-
613-
info.func = func;
614-
info.priv_data = priv_data;
615-
info.name = (char *)name;
616-
617-
return common_register_handler(irq, &info);
618-
}
619-
620585
#ifdef HV_DEBUG
621586
void get_cpu_interrupt_info(char *str_arg, int str_max)
622587
{

hypervisor/arch/x86/notify.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int request_notification_irq(irq_action_t func, void *data,
2929
}
3030

3131
/* all cpu register the same notification vector */
32-
retval = pri_register_handler(NOTIFY_IRQ, func, data, name);
32+
retval = request_irq(NOTIFY_IRQ, func, data, name);
3333
if (retval < 0) {
3434
pr_err("Failed to add notify isr");
3535
return -ENODEV;
@@ -64,7 +64,7 @@ void setup_notification(void)
6464
static void cleanup_notification(void)
6565
{
6666
if (notification_irq != IRQ_INVALID) {
67-
unregister_handler_common(notification_irq);
67+
free_irq(notification_irq);
6868
}
6969
notification_irq = IRQ_INVALID;
7070
}

hypervisor/arch/x86/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int request_timer_irq(irq_action_t func, const char *name)
111111
{
112112
int32_t retval;
113113

114-
retval = pri_register_handler(TIMER_IRQ, func, NULL, name);
114+
retval = request_irq(TIMER_IRQ, func, NULL, name);
115115
if (retval >= 0) {
116116
update_irq_handler(TIMER_IRQ, quick_handler_nolock);
117117
} else {
@@ -208,7 +208,7 @@ void timer_cleanup(void)
208208
uint16_t pcpu_id = get_cpu_id();
209209

210210
if (pcpu_id == BOOT_CPU_ID) {
211-
unregister_handler_common(TIMER_IRQ);
211+
free_irq(TIMER_IRQ);
212212
}
213213
}
214214

hypervisor/arch/x86/vtd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,10 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint)
826826
return 0;
827827
}
828828

829-
retval = normal_register_handler(IRQ_INVALID,
830-
dmar_fault_handler,
831-
dmar_uint,
832-
"dmar_fault_event");
829+
retval = request_irq(IRQ_INVALID,
830+
dmar_fault_handler,
831+
dmar_uint,
832+
"dmar_fault_event");
833833

834834
if (retval < 0 ) {
835835
pr_err("%s: fail to setup interrupt", __func__);

hypervisor/common/ptdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq)
134134
int32_t retval;
135135

136136
/* register and allocate host vector/irq */
137-
retval = normal_register_handler(phys_irq, ptdev_interrupt_handler,
137+
retval = request_irq(phys_irq, ptdev_interrupt_handler,
138138
(void *)entry, "dev assign");
139139

140140
ASSERT(retval >= 0, "dev register failed");
@@ -150,7 +150,7 @@ ptdev_deactivate_entry(struct ptdev_remapping_info *entry)
150150

151151
atomic_clear32(&entry->active, ACTIVE_FLAG);
152152

153-
unregister_handler_common(entry->allocated_pirq);
153+
free_irq(entry->allocated_pirq);
154154
entry->allocated_pirq = IRQ_INVALID;
155155

156156
/* remove from softirq list if added */

hypervisor/include/common/irq.h

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,7 @@ enum irq_desc_state {
2323
IRQ_DESC_IN_PROCESS,
2424
};
2525

26-
typedef int (*irq_action_t)(uint32_t irq, void *dev_data);
27-
struct irq_request_info {
28-
/* vector set to 0xE0 ~ 0xFF for pri_register_handler
29-
* and set to VECTOR_INVALID for normal_register_handler
30-
*/
31-
irq_action_t func;
32-
void *priv_data;
33-
char *name;
34-
};
26+
typedef int (*irq_action_t)(uint32_t irq, void *priv_data);
3527

3628
/* any field change in below required irq_lock protection with irqsave */
3729
struct irq_desc {
@@ -58,17 +50,12 @@ void irq_desc_try_free_vector(uint32_t irq);
5850

5951
uint32_t irq_to_vector(uint32_t irq);
6052

61-
int32_t pri_register_handler(uint32_t irq,
62-
irq_action_t func,
63-
void *priv_data,
64-
const char *name);
65-
66-
int32_t normal_register_handler(uint32_t irq,
67-
irq_action_t func,
68-
void *priv_data,
69-
const char *name);
53+
int32_t request_irq(uint32_t irq,
54+
irq_action_t action_fn,
55+
void *priv_data,
56+
const char *name);
7057

71-
void unregister_handler_common(uint32_t irq);
58+
void free_irq(uint32_t irq);
7259

7360
typedef int (*irq_handler_t)(struct irq_desc *desc, void *handler_data);
7461
void update_irq_handler(uint32_t irq, irq_handler_t func);

0 commit comments

Comments
 (0)