mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
virtio: switch to accessor for msix config
Convert the pub member to private and provide an accessor. Prevents the spread of poking in to a private member from vhost. Change-Id: Ib2070e990dc91c532164cc83f5af72bfbc9b2e89 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2795283 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
parent
8a7cc6bf2d
commit
a73b6522c4
3 changed files with 12 additions and 7 deletions
|
@ -13,7 +13,7 @@ pub struct Interrupt {
|
|||
interrupt_status: Arc<AtomicUsize>,
|
||||
interrupt_evt: Event,
|
||||
interrupt_resample_evt: Event,
|
||||
pub msix_config: Option<Arc<Mutex<MsixConfig>>>,
|
||||
msix_config: Option<Arc<Mutex<MsixConfig>>>,
|
||||
config_msix_vector: u16,
|
||||
}
|
||||
|
||||
|
@ -91,4 +91,9 @@ impl Interrupt {
|
|||
pub fn get_resample_evt(&self) -> &Event {
|
||||
&self.interrupt_resample_evt
|
||||
}
|
||||
|
||||
/// Get a reference to the msix configuration
|
||||
pub fn get_msix_config(&self) -> &Option<Arc<Mutex<MsixConfig>>> {
|
||||
&self.msix_config
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,11 +173,11 @@ impl VhostUserHandler {
|
|||
.set_vring_base(queue_index, 0)
|
||||
.map_err(Error::SetVringBase)?;
|
||||
|
||||
let msix_config = interrupt
|
||||
.msix_config
|
||||
let msix_config_opt = interrupt
|
||||
.get_msix_config()
|
||||
.as_ref()
|
||||
.ok_or(Error::MsixConfigUnavailable)?
|
||||
.lock();
|
||||
.ok_or(Error::MsixConfigUnavailable)?;
|
||||
let msix_config = msix_config_opt.lock();
|
||||
let irqfd = msix_config
|
||||
.get_irqfd(queue.vector as usize)
|
||||
.ok_or(Error::MsixIrqfdUnavailable)?;
|
||||
|
|
|
@ -199,7 +199,7 @@ impl<T: Vhost> Worker<T> {
|
|||
// with the msix. Due to this, cannot use the direct irq fd but
|
||||
// should fall back to indirect irq fd.
|
||||
if self.response_tube.is_some() {
|
||||
if let Some(msix_config) = &self.interrupt.msix_config {
|
||||
if let Some(msix_config) = self.interrupt.get_msix_config() {
|
||||
let msix_config = msix_config.lock();
|
||||
let msix_masked = msix_config.masked();
|
||||
if msix_masked {
|
||||
|
@ -227,7 +227,7 @@ impl<T: Vhost> Worker<T> {
|
|||
}
|
||||
|
||||
fn set_vring_calls(&self) -> Result<()> {
|
||||
if let Some(msix_config) = &self.interrupt.msix_config {
|
||||
if let Some(msix_config) = self.interrupt.get_msix_config() {
|
||||
let msix_config = msix_config.lock();
|
||||
if msix_config.masked() {
|
||||
for (queue_index, _) in self.queues.iter().enumerate() {
|
||||
|
|
Loading…
Reference in a new issue