Skip to content

Commit 933440e

Browse files
committed
pci: remove unused type from PciDevice::allocate_bars
Cloud Hypervisor code is passing a resource type argument in the logic that allocates BARs for devices. `Resource` is an Enum where one of its variants is `PciBar`. Not sure what Cloud Hypervisor uses this for, but it seems redundant since this method is specifically used to allocate BAR memory for devices. We definitely don't use it, so remove it. Signed-off-by: Babis Chalios <[email protected]>
1 parent d12e141 commit 933440e

File tree

4 files changed

+1
-28
lines changed

4 files changed

+1
-28
lines changed

src/pci/src/configuration.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::sync::{Arc, Mutex};
1010

1111
use byteorder::{ByteOrder, LittleEndian};
1212
use serde::{Deserialize, Serialize};
13-
use vm_device::PciBarType;
1413

1514
use crate::device::BarReprogrammingParams;
1615
use crate::MsixConfig;
@@ -443,26 +442,6 @@ pub enum PciBarRegionType {
443442
Memory64BitRegion = 0x04,
444443
}
445444

446-
impl From<PciBarType> for PciBarRegionType {
447-
fn from(type_: PciBarType) -> Self {
448-
match type_ {
449-
PciBarType::Io => PciBarRegionType::IoRegion,
450-
PciBarType::Mmio32 => PciBarRegionType::Memory32BitRegion,
451-
PciBarType::Mmio64 => PciBarRegionType::Memory64BitRegion,
452-
}
453-
}
454-
}
455-
456-
impl From<PciBarRegionType> for PciBarType {
457-
fn from(val: PciBarRegionType) -> Self {
458-
match val {
459-
PciBarRegionType::IoRegion => PciBarType::Io,
460-
PciBarRegionType::Memory32BitRegion => PciBarType::Mmio32,
461-
PciBarRegionType::Memory64BitRegion => PciBarType::Mmio64,
462-
}
463-
}
464-
}
465-
466445
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
467446
pub enum PciBarPrefetchable {
468447
NotPrefetchable = 0,

src/pci/src/device.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use std::sync::{Arc, Barrier};
1010
use std::{io, result};
1111

1212
use vm_allocator::AddressAllocator;
13-
use vm_device::Resource;
1413

1514
use crate::configuration::{self, PciBarRegionType};
1615
use crate::PciBarConfiguration;
@@ -25,8 +24,6 @@ pub enum Error {
2524
IoRegistrationFailed(u64, configuration::Error),
2625
/// Expected resource not found.
2726
MissingResource,
28-
/// Invalid resource
29-
InvalidResource(Resource),
3027
}
3128
pub type Result<T> = std::result::Result<T, Error>;
3229

@@ -45,7 +42,6 @@ pub trait PciDevice: Send {
4542
&mut self,
4643
_mmio32_allocator: &mut AddressAllocator,
4744
_mmio64_allocator: &mut AddressAllocator,
48-
_resources: Option<Vec<Resource>>,
4945
) -> Result<Vec<PciBarConfiguration>> {
5046
Ok(Vec::new())
5147
}

src/vmm/src/device_manager/pci_mngr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ impl PciDevices {
143143
virtio_device.allocate_bars(
144144
&mut resource_allocator.mmio32_memory,
145145
&mut resource_allocator.mmio64_memory,
146-
None,
147146
)?;
148147

149148
let virtio_device = Arc::new(Mutex::new(virtio_device));

src/vmm/src/devices/virtio/transport/pci/device.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use serde::{Deserialize, Serialize};
2727
use thiserror::Error;
2828
use vm_allocator::{AddressAllocator, AllocPolicy, RangeInclusive};
2929
use vm_device::interrupt::{InterruptIndex, InterruptSourceGroup, MsiIrqGroupConfig};
30-
use vm_device::{BusDevice, PciBarType, Resource};
30+
use vm_device::{BusDevice, PciBarType};
3131
use vm_memory::{Address, ByteValued, GuestAddress, Le32};
3232
use vmm_sys_util::errno;
3333
use vmm_sys_util::eventfd::EventFd;
@@ -886,7 +886,6 @@ impl PciDevice for VirtioPciDevice {
886886
&mut self,
887887
mmio32_allocator: &mut AddressAllocator,
888888
mmio64_allocator: &mut AddressAllocator,
889-
_resources: Option<Vec<Resource>>,
890889
) -> std::result::Result<Vec<PciBarConfiguration>, PciDeviceError> {
891890
let mut bars = Vec::new();
892891
let device_clone = self.device.clone();

0 commit comments

Comments
 (0)