hv: pirq: do not indicate priority when allocate vector

It's not necessary to specify priority for dynamic allocated vector, because
nested irq is not supported on HV, and irq of any priority would cause VM exit.

This commit makes the following changes:
 - remove the argument indicating priority in struct irq_request_info and
   following functions:
    ptdev_activate_entry()
    find_available_vector()
    irq_desc_alloc_vector()
    normal_register_handler()
 - change the macro of vector ranges:
    VECTOR_DYNAMIC_START/END for dynamically allocable vectors;
    VECTOR_FIXED_START/END for fixed allocated vectors, such as vector for
    timer etc.

Signed-off-by: Yan, Like <like.yan@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Yan, Like
2018-08-06 17:48:45 +08:00
committed by lijinxia
parent 229bf32eb5
commit c492a14e53
9 changed files with 27 additions and 49 deletions

View File

@@ -629,7 +629,6 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf,
struct ptdev_msi_info *info)
{
struct ptdev_remapping_info *entry;
bool lowpri = !is_vm0(vm);
/*
* Device Model should pre-hold the mapping entries by calling
@@ -668,7 +667,7 @@ int ptdev_msix_remap(struct vm *vm, uint16_t virt_bdf,
if (!is_entry_active(entry)) {
/* update msi source and active entry */
ptdev_activate_entry(entry, IRQ_INVALID, lowpri);
ptdev_activate_entry(entry, IRQ_INVALID);
}
/* build physical config MSI, update to info->pmsi_xxx */
@@ -738,7 +737,6 @@ int ptdev_intx_pin_remap(struct vm *vm, struct ptdev_intx_info *info)
union ioapic_rte rte;
uint32_t phys_irq;
uint8_t phys_pin;
bool lowpri = !is_vm0(vm);
bool need_switch_vpin_src = false;
struct ptdev_intx_info *intx;
@@ -874,7 +872,7 @@ int ptdev_intx_pin_remap(struct vm *vm, struct ptdev_intx_info *info)
activate_physical_ioapic(vm, entry);
} else {
/* active entry */
ptdev_activate_entry(entry, phys_irq, lowpri);
ptdev_activate_entry(entry, phys_irq);
activate_physical_ioapic(vm, entry);

View File

@@ -472,7 +472,7 @@ vioapic_process_eoi(struct vm *vm, uint32_t vector)
uint32_t pin, pincount = vioapic_pincount(vm);
union ioapic_rte rte;
if (vector < VECTOR_FOR_INTR_START || vector > NR_MAX_VECTOR) {
if (vector < VECTOR_DYNAMIC_START || vector > NR_MAX_VECTOR) {
pr_err("vioapic_process_eoi: invalid vector %u", vector);
}

View File

@@ -372,7 +372,7 @@ void setup_ioapic_irq(void)
* for legacy irq, reserved vector and never free
*/
if (gsi < NR_LEGACY_IRQ) {
vr = irq_desc_alloc_vector(gsi, false);
vr = irq_desc_alloc_vector(gsi);
if (vr > NR_MAX_VECTOR) {
pr_err("failed to alloc VR");
gsi++;

View File

@@ -31,24 +31,14 @@ static void init_irq_desc(void)
}
/*
* alloc vector 0x20-0xDF for irq
* lowpri: 0x20-0x7F
* highpri: 0x80-0xDF
* find available vector VECTOR_DYNAMIC_START ~ VECTOR_DYNAMIC_END
*/
static uint32_t find_available_vector(bool lowpri)
static uint32_t find_available_vector()
{
uint32_t i, start, end;
if (lowpri) {
start = VECTOR_FOR_NOR_LOWPRI_START;
end = VECTOR_FOR_NOR_LOWPRI_END;
} else {
start = VECTOR_FOR_NOR_HIGHPRI_START;
end = VECTOR_FOR_NOR_HIGHPRI_END;
}
uint32_t i;
/* TODO: vector lock required */
for (i = start; i < end; i++) {
for (i = VECTOR_DYNAMIC_START; i <= VECTOR_DYNAMIC_END; i++) {
if (vector_to_irq[i] == IRQ_INVALID) {
return i;
}
@@ -269,11 +259,11 @@ common_register_handler(uint32_t irq_arg,
OUT:
if (added) {
/* it is safe to call irq_desc_alloc_vector multiple times*/
if (info->vector >= VECTOR_FOR_PRI_START &&
info->vector <= VECTOR_FOR_PRI_END) {
if (info->vector >= VECTOR_FIXED_START &&
info->vector <= VECTOR_FIXED_END) {
irq_desc_set_vector(irq, info->vector);
} else if (info->vector > NR_MAX_VECTOR) {
irq_desc_alloc_vector(irq, info->lowpri);
irq_desc_alloc_vector(irq);
} else {
pr_err("the input vector is not correct");
free(node);
@@ -296,7 +286,7 @@ OUT:
}
/* it is safe to call irq_desc_alloc_vector multiple times*/
uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri)
uint32_t irq_desc_alloc_vector(uint32_t irq)
{
uint32_t vr = VECTOR_INVALID;
struct irq_desc *desc;
@@ -316,7 +306,7 @@ uint32_t irq_desc_alloc_vector(uint32_t irq, bool lowpri)
}
/* FLAT mode, a irq connected to every cpu's same vector */
vr = find_available_vector(lowpri);
vr = find_available_vector();
if (vr > NR_MAX_VECTOR) {
pr_err("no vector found for irq[%d]", irq);
goto OUT;
@@ -634,20 +624,18 @@ UNLOCK_EXIT:
}
/*
* Allocate IRQ with Vector from 0x20 ~ 0xDF
* Allocate IRQ with Vector from VECTOR_DYNAMIC_START ~ VECTOR_DYNAMIC_END
*/
struct dev_handler_node*
normal_register_handler(uint32_t irq,
dev_handler_t func,
void *dev_data,
bool share,
bool lowpri,
const char *name)
{
struct irq_request_info info;
info.vector = VECTOR_INVALID;
info.lowpri = lowpri;
info.func = func;
info.dev_data = dev_data;
info.share = share;
@@ -657,7 +645,7 @@ normal_register_handler(uint32_t irq,
}
/*
* Allocate IRQ with vector from 0xE0 ~ 0xFF
* Allocate IRQ with vector from VECTOR_FIXED_START ~ VECTOR_FIXED_END
* Allocate a IRQ and install isr on that specific cpu
* User can install same irq/isr on different CPU by call this function multiple
* times
@@ -671,12 +659,11 @@ pri_register_handler(uint32_t irq,
{
struct irq_request_info info;
if (vector < VECTOR_FOR_PRI_START || vector > VECTOR_FOR_PRI_END) {
if (vector < VECTOR_FIXED_START || vector > VECTOR_FIXED_END) {
return NULL;
}
info.vector = vector;
info.lowpri = false;
info.func = func;
info.dev_data = dev_data;
info.share = true;

View File

@@ -827,7 +827,7 @@ static int dmar_setup_interrupt(struct dmar_drhd_rt *dmar_uint)
dmar_uint->dmar_irq_node = normal_register_handler(IRQ_INVALID,
dmar_fault_handler,
dmar_uint, true, false,
dmar_uint, true,
"dmar_fault_event");
if (dmar_uint->dmar_irq_node == NULL) {