hw/bt: Work around QEMU lost interrupt bug

QEMU has a bug where it loses the BT interrupt somewhere between BT
and XIVE when the OS boots.

For now, add a workaround QEMU quirk in the poller to try to kick
things along again.

SBE suffers the same problem but it has a poller that kicks the SBE and
gets it going again. Suspect the PSI interrupts may not be re-presented
after the OS re-initialises XIVE. This issue does not seem to appear on
real hardware.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
diff --git a/hw/bt.c b/hw/bt.c
index 1912cd3..f813185 100644
--- a/hw/bt.c
+++ b/hw/bt.c
@@ -490,6 +490,16 @@
 #if BT_QUEUE_DEBUG
 	print_debug_queue_info();
 #endif
+	if (chip_quirk(QUIRK_QEMU) && !bt.irq_ok) {
+		/*
+		 * QEMU has a bug where PSI interrupts are lost when booting
+		 * the OS (perhaps when XIVE is reset, are the interrupts not
+		 * re-presented?) Clearing the irq here gets things moving.
+		 */
+		if (bt_inb(BT_INTMASK) & BT_INTMASK_B2H_IRQ)
+			bt_outb(BT_INTMASK_B2H_IRQ | BT_INTMASK_B2H_IRQEN,
+					BT_INTMASK);
+	}
 
 	bt_ctrl = bt_inb(BT_CTRL);