mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +00:00
pci: Remove all Weak references from PciBus
Now that the BusDevice devices are stored as Weak references by the IO and MMIO buses, there's no need to use Weak references from the PciBus anymore. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
ca426cfdf4
commit
49268bff3b
@ -11,7 +11,7 @@ use devices::BusDevice;
|
||||
use std;
|
||||
use std::any::Any;
|
||||
use std::ops::DerefMut;
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use vm_memory::{Address, GuestAddress, GuestUsize};
|
||||
|
||||
const VENDOR_ID_INTEL: u16 = 0x8086;
|
||||
@ -80,11 +80,11 @@ pub struct PciBus {
|
||||
/// Devices attached to this bus.
|
||||
/// Device 0 is host bridge.
|
||||
devices: Vec<Arc<Mutex<dyn PciDevice>>>,
|
||||
device_reloc: Weak<dyn DeviceRelocation>,
|
||||
device_reloc: Arc<dyn DeviceRelocation>,
|
||||
}
|
||||
|
||||
impl PciBus {
|
||||
pub fn new(pci_root: PciRoot, device_reloc: Weak<dyn DeviceRelocation>) -> Self {
|
||||
pub fn new(pci_root: PciRoot, device_reloc: Arc<dyn DeviceRelocation>) -> Self {
|
||||
let mut devices: Vec<Arc<Mutex<dyn PciDevice>>> = Vec::new();
|
||||
|
||||
devices.push(Arc::new(Mutex::new(pci_root)));
|
||||
@ -197,7 +197,7 @@ impl PciConfigIo {
|
||||
// Find out if one of the device's BAR is being reprogrammed, and
|
||||
// reprogram it if needed.
|
||||
if let Some(params) = device.detect_bar_reprogramming(register, data) {
|
||||
if let Err(e) = pci_bus.device_reloc.upgrade().unwrap().move_bar(
|
||||
if let Err(e) = pci_bus.device_reloc.move_bar(
|
||||
params.old_base,
|
||||
params.new_base,
|
||||
params.len,
|
||||
@ -313,7 +313,7 @@ impl PciConfigMmio {
|
||||
// Find out if one of the device's BAR is being reprogrammed, and
|
||||
// reprogram it if needed.
|
||||
if let Some(params) = device.detect_bar_reprogramming(register, data) {
|
||||
if let Err(e) = pci_bus.device_reloc.upgrade().unwrap().move_bar(
|
||||
if let Err(e) = pci_bus.device_reloc.move_bar(
|
||||
params.old_base,
|
||||
params.new_base,
|
||||
params.len,
|
||||
|
@ -630,7 +630,7 @@ impl DeviceManager {
|
||||
let pci_root = PciRoot::new(None);
|
||||
let mut pci_bus = PciBus::new(
|
||||
pci_root,
|
||||
Arc::downgrade(&self.address_manager) as Weak<dyn DeviceRelocation>,
|
||||
Arc::clone(&self.address_manager) as Arc<dyn DeviceRelocation>,
|
||||
);
|
||||
|
||||
let (iommu_device, iommu_mapping) = if self.config.lock().unwrap().iommu {
|
||||
|
Loading…
x
Reference in New Issue
Block a user