summary refs log tree commit diff
path: root/arch/src/lib.rs
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@chromium.org>2019-02-20 18:56:22 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-01 01:08:28 -0800
commite32a6c9b930166a7e64cc9200abb4279eb097c56 (patch)
treeab801543fd8343a7cb0d63e675c81c640adbad77 /arch/src/lib.rs
parentebc156186b6263c06deee7f361d7e558d352c2e0 (diff)
downloadcrosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.tar
crosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.tar.gz
crosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.tar.bz2
crosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.tar.lz
crosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.tar.xz
crosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.tar.zst
crosvm-e32a6c9b930166a7e64cc9200abb4279eb097c56.zip
devices: PCI: use configuration callback
Not sure if adding the device addresses to the mmio bus
is the desired behavior, but it seems to work.

BUG=chromium:924405
TEST=boot VM

Change-Id: I7f6057b3e7d041a52b251af1203353ba7a0d3c22
Reviewed-on: https://chromium-review.googlesource.com/1480743
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'arch/src/lib.rs')
-rw-r--r--arch/src/lib.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index 74545a5..2560ff5 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -94,6 +94,8 @@ pub trait LinuxArch {
 pub enum DeviceRegistrationError {
     /// Could not allocate IO space for the device.
     AllocateIoAddrs(PciDeviceError),
+    /// Could not allocate device address space for the device.
+    AllocateDeviceAddrs(PciDeviceError),
     /// Could not allocate an IRQ number.
     AllocateIrq,
     /// Could not create the mmio device to wrap a VirtioDevice.
@@ -122,6 +124,9 @@ impl fmt::Display for DeviceRegistrationError {
             DeviceRegistrationError::AllocateIoAddrs(e) => {
                 write!(f, "Allocating IO addresses: {}", e)
             }
+            DeviceRegistrationError::AllocateDeviceAddrs(e) => {
+                write!(f, "Allocating device addresses: {:?}", e)
+            }
             DeviceRegistrationError::AllocateIrq => write!(f, "Allocating IRQ number"),
             DeviceRegistrationError::CreateMmioDevice(e) => {
                 write!(f, "failed to create mmio device: {}", e)
@@ -187,6 +192,9 @@ pub fn generate_pci_root(
         let ranges = device
             .allocate_io_bars(resources)
             .map_err(DeviceRegistrationError::AllocateIoAddrs)?;
+        let device_ranges = device
+            .allocate_device_bars(resources)
+            .map_err(DeviceRegistrationError::AllocateDeviceAddrs)?;
         for (event, addr, datamatch) in device.ioeventfds() {
             let io_addr = IoeventAddress::Mmio(addr);
             vm.register_ioevent(&event, io_addr, datamatch)
@@ -207,6 +215,12 @@ pub fn generate_pci_root(
                 .insert(arced_dev.clone(), range.0, range.1, true)
                 .map_err(DeviceRegistrationError::MmioInsert)?;
         }
+
+        for range in &device_ranges {
+            mmio_bus
+                .insert(arced_dev.clone(), range.0, range.1, true)
+                .map_err(DeviceRegistrationError::MmioInsert)?;
+        }
     }
     Ok((root, pci_irqs, pid_labels))
 }