rocr/driver: add GetDeviceHandle to driver interface

This commit introduces a new GetDeviceHandle API to the driver
interface, allowing retrieval of the device handle for a
specific node.

- Implemented GetDeviceHandle in KfdDriver to fetch the AMD GPU
  device handle using hsaKmtGetAMDGPUDeviceHandle.
- Added a stub implementation of GetDeviceHandle in XdnaDriver
  that returns HSA_STATUS_ERROR.
- Modified GpuAgent::InitLibDrm to use driver().GetDeviceHandle
  instead of directly calling hsaKmtGetAMDGPUDeviceHandle.

Signed-off-by: Honglei Huang <Honglei1.Huang@amd.com>
This commit is contained in:
Honglei Huang
2025-07-01 14:00:37 +08:00
committed by Huang, Honglei1
parent 837fd044d0
commit 05b83e72d9
6 changed files with 26 additions and 4 deletions
@@ -124,6 +124,7 @@ public:
bool* is_spm_data_loss) const override;
hsa_status_t SetTrapHandler(uint32_t node_id, const void* base, uint64_t base_size,
const void* buffer_base, uint64_t buffer_base_size) const override;
hsa_status_t GetDeviceHandle(uint32_t node_id, void** device_handle) const override;
hsa_status_t OpenSMI(uint32_t node_id, int* fd) const override;
@@ -238,6 +238,7 @@ public:
bool* is_spm_data_loss) const override;
hsa_status_t SetTrapHandler(uint32_t node_id, const void* base, uint64_t base_size,
const void* buffer_base, uint64_t buffer_base_size) const override;
hsa_status_t GetDeviceHandle(uint32_t node_id, void** device_handle) const override;
hsa_status_t IsModelEnabled(bool* enable) const override;
+7
View File
@@ -269,6 +269,13 @@ public:
virtual hsa_status_t SetTrapHandler(uint32_t node_id, const void* base, uint64_t base_size,
const void* buffer_base, uint64_t buffer_base_size) const = 0;
/// @brief Gets the device handle for a specific node.
/// @param node_id Node ID of the agent
/// @param device_handle Device handle
/// @return HSA_STATUS_SUCCESS if the driver successfully returns the device
virtual hsa_status_t GetDeviceHandle(uint32_t node_id, void** device_handle) const = 0;
/// @brief Check if the HSA KMT Model is enabled
/// @param[out] enable True if the model is enabled, false otherwise
virtual hsa_status_t IsModelEnabled(bool* enable) const = 0;