@@ -24,12 +24,12 @@ static inline uint16_t ptirq_alloc_entry_id(void)
24
24
25
25
while (id < CONFIG_MAX_PT_IRQ_ENTRIES ) {
26
26
if (!bitmap_test_and_set_lock ((id & 0x3FU ), & ptirq_entry_bitmaps [id >> 6U ])) {
27
- return id ;
27
+ break ;
28
28
}
29
29
id = (uint16_t )ffz64_ex (ptirq_entry_bitmaps , CONFIG_MAX_PT_IRQ_ENTRIES );
30
30
}
31
31
32
- return INVALID_PTDEV_ENTRY_ID ;
32
+ return ( id < CONFIG_MAX_PT_IRQ_ENTRIES ) ? id : INVALID_PTDEV_ENTRY_ID ;
33
33
}
34
34
35
35
static void ptirq_enqueue_softirq (struct ptirq_remapping_info * entry )
@@ -86,27 +86,26 @@ struct ptirq_remapping_info *ptirq_dequeue_softirq(struct acrn_vm *vm)
86
86
87
87
struct ptirq_remapping_info * ptirq_alloc_entry (struct acrn_vm * vm , uint32_t intr_type )
88
88
{
89
- struct ptirq_remapping_info * entry ;
89
+ struct ptirq_remapping_info * entry = NULL ;
90
90
uint16_t ptirq_id = ptirq_alloc_entry_id ();
91
91
92
- if (ptirq_id >= CONFIG_MAX_PT_IRQ_ENTRIES ) {
93
- pr_err ("Alloc ptdev irq entry failed" );
94
- return NULL ;
95
- }
96
-
97
- entry = & ptirq_entries [ptirq_id ];
98
- (void )memset ((void * )entry , 0U , sizeof (struct ptirq_remapping_info ));
99
- entry -> ptdev_entry_id = ptirq_id ;
100
- entry -> intr_type = intr_type ;
101
- entry -> vm = vm ;
102
- entry -> intr_count = 0UL ;
92
+ if (ptirq_id < CONFIG_MAX_PT_IRQ_ENTRIES ) {
93
+ entry = & ptirq_entries [ptirq_id ];
94
+ (void )memset ((void * )entry , 0U , sizeof (struct ptirq_remapping_info ));
95
+ entry -> ptdev_entry_id = ptirq_id ;
96
+ entry -> intr_type = intr_type ;
97
+ entry -> vm = vm ;
98
+ entry -> intr_count = 0UL ;
103
99
104
- INIT_LIST_HEAD (& entry -> softirq_node );
100
+ INIT_LIST_HEAD (& entry -> softirq_node );
105
101
106
- initialize_timer (& entry -> intr_delay_timer , ptirq_intr_delay_callback ,
107
- entry , 0UL , 0 , 0UL );
102
+ initialize_timer (& entry -> intr_delay_timer , ptirq_intr_delay_callback ,
103
+ entry , 0UL , 0 , 0UL );
108
104
109
- atomic_clear32 (& entry -> active , ACTIVE_FLAG );
105
+ atomic_clear32 (& entry -> active , ACTIVE_FLAG );
106
+ } else {
107
+ pr_err ("Alloc ptdev irq entry failed" );
108
+ }
110
109
111
110
return entry ;
112
111
}
@@ -188,12 +187,11 @@ void ptirq_deactivate_entry(struct ptirq_remapping_info *entry)
188
187
189
188
void ptdev_init (void )
190
189
{
191
- if (get_cpu_id () != BOOT_CPU_ID ) {
192
- return ;
193
- }
190
+ if (get_cpu_id () == BOOT_CPU_ID ) {
194
191
195
- spinlock_init (& ptdev_lock );
196
- register_softirq (SOFTIRQ_PTDEV , ptirq_softirq );
192
+ spinlock_init (& ptdev_lock );
193
+ register_softirq (SOFTIRQ_PTDEV , ptirq_softirq );
194
+ }
197
195
}
198
196
199
197
void ptdev_release_all_entries (const struct acrn_vm * vm )
0 commit comments