diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp index 9478b9948d..0c2b5479ff 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp @@ -10,6 +10,7 @@ #include "shared/source/command_stream/csr_definitions.h" #include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/bit_helpers.h" #include "shared/source/helpers/common_types.h" @@ -181,7 +182,6 @@ bool IoctlHelperXe::initialize() { chipsetId = config->info[XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff; revId = static_cast(config->info[XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16); hasVram = config->info[XE_QUERY_CONFIG_FLAGS] & XE_QUERY_CONFIG_FLAGS_HAS_VRAM ? 1 : 0; - addressWidth = static_cast(config->info[XE_QUERY_CONFIG_VA_BITS]); memset(&queryConfig, 0, sizeof(queryConfig)); queryConfig.query = DRM_XE_DEVICE_QUERY_HWCONFIG; @@ -909,10 +909,6 @@ void IoctlHelperXe::xeSyncObjDestroy(uint32_t handle) { UNRECOVERABLE_IF(ret); } -uint64_t IoctlHelperXe::xeDecanonize(uint64_t address) { - return (address & maxNBitValue(addressWidth)); -} - int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) { int ret = -1; xeLog(" => IoctlHelperXe::%s 0x%x\n", __FUNCTION__, request); @@ -988,10 +984,11 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) { case DrmIoctl::GemContextGetparam: { GemContextParam *d = static_cast(arg); + auto addressSpace = drm.getRootDeviceEnvironment().getHardwareInfo()->capabilityTable.gpuAddressSpace; ret = 0; switch (d->param) { case static_cast(DrmParam::ContextParamGttSize): - d->value = 0x1ull << addressWidth; + d->value = addressSpace + 1u; break; case static_cast(DrmParam::ContextParamSseu): d->value = 0x55fdd94d4e40; @@ -1244,7 +1241,8 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool bindOp) { } } } else { - uint64_t ad = xeDecanonize(vmBindParams.start); + auto gmmHelper = drm.getRootDeviceEnvironment().getGmmHelper(); + uint64_t ad = gmmHelper->decanonize(vmBindParams.start); for (unsigned int i = 0; i < bindInfo.size(); i++) { if (ad == bindInfo[i].addr) { found = i; @@ -1269,7 +1267,10 @@ int IoctlHelperXe::xeVmBind(const VmBindParams &vmBindParams, bool bindOp) { bind.bind.obj = vmBindParams.handle; bind.bind.obj_offset = vmBindParams.offset; bind.bind.range = vmBindParams.length; - bind.bind.addr = xeDecanonize(vmBindParams.start); + + auto gmmHelper = drm.getRootDeviceEnvironment().getGmmHelper(); + + bind.bind.addr = gmmHelper->decanonize(vmBindParams.start); bind.bind.op = XE_VM_BIND_OP_MAP; bind.num_syncs = 1; bind.syncs = reinterpret_cast(&sync); diff --git a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h index a7a6c9a88c..90df0ea2b4 100644 --- a/shared/source/os_interface/linux/xe/ioctl_helper_xe.h +++ b/shared/source/os_interface/linux/xe/ioctl_helper_xe.h @@ -114,7 +114,6 @@ class IoctlHelperXe : public IoctlHelper { struct drm_xe_engine_class_instance *xeFindMatchingEngine(uint16_t engineClass, uint16_t engineInstance); protected: - uint64_t xeDecanonize(uint64_t address); const char *xeGetClassName(int className); const char *xeGetBindOpName(int bindOp); const char *xeGetengineClassName(uint32_t engineClass); @@ -137,7 +136,6 @@ class IoctlHelperXe : public IoctlHelper { int hasVram = 0; uint32_t xeVmId = 0; uint32_t userPtrHandle = 0; - uint32_t addressWidth = 48; int xeFileHandle = 0; std::mutex xeLock; std::vector bindInfo; diff --git a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp index 974667643d..f251d37304 100644 --- a/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp @@ -29,7 +29,6 @@ using NEO::PrelimI915::drm_syncobj_wait; struct MockIoctlHelperXe : IoctlHelperXe { using IoctlHelperXe::bindInfo; using IoctlHelperXe::IoctlHelperXe; - using IoctlHelperXe::xeDecanonize; using IoctlHelperXe::xeGetBindOpName; using IoctlHelperXe::xeGetClassName; using IoctlHelperXe::xeGetengineClassName; @@ -381,9 +380,6 @@ TEST(IoctlHelperXeTest, verifyPublicFunctions) { verifyXeEngineClassName("DRM_XE_ENGINE_CLASS_COMPUTE", DRM_XE_ENGINE_CLASS_COMPUTE); verifyXeEngineClassName("?", 0xffffffff); - // Default is 48b - EXPECT_EQ(0xffffffa10000ul, mockXeIoctlHelper->xeDecanonize(0xffffffffffa10000)); - Query query{}; QueryItem queryItem{}; queryItem.queryId = 999999; @@ -733,13 +729,17 @@ TEST(IoctlHelperXeTest, whenCallingIoctlThenProperValueIsReturned) { EXPECT_EQ(-1, ret); } { + auto hwInfo = drm.getRootDeviceEnvironment().getHardwareInfo(); + GemContextParam test = {}; ret = mockXeIoctlHelper->ioctl(DrmIoctl::GemContextGetparam, &test); EXPECT_EQ(-1, ret); test.param = static_cast(DrmParam::ContextParamGttSize); ret = mockXeIoctlHelper->ioctl(DrmIoctl::GemContextGetparam, &test); EXPECT_EQ(0, ret); - EXPECT_EQ(0x1ull << 48, test.value); + + auto expectedAddressWidth = hwInfo->capabilityTable.gpuAddressSpace + 1u; + EXPECT_EQ(expectedAddressWidth, test.value); test.param = static_cast(DrmParam::ContextParamSseu); ret = mockXeIoctlHelper->ioctl(DrmIoctl::GemContextGetparam, &test); EXPECT_EQ(0, ret);