From ecfed3ab954dd5ecc7e9db4b24c92339e9c6b4d5 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 31 Oct 2019 17:10:51 -0700 Subject: [PATCH] devices: virtio: factor out interrupt signal function This will be used for configuration interrupts as well. No functional change. BUG=chromium:854765 TEST=./build_test.py Change-Id: Iacccfd0a93a5c90783033a8e37598c2683704351 Signed-off-by: Daniel Verkamp Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898267 Tested-by: kokoro Reviewed-by: Zide Chen Reviewed-by: Zach Reizner --- devices/src/virtio/interrupt.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/devices/src/virtio/interrupt.rs b/devices/src/virtio/interrupt.rs index 2715d12ffb..0665b3fc99 100644 --- a/devices/src/virtio/interrupt.rs +++ b/devices/src/virtio/interrupt.rs @@ -35,7 +35,7 @@ impl Interrupt { /// /// If MSI-X is enabled in this device, MSI-X interrupt is preferred. /// Write to the irqfd to VMM to deliver virtual interrupt to the guest - pub fn signal_used_queue(&self, vector: u16) { + fn signal(&self, vector: u16, interrupt_status_mask: u32) { // Don't need to set ISR for MSI-X interrupts if let Some(msix_config) = &self.msix_config { let mut msix_config = msix_config.lock(); @@ -47,11 +47,11 @@ impl Interrupt { } } - // Set BIT0 in ISR and inject the interrupt if it was not already pending. + // Set bit in ISR and inject the interrupt if it was not already pending. // Don't need to inject the interrupt if the guest hasn't processed it. if self .interrupt_status - .fetch_or(INTERRUPT_STATUS_USED_RING as usize, Ordering::SeqCst) + .fetch_or(interrupt_status_mask as usize, Ordering::SeqCst) == 0 { // Write to irqfd to inject INTx interrupt @@ -59,6 +59,11 @@ impl Interrupt { } } + /// Notify the driver that buffers have been placed in the used queue. + pub fn signal_used_queue(&self, vector: u16) { + self.signal(vector, INTERRUPT_STATUS_USED_RING) + } + /// Notification of Device Configuration Changes /// Set BIT1 in ISR and write to irqfd pub fn signal_config_changed(&self) {