ptdev: assert/deassert interrupt according to polarity

add active_polarity to decide what signal to call: GSI_SET_LOW, GSI_SET_HIGH,
GSI_FALLING_PULSE or GSI_RAISING_PULSE.

Tracked-On: #1269
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ 2018-09-28 15:20:02 +08:00 committed by Xie, Nanlin
parent e49233ba9b
commit 099203c15a
2 changed files with 37 additions and 5 deletions

View File

@ -107,6 +107,23 @@ ptdev_build_physical_rte(struct vm *vm,
vioapic_get_rte(vm, virt_sid->intx_id.pin, &virt_rte);
rte = virt_rte;
/* init polarity & pin state */
if ((rte.full & IOAPIC_RTE_INTPOL) != 0UL) {
if (entry->polarity == 0U) {
vioapic_set_irq_nolock(vm,
(uint32_t)virt_sid->intx_id.pin,
GSI_SET_HIGH);
}
entry->polarity = 1U;
} else {
if (entry->polarity == 1U) {
vioapic_set_irq_nolock(vm,
(uint32_t)virt_sid->intx_id.pin,
GSI_SET_LOW);
}
entry->polarity = 0U;
}
/* physical destination cpu mask */
phys = ((virt_rte.full & IOAPIC_RTE_DESTMOD) == IOAPIC_RTE_DESTPHY);
dest = (uint32_t)(virt_rte.full >> IOAPIC_RTE_DEST_SHIFT);
@ -359,12 +376,22 @@ static void ptdev_intr_handle_irq(struct vm *vm,
}
if (trigger_lvl) {
if (entry->polarity) {
vioapic_set_irq(vm, virt_sid->intx_id.pin,
GSI_SET_LOW);
} else {
vioapic_set_irq(vm, virt_sid->intx_id.pin,
GSI_SET_HIGH);
}
} else {
if (entry->polarity) {
vioapic_set_irq(vm, virt_sid->intx_id.pin,
GSI_FALLING_PULSE);
} else {
vioapic_set_irq(vm, virt_sid->intx_id.pin,
GSI_RAISING_PULSE);
}
}
dev_dbg(ACRN_DBG_PTIRQ,
"dev-assign: irq=0x%x assert vr: 0x%x vRTE=0x%lx",
@ -460,7 +487,11 @@ void ptdev_intx_ack(struct vm *vm, uint8_t virt_pin,
*/
switch (vpin_src) {
case PTDEV_VPIN_IOAPIC:
if (entry->polarity) {
vioapic_set_irq(vm, virt_pin, GSI_SET_HIGH);
} else {
vioapic_set_irq(vm, virt_pin, GSI_SET_LOW);
}
break;
case PTDEV_VPIN_PIC:
vpic_set_irq(vm, virt_pin, GSI_SET_LOW);

View File

@ -58,6 +58,7 @@ struct ptdev_remapping_info {
struct vm *vm;
uint32_t active; /* 1=active, 0=inactive and to free*/
uint32_t allocated_pirq;
uint32_t polarity; /* 0=active high, 1=active low*/
struct list_head softirq_node;
struct list_head entry_node;
struct ptdev_msi_info msi;