vuart: assert COM1_IRQ based on its pin's polarity

COM1_IRQ's polarity setting is from ACPI table, as hypervisor do not want
to parse ACPI table here, it just get the configuration from vioapic RTE
setting as a work-around.

TODO:
Here should assert vuart irq according to COM1_IRQ polarity.  The best way
is to get the polarity info from ACIP table. But we just get the info from
vioapic configuration. Based on this, we can still have irq storm during
guest modify the vioapic setting.
As it's only for debug uart, we want to make it as an known issue.

Tracked-On: https://github.com/projectacrn/acrn-hypervisor/issues/1432
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ 2018-10-11 11:16:33 +08:00 committed by wenlingz
parent a11a10fa4e
commit 71927f3c5b

View File

@ -129,14 +129,30 @@ static uint8_t vuart_intr_reason(struct acrn_vuart *vu)
static void vuart_toggle_intr(struct acrn_vuart *vu) static void vuart_toggle_intr(struct acrn_vuart *vu)
{ {
uint8_t intr_reason; uint8_t intr_reason;
union ioapic_rte rte;
uint32_t operation;
intr_reason = vuart_intr_reason(vu); intr_reason = vuart_intr_reason(vu);
vioapic_get_rte(vu->vm, COM1_IRQ, &rte);
if (intr_reason != IIR_NOPEND) { /* TODO:
/* active low for COM1_IRQ polarity */ * Here should assert vuart irq according to COM1_IRQ polarity.
vpic_set_irq(vu->vm, COM1_IRQ, GSI_FALLING_PULSE); * The best way is to get the polarity info from ACIP table.
vioapic_set_irq(vu->vm, COM1_IRQ, GSI_FALLING_PULSE); * Here we just get the info from vioapic configuration.
* based on this, we can still have irq storm during guest
* modify the vioapic setting, as it's only for debug uart,
* we want to make it as an known issue.
*/
if ((rte.full & IOAPIC_RTE_INTPOL) != 0UL) {
operation = (intr_reason != IIR_NOPEND) ?
GSI_SET_LOW : GSI_SET_HIGH;
} else {
operation = (intr_reason != IIR_NOPEND) ?
GSI_SET_HIGH : GSI_SET_LOW;
} }
vpic_set_irq(vu->vm, COM1_IRQ, operation);
vioapic_set_irq(vu->vm, COM1_IRQ, operation);
} }
static void vuart_write(struct vm *vm, uint16_t offset_arg, static void vuart_write(struct vm *vm, uint16_t offset_arg,