mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Fix ioctl call for context persistence change
Change-Id: I2b6048b812abdc00f07d549423901a2b0e85f7ee Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
@@ -212,16 +212,10 @@ bool Drm::setQueueSliceCount(uint64_t sliceCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Drm::checkNonPersistentContextsSupport() {
|
||||
void Drm::checkContextPersistenceChangeSupport() {
|
||||
drm_i915_gem_context_param contextParam = {};
|
||||
contextParam.param = I915_CONTEXT_PARAM_PERSISTENCE;
|
||||
|
||||
auto retVal = ioctl(DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &contextParam);
|
||||
if (retVal == 0 && contextParam.value == 1) {
|
||||
nonPersistentContextsSupported = true;
|
||||
} else {
|
||||
nonPersistentContextsSupported = false;
|
||||
}
|
||||
contextPersistenceChangeSupported = (ioctl(DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &contextParam) == 0);
|
||||
}
|
||||
|
||||
void Drm::setNonPersistentContext(uint32_t drmContextId) {
|
||||
@@ -229,7 +223,12 @@ void Drm::setNonPersistentContext(uint32_t drmContextId) {
|
||||
contextParam.ctx_id = drmContextId;
|
||||
contextParam.param = I915_CONTEXT_PARAM_PERSISTENCE;
|
||||
|
||||
ioctl(DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &contextParam);
|
||||
auto retVal = ioctl(DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &contextParam);
|
||||
if (retVal == ENODEV) {
|
||||
contextPersistenceChangeSupported = false;
|
||||
} else {
|
||||
UNRECOVERABLE_IF(retVal != 0);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Drm::createDrmContext() {
|
||||
|
||||
@@ -83,8 +83,8 @@ class Drm {
|
||||
bool queryMemoryInfo();
|
||||
int setupHardwareInfo(DeviceDescriptor *, bool);
|
||||
|
||||
bool areNonPersistentContextsSupported() const { return nonPersistentContextsSupported; }
|
||||
void checkNonPersistentContextsSupport();
|
||||
bool isContextPersistenceChangeSupported() const { return contextPersistenceChangeSupported; }
|
||||
void checkContextPersistenceChangeSupport();
|
||||
void setNonPersistentContext(uint32_t drmContextId);
|
||||
|
||||
MemoryInfo *getMemoryInfo() const {
|
||||
@@ -99,8 +99,8 @@ class Drm {
|
||||
bool sliceCountChangeSupported = false;
|
||||
drm_i915_gem_context_param_sseu sseu{};
|
||||
bool preemptionSupported = false;
|
||||
bool nonPersistentContextsSupported = false;
|
||||
std::unique_ptr<HwDeviceId> hwDeviceId;
|
||||
bool contextPersistenceChangeSupported = false;
|
||||
int deviceId = 0;
|
||||
int revisionId = 0;
|
||||
GTTYPE eGtType = GTTYPE_UNDEFINED;
|
||||
|
||||
@@ -161,7 +161,7 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou
|
||||
outHwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
outHwInfo->capabilityTable.ftrRenderCompressedImages = false;
|
||||
drm->checkQueueSliceSupport();
|
||||
drm->checkNonPersistentContextsSupport();
|
||||
drm->checkContextPersistenceChangeSupport();
|
||||
drm->checkPreemptionSupport();
|
||||
bool preemption = drm->isPreemptionSupported();
|
||||
PreemptionHelper::adjustDefaultPreemptionMode(outHwInfo->capabilityTable,
|
||||
|
||||
@@ -27,7 +27,7 @@ OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, DeviceBitfield devi
|
||||
for (auto deviceIndex = 0u; deviceIndex < deviceBitfield.size(); deviceIndex++) {
|
||||
if (deviceBitfield.test(deviceIndex)) {
|
||||
auto drmContextId = drm.createDrmContext();
|
||||
if (drm.areNonPersistentContextsSupported()) {
|
||||
if (drm.isContextPersistenceChangeSupported()) {
|
||||
drm.setNonPersistentContext(drmContextId);
|
||||
}
|
||||
if (drm.isPreemptionSupported() && lowPriority) {
|
||||
|
||||
@@ -88,7 +88,7 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
return this->StoredRetValForSetSSEU;
|
||||
}
|
||||
if (receivedContextParamRequest.param == I915_CONTEXT_PARAM_PERSISTENCE) {
|
||||
return this->StoredRetValForPersistant;
|
||||
return this->StoredRetValForPersistent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,8 +106,7 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
return this->StoredRetValForGetSSEU;
|
||||
}
|
||||
if (receivedContextParamRequest.param == I915_CONTEXT_PARAM_PERSISTENCE) {
|
||||
static_cast<drm_i915_gem_context_param *>(arg)->value = this->StoredPersistentContextsSupport;
|
||||
return this->StoredRetValForPersistant;
|
||||
return this->StoredRetValForPersistent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ using namespace NEO;
|
||||
class DrmMock : public Drm {
|
||||
public:
|
||||
using Drm::checkQueueSliceSupport;
|
||||
using Drm::contextPersistenceChangeSupported;
|
||||
using Drm::engineInfo;
|
||||
using Drm::getQueueSliceCount;
|
||||
using Drm::memoryInfo;
|
||||
using Drm::nonPersistentContextsSupported;
|
||||
using Drm::preemptionSupported;
|
||||
using Drm::query;
|
||||
using Drm::sliceCountChangeSupported;
|
||||
@@ -90,7 +90,6 @@ class DrmMock : public Drm {
|
||||
int StoredDeviceRevID = 1;
|
||||
int StoredHasPooledEU = 1;
|
||||
int StoredMinEUinPool = 1;
|
||||
int StoredPersistentContextsSupport = 1;
|
||||
int StoredRetVal = 0;
|
||||
int StoredRetValForGetGttSize = 0;
|
||||
int StoredRetValForGetSSEU = 0;
|
||||
@@ -101,7 +100,7 @@ class DrmMock : public Drm {
|
||||
int StoredRetValForDeviceRevID = 0;
|
||||
int StoredRetValForPooledEU = 0;
|
||||
int StoredRetValForMinEUinPool = 0;
|
||||
int StoredRetValForPersistant = 0;
|
||||
int StoredRetValForPersistent = 0;
|
||||
int StoredPreemptionSupport =
|
||||
I915_SCHEDULER_CAP_ENABLED |
|
||||
I915_SCHEDULER_CAP_PRIORITY |
|
||||
|
||||
@@ -197,7 +197,7 @@ TEST(DrmTest, givenDrmWhenOsContextIsCreatedThenCreateAndDestroyNewDrmOsContext)
|
||||
EXPECT_EQ(0u, drmMock.receivedContextParamRequestCount);
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenDrmAndNegativeCheckNonPersistentContextsSupportWhenOsContextIsCreatedThenReceivedContextParamRequestCountReturnsCorrectValue) {
|
||||
TEST(DrmTest, givenDrmAndNegativeCheckContextPersistenceChangeSupportWhenOsContextIsCreatedThenReceivedContextParamRequestCountReturnsCorrectValue) {
|
||||
|
||||
DrmMock drmMock;
|
||||
uint32_t drmContextId1 = 123;
|
||||
@@ -205,15 +205,15 @@ TEST(DrmTest, givenDrmAndNegativeCheckNonPersistentContextsSupportWhenOsContextI
|
||||
auto expectedCount = 0u;
|
||||
|
||||
{
|
||||
drmMock.StoredRetValForPersistant = -1;
|
||||
drmMock.checkNonPersistentContextsSupport();
|
||||
drmMock.StoredRetValForPersistent = -1;
|
||||
drmMock.checkContextPersistenceChangeSupport();
|
||||
++expectedCount;
|
||||
OsContextLinux osContext(drmMock, 0u, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);
|
||||
EXPECT_EQ(expectedCount, drmMock.receivedContextParamRequestCount);
|
||||
}
|
||||
{
|
||||
drmMock.StoredRetValForPersistant = 0;
|
||||
drmMock.checkNonPersistentContextsSupport();
|
||||
drmMock.StoredRetValForPersistent = 0;
|
||||
drmMock.checkContextPersistenceChangeSupport();
|
||||
++expectedCount;
|
||||
OsContextLinux osContext(drmMock, 0u, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);
|
||||
++expectedCount;
|
||||
@@ -221,6 +221,29 @@ TEST(DrmTest, givenDrmAndNegativeCheckNonPersistentContextsSupportWhenOsContextI
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenUnsupportedPlatformWhenOsContextIsCreatedAndThenIsContextPersistenceChangeSupportedReturnsFalse) {
|
||||
|
||||
DrmMock drmMock;
|
||||
uint32_t drmContextId1 = 123;
|
||||
drmMock.StoredCtxId = drmContextId1;
|
||||
auto expectedCount = 0u;
|
||||
auto unsupportedPlatformErrorCode = ENODEV;
|
||||
|
||||
drmMock.StoredRetValForPersistent = 0;
|
||||
drmMock.checkContextPersistenceChangeSupport();
|
||||
++expectedCount;
|
||||
|
||||
{
|
||||
EXPECT_TRUE(drmMock.isContextPersistenceChangeSupported());
|
||||
drmMock.StoredRetValForPersistent = unsupportedPlatformErrorCode;
|
||||
OsContextLinux osContext(drmMock, 0u, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false);
|
||||
++expectedCount;
|
||||
EXPECT_FALSE(drmMock.isContextPersistenceChangeSupported());
|
||||
}
|
||||
|
||||
EXPECT_EQ(expectedCount, drmMock.receivedContextParamRequestCount);
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenDrmPreemptionEnabledAndLowPriorityEngineWhenCreatingOsContextThenCallSetContextPriorityIoctl) {
|
||||
DrmMock drmMock;
|
||||
drmMock.StoredCtxId = 123;
|
||||
@@ -354,14 +377,14 @@ TEST(DrmTest, givenPlatformWhereGetSseuRetFailureWhenCallSetQueueSliceCountThenS
|
||||
EXPECT_NE(drm->getSliceMask(newSliceCount), drm->storedParamSseu);
|
||||
}
|
||||
|
||||
TEST(DrmTest, whenCheckNonPeristentSupportIsCalledThenAreNonPersistentContextsSupportedReturnsCorrectValues) {
|
||||
TEST(DrmTest, whenCheckContextPersistenceChangeSupportIsCalledThenIsContextPersistenceChangeSupportedReturnsCorrectValues) {
|
||||
std::unique_ptr<DrmMock> drm = std::make_unique<DrmMock>();
|
||||
drm->StoredRetValForPersistant = -1;
|
||||
drm->checkNonPersistentContextsSupport();
|
||||
EXPECT_FALSE(drm->areNonPersistentContextsSupported());
|
||||
drm->StoredRetValForPersistant = 0;
|
||||
drm->checkNonPersistentContextsSupport();
|
||||
EXPECT_TRUE(drm->areNonPersistentContextsSupported());
|
||||
drm->StoredRetValForPersistent = -1;
|
||||
drm->checkContextPersistenceChangeSupport();
|
||||
EXPECT_FALSE(drm->isContextPersistenceChangeSupported());
|
||||
drm->StoredRetValForPersistent = 0;
|
||||
drm->checkContextPersistenceChangeSupport();
|
||||
EXPECT_TRUE(drm->isContextPersistenceChangeSupported());
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenPlatformWhereSetSseuRetFailureWhenCallSetQueueSliceCountThenReturnFalse) {
|
||||
|
||||
@@ -267,17 +267,17 @@ TEST_F(HwInfoConfigTestLinuxDummy, dummyNegativeUnknownDeviceId) {
|
||||
EXPECT_EQ(-1, ret);
|
||||
}
|
||||
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, whenConfigureHwInfoIsCalledThenAreNonPersistentContextsSupportedReturnsTrue) {
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, whenConfigureHwInfoIsCalledThenIsContextPersistenceChangeSupportedReturnsTrue) {
|
||||
int ret = hwConfig.configureHwInfo(&pInHwInfo, &outHwInfo, osInterface);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_TRUE(drm->areNonPersistentContextsSupported());
|
||||
EXPECT_TRUE(drm->isContextPersistenceChangeSupported());
|
||||
}
|
||||
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, whenConfigureHwInfoIsCalledAndPersitentContextIsUnsupportedThenAreNonPersistentContextsSupportedReturnsFalse) {
|
||||
drm->StoredPersistentContextsSupport = 0;
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, whenConfigureHwInfoIsCalledAndPersitentContextIsUnsupportedThenIsContextPersistenceChangeSupportedReturnsFalse) {
|
||||
drm->StoredRetValForPersistent = -1;
|
||||
int ret = hwConfig.configureHwInfo(&pInHwInfo, &outHwInfo, osInterface);
|
||||
EXPECT_EQ(0, ret);
|
||||
EXPECT_FALSE(drm->areNonPersistentContextsSupported());
|
||||
EXPECT_FALSE(drm->isContextPersistenceChangeSupported());
|
||||
}
|
||||
|
||||
TEST_F(HwInfoConfigTestLinuxDummy, dummyConfigPreemptionDrmEnabledMidThreadOn) {
|
||||
|
||||
Reference in New Issue
Block a user