Add support for legacy kernel MOCS selection.

- Detect if driver is operating on patched legacy kernel.
- If turbo patch is detected, assume legacy custom kernel.
- Add simplified MOCS selection logic to GMM helper

Change-Id: I1ae821336205e473f00d72ddbfebee828427dfc7
This commit is contained in:
Mrozek, Michal
2018-01-25 08:30:57 +01:00
parent 0b6b12ea57
commit 6b368803fc
5 changed files with 51 additions and 0 deletions

View File

@@ -25,6 +25,7 @@
#include "runtime/helpers/options.h"
#include "runtime/os_interface/linux/drm_neo.h"
#include "runtime/os_interface/linux/drm_null_device.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "drm/i915_drm.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include <stdio.h>
@@ -212,6 +213,8 @@ Drm *Drm::create(int32_t deviceOrdinal) {
// Activate the Turbo Boost Frequency feature
ret = drmObject->enableTurboBoost();
if (ret != 0) {
//turbo patch not present, we are not on custom Kernel, switch to simplified Mocs selection
Gmm::useSimplifiedMocsTable = true;
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
}

View File

@@ -78,6 +78,14 @@ bool Gmm::initContext(const PLATFORM *pPlatform,
}
uint32_t Gmm::getMOCS(uint32_t type) {
if (useSimplifiedMocsTable) {
if (type == GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) {
return cacheDisabledIndex;
} else {
return cacheEnabledIndex;
}
}
MEMORY_OBJECT_CONTROL_STATE mocs =
pGmmGlobalContext->GetCachePolicyObj()->CachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
@@ -385,4 +393,7 @@ uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t heig
return this->gmmResourceInfo->cpuBlt(&gmmResourceCopyBLT);
}
bool Gmm::useSimplifiedMocsTable = false;
} // namespace OCLRT

View File

@@ -49,6 +49,9 @@ enum OCLPlane {
PLANE_UV
};
constexpr uint32_t cacheDisabledIndex = 0;
constexpr uint32_t cacheEnabledIndex = 4;
class Gmm {
public:
static const uint32_t maxPossiblePitch = 2147483648;
@@ -93,5 +96,6 @@ class Gmm {
std::unique_ptr<GmmResourceInfo> gmmResourceInfo;
bool isRenderCompressed = false;
static bool useSimplifiedMocsTable;
};
} // namespace OCLRT

View File

@@ -560,4 +560,21 @@ TEST_F(GmmTests, copyResourceBlt) {
EXPECT_EQ(1u, retVal);
EXPECT_TRUE(memcmp(&expectedCpuBlt, &requestedCpuBlt, sizeof(GMM_RES_COPY_BLT)) == 0);
}
TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicyWhenItIsAskedForUncachedIndexThen0IsReturned) {
Gmm::useSimplifiedMocsTable = true;
auto index = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
auto expectedIndex = cacheDisabledIndex;
EXPECT_EQ(expectedIndex, index);
Gmm::useSimplifiedMocsTable = false;
}
TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicyWhenItIsAskedForCachedIndexThen4IsReturned) {
Gmm::useSimplifiedMocsTable = true;
auto index = Gmm::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
auto expectedIndex = cacheEnabledIndex;
EXPECT_EQ(expectedIndex, index);
Gmm::useSimplifiedMocsTable = false;
}
} // namespace OCLRT

View File

@@ -21,6 +21,7 @@
*/
#include "mock_os_layer.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "unit_tests/custom_event_listener.h"
#include "test.h"
@@ -202,6 +203,21 @@ TEST_F(DrmTests, failOnParamBoost) {
EXPECT_NE(ptr, nullptr);
}
TEST_F(DrmTests, givenKernelNotSupportingTurboPatchWhenDeviceIsCreatedThenGmmSwitchesToSimplifiedMocsSelection) {
Gmm::useSimplifiedMocsTable = false;
failOnParamBoost = -1;
auto ptr = DrmWrap::createDrm(0);
EXPECT_NE(ptr, nullptr);
EXPECT_TRUE(Gmm::useSimplifiedMocsTable);
Gmm::useSimplifiedMocsTable = false;
}
TEST_F(DrmTests, givenKernelSupportingTurboPatchWhenDeviceIsCreatedThenSimplifiedMocsSelectionIsFalse) {
auto ptr = DrmWrap::createDrm(0);
EXPECT_NE(ptr, nullptr);
EXPECT_FALSE(Gmm::useSimplifiedMocsTable);
}
#if defined(I915_PARAM_HAS_PREEMPTION)
TEST_F(DrmTests, checkPreemption) {
auto ptr = DrmWrap::createDrm(0);