Revert "rocr: river interface changes" (#724)

This commit reverts the following related commits which cause
test failures:

6d15779b3e rocr/driver: add PC sampling support to driver interface
56cb9390ff rocr/driver: add PC sampling support to driver interface
76bf829f09 rocr/driver: add ASAN header page management to Driver class
a47c060d6a rocr/driver: add ASAN header page management to Driver class
02d7eaf3b7 rocr: add memory sharing call to Driver interface
9312468655 rocr: add memory sharing call to Driver interface
Dieser Commit ist enthalten in:
cfreeamd
2025-08-25 02:14:26 -05:00
committet von GitHub
Ursprung f2f7f03d61
Commit a013e141b7
6 geänderte Dateien mit 25 neuen und 243 gelöschten Zeilen
@@ -2553,14 +2553,14 @@ hsa_status_t GpuAgent::PcSamplingIterateConfig(hsa_ven_amd_pcs_iterate_configura
return HSA_STATUS_ERROR;
// First query to get size of list needed
hsa_status_t ret = driver().PcSamplingQueryCapabilities(node_id(), NULL, 0, &size);
if (ret != HSA_STATUS_SUCCESS || size == 0) return ret;
HSAKMT_STATUS ret = HSAKMT_CALL(hsaKmtPcSamplingQueryCapabilities(node_id(), NULL, 0, &size));
if (ret != HSAKMT_STATUS_SUCCESS || size == 0) return HSA_STATUS_ERROR;
std::vector<HsaPcSamplingInfo> sampleInfoList(size);
ret = driver().PcSamplingQueryCapabilities(node_id(), sampleInfoList.data(),
sampleInfoList.size(), &size);
ret = HSAKMT_CALL(hsaKmtPcSamplingQueryCapabilities(node_id(), sampleInfoList.data(), sampleInfoList.size(),
&size));
if (ret != HSA_STATUS_SUCCESS) return ret;
if (ret != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR;
for (uint32_t i = 0; i < size; i++) {
hsa_ven_amd_pcs_configuration_t hsaPcSampling;
@@ -2586,9 +2586,10 @@ hsa_status_t GpuAgent::PcSamplingCreate(pcs::PcsRuntime::PcSamplingSession& sess
// Pass the sampling information to the kernel driver to create PC
// sampling session.
ret = driver().PcSamplingCreate(node_id(), &sampleInfo, &thunkId);
if (ret != HSA_STATUS_SUCCESS) {
return ret;
HSAKMT_STATUS retkmt = HSAKMT_CALL(hsaKmtPcSamplingCreate(node_id(), &sampleInfo, &thunkId));
if (retkmt != HSAKMT_STATUS_SUCCESS) {
return (retkmt == HSAKMT_STATUS_KERNEL_ALREADY_OPENED) ? (hsa_status_t)HSA_STATUS_ERROR_RESOURCE_BUSY
: HSA_STATUS_ERROR;
}
debug_print("Created PC sampling session with thunkId:%d\n", thunkId);
@@ -2794,7 +2795,7 @@ hsa_status_t GpuAgent::PcSamplingCreateFromId(HsaPcSamplingTraceId ioctlId,
hsa_status_t GpuAgent::PcSamplingDestroy(pcs::PcsRuntime::PcSamplingSession& session) {
if (PcSamplingStop(session) != HSA_STATUS_SUCCESS) return HSA_STATUS_ERROR;
hsa_status_t ret = driver().PcSamplingDestroy(node_id(), session.ThunkId());
HSAKMT_STATUS retKmt = HSAKMT_CALL(hsaKmtPcSamplingDestroy(node_id(), session.ThunkId()));
hsa_ven_amd_pcs_method_kind_t sampling_method = session.method();
pcs_data_t* pcs_data = nullptr;
@@ -2826,7 +2827,7 @@ hsa_status_t GpuAgent::PcSamplingDestroy(pcs::PcsRuntime::PcSamplingSession& ses
// Update the trap handler to clear any associated device data
UpdateTrapHandlerWithPCS(nullptr, nullptr);
return ret;
return (retKmt == HSAKMT_STATUS_SUCCESS) ? HSA_STATUS_SUCCESS : HSA_STATUS_ERROR;
}
hsa_status_t GpuAgent::PcSamplingStart(pcs::PcsRuntime::PcSamplingSession& session) {
@@ -2893,9 +2894,8 @@ hsa_status_t GpuAgent::PcSamplingStart(pcs::PcsRuntime::PcSamplingSession& sessi
}
// Start the sampling session in the kernel driver
if (driver().PcSamplingStart(node_id(), session.ThunkId()) == HSA_STATUS_SUCCESS) {
if (HSAKMT_CALL(hsaKmtPcSamplingStart(node_id(), session.ThunkId())) == HSAKMT_STATUS_SUCCESS)
return HSA_STATUS_SUCCESS;
}
debug_print("Failed to start PC sampling session with thunkId:%d\n", session.ThunkId());
// Clean up if starting the session failed
@@ -2915,8 +2915,8 @@ hsa_status_t GpuAgent::PcSamplingStop(pcs::PcsRuntime::PcSamplingSession& sessio
session.stop();
// Stop PC sampling in the kernel driver
hsa_status_t ret = driver().PcSamplingStop(node_id(), session.ThunkId());
if (ret != HSA_STATUS_SUCCESS)
HSAKMT_STATUS retKmt = HSAKMT_CALL(hsaKmtPcSamplingStop(node_id(), session.ThunkId()));
if (retKmt != HSAKMT_STATUS_SUCCESS)
throw AMD::hsa_exception(HSA_STATUS_ERROR, "Failed to stop PC Sampling session.");
// Determine the sampling method and corresponding data
@@ -368,7 +368,7 @@ hsa_status_t Runtime::FreeMemory(void* ptr) {
}
if (alloc_flags & core::MemoryRegion::AllocateAsan)
assert(region->owner()->driver().ReturnAsanHeaderPage(ptr) == HSA_STATUS_SUCCESS);
assert(HSAKMT_CALL(hsaKmtReturnAsanHeaderPage(ptr)) == HSAKMT_STATUS_SUCCESS);
const hsa_status_t err = region->Free(ptr, size);
if (err != HSA_STATUS_SUCCESS) {
@@ -1297,7 +1297,6 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han
if (info.agentBaseAddress != ptr || info.sizeInBytes != len)
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
Agent* agent = Agent::Convert(info.agentOwner);
bool useFrag = (block.base != ptr || block.length != len);
// Assume all pointers and blocks are 4Kb aligned.
uint32_t fragOffset = (reinterpret_cast<uint8_t*>(ptr) -
@@ -1311,7 +1310,7 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han
if (!ipc_dmabuf_supported_) {
HsaSharedMemoryHandle *sHandle = reinterpret_cast<HsaSharedMemoryHandle*>(handle);
if (agent->driver().ShareMemory(block.base, block.length, sHandle) != HSA_STATUS_SUCCESS)
if (HSAKMT_CALL(hsaKmtShareMemory(block.base, block.length, sHandle)) != HSAKMT_STATUS_SUCCESS)
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
hsa_status_t err = HSA_STATUS_SUCCESS;
@@ -1332,6 +1331,7 @@ hsa_status_t Runtime::IPCCreate(void* ptr, size_t len, hsa_amd_ipc_memory_t* han
handle->handle[1] = dmaBufFdHandleHi;
handle->handle[2] = getpid(); // socket server name handle
Agent *agent = Agent::Convert(info.agentOwner);
handle->handle[3] = agent->device_type() == Agent::kAmdCpuDevice;
// System sub allocations are not supported for now.
if (handle->handle[3] && useFrag) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
@@ -1472,9 +1472,6 @@ hsa_status_t Runtime::IPCAttach(const hsa_amd_ipc_memory_t* handle, size_t len,
bool isFragment = false;
uint32_t fragOffset = 0;
if (Runtime::IsDifferentDriver(*agents, num_agents)) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
core::Driver* driver = &agents[0]->driver();
auto fixFragment = [&](amdgpu_bo_handle ldrm_bo) {
if (isFragment) {
importAddress = reinterpret_cast<uint8_t*>(importAddress) + fragOffset;
@@ -1486,17 +1483,14 @@ hsa_status_t Runtime::IPCAttach(const hsa_amd_ipc_memory_t* handle, size_t len,
allocation_map_[importAddress].ldrm_bo = ldrm_bo;
};
auto importMemory = [&](unsigned int numNodes, HSAuint32* nodes, amdgpu_bo_import_result* res) {
if (ipc_dmabuf_supported_) {
int ret = IPCClientImport(importHandle.handle[2], dmaBufFDHandle, res, numNodes, nodes,
&importAddress, &importSize);
if (ret != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
} else {
hsa_status_t ret = driver->RegisterSharedHandle(
reinterpret_cast<const HsaSharedMemoryHandle*>(&importHandle), &importAddress,
&importSize);
if (ret != HSA_STATUS_SUCCESS) return ret;
}
auto importMemory = [&](unsigned int numNodes, HSAuint32 *nodes,
amdgpu_bo_import_result *res) {
int ret = ipc_dmabuf_supported_ ?
IPCClientImport(importHandle.handle[2], dmaBufFDHandle, res,
numNodes, nodes, &importAddress, &importSize) :
HSAKMT_CALL(hsaKmtRegisterSharedHandle(reinterpret_cast<const HsaSharedMemoryHandle*>(&importHandle),
&importAddress, &importSize));
if (ret != HSAKMT_STATUS_SUCCESS) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
return HSA_STATUS_SUCCESS;
};