mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-18 19:57:31 +00:00
hv: ptdev: refine ptdev active flag
Since spinlock ptdev_lock is used to protect ptdev entry, there's no need to use atomic operation to protect ptdev active flag in split of it's wrong used to protect ptdev entry. And refine active flag data type to bool. Tracked-On: #1842 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
cb8bbf7bea
commit
647797ff1a
@ -8,7 +8,6 @@
|
||||
#include <softirq.h>
|
||||
#include <ptdev.h>
|
||||
#include <irq.h>
|
||||
#include <atomic.h>
|
||||
#include <logmsg.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include <pci.h>
|
||||
#include <timer.h>
|
||||
|
||||
#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);
|
||||
|
Loading…
Reference in New Issue
Block a user