From 30e421d2e519641d73c6bf7b6d41794302aec1b9 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 28 Nov 2022 15:18:45 +0100 Subject: [PATCH] pci: Remove unused restore() implementations Now that VirtioPciDevice, VfioPciDevice and VfioUserPciDevice have all been moved to the new restore design, there's no need to keep the old way around, therefore the restore() implementations for MsiConfig, MsixConfig and PciConfiguration can be removed. Signed-off-by: Sebastien Boeuf --- pci/src/configuration.rs | 17 -------------- pci/src/msi.rs | 41 ---------------------------------- pci/src/msix.rs | 48 ---------------------------------------- 3 files changed, 106 deletions(-) diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index 95379d9a6..62be16f8e 100644 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -644,18 +644,6 @@ impl PciConfiguration { } } - fn set_state(&mut self, state: &PciConfigurationState) { - self.registers.clone_from_slice(state.registers.as_slice()); - self.writable_bits - .clone_from_slice(state.writable_bits.as_slice()); - self.bars.clone_from_slice(state.bars.as_slice()); - self.rom_bar_addr = state.rom_bar_addr; - self.rom_bar_size = state.rom_bar_size; - self.rom_bar_used = state.rom_bar_used; - self.last_capability = state.last_capability; - self.msix_cap_reg_idx = state.msix_cap_reg_idx; - } - /// Reads a 32bit register from `reg_idx` in the register map. pub fn read_reg(&self, reg_idx: usize) -> u32 { *(self.registers.get(reg_idx).unwrap_or(&0xffff_ffff)) @@ -1086,11 +1074,6 @@ impl Snapshottable for PciConfiguration { fn snapshot(&mut self) -> std::result::Result { Snapshot::new_from_versioned_state(&self.id(), &self.state()) } - - fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> { - self.set_state(&snapshot.to_versioned_state(&self.id())?); - Ok(()) - } } impl Default for PciBarConfiguration { diff --git a/pci/src/msi.rs b/pci/src/msi.rs index 625842014..de9af3ab0 100644 --- a/pci/src/msi.rs +++ b/pci/src/msi.rs @@ -3,7 +3,6 @@ // SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause // -use anyhow::anyhow; use byteorder::{ByteOrder, LittleEndian}; use std::io; use std::sync::Arc; @@ -233,35 +232,6 @@ impl MsiConfig { MsiConfigState { cap: self.cap } } - fn set_state(&mut self, state: &MsiConfigState) -> Result<(), Error> { - self.cap = state.cap; - - if self.enabled() { - for idx in 0..self.num_enabled_vectors() { - let config = MsiIrqSourceConfig { - high_addr: self.cap.msg_addr_hi, - low_addr: self.cap.msg_addr_lo, - data: self.cap.msg_data as u32, - devid: 0, - }; - - self.interrupt_source_group - .update( - idx as InterruptIndex, - InterruptSourceConfig::MsiIrq(config), - self.cap.vector_masked(idx), - ) - .map_err(Error::UpdateInterruptRoute)?; - } - - self.interrupt_source_group - .enable() - .map_err(Error::EnableInterruptRoute)?; - } - - Ok(()) - } - pub fn enabled(&self) -> bool { self.cap.enabled() } @@ -320,15 +290,4 @@ impl Snapshottable for MsiConfig { fn snapshot(&mut self) -> std::result::Result { Snapshot::new_from_versioned_state(&self.id(), &self.state()) } - - fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> { - self.set_state(&snapshot.to_versioned_state(&self.id())?) - .map_err(|e| { - MigratableError::Restore(anyhow!( - "Could not restore state for {}: {:?}", - self.id(), - e - )) - }) - } } diff --git a/pci/src/msix.rs b/pci/src/msix.rs index fe5b95d11..28b851fae 100644 --- a/pci/src/msix.rs +++ b/pci/src/msix.rs @@ -4,7 +4,6 @@ // use crate::{PciCapability, PciCapabilityId}; -use anyhow::anyhow; use byteorder::{ByteOrder, LittleEndian}; use std::io; use std::result; @@ -152,42 +151,6 @@ impl MsixConfig { } } - fn set_state(&mut self, state: &MsixConfigState) -> result::Result<(), Error> { - self.table_entries = state.table_entries.clone(); - self.pba_entries = state.pba_entries.clone(); - self.masked = state.masked; - self.enabled = state.enabled; - - if self.enabled && !self.masked { - for (idx, table_entry) in self.table_entries.iter().enumerate() { - if table_entry.masked() { - continue; - } - - let config = MsiIrqSourceConfig { - high_addr: table_entry.msg_addr_hi, - low_addr: table_entry.msg_addr_lo, - data: table_entry.msg_data, - devid: self.devid, - }; - - self.interrupt_source_group - .update( - idx as InterruptIndex, - InterruptSourceConfig::MsiIrq(config), - self.masked, - ) - .map_err(Error::UpdateInterruptRoute)?; - - self.interrupt_source_group - .enable() - .map_err(Error::EnableInterruptRoute)?; - } - } - - Ok(()) - } - pub fn masked(&self) -> bool { self.masked } @@ -472,17 +435,6 @@ impl Snapshottable for MsixConfig { fn snapshot(&mut self) -> std::result::Result { Snapshot::new_from_versioned_state(&self.id(), &self.state()) } - - fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> { - self.set_state(&snapshot.to_versioned_state(&self.id())?) - .map_err(|e| { - MigratableError::Restore(anyhow!( - "Could not restore state for {}: {:?}", - self.id(), - e - )) - }) - } } #[allow(dead_code)]