mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 16:57:20 +00:00
hv:Replace dynamic memory with static for ptdev
-- Config MAX_PT_IRQ_ENTRIES 64 in Kconfig -- Remove ptdev list -- Add alloc_ptdev_entry_id api v3-->v4: -- move is_entry_active from assign.c to ptdev.h -- Add clear active flag in release_entry v2-->v3: -- Remove redundancy active check for ptdev entry in release_all_entries and get_ptdev_info v1-->v2: -- split to small patches Tracked-On: #861 Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Reviewed-by: Binbin Wu <binbin.wu@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -113,6 +113,11 @@ config MAX_EMULATED_MMIO_REGIONS
|
||||
range 0 128
|
||||
default 16
|
||||
|
||||
config MAX_PT_IRQ_ENTRIES
|
||||
int "Maximum number of interrupt source for PT devices"
|
||||
range 0 128
|
||||
default 64
|
||||
|
||||
config MAX_IOMMU_NUM
|
||||
int "Maximum number of IOMMU devices"
|
||||
range 1 2
|
||||
|
@@ -19,12 +19,14 @@ static inline struct ptdev_remapping_info *
|
||||
ptdev_lookup_entry_by_sid(uint32_t intr_type,
|
||||
const union source_id *sid,const struct acrn_vm *vm)
|
||||
{
|
||||
uint16_t idx;
|
||||
struct ptdev_remapping_info *entry;
|
||||
struct list_head *pos;
|
||||
|
||||
list_for_each(pos, &ptdev_list) {
|
||||
entry = list_entry(pos, struct ptdev_remapping_info,
|
||||
entry_node);
|
||||
for (idx = 0U; idx < CONFIG_MAX_PT_IRQ_ENTRIES; idx++) {
|
||||
entry = &ptdev_irq_entries[idx];
|
||||
if (!is_entry_active(entry)) {
|
||||
continue;
|
||||
}
|
||||
if ((intr_type == entry->intr_type) &&
|
||||
((vm == NULL) ?
|
||||
(sid->value == entry->phys_sid.value) :
|
||||
@@ -37,12 +39,6 @@ ptdev_lookup_entry_by_sid(uint32_t intr_type,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_entry_active(const struct ptdev_remapping_info *entry)
|
||||
{
|
||||
return atomic_load32(&entry->active) == ACTIVE_FLAG;
|
||||
}
|
||||
|
||||
#ifdef HV_DEBUG
|
||||
static bool ptdev_hv_owned_intx(const struct acrn_vm *vm, const union source_id *virt_sid)
|
||||
{
|
||||
@@ -209,6 +205,9 @@ static struct ptdev_remapping_info *add_msix_remapping(struct acrn_vm *vm,
|
||||
}
|
||||
|
||||
entry = alloc_entry(vm, PTDEV_INTR_MSI);
|
||||
if (entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
entry->phys_sid.value = phys_sid.value;
|
||||
entry->virt_sid.value = virt_sid.value;
|
||||
|
||||
@@ -299,6 +298,9 @@ static struct ptdev_remapping_info *add_intx_remapping(struct acrn_vm *vm, uint8
|
||||
return NULL;
|
||||
}
|
||||
entry = alloc_entry(vm, PTDEV_INTR_INTX);
|
||||
if (entry == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
entry->phys_sid.value = phys_sid.value;
|
||||
entry->virt_sid.value = virt_sid.value;
|
||||
|
||||
@@ -830,6 +832,7 @@ void get_ptdev_info(char *str_arg, size_t str_max)
|
||||
{
|
||||
char *str = str_arg;
|
||||
struct ptdev_remapping_info *entry;
|
||||
uint16_t idx;
|
||||
size_t len, size = str_max;
|
||||
uint32_t irq, vector;
|
||||
char type[16];
|
||||
@@ -837,7 +840,6 @@ void get_ptdev_info(char *str_arg, size_t str_max)
|
||||
bool lvl_tm;
|
||||
uint8_t pin, vpin;
|
||||
uint32_t bdf, vbdf;
|
||||
struct list_head *pos;
|
||||
|
||||
len = snprintf(str, size, "\r\nVM\tTYPE\tIRQ\tVEC\tDEST\tTM\tPIN\tVPIN\tBDF\tVBDF");
|
||||
if (len >= size) {
|
||||
@@ -847,9 +849,8 @@ void get_ptdev_info(char *str_arg, size_t str_max)
|
||||
str += len;
|
||||
|
||||
spinlock_obtain(&ptdev_lock);
|
||||
list_for_each(pos, &ptdev_list) {
|
||||
entry = list_entry(pos, struct ptdev_remapping_info,
|
||||
entry_node);
|
||||
for (idx = 0U; idx < CONFIG_MAX_PT_IRQ_ENTRIES; idx++) {
|
||||
entry = &ptdev_irq_entries[idx];
|
||||
if (is_entry_active(entry)) {
|
||||
get_entry_info(entry, type, &irq, &vector,
|
||||
&dest, &lvl_tm, &pin, &vpin,
|
||||
|
Reference in New Issue
Block a user