mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 06:29:19 +00:00
hv: ptdev: fix MISRAC violations
This patch fixs MISRAC violations in common/ptdev.c and include/common/ptdev.h Tracked-On: #861 Signed-off-by: Binbin Wu <binbin.wu@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
parent
ccda4595bc
commit
83ebd43239
@ -24,12 +24,12 @@ static inline uint16_t ptirq_alloc_entry_id(void)
|
|||||||
|
|
||||||
while (id < CONFIG_MAX_PT_IRQ_ENTRIES) {
|
while (id < CONFIG_MAX_PT_IRQ_ENTRIES) {
|
||||||
if (!bitmap_test_and_set_lock((id & 0x3FU), &ptirq_entry_bitmaps[id >> 6U])) {
|
if (!bitmap_test_and_set_lock((id & 0x3FU), &ptirq_entry_bitmaps[id >> 6U])) {
|
||||||
return id;
|
break;
|
||||||
}
|
}
|
||||||
id = (uint16_t)ffz64_ex(ptirq_entry_bitmaps, CONFIG_MAX_PT_IRQ_ENTRIES);
|
id = (uint16_t)ffz64_ex(ptirq_entry_bitmaps, CONFIG_MAX_PT_IRQ_ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
return INVALID_PTDEV_ENTRY_ID;
|
return (id < CONFIG_MAX_PT_IRQ_ENTRIES) ? id: INVALID_PTDEV_ENTRY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ptirq_enqueue_softirq(struct ptirq_remapping_info *entry)
|
static void ptirq_enqueue_softirq(struct ptirq_remapping_info *entry)
|
||||||
@ -86,28 +86,27 @@ struct ptirq_remapping_info *ptirq_dequeue_softirq(struct acrn_vm *vm)
|
|||||||
|
|
||||||
struct ptirq_remapping_info *ptirq_alloc_entry(struct acrn_vm *vm, uint32_t intr_type)
|
struct ptirq_remapping_info *ptirq_alloc_entry(struct acrn_vm *vm, uint32_t intr_type)
|
||||||
{
|
{
|
||||||
struct ptirq_remapping_info *entry;
|
struct ptirq_remapping_info *entry = NULL;
|
||||||
uint16_t ptirq_id = ptirq_alloc_entry_id();
|
uint16_t ptirq_id = ptirq_alloc_entry_id();
|
||||||
|
|
||||||
if (ptirq_id >= CONFIG_MAX_PT_IRQ_ENTRIES) {
|
if (ptirq_id < CONFIG_MAX_PT_IRQ_ENTRIES) {
|
||||||
|
entry = &ptirq_entries[ptirq_id];
|
||||||
|
(void)memset((void *)entry, 0U, sizeof(struct ptirq_remapping_info));
|
||||||
|
entry->ptdev_entry_id = ptirq_id;
|
||||||
|
entry->intr_type = intr_type;
|
||||||
|
entry->vm = vm;
|
||||||
|
entry->intr_count = 0UL;
|
||||||
|
|
||||||
|
INIT_LIST_HEAD(&entry->softirq_node);
|
||||||
|
|
||||||
|
initialize_timer(&entry->intr_delay_timer, ptirq_intr_delay_callback,
|
||||||
|
entry, 0UL, 0, 0UL);
|
||||||
|
|
||||||
|
atomic_clear32(&entry->active, ACTIVE_FLAG);
|
||||||
|
} else {
|
||||||
pr_err("Alloc ptdev irq entry failed");
|
pr_err("Alloc ptdev irq entry failed");
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = &ptirq_entries[ptirq_id];
|
|
||||||
(void)memset((void *)entry, 0U, sizeof(struct ptirq_remapping_info));
|
|
||||||
entry->ptdev_entry_id = ptirq_id;
|
|
||||||
entry->intr_type = intr_type;
|
|
||||||
entry->vm = vm;
|
|
||||||
entry->intr_count = 0UL;
|
|
||||||
|
|
||||||
INIT_LIST_HEAD(&entry->softirq_node);
|
|
||||||
|
|
||||||
initialize_timer(&entry->intr_delay_timer, ptirq_intr_delay_callback,
|
|
||||||
entry, 0UL, 0, 0UL);
|
|
||||||
|
|
||||||
atomic_clear32(&entry->active, ACTIVE_FLAG);
|
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,12 +187,11 @@ void ptirq_deactivate_entry(struct ptirq_remapping_info *entry)
|
|||||||
|
|
||||||
void ptdev_init(void)
|
void ptdev_init(void)
|
||||||
{
|
{
|
||||||
if (get_cpu_id() != BOOT_CPU_ID) {
|
if (get_cpu_id() == BOOT_CPU_ID) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
spinlock_init(&ptdev_lock);
|
spinlock_init(&ptdev_lock);
|
||||||
register_softirq(SOFTIRQ_PTDEV, ptirq_softirq);
|
register_softirq(SOFTIRQ_PTDEV, ptirq_softirq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ptdev_release_all_entries(const struct acrn_vm *vm)
|
void ptdev_release_all_entries(const struct acrn_vm *vm)
|
||||||
|
@ -68,7 +68,7 @@ struct ptirq_remapping_info {
|
|||||||
struct hv_timer intr_delay_timer; /* used for delay intr injection */
|
struct hv_timer intr_delay_timer; /* used for delay intr injection */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ptirq_remapping_info ptirq_entries[];
|
extern struct ptirq_remapping_info ptirq_entries[CONFIG_MAX_PT_IRQ_ENTRIES];
|
||||||
extern spinlock_t ptdev_lock;
|
extern spinlock_t ptdev_lock;
|
||||||
|
|
||||||
bool is_entry_active(const struct ptirq_remapping_info *entry);
|
bool is_entry_active(const struct ptirq_remapping_info *entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user