summary refs log tree commit diff
path: root/vm_control/src/lib.rs
diff options
context:
space:
mode:
authorGurchetan Singh <gurchetansingh@chromium.org>2020-01-22 17:59:22 -0800
committerCommit Bot <commit-bot@chromium.org>2020-03-23 20:37:12 +0000
commit83fc5c49ba930a62ef1f4d93bc2004d779b6d16f (patch)
tree514d89cc061e6b34acaf5cbe10c254368729976a /vm_control/src/lib.rs
parent151af70ac9778f5247f6fd58fe8b20c089604429 (diff)
downloadcrosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.tar
crosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.tar.gz
crosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.tar.bz2
crosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.tar.lz
crosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.tar.xz
crosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.tar.zst
crosvm-83fc5c49ba930a62ef1f4d93bc2004d779b6d16f.zip
devices: gpu: complete resource V2 rebase
* Remove RESOURCE_V2_UNREF
* Add RESOURCE_MAP/RESOURCE_UNMAP to enable resources without guest
  storage that don't need to be mapped directly either

BUG=chromium:924405
TEST=compile and test

Change-Id: I10d6cd120d86131fa7ed8917ddad25cdb99ae50c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2015587
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Diffstat (limited to 'vm_control/src/lib.rs')
-rw-r--r--vm_control/src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/vm_control/src/lib.rs b/vm_control/src/lib.rs
index 298d800..b2577d9 100644
--- a/vm_control/src/lib.rs
+++ b/vm_control/src/lib.rs
@@ -192,7 +192,7 @@ pub enum VmMemoryRequest {
     RegisterMemory(MaybeOwnedFd, usize),
     /// Similiar to `VmMemoryRequest::RegisterMemory`, but doesn't allocate new address space.
     /// Useful for cases where the address space is already allocated (PCI regions).
-    RegisterMemoryAtAddress(Alloc, MaybeOwnedFd, usize, u64),
+    RegisterFdAtPciBarOffset(Alloc, MaybeOwnedFd, usize, u64),
     /// Unregister the given memory slot that was previously registereed with `RegisterMemory`.
     UnregisterMemory(u32),
     /// Allocate GPU buffer of a given size/format and register the memory into guest address space.
@@ -230,8 +230,8 @@ impl VmMemoryRequest {
                     Err(e) => VmMemoryResponse::Err(e),
                 }
             }
-            RegisterMemoryAtAddress(alloc, ref fd, size, guest_addr) => {
-                match register_memory(vm, sys_allocator, fd, size, Some((alloc, guest_addr))) {
+            RegisterFdAtPciBarOffset(alloc, ref fd, size, offset) => {
+                match register_memory(vm, sys_allocator, fd, size, Some((alloc, offset))) {
                     Ok((pfn, slot)) => VmMemoryResponse::RegisterMemory { pfn, slot },
                     Err(e) => VmMemoryResponse::Err(e),
                 }
@@ -433,12 +433,13 @@ fn register_memory(
     };
 
     let addr = match allocation {
-        Some((Alloc::PciBar { bus, dev, bar }, address)) => {
+        Some((Alloc::PciBar { bus, dev, bar }, offset)) => {
             match allocator
                 .mmio_allocator(MmioType::High)
                 .get(&Alloc::PciBar { bus, dev, bar })
             {
                 Some((start_addr, length, _)) => {
+                    let address = *start_addr + offset;
                     let range = *start_addr..*start_addr + *length;
                     let end = address + (size as u64);
                     match (range.contains(&address), range.contains(&end)) {