fix: Correct IoctlHelperXe logic to query PF support
Move logic in order to respect relevant checks before trying to query support. Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
parent
0b46fb9f0d
commit
3e59a2f108
|
@ -265,7 +265,6 @@ bool IoctlHelperXe::initialize() {
|
||||||
assignValue(tileIdToMediaGtId, gt.tile_id, gt.gt_id);
|
assignValue(tileIdToMediaGtId, gt.tile_id, gt.gt_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
querySupportedFeatures();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,8 +1016,25 @@ int IoctlHelperXe::queryDistances(std::vector<QueryItem> &queryItems, std::vecto
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IoctlHelperXe::isPageFaultSupported() {
|
bool IoctlHelperXe::isPageFaultSupported() {
|
||||||
xeLog(" -> IoctlHelperXe::%s %d\n", __FUNCTION__, false);
|
auto checkVmCreateFlagsSupport = [&](uint32_t flags) -> bool {
|
||||||
return false;
|
struct drm_xe_vm_create vmCreate = {};
|
||||||
|
vmCreate.flags = flags;
|
||||||
|
|
||||||
|
auto ret = IoctlHelper::ioctl(DrmIoctl::gemVmCreate, &vmCreate);
|
||||||
|
if (ret == 0) {
|
||||||
|
struct drm_xe_vm_destroy vmDestroy = {};
|
||||||
|
vmDestroy.vm_id = vmCreate.vm_id;
|
||||||
|
ret = IoctlHelper::ioctl(DrmIoctl::gemVmDestroy, &vmDestroy);
|
||||||
|
DEBUG_BREAK_IF(ret != 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
bool pageFaultSupport = checkVmCreateFlagsSupport(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE);
|
||||||
|
|
||||||
|
xeLog(" -> IoctlHelperXe::%s %d\n", __FUNCTION__, pageFaultSupport);
|
||||||
|
|
||||||
|
return pageFaultSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t IoctlHelperXe::getEuStallFdParameter() {
|
uint32_t IoctlHelperXe::getEuStallFdParameter() {
|
||||||
|
@ -1864,22 +1880,4 @@ std::string IoctlHelperXe::getIoctlString(DrmIoctl ioctlRequest) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IoctlHelperXe::querySupportedFeatures() {
|
|
||||||
auto checkVmCreateFlagsSupport = [&](uint32_t flags) -> bool {
|
|
||||||
struct drm_xe_vm_create vmCreate = {};
|
|
||||||
vmCreate.flags = flags;
|
|
||||||
|
|
||||||
auto ret = IoctlHelper::ioctl(DrmIoctl::gemVmCreate, &vmCreate);
|
|
||||||
if (ret == 0) {
|
|
||||||
struct drm_xe_vm_destroy vmDestroy = {};
|
|
||||||
vmDestroy.vm_id = vmCreate.vm_id;
|
|
||||||
ret = IoctlHelper::ioctl(DrmIoctl::gemVmDestroy, &vmDestroy);
|
|
||||||
DEBUG_BREAK_IF(ret != 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
supportedFeatures.flags.pageFault = checkVmCreateFlagsSupport(DRM_XE_VM_CREATE_FLAG_LR_MODE | DRM_XE_VM_CREATE_FLAG_FAULT_MODE);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|
|
@ -223,18 +223,6 @@ class IoctlHelperXe : public IoctlHelper {
|
||||||
uint32_t drmContextId;
|
uint32_t drmContextId;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SupportedFeatures {
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint32_t pageFault : 1;
|
|
||||||
uint32_t reserved : 31;
|
|
||||||
} flags;
|
|
||||||
uint32_t allFlags = 0;
|
|
||||||
};
|
|
||||||
} supportedFeatures{};
|
|
||||||
static_assert(sizeof(SupportedFeatures::flags) == sizeof(SupportedFeatures::allFlags), "");
|
|
||||||
|
|
||||||
void querySupportedFeatures();
|
|
||||||
std::unique_ptr<EuDebugInterface> euDebugInterface;
|
std::unique_ptr<EuDebugInterface> euDebugInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ struct MockIoctlHelperXe : IoctlHelperXe {
|
||||||
using IoctlHelperXe::maxExecQueuePriority;
|
using IoctlHelperXe::maxExecQueuePriority;
|
||||||
using IoctlHelperXe::queryGtListData;
|
using IoctlHelperXe::queryGtListData;
|
||||||
using IoctlHelperXe::setContextProperties;
|
using IoctlHelperXe::setContextProperties;
|
||||||
using IoctlHelperXe::supportedFeatures;
|
|
||||||
using IoctlHelperXe::tileIdToGtId;
|
using IoctlHelperXe::tileIdToGtId;
|
||||||
using IoctlHelperXe::updateBindInfo;
|
using IoctlHelperXe::updateBindInfo;
|
||||||
using IoctlHelperXe::UserFenceExtension;
|
using IoctlHelperXe::UserFenceExtension;
|
||||||
|
|
|
@ -414,8 +414,6 @@ TEST_F(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingAnyMethodThenDummyValueIs
|
||||||
|
|
||||||
EXPECT_FALSE(xeIoctlHelper->completionFenceExtensionSupported(false));
|
EXPECT_FALSE(xeIoctlHelper->completionFenceExtensionSupported(false));
|
||||||
|
|
||||||
EXPECT_EQ(false, xeIoctlHelper->isPageFaultSupported());
|
|
||||||
|
|
||||||
EXPECT_EQ(nullptr, xeIoctlHelper->createVmControlExtRegion({}));
|
EXPECT_EQ(nullptr, xeIoctlHelper->createVmControlExtRegion({}));
|
||||||
|
|
||||||
GemContextCreateExt gcc;
|
GemContextCreateExt gcc;
|
||||||
|
@ -2391,68 +2389,35 @@ TEST_F(IoctlHelperXeTest, givenImmediateAndReadOnlyBindFlagsSupportedWhenGetting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DrmMockXeVmBind : public DrmMockXe {
|
struct DrmMockXePageFault : public DrmMockXe {
|
||||||
static auto create(RootDeviceEnvironment &rootDeviceEnvironment) {
|
static auto create(RootDeviceEnvironment &rootDeviceEnvironment) {
|
||||||
auto drm = std::unique_ptr<DrmMockXeVmBind>(new DrmMockXeVmBind{rootDeviceEnvironment});
|
auto drm = std::unique_ptr<DrmMockXePageFault>(new DrmMockXePageFault{rootDeviceEnvironment});
|
||||||
drm->initInstance();
|
drm->initInstance();
|
||||||
|
|
||||||
return drm;
|
return drm;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ioctl(DrmIoctl request, void *arg) override {
|
int ioctl(DrmIoctl request, void *arg) override {
|
||||||
switch (request) {
|
if (supportsRecoverablePageFault) {
|
||||||
case DrmIoctl::gemVmCreate: {
|
|
||||||
auto vmCreate = static_cast<drm_xe_vm_create *>(arg);
|
|
||||||
if (deviceIsInFaultMode &&
|
|
||||||
((vmCreate->flags & DRM_XE_VM_CREATE_FLAG_LR_MODE) == 0 ||
|
|
||||||
(vmCreate->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE) == 0)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((vmCreate->flags & DRM_XE_VM_CREATE_FLAG_FAULT_MODE) == DRM_XE_VM_CREATE_FLAG_FAULT_MODE &&
|
|
||||||
(vmCreate->flags & DRM_XE_VM_CREATE_FLAG_LR_MODE) == DRM_XE_VM_CREATE_FLAG_LR_MODE &&
|
|
||||||
(!supportsRecoverablePageFault)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
} break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return DrmMockXe::ioctl(request, arg);
|
|
||||||
}
|
}
|
||||||
|
return -EINVAL;
|
||||||
};
|
};
|
||||||
bool supportsRecoverablePageFault = true;
|
bool supportsRecoverablePageFault = true;
|
||||||
|
|
||||||
bool deviceIsInFaultMode = false;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Don't call directly, use the create() function
|
// Don't call directly, use the create() function
|
||||||
DrmMockXeVmBind(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockXe(rootDeviceEnvironment) {}
|
DrmMockXePageFault(RootDeviceEnvironment &rootDeviceEnvironment) : DrmMockXe(rootDeviceEnvironment) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(IoctlHelperXeTest, whenInitializeIoctlHelperThenQueryPageFaultFlagsSupport) {
|
TEST_F(IoctlHelperXeTest, givenPageFaultSupportIsSetWhenCallingIsPageFaultSupportedThenProperValueIsReturned) {
|
||||||
|
|
||||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||||
auto drm = DrmMockXeVmBind::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
auto drm = DrmMockXePageFault::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||||
|
|
||||||
for (const auto &recoverablePageFault : ::testing::Bool()) {
|
for (const auto &recoverablePageFault : ::testing::Bool()) {
|
||||||
drm->supportsRecoverablePageFault = recoverablePageFault;
|
drm->supportsRecoverablePageFault = recoverablePageFault;
|
||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(*drm);
|
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(*drm);
|
||||||
xeIoctlHelper->initialize();
|
xeIoctlHelper->initialize();
|
||||||
EXPECT_EQ(xeIoctlHelper->supportedFeatures.flags.pageFault, recoverablePageFault);
|
EXPECT_EQ(xeIoctlHelper->isPageFaultSupported(), recoverablePageFault);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(IoctlHelperXeTest, givenDeviceInFaultModeWhenInitializeIoctlHelperThenQueryFeaturesIsSuccessful) {
|
|
||||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
|
||||||
auto drm = DrmMockXeVmBind::create(*executionEnvironment->rootDeviceEnvironments[0]);
|
|
||||||
drm->deviceIsInFaultMode = true;
|
|
||||||
|
|
||||||
for (const auto &recoverablePageFault : ::testing::Bool()) {
|
|
||||||
drm->supportsRecoverablePageFault = recoverablePageFault;
|
|
||||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(*drm);
|
|
||||||
xeIoctlHelper->initialize();
|
|
||||||
EXPECT_EQ(xeIoctlHelper->supportedFeatures.flags.pageFault, recoverablePageFault);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2982,4 +2947,4 @@ TEST_F(IoctlHelperXeTest, whenInitializeIoctlHelperAndLowLatencyAvailableButDebu
|
||||||
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_FLAGS] = DRM_XE_QUERY_CONFIG_FLAG_HAS_LOW_LATENCY;
|
xeQueryConfig->info[DRM_XE_QUERY_CONFIG_FLAGS] = DRM_XE_QUERY_CONFIG_FLAG_HAS_LOW_LATENCY;
|
||||||
xeIoctlHelper->initialize();
|
xeIoctlHelper->initialize();
|
||||||
EXPECT_FALSE(static_cast<MockIoctlHelperXe *>(xeIoctlHelper)->isLowLatencyHintAvailable);
|
EXPECT_FALSE(static_cast<MockIoctlHelperXe *>(xeIoctlHelper)->isLowLatencyHintAvailable);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue