summary refs log tree commit diff
path: root/devices/src
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-10-31 16:59:23 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-06 22:20:42 +0000
commit0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e (patch)
tree3cf8881aca8ca2e7d19474678f9eec95c80d8e42 /devices/src
parentf5ee34a48299be8af3852d6e769274530a798a2c (diff)
downloadcrosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.tar
crosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.tar.gz
crosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.tar.bz2
crosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.tar.lz
crosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.tar.xz
crosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.tar.zst
crosvm-0a517b31795b2ab8c70b3d5dcc5565da6e6cc53e.zip
devices: virtio: simplify interrupt status update
The first interrupt_status.fetch_or() operation already sets the
appropriate bit; calling fetch_or() again with the same value is
unnecessary.

In addition, if the interrupt_status field has any bit set (not just the
USED_RING bit), then the interrupt is already pending and we don't need
to trigger it again.

BUG=chromium:854765
TEST=./build_test.py

Change-Id: Iba7fb9b934d062db801f8ba0e743618f9db580ee
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898045
Reviewed-by: Zide Chen <zide.chen@intel.corp-partner.google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'devices/src')
-rw-r--r--devices/src/virtio/interrupt.rs6
1 files changed, 2 insertions, 4 deletions
diff --git a/devices/src/virtio/interrupt.rs b/devices/src/virtio/interrupt.rs
index 3a3d7e2..dd17ba7 100644
--- a/devices/src/virtio/interrupt.rs
+++ b/devices/src/virtio/interrupt.rs
@@ -45,16 +45,14 @@ impl Interrupt {
             }
         }
 
+        // Set BIT0 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)
-            & INTERRUPT_STATUS_USED_RING as usize
             == 0
         {
-            // Set BIT0 in ISR and write to irqfd to inject INTx interrupt
-            self.interrupt_status
-                .fetch_or(INTERRUPT_STATUS_USED_RING as usize, Ordering::SeqCst);
+            // Write to irqfd to inject INTx interrupt
             self.interrupt_evt.write(1).unwrap();
         }
     }