From 95f1bca33a5ad31f429e8868182eed34c1826b7f Mon Sep 17 00:00:00 2001 From: Dylan Reid Date: Wed, 24 Jun 2020 22:22:36 -0700 Subject: [PATCH] devices: interrupt: add simple resample Instead of coupling the reading of the event fd and the resampling of the interrupt, add a separate member to just do the resample. This will be used by async code that waits for and reads the event fd in one step. Change-Id: Ic5b1fd9adf8e32a572f31dc1c0c5ab32e94f4981 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2268978 Commit-Queue: Dylan Reid Tested-by: Dylan Reid Tested-by: kokoro Reviewed-by: Daniel Verkamp --- devices/src/virtio/interrupt.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/devices/src/virtio/interrupt.rs b/devices/src/virtio/interrupt.rs index 91a3942384..2568080d02 100644 --- a/devices/src/virtio/interrupt.rs +++ b/devices/src/virtio/interrupt.rs @@ -72,9 +72,15 @@ impl Interrupt { self.signal(self.config_msix_vector, INTERRUPT_STATUS_CONFIG_CHANGED) } - /// Handle interrupt resampling event + /// Handle interrupt resampling event, reading the value from the event and doing the resample. pub fn interrupt_resample(&self) { let _ = self.interrupt_resample_evt.read(); + self.do_interrupt_resample(); + } + + /// Read the status and write to the interrupt event. Don't read the resample event, assume the + /// resample has been requested. + pub fn do_interrupt_resample(&self) { if self.interrupt_status.load(Ordering::SeqCst) != 0 { self.interrupt_evt.write(1).unwrap(); }