[magma] Drop use of deprecated magma_map*
Change-Id: I24954e59924133146b948190e5b5c0e3b4c26138
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/github.com/ARM-software/HWCPipe/+/452321
Reviewed-by: John Bauman <jbauman@google.com>
diff --git a/vendor/arm/mali/mali_profiler_magma.cpp b/vendor/arm/mali/mali_profiler_magma.cpp
index 03e4034..ab2dc58 100644
--- a/vendor/arm/mali/mali_profiler_magma.cpp
+++ b/vendor/arm/mali/mali_profiler_magma.cpp
@@ -34,6 +34,7 @@
#include <filesystem>
#include <lib/fdio/directory.h>
#include <lib/zx/channel.h>
+#include <lib/zx/vmar.h>
using mali_userspace::MALI_NAME_BLOCK_JM;
using mali_userspace::MALI_NAME_BLOCK_MMU;
@@ -447,13 +448,30 @@
{
throw std::runtime_error("Read performance counters failed.");
}
- void *data;
- status = magma_map(connection_, buffer_, &data);
- if (status != MAGMA_STATUS_OK)
+ void* data {};
{
- throw std::runtime_error("Mapping performance counters failed.");
+ magma_handle_t handle;
+ magma_status_t status = magma_get_buffer_handle(connection_, buffer_, &handle);
+ if (status != MAGMA_STATUS_OK)
+ throw std::runtime_error("Failed to get buffer handle");
+
+ zx::vmo vmo(handle);
+ zx_vaddr_t zx_vaddr;
+ zx_status_t zx_status = zx::vmar::root_self()->map(ZX_VM_PERM_READ | ZX_VM_PERM_WRITE,
+ 0, //vmar_offset,
+ vmo,
+ 0, //offset
+ buffer_size_, &zx_vaddr);
+ if (zx_status != ZX_OK)
+ throw std::runtime_error("Failed to map buffer");
+
+ data = reinterpret_cast<void *>(zx_vaddr);
}
+
memcpy(raw_counter_buffer_.data(), data, 4096);
+
+ zx::vmar::root_self()->unmap(reinterpret_cast<zx_vaddr_t>(data), buffer_size_);
+
timestamp_ = time;
magma_buffer_offset offset;
offset.buffer_id = magma_get_buffer_id(buffer_);