mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
fix: using canonized addr in xe kmd
Related-To: NEO-7313 Signed-off-by: Wojciech Konior <wojciech.konior@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
546e8fa230
commit
683d7c7acf
@@ -315,7 +315,7 @@ ze_result_t DebugSessionLinux::readGpuMemory(uint64_t vmHandle, char *output, si
|
|||||||
|
|
||||||
int64_t retVal = 0;
|
int64_t retVal = 0;
|
||||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||||
gpuVa = gmmHelper->decanonize(gpuVa);
|
gpuVa = gmmHelper->canonize(gpuVa);
|
||||||
if (flushVmCache(vmDebugFd) != 0) {
|
if (flushVmCache(vmDebugFd) != 0) {
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
@@ -377,7 +377,7 @@ ze_result_t DebugSessionLinux::writeGpuMemory(uint64_t vmHandle, const char *inp
|
|||||||
|
|
||||||
int64_t retVal = 0;
|
int64_t retVal = 0;
|
||||||
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper();
|
||||||
gpuVa = gmmHelper->decanonize(gpuVa);
|
gpuVa = gmmHelper->canonize(gpuVa);
|
||||||
if (flushVmCache(vmDebugFd) != 0) {
|
if (flushVmCache(vmDebugFd) != 0) {
|
||||||
return ZE_RESULT_ERROR_UNKNOWN;
|
return ZE_RESULT_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022-2024 Intel Corporation
|
* Copyright (C) 2022-2025 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -641,8 +641,8 @@ bool DebugSessionLinuxi915::handleVmBindEvent(prelim_drm_i915_debug_event_vm_bin
|
|||||||
std::unique_lock<std::mutex> memLock(asyncThreadMutex);
|
std::unique_lock<std::mutex> memLock(asyncThreadMutex);
|
||||||
isaMap[vmBind->va_start] = std::move(isa);
|
isaMap[vmBind->va_start] = std::move(isa);
|
||||||
|
|
||||||
// Expect non canonical va_start
|
// Expect canonical va_start
|
||||||
DEBUG_BREAK_IF(gmmHelper->decanonize(vmBind->va_start) != vmBind->va_start);
|
DEBUG_BREAK_IF(gmmHelper->canonize(vmBind->va_start) != vmBind->va_start);
|
||||||
|
|
||||||
bool apiEventNeedsAck = (vmBind->base.flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK);
|
bool apiEventNeedsAck = (vmBind->base.flags & PRELIM_DRM_I915_DEBUG_EVENT_NEED_ACK);
|
||||||
// If ACK flag is not set when triggering MODULE LOAD event, auto-ack immediately
|
// If ACK flag is not set when triggering MODULE LOAD event, auto-ack immediately
|
||||||
|
|||||||
@@ -466,6 +466,7 @@ bool DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
|
|||||||
if (vmBindOp.base.flags & euDebugInterface->getParamValue(NEO::EuDebugParam::eventBitCreate)) {
|
if (vmBindOp.base.flags & euDebugInterface->getParamValue(NEO::EuDebugParam::eventBitCreate)) {
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(asyncThreadMutex);
|
std::lock_guard<std::mutex> lock(asyncThreadMutex);
|
||||||
|
|
||||||
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataSbaArea)) {
|
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataSbaArea)) {
|
||||||
connection->vmToStateBaseAreaBindInfo[vmBindData.vmBind.vmHandle] = {vmBindOp.addr, vmBindOp.range};
|
connection->vmToStateBaseAreaBindInfo[vmBindData.vmBind.vmHandle] = {vmBindOp.addr, vmBindOp.range};
|
||||||
}
|
}
|
||||||
@@ -473,6 +474,7 @@ bool DebugSessionLinuxXe::handleVmBind(VmBindData &vmBindData) {
|
|||||||
connection->vmToContextStateSaveAreaBindInfo[vmBindData.vmBind.vmHandle] = {vmBindOp.addr, vmBindOp.range};
|
connection->vmToContextStateSaveAreaBindInfo[vmBindData.vmBind.vmHandle] = {vmBindOp.addr, vmBindOp.range};
|
||||||
}
|
}
|
||||||
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataModuleArea)) {
|
if (metaDataEntry.metadata.type == euDebugInterface->getParamValue(NEO::EuDebugParam::metadataModuleArea)) {
|
||||||
|
|
||||||
isaAddr = vmBindOp.addr;
|
isaAddr = vmBindOp.addr;
|
||||||
if (connection->isaMap[tileIndex].find(vmBindOp.addr) == connection->isaMap[tileIndex].end()) {
|
if (connection->isaMap[tileIndex].find(vmBindOp.addr) == connection->isaMap[tileIndex].end()) {
|
||||||
auto &isaMap = connection->isaMap[tileIndex];
|
auto &isaMap = connection->isaMap[tileIndex];
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "shared/source/command_stream/task_count_helper.h"
|
#include "shared/source/command_stream/task_count_helper.h"
|
||||||
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||||
#include "shared/source/helpers/topology_map.h"
|
#include "shared/source/helpers/topology_map.h"
|
||||||
#include "shared/source/os_interface/linux/drm_allocation.h"
|
#include "shared/source/os_interface/linux/drm_allocation.h"
|
||||||
#include "shared/source/os_interface/linux/drm_debug.h"
|
#include "shared/source/os_interface/linux/drm_debug.h"
|
||||||
|
|||||||
@@ -1341,7 +1341,6 @@ int IoctlHelperXe::createDrmContext(Drm &drm, OsContextLinux &osContext, uint32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
|
int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
|
||||||
auto gmmHelper = drm.getRootDeviceEnvironment().getGmmHelper();
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const char *operation = isBind ? "bind" : "unbind";
|
const char *operation = isBind ? "bind" : "unbind";
|
||||||
|
|
||||||
@@ -1353,14 +1352,14 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
|
|||||||
for (auto i = 0u; i < bindInfo.size(); i++) {
|
for (auto i = 0u; i < bindInfo.size(); i++) {
|
||||||
if (vmBindParams.userptr == bindInfo[i].userptr) {
|
if (vmBindParams.userptr == bindInfo[i].userptr) {
|
||||||
userptr = bindInfo[i].userptr;
|
userptr = bindInfo[i].userptr;
|
||||||
bindInfo[i].addr = gmmHelper->decanonize(vmBindParams.start);
|
bindInfo[i].addr = vmBindParams.start;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else // unbind
|
} else // unbind
|
||||||
{
|
{
|
||||||
auto address = gmmHelper->decanonize(vmBindParams.start);
|
auto address = vmBindParams.start;
|
||||||
for (auto i = 0u; i < bindInfo.size(); i++) {
|
for (auto i = 0u; i < bindInfo.size(); i++) {
|
||||||
if (address == bindInfo[i].addr) {
|
if (address == bindInfo[i].addr) {
|
||||||
userptr = bindInfo[i].userptr;
|
userptr = bindInfo[i].userptr;
|
||||||
@@ -1385,7 +1384,10 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool isBind) {
|
|||||||
if (vmBindParams.sharedSystemUsmBind == true) {
|
if (vmBindParams.sharedSystemUsmBind == true) {
|
||||||
bind.bind.addr = 0;
|
bind.bind.addr = 0;
|
||||||
} else {
|
} else {
|
||||||
bind.bind.addr = gmmHelper->decanonize(vmBindParams.start);
|
// Expect canonical address
|
||||||
|
DEBUG_BREAK_IF(drm.getRootDeviceEnvironment().getGmmHelper()->canonize(vmBindParams.start) != vmBindParams.start);
|
||||||
|
|
||||||
|
bind.bind.addr = vmBindParams.start;
|
||||||
}
|
}
|
||||||
bind.num_syncs = 1;
|
bind.num_syncs = 1;
|
||||||
UNRECOVERABLE_IF(vmBindParams.userFence == 0x0);
|
UNRECOVERABLE_IF(vmBindParams.userFence == 0x0);
|
||||||
|
|||||||
@@ -2090,6 +2090,41 @@ TEST_F(IoctlHelperXeTest, givenMultipleBindInfosWhenVmBindIsCalledThenProperHand
|
|||||||
ioctlHelper->bindInfo.clear();
|
ioctlHelper->bindInfo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(IoctlHelperXeTest, whenVmBindIsCalledThenProperCanonicalOrNonCanonicalAddressIsExpectedInVmBindInputsList) {
|
||||||
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||||
|
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
auto ioctlHelper = static_cast<MockIoctlHelperXe *>(drm->getIoctlHelper());
|
||||||
|
unsigned int idx = 0;
|
||||||
|
|
||||||
|
auto testAddress = [&](uint64_t addr) {
|
||||||
|
MockIoctlHelperXe::UserFenceExtension userFence{};
|
||||||
|
userFence.tag = userFence.tagValue;
|
||||||
|
userFence.addr = idx + 1;
|
||||||
|
|
||||||
|
VmBindParams vmBindParams{};
|
||||||
|
vmBindParams.userFence = castToUint64(&userFence);
|
||||||
|
vmBindParams.handle = idx + 1;
|
||||||
|
vmBindParams.userptr = idx + 1;
|
||||||
|
vmBindParams.start = addr;
|
||||||
|
|
||||||
|
auto ret = ioctlHelper->vmBind(vmBindParams);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
|
||||||
|
auto &list = drm->vmBindInputs;
|
||||||
|
EXPECT_EQ(list.size(), idx + 1);
|
||||||
|
|
||||||
|
if (list.size() == idx + 1) {
|
||||||
|
EXPECT_EQ(list[idx].num_binds, 1u);
|
||||||
|
EXPECT_EQ(list[idx].bind.addr, vmBindParams.start);
|
||||||
|
}
|
||||||
|
|
||||||
|
idx++;
|
||||||
|
};
|
||||||
|
|
||||||
|
testAddress(0xfffff00000000000); // canonical address test
|
||||||
|
testAddress(0xf00000000000); // non-canonical address test
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(IoctlHelperXeTest, givenLowPriorityContextWhenSettingPropertiesThenCorrectIndexIsUsedAndReturend) {
|
TEST_F(IoctlHelperXeTest, givenLowPriorityContextWhenSettingPropertiesThenCorrectIndexIsUsedAndReturend) {
|
||||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||||
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
auto drm = DrmMockXe::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|||||||
Reference in New Issue
Block a user