git: 596a470a1baa - main - bhyve: e82545: deassert the interrupt when its last cause is masked

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 16 Nov 2026 18:33:41 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=596a470a1baa5c828ab78918ce4301a96a057f4c

commit 596a470a1baa5c828ab78918ce4301a96a057f4c
Author:     Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2026-11-16 17:52:42 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-11-16 17:54:46 +0000

    bhyve: e82545: deassert the interrupt when its last cause is masked
    
    A write to IMC only cleared the bits in the mask.  If the device was
    asserting INTx for a cause that the write masked, the line stayed up
    until the guest cleared the cause in ICR.  The hardware deasserts INTx
    as soon as no unmasked cause is left, and a guest may rely on that:
    Windows masks all causes and unloads its driver when it shuts down, and
    then spends its time in the handlers of whatever shares the interrupt.
    
    Do what the comment in the code asked for.
    
    Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
    
    Reviewed by:    jhb
    Sponsored by:   keelos.dev
    Differential Revision:  https://reviews.freebsd.org/D60230
---
 usr.sbin/bhyve/pci_e82545.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/bhyve/pci_e82545.c b/usr.sbin/bhyve/pci_e82545.c
index 1afcb559f2bb..b893c4e1b9c5 100644
--- a/usr.sbin/bhyve/pci_e82545.c
+++ b/usr.sbin/bhyve/pci_e82545.c
@@ -671,8 +671,9 @@ e82545_intr_write(struct e82545_softc *sc, uint32_t offset, uint32_t value)
 	case E1000_IMC:
 		sc->esc_IMC = value;	/* for debug */
 		sc->esc_IMS &= ~value;
-		// XXX clear interrupts if all ICR bits now masked
-		// and interrupt was pending ?
+
+		/* Clear the interrupt if no unmasked source is left. */
+		e82545_icr_deassert(sc, 0);
 		break;
 	default:
 		break;