diff --git a/hypervisor/common/ptdev.c b/hypervisor/common/ptdev.c index a057b13a4..6d2d149b1 100644 --- a/hypervisor/common/ptdev.c +++ b/hypervisor/common/ptdev.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #define PTIRQ_BITMAP_ARRAY_SIZE INT_DIV_ROUNDUP(CONFIG_MAX_PT_IRQ_ENTRIES, 64U) @@ -16,11 +15,6 @@ struct ptirq_remapping_info ptirq_entries[CONFIG_MAX_PT_IRQ_ENTRIES]; static uint64_t ptirq_entry_bitmaps[PTIRQ_BITMAP_ARRAY_SIZE]; spinlock_t ptdev_lock; -bool is_entry_active(const struct ptirq_remapping_info *entry) -{ - return atomic_load32(&entry->active) == ACTIVE_FLAG; -} - static inline uint16_t ptirq_alloc_entry_id(void) { uint16_t id = (uint16_t)ffz64_ex(ptirq_entry_bitmaps, CONFIG_MAX_PT_IRQ_ENTRIES); @@ -100,7 +94,7 @@ struct ptirq_remapping_info *ptirq_alloc_entry(struct acrn_vm *vm, uint32_t intr initialize_timer(&entry->intr_delay_timer, ptirq_intr_delay_callback, entry, 0UL, 0, 0UL); - atomic_clear32(&entry->active, ACTIVE_FLAG); + entry->active = false; } else { pr_err("Alloc ptdev irq entry failed"); } @@ -167,7 +161,7 @@ int32_t ptirq_activate_entry(struct ptirq_remapping_info *entry, uint32_t phys_i pr_err("request irq failed, please check!, phys-irq=%d", phys_irq); } else { entry->allocated_pirq = (uint32_t)retval; - atomic_set32(&entry->active, ACTIVE_FLAG); + entry->active = true; } return retval; @@ -175,7 +169,7 @@ int32_t ptirq_activate_entry(struct ptirq_remapping_info *entry, uint32_t phys_i void ptirq_deactivate_entry(struct ptirq_remapping_info *entry) { - atomic_clear32(&entry->active, ACTIVE_FLAG); + entry->active = false; free_irq(entry->allocated_pirq); } diff --git a/hypervisor/include/common/ptdev.h b/hypervisor/include/common/ptdev.h index f8677be65..237edd72a 100644 --- a/hypervisor/include/common/ptdev.h +++ b/hypervisor/include/common/ptdev.h @@ -11,8 +11,6 @@ #include #include -#define ACTIVE_FLAG 0x1U /* any non zero should be okay */ - #define PTDEV_INTR_MSI (1U << 0U) #define PTDEV_INTR_INTX (1U << 1U) @@ -133,7 +131,7 @@ struct ptirq_remapping_info { union source_id phys_sid; union source_id virt_sid; struct acrn_vm *vm; - uint32_t active; /* 1=active, 0=inactive and to free*/ + bool active; /* true=active, false=inactive*/ uint32_t allocated_pirq; uint32_t polarity; /* 0=active high, 1=active low*/ struct list_head softirq_node; @@ -144,10 +142,14 @@ struct ptirq_remapping_info { ptirq_arch_release_fn_t release_cb; }; +static inline bool is_entry_active(const struct ptirq_remapping_info *entry) +{ + return entry->active; +} + extern struct ptirq_remapping_info ptirq_entries[CONFIG_MAX_PT_IRQ_ENTRIES]; extern spinlock_t ptdev_lock; -bool is_entry_active(const struct ptirq_remapping_info *entry); void ptirq_softirq(uint16_t pcpu_id); void ptdev_init(void); void ptdev_release_all_entries(const struct acrn_vm *vm);