mirror of
https://github.com/google/alioth.git
synced 2024-11-24 04:09:36 +00:00
perf(pci): remove Arc from PCI configs
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
This commit is contained in:
parent
08aa5a7012
commit
607db09ee5
7 changed files with 20 additions and 30 deletions
|
@ -55,7 +55,7 @@ impl<const N: u64> Mmio for PvPanicBar<N> {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct PvPanic {
|
||||
pub config: Arc<EmulatedConfig>,
|
||||
pub config: EmulatedConfig,
|
||||
}
|
||||
|
||||
impl PvPanic {
|
||||
|
@ -82,9 +82,7 @@ impl PvPanic {
|
|||
let mut bars = [const { PciBar::Empty }; 6];
|
||||
bars[0] = bar0;
|
||||
let config = EmulatedConfig::new_device(header, bar_masks, bars, PciCapList::new());
|
||||
PvPanic {
|
||||
config: Arc::new(config),
|
||||
}
|
||||
PvPanic { config }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,8 +93,8 @@ impl Default for PvPanic {
|
|||
}
|
||||
|
||||
impl Pci for PvPanic {
|
||||
fn config(&self) -> Arc<dyn PciConfig> {
|
||||
self.config.clone()
|
||||
fn config(&self) -> &dyn PciConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
fn reset(&self) -> pci::Result<()> {
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::pci;
|
||||
use crate::pci::cap::PciCapList;
|
||||
use crate::pci::config::{CommonHeader, DeviceHeader, EmulatedConfig, HeaderType, PciConfig};
|
||||
|
@ -21,7 +19,7 @@ use crate::pci::{Pci, PciBar};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct HostBridge {
|
||||
pub config: Arc<EmulatedConfig>,
|
||||
pub config: EmulatedConfig,
|
||||
}
|
||||
|
||||
impl Default for HostBridge {
|
||||
|
@ -45,15 +43,13 @@ impl HostBridge {
|
|||
};
|
||||
let bars = [const { PciBar::Empty }; 6];
|
||||
let config = EmulatedConfig::new_device(header, [0; 6], bars, PciCapList::new());
|
||||
HostBridge {
|
||||
config: Arc::new(config),
|
||||
}
|
||||
HostBridge { config }
|
||||
}
|
||||
}
|
||||
|
||||
impl Pci for HostBridge {
|
||||
fn config(&self) -> Arc<dyn PciConfig> {
|
||||
self.config.clone()
|
||||
fn config(&self) -> &dyn PciConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
fn reset(&self) -> pci::Result<()> {
|
||||
|
|
|
@ -61,7 +61,7 @@ pub enum Error {
|
|||
pub type Result<T, E = Error> = std::result::Result<T, E>;
|
||||
|
||||
pub trait Pci: Debug + Send + Sync + 'static {
|
||||
fn config(&self) -> Arc<dyn PciConfig>;
|
||||
fn config(&self) -> &dyn PciConfig;
|
||||
fn reset(&self) -> Result<()>;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ use crate::pci::{Bdf, Pci, PciDevice, Result};
|
|||
struct EmptyDevice;
|
||||
|
||||
impl Pci for EmptyDevice {
|
||||
fn config(&self) -> Arc<dyn PciConfig> {
|
||||
fn config(&self) -> &dyn PciConfig {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
|
|
@ -387,7 +387,7 @@ pub struct VfioPciDev<M, D>
|
|||
where
|
||||
M: MsiSender,
|
||||
{
|
||||
config: Arc<PciPthConfig<D>>,
|
||||
config: PciPthConfig<D>,
|
||||
msix_table: Arc<MsixTableMmio<M::IrqFd>>,
|
||||
}
|
||||
|
||||
|
@ -396,8 +396,8 @@ where
|
|||
D: Device,
|
||||
M: MsiSender,
|
||||
{
|
||||
fn config(&self) -> Arc<dyn PciConfig> {
|
||||
self.config.clone()
|
||||
fn config(&self) -> &dyn PciConfig {
|
||||
&self.config
|
||||
}
|
||||
|
||||
fn reset(&self) -> pci::Result<()> {
|
||||
|
@ -538,7 +538,7 @@ where
|
|||
}
|
||||
|
||||
Ok(VfioPciDev {
|
||||
config: Arc::new(PciPthConfig {
|
||||
config: PciPthConfig {
|
||||
header: EmulatedHeader {
|
||||
data: Arc::new(RwLock::new(HeaderData {
|
||||
header: config_header,
|
||||
|
@ -555,7 +555,7 @@ where
|
|||
offset: region_config.offset,
|
||||
size: region_config.size as usize,
|
||||
},
|
||||
}),
|
||||
},
|
||||
msix_table,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -635,7 +635,7 @@ where
|
|||
E: IoeventFd,
|
||||
{
|
||||
pub dev: VirtioDevice<D, PciIrqSender<M>, E>,
|
||||
pub config: Arc<EmulatedConfig>,
|
||||
pub config: EmulatedConfig,
|
||||
pub registers: Arc<VirtioPciRegisterMmio<M>>,
|
||||
}
|
||||
|
||||
|
@ -854,9 +854,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
let config = Arc::new(EmulatedConfig::new_device(
|
||||
header, bar_masks, bars, cap_list,
|
||||
));
|
||||
let config = EmulatedConfig::new_device(header, bar_masks, bars, cap_list);
|
||||
|
||||
Ok(VirtioPciDevice {
|
||||
dev,
|
||||
|
@ -872,8 +870,8 @@ where
|
|||
D: Virtio,
|
||||
E: IoeventFd,
|
||||
{
|
||||
fn config(&self) -> Arc<dyn PciConfig> {
|
||||
self.config.clone()
|
||||
fn config(&self) -> &dyn PciConfig {
|
||||
&self.config
|
||||
}
|
||||
fn reset(&self) -> pci::Result<()> {
|
||||
self.registers.wake_up_dev(WakeEvent::Reset);
|
||||
|
|
|
@ -212,10 +212,8 @@ where
|
|||
} else {
|
||||
self.board.pci_bus.reserve(None, name.clone()).unwrap()
|
||||
};
|
||||
let config = dev.dev.config();
|
||||
dev.dev.config().get_header().set_bdf(bdf);
|
||||
self.board.pci_bus.add(bdf, dev);
|
||||
let header = config.get_header();
|
||||
header.set_bdf(bdf);
|
||||
log::info!("{bdf}: device: {name}");
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue