libdmabufheap: test: Don't create mapping if heap is supported neither in DMA-BUF heaps nor ION
If a client creates a legacy ION mapping for the system-uncached DMA-BUF heap
but neither supports the DMA-BUF heap nor its ION version, the
AllocSystem() API fails when 'cpu_access_needed' argument is false.
The API first tries to allocate in the system-uncached DMA-BUF heap.
When it finds the heap unsupported, it looks for any existing mappings
and assumes that since a legacy ION mapping has been created, the ION
variant of the heap must be supported.
Since it is not mandatory to support system-uncached DMA-BUF heap or its
ION variant, this patch fixes the usecase by creating the legacy mapping
only when ION is supported on the device.
Bug: 196079974
Test: atest dmabufheap-vts-unit-tests
Change-Id: I03e81235df381a080edbd506596f04bbeafaefda
Signed-off-by: Hridya Valsaraju <hridya@google.com>
diff --git a/tests/dmabuf_heap_test.cpp b/tests/dmabuf_heap_test.cpp
index 243f703..c88cf14 100644
--- a/tests/dmabuf_heap_test.cpp
+++ b/tests/dmabuf_heap_test.cpp
@@ -116,12 +116,14 @@
* available heap when asked to allocate from the system or system-uncached
* heap.
*/
- allocator->MapNameToIonHeap(kDmabufSystemHeapName, "" /* no mapping for non-legacy */,
- 0 /* no mapping for non-legacy ion */,
- ~0 /* legacy ion heap mask */);
- allocator->MapNameToIonHeap(kDmabufSystemUncachedHeapName, "" /* no mapping for non-legacy */,
- 0 /* no mapping for non-legacy ion */,
- ~0 /* legacy ion heap mask */);
+ if (BufferAllocator::CheckIonSupport()) {
+ allocator->MapNameToIonHeap(kDmabufSystemHeapName, "" /* no mapping for non-legacy */,
+ 0 /* no mapping for non-legacy ion */,
+ ~0 /* legacy ion heap mask */);
+ allocator->MapNameToIonHeap(
+ kDmabufSystemUncachedHeapName, "" /* no mapping for non-legacy */,
+ 0 /* no mapping for non-legacy ion */, ~0 /* legacy ion heap mask */);
+ }
}
TEST_F(DmaBufHeapTest, Allocate) {