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
@@ -574,6 +574,15 @@ hsa_status_t KfdDriver::SetTrapHandler(uint32_t node_id, const void* base, uint6
return HSA_STATUS_SUCCESS;
}
hsa_status_t KfdDriver::GetDeviceHandle(uint32_t node_id, void** device_handle) const {
assert(device_handle);
if (HSAKMT_CALL(hsaKmtGetAMDGPUDeviceHandle(node_id, reinterpret_cast<HsaAMDGPUDeviceHandle*>(device_handle))) != HSAKMT_STATUS_SUCCESS)
return HSA_STATUS_ERROR;
return HSA_STATUS_SUCCESS;
}
hsa_status_t KfdDriver::IsModelEnabled(bool* enable) const {
// AIE does not support streaming performance monitor.
HSAKMT_STATUS status = HSAKMT_STATUS_ERROR;
@@ -877,5 +877,9 @@ hsa_status_t XdnaDriver::SetTrapHandler(uint32_t node_id, const void* base, uint
return HSA_STATUS_ERROR;
}
hsa_status_t XdnaDriver::GetDeviceHandle(uint32_t node_id, void** device_handle) const {
return HSA_STATUS_ERROR;
}
} // namespace AMD
} // namespace rocr