devices: virtio: use signal helper for config changes

Add handling of the virtio device MSI-X configuration change vector by
using the signal function that was previously factored out.

BUG=chromium:854765
TEST=./build_test
TEST=trigger disk config change with `crosvm disk resize ...`

Change-Id: I462c23e10d152f896586bb70b95634a53088d480
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1898269
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zide Chen <zide.chen@intel.corp-partner.google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
Daniel Verkamp 2019-11-01 10:34:02 -07:00 committed by Commit Bot
parent 24eeed2b6f
commit 5eca937941
4 changed files with 10 additions and 6 deletions

View file

@ -14,6 +14,7 @@ pub struct Interrupt {
interrupt_evt: EventFd,
interrupt_resample_evt: EventFd,
msix_config: Option<Arc<Mutex<MsixConfig>>>,
config_msix_vector: u16,
}
impl Interrupt {
@ -22,12 +23,14 @@ impl Interrupt {
interrupt_evt: EventFd,
interrupt_resample_evt: EventFd,
msix_config: Option<Arc<Mutex<MsixConfig>>>,
config_msix_vector: u16,
) -> Interrupt {
Interrupt {
interrupt_status,
interrupt_evt,
interrupt_resample_evt,
msix_config,
config_msix_vector,
}
}
@ -64,12 +67,9 @@ impl Interrupt {
self.signal(vector, INTERRUPT_STATUS_USED_RING)
}
/// Notification of Device Configuration Changes
/// Set BIT1 in ISR and write to irqfd
/// Notify the driver that the device configuration has changed.
pub fn signal_config_changed(&self) {
self.interrupt_status
.fetch_or(INTERRUPT_STATUS_CONFIG_CHANGED as usize, Ordering::SeqCst);
self.interrupt_evt.write(1).unwrap();
self.signal(self.config_msix_vector, INTERRUPT_STATUS_CONFIG_CHANGED)
}
/// Handle interrupt resampling event

View file

@ -233,6 +233,7 @@ where
#[cfg(test)]
pub mod tests {
use super::*;
use crate::virtio::VIRTIO_MSI_NO_VECTOR;
use net_util::fakes::FakeTap;
use std::result;
use std::sync::atomic::AtomicUsize;
@ -295,6 +296,7 @@ pub mod tests {
EventFd::new().unwrap(),
EventFd::new().unwrap(),
None,
VIRTIO_MSI_NO_VECTOR,
),
vec![Queue::new(1)],
vec![EventFd::new().unwrap()],

View file

@ -618,6 +618,7 @@ impl PciDevice for VirtioPciDevice {
interrupt_evt,
interrupt_resample_evt,
msix_config,
self.common_config.msix_config,
);
self.device.activate(

View file

@ -88,7 +88,8 @@ fuzz_target!(|bytes| {
Arc::new(AtomicUsize::new(0)),
EventFd::new().unwrap(),
EventFd::new().unwrap(),
None, // msix_config
None, // msix_config
0xFFFF, // VIRTIO_MSI_NO_VECTOR
),
vec![q],
queue_evts,