Change libdrm initialization

Change initialize libdrm device and file descriptor initialization
to use new APIs from Thunk. Libdrm recommends that we re-use the same
file descriptor thoughout the life of a process instead of re-creating
new one each time.

This is part of patch series for Virtual Memory API.

Change-Id: I1c0b8d1bd660cd25478b5f94c84071b90d93fc6c


[ROCm/ROCR-Runtime commit: a55f11025b]
This commit is contained in:
David Yat Sin
2022-12-18 23:54:22 +00:00
parent 2a5f4263a8
commit 667ed434fb
3 changed files with 30 additions and 14 deletions
@@ -343,6 +343,9 @@ class GpuAgent : public GpuAgentInt {
// @brief returns true if agent uses MES scheduler
__forceinline const bool isMES() const { return (isa_->GetMajorVersion() >= 11) ? true : false; };
// @brief returns the libdrm device handle
__forceinline amdgpu_device_handle libDrmDev() const { return ldrm_dev_; }
void ReserveScratch();
void Trim() override;
@@ -554,6 +557,9 @@ class GpuAgent : public GpuAgentInt {
// Bind the Blit object that will drive the copy operation by engine ID
lazy_ptr<core::Blit>& GetBlitObject(uint32_t engine_id);
// @brief initialize libdrm handle
void InitLibDrm();
// @brief Alternative aperture base address. Only on KV.
uintptr_t ape1_base_;
@@ -584,6 +590,9 @@ class GpuAgent : public GpuAgentInt {
std::function<void(void*)> system_deallocator_;
// @brief device handle
amdgpu_device_handle ldrm_dev_;
DISALLOW_COPY_AND_ASSIGN(GpuAgent);
// Check if SDMA engine by ID is free
@@ -52,6 +52,11 @@
#include <utility>
#include <thread>
#if defined(__linux__)
#include <xf86drm.h>
#include <amdgpu.h>
#endif
#include "core/inc/hsa_ext_interface.h"
#include "core/inc/hsa_internal.h"
#include "core/inc/hsa_ext_amd_impl.h"