Skip to content

Commit f77d885

Browse files
lyan3lijinxia
authored andcommitted
hv: pirq: clean up unnecessary fields of irq_desc
This commit cleans up fiels of struct irq_desc: - remove name, irq_desc_state, irq_cnt and irq_lost_cnt which are not used. - remove irq_ prefix of irq_lock field of struct irq_desc; - change enum irq_state to enum irq_use_state; Signed-off-by: Yan, Like <like.yan@intel.com> Reviewed-by: Li, Fei <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent bdcc3ae commit f77d885

File tree

6 files changed

+47
-114
lines changed

6 files changed

+47
-114
lines changed

hypervisor/arch/x86/irq.c

Lines changed: 34 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static void init_irq_desc(void)
2727
for (i = 0U; i < NR_IRQS; i++) {
2828
irq_desc_array[i].irq = i;
2929
irq_desc_array[i].vector = VECTOR_INVALID;
30-
spinlock_init(&irq_desc_array[i].irq_lock);
30+
spinlock_init(&irq_desc_array[i].lock);
3131
}
3232

3333
for (i = 0U; i <= NR_MAX_VECTOR; i++) {
@@ -75,11 +75,11 @@ uint32_t irq_mark_used(uint32_t irq)
7575
}
7676

7777
desc = &irq_desc_array[irq];
78-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
78+
spinlock_irqsave_obtain(&desc->lock, &rflags);
7979
if (desc->used == IRQ_NOT_ASSIGNED) {
8080
desc->used = IRQ_ASSIGNED;
8181
}
82-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
82+
spinlock_irqrestore_release(&desc->lock, rflags);
8383
return irq;
8484
}
8585

@@ -96,18 +96,18 @@ static uint32_t alloc_irq(void)
9696

9797
for (i = irq_gsi_num(); i < NR_IRQS; i++) {
9898
desc = &irq_desc_array[i];
99-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
99+
spinlock_irqsave_obtain(&desc->lock, &rflags);
100100
if (desc->used == IRQ_NOT_ASSIGNED) {
101101
desc->used = IRQ_ASSIGNED;
102-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
102+
spinlock_irqrestore_release(&desc->lock, rflags);
103103
break;
104104
}
105-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
105+
spinlock_irqrestore_release(&desc->lock, rflags);
106106
}
107107
return (i == NR_IRQS) ? IRQ_INVALID : i;
108108
}
109109

110-
/* need irq_lock protection before use */
110+
/* need lock protection before use */
111111
static void local_irq_desc_set_vector(uint32_t irq, uint32_t vr)
112112
{
113113
struct irq_desc *desc;
@@ -124,13 +124,13 @@ static void irq_desc_set_vector(uint32_t irq, uint32_t vr)
124124
struct irq_desc *desc;
125125

126126
desc = &irq_desc_array[irq];
127-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
127+
spinlock_irqsave_obtain(&desc->lock, &rflags);
128128
vector_to_irq[vr] = irq;
129129
desc->vector = vr;
130-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
130+
spinlock_irqrestore_release(&desc->lock, rflags);
131131
}
132132

133-
/* used with holding irq_lock outside */
133+
/* used with holding lock outside */
134134
static void _irq_desc_free_vector(uint32_t irq)
135135
{
136136
struct irq_desc *desc;
@@ -145,7 +145,6 @@ static void _irq_desc_free_vector(uint32_t irq)
145145

146146
vr = desc->vector;
147147
desc->used = IRQ_NOT_ASSIGNED;
148-
desc->state = IRQ_DESC_PENDING;
149148
desc->vector = VECTOR_INVALID;
150149

151150
vr &= NR_MAX_VECTOR;
@@ -166,8 +165,7 @@ static void disable_pic_irq(void)
166165

167166
int32_t request_irq(uint32_t irq_arg,
168167
irq_action_t action_fn,
169-
void *priv_data,
170-
const char *name)
168+
void *priv_data)
171169
{
172170
struct irq_desc *desc;
173171
uint32_t irq = irq_arg, vector;
@@ -235,25 +233,20 @@ int32_t request_irq(uint32_t irq_arg,
235233
}
236234

237235
if (desc->action == NULL) {
238-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
236+
spinlock_irqsave_obtain(&desc->lock, &rflags);
239237
desc->priv_data = priv_data;
240238
desc->action = action_fn;
241239

242-
/* we are okay using strcpy_s here even with spinlock
243-
* since no #PG in HV right now
244-
*/
245-
(void)strcpy_s(desc->name, 32U, name);
246-
247-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
240+
spinlock_irqrestore_release(&desc->lock, rflags);
248241
} else {
249-
pr_err("%s: request irq(%u) vr(%u) for %s failed,\
242+
pr_err("%s: request irq(%u) vr(%u) failed,\
250243
already requested", __func__,
251-
irq, irq_to_vector(irq), name);
244+
irq, irq_to_vector(irq));
252245
return -EBUSY;
253246
}
254247

255-
dev_dbg(ACRN_DBG_IRQ, "[%s] %s irq%d vr:0x%x",
256-
__func__, desc->name, irq, desc->vector);
248+
dev_dbg(ACRN_DBG_IRQ, "[%s] irq%d vr:0x%x",
249+
__func__, irq, desc->vector);
257250

258251
return (int32_t)irq;
259252
}
@@ -272,7 +265,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq)
272265
}
273266

274267
desc = &irq_desc_array[irq];
275-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
268+
spinlock_irqsave_obtain(&desc->lock, &rflags);
276269
if (desc->vector != VECTOR_INVALID) {
277270
/* already allocated a vector */
278271
goto OUT;
@@ -286,7 +279,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq)
286279
}
287280
local_irq_desc_set_vector(irq, vr);
288281
OUT:
289-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
282+
spinlock_irqrestore_release(&desc->lock, rflags);
290283
return vr;
291284
}
292285

@@ -301,12 +294,12 @@ void irq_desc_try_free_vector(uint32_t irq)
301294
}
302295

303296
desc = &irq_desc_array[irq];
304-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
297+
spinlock_irqsave_obtain(&desc->lock, &rflags);
305298
if (desc->action == NULL) {
306299
_irq_desc_free_vector(irq);
307300
}
308301

309-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
302+
spinlock_irqrestore_release(&desc->lock, rflags);
310303

311304
}
312305

@@ -421,18 +414,7 @@ int handle_level_interrupt_common(struct irq_desc *desc,
421414
uint64_t rflags;
422415
irq_action_t action = desc->action;
423416

424-
/*
425-
* give other Core a try to return without hold irq_lock
426-
* and record irq_lost count here
427-
*/
428-
if (desc->state != IRQ_DESC_PENDING) {
429-
send_lapic_eoi();
430-
desc->irq_lost_cnt++;
431-
return 0;
432-
}
433-
434-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
435-
desc->state = IRQ_DESC_IN_PROCESS;
417+
spinlock_irqsave_obtain(&desc->lock, &rflags);
436418

437419
/* mask iopaic pin */
438420
if (irq_is_gsi(desc->irq)) {
@@ -450,8 +432,7 @@ int handle_level_interrupt_common(struct irq_desc *desc,
450432
GSI_UNMASK_IRQ(desc->irq);
451433
}
452434

453-
desc->state = IRQ_DESC_PENDING;
454-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
435+
spinlock_irqrestore_release(&desc->lock, rflags);
455436

456437
return 0;
457438
}
@@ -461,18 +442,7 @@ int common_handler_edge(struct irq_desc *desc, __unused void *handler_data)
461442
uint64_t rflags;
462443
irq_action_t action = desc->action;
463444

464-
/*
465-
* give other Core a try to return without hold irq_lock
466-
* and record irq_lost count here
467-
*/
468-
if (desc->state != IRQ_DESC_PENDING) {
469-
send_lapic_eoi();
470-
desc->irq_lost_cnt++;
471-
return 0;
472-
}
473-
474-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
475-
desc->state = IRQ_DESC_IN_PROCESS;
445+
spinlock_irqsave_obtain(&desc->lock, &rflags);
476446

477447
/* Send EOI to LAPIC/IOAPIC IRR */
478448
send_lapic_eoi();
@@ -481,8 +451,7 @@ int common_handler_edge(struct irq_desc *desc, __unused void *handler_data)
481451
action(desc->irq, desc->priv_data);
482452
}
483453

484-
desc->state = IRQ_DESC_PENDING;
485-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
454+
spinlock_irqrestore_release(&desc->lock, rflags);
486455

487456
return 0;
488457
}
@@ -492,18 +461,7 @@ int common_dev_handler_level(struct irq_desc *desc, __unused void *handler_data)
492461
uint64_t rflags;
493462
irq_action_t action = desc->action;
494463

495-
/*
496-
* give other Core a try to return without hold irq_lock
497-
* and record irq_lost count here
498-
*/
499-
if (desc->state != IRQ_DESC_PENDING) {
500-
send_lapic_eoi();
501-
desc->irq_lost_cnt++;
502-
return 0;
503-
}
504-
505-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
506-
desc->state = IRQ_DESC_IN_PROCESS;
464+
spinlock_irqsave_obtain(&desc->lock, &rflags);
507465

508466
/* mask iopaic pin */
509467
if (irq_is_gsi(desc->irq)) {
@@ -517,14 +475,13 @@ int common_dev_handler_level(struct irq_desc *desc, __unused void *handler_data)
517475
action(desc->irq, desc->priv_data);
518476
}
519477

520-
desc->state = IRQ_DESC_PENDING;
521-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
478+
spinlock_irqrestore_release(&desc->lock, rflags);
522479

523480
/* we did not unmask irq until guest EOI the vector */
524481
return 0;
525482
}
526483

527-
/* no desc->irq_lock for quick handling local interrupt like lapic timer */
484+
/* no desc->lock for quick handling local interrupt like lapic timer */
528485
int quick_handler_nolock(struct irq_desc *desc, __unused void *handler_data)
529486
{
530487
irq_action_t action = desc->action;
@@ -549,9 +506,9 @@ void update_irq_handler(uint32_t irq, irq_handler_t func)
549506
}
550507

551508
desc = &irq_desc_array[irq];
552-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
509+
spinlock_irqsave_obtain(&desc->lock, &rflags);
553510
desc->irq_handler = func;
554-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
511+
spinlock_irqrestore_release(&desc->lock, rflags);
555512
}
556513

557514
void free_irq(uint32_t irq)
@@ -564,16 +521,15 @@ void free_irq(uint32_t irq)
564521
}
565522

566523
desc = &irq_desc_array[irq];
567-
dev_dbg(ACRN_DBG_IRQ, "[%s] %s irq%d vr:0x%x",
568-
__func__, desc->name, irq, irq_to_vector(irq));
524+
dev_dbg(ACRN_DBG_IRQ, "[%s] irq%d vr:0x%x",
525+
__func__, irq, irq_to_vector(irq));
569526

570-
spinlock_irqsave_obtain(&desc->irq_lock, &rflags);
527+
spinlock_irqsave_obtain(&desc->lock, &rflags);
571528

572529
desc->action = NULL;
573530
desc->priv_data = NULL;
574-
memset(desc->name, '\0', 32U);
575531

576-
spinlock_irqrestore_release(&desc->irq_lock, rflags);
532+
spinlock_irqrestore_release(&desc->lock, rflags);
577533
irq_desc_try_free_vector(desc->irq);
578534
}
579535

@@ -594,9 +550,6 @@ void get_cpu_interrupt_info(char *str_arg, int str_max)
594550
size -= len;
595551
str += len;
596552
}
597-
len = snprintf(str, size, "\tLOST");
598-
size -= len;
599-
str += len;
600553

601554
for (irq = 0U; irq < NR_IRQS; irq++) {
602555
desc = &irq_desc_array[irq];
@@ -612,9 +565,6 @@ void get_cpu_interrupt_info(char *str_arg, int str_max)
612565
size -= len;
613566
str += len;
614567
}
615-
len = snprintf(str, size, "\t%d", desc->irq_lost_cnt);
616-
size -= len;
617-
str += len;
618568
}
619569
}
620570
snprintf(str, size, "\r\n");

hypervisor/arch/x86/notify.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ void smp_call_function(uint64_t mask, smp_call_func_t func, void *data)
5555
wait_sync_change(&smp_call_mask, 0UL);
5656
}
5757

58-
static int request_notification_irq(irq_action_t func, void *data,
59-
const char *name)
58+
static int request_notification_irq(irq_action_t func, void *data)
6059
{
6160
int32_t retval;
6261

@@ -67,7 +66,7 @@ static int request_notification_irq(irq_action_t func, void *data,
6766
}
6867

6968
/* all cpu register the same notification vector */
70-
retval = request_irq(NOTIFY_IRQ, func, data, name);
69+
retval = request_irq(NOTIFY_IRQ, func, data);
7170
if (retval < 0) {
7271
pr_err("Failed to add notify isr");
7372
return -ENODEV;
@@ -80,17 +79,14 @@ static int request_notification_irq(irq_action_t func, void *data,
8079

8180
void setup_notification(void)
8281
{
83-
uint16_t cpu;
84-
char name[32] = {0};
82+
uint16_t cpu = get_cpu_id();
8583

86-
cpu = get_cpu_id();
8784
if (cpu > 0U) {
8885
return;
8986
}
9087

9188
/* support IPI notification, VM0 will register all CPU */
92-
snprintf(name, 32, "NOTIFY_ISR%d", cpu);
93-
if (request_notification_irq(kick_notification, NULL, name) < 0) {
89+
if (request_notification_irq(kick_notification, NULL) < 0) {
9490
pr_err("Failed to setup notification");
9591
return;
9692
}

hypervisor/arch/x86/timer.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ void del_timer(struct hv_timer *timer)
107107
}
108108
}
109109

110-
static int request_timer_irq(irq_action_t func, const char *name)
110+
static int request_timer_irq(irq_action_t func)
111111
{
112112
int32_t retval;
113113

114-
retval = request_irq(TIMER_IRQ, func, NULL, name);
114+
retval = request_irq(TIMER_IRQ, func, NULL);
115115
if (retval >= 0) {
116116
update_irq_handler(TIMER_IRQ, quick_handler_nolock);
117117
} else {
@@ -185,16 +185,14 @@ static void timer_softirq(uint16_t pcpu_id)
185185

186186
void timer_init(void)
187187
{
188-
char name[32] = {0};
189188
uint16_t pcpu_id = get_cpu_id();
190189

191190
init_percpu_timer(pcpu_id);
192191

193-
snprintf(name, 32, "timer_tick[%hu]", pcpu_id);
194192
if (pcpu_id == BOOT_CPU_ID) {
195193
register_softirq(SOFTIRQ_TIMER, timer_softirq);
196194

197-
if (request_timer_irq((irq_action_t)tsc_deadline_handler, name)
195+
if (request_timer_irq((irq_action_t)tsc_deadline_handler)
198196
< 0) {
199197
pr_err("Timer setup failed");
200198
return;

hypervisor/arch/x86/vtd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,7 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint)
828828

829829
retval = request_irq(IRQ_INVALID,
830830
dmar_fault_handler,
831-
dmar_uint,
832-
"dmar_fault_event");
831+
dmar_uint);
833832

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

hypervisor/common/ptdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ ptdev_activate_entry(struct ptdev_remapping_info *entry, uint32_t phys_irq)
136136

137137
/* register and allocate host vector/irq */
138138
retval = request_irq(phys_irq, ptdev_interrupt_handler,
139-
(void *)entry, "dev assign");
139+
(void *)entry);
140140

141141
ASSERT(retval >= 0, "dev register failed");
142142
entry->allocated_pirq = (uint32_t)retval;

0 commit comments

Comments
 (0)