mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
refactor: Gate shared system mem caps with KMD cap
Enabled only by setting EnableSharedSystemUsmSupport=1 flag Related-To: NEO-12988 Signed-off-by: John Falkowski <john.falkowski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
08476d3727
commit
8e59ac7576
@@ -727,8 +727,8 @@ bool Device::areSharedSystemAllocationsAllowed() const {
|
||||
if ((debugManager.flags.EnableRecoverablePageFaults.get() == 0) || (debugManager.flags.EnableSharedSystemUsmSupport.get() == 0)) {
|
||||
return false;
|
||||
}
|
||||
uint64_t mask = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::sharedSystemPageFaultEnabled;
|
||||
if (((getHardwareInfo().capabilityTable.sharedSystemMemCapabilities) & mask) == mask) {
|
||||
uint64_t mask = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
if (getHardwareInfo().capabilityTable.sharedSystemMemCapabilities & mask) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -63,11 +63,6 @@ Drm *Drm::create(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceId, RootDeviceEnvironm
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (drm->isSharedSystemAllocEnabled()) {
|
||||
auto hwInfo = drm->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
hwInfo->capabilityTable.sharedSystemMemCapabilities |= UnifiedSharedMemoryFlags::sharedSystemPageFaultEnabled;
|
||||
}
|
||||
|
||||
if (drm->enableTurboBoost()) {
|
||||
printDebugString(debugManager.flags.PrintDebugMessages.get(), stderr, "%s", "WARNING: Failed to request OCL Turbo Boost\n");
|
||||
}
|
||||
|
||||
@@ -496,6 +496,7 @@ int Drm::setupHardwareInfo(const DeviceDescriptor *device, bool setupFeatureTabl
|
||||
|
||||
auto releaseHelper = rootDeviceEnvironment.getReleaseHelper();
|
||||
device->setupHardwareInfo(hwInfo, setupFeatureTableAndWorkaroundTable, releaseHelper);
|
||||
this->adjustSharedSystemMemCapabilities();
|
||||
|
||||
querySystemInfo();
|
||||
|
||||
@@ -1861,6 +1862,12 @@ bool Drm::queryDeviceIdAndRevision() {
|
||||
return IoctlHelperI915::queryDeviceIdAndRevision(*this);
|
||||
}
|
||||
|
||||
void Drm::adjustSharedSystemMemCapabilities() {
|
||||
if (!this->isSharedSystemAllocEnabled()) {
|
||||
this->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Drm::getAggregatedProcessCount() const {
|
||||
return ioctlHelper->getNumProcesses();
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ class Drm : public DriverModel {
|
||||
bool isDirectSubmissionActive() const { return this->directSubmissionActive; }
|
||||
MOCKABLE_VIRTUAL void setSharedSystemAllocEnable(bool value) { this->sharedSystemAllocEnable = value; }
|
||||
MOCKABLE_VIRTUAL bool isSharedSystemAllocEnabled() const { return this->sharedSystemAllocEnable; }
|
||||
void adjustSharedSystemMemCapabilities();
|
||||
|
||||
MOCKABLE_VIRTUAL bool isSetPairAvailable();
|
||||
MOCKABLE_VIRTUAL bool getSetPairAvailable() { return setPairAvailable; }
|
||||
|
||||
@@ -160,7 +160,7 @@ bool IoctlHelperXe::queryDeviceIdAndRevision(Drm &drm) {
|
||||
hwInfo->platform.usDeviceID = config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] & 0xffff;
|
||||
hwInfo->platform.usRevId = static_cast<int>((config->info[DRM_XE_QUERY_CONFIG_REV_AND_DEVICE_ID] >> 16) & 0xff);
|
||||
|
||||
if ((debugManager.flags.EnableRecoverablePageFaults.get() != 0) && (debugManager.flags.EnableSharedSystemUsmSupport.get() != 0) && (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR)) {
|
||||
if ((debugManager.flags.EnableRecoverablePageFaults.get() != 0) && (debugManager.flags.EnableSharedSystemUsmSupport.get() == 1) && (config->info[DRM_XE_QUERY_CONFIG_FLAGS] & DRM_XE_QUERY_CONFIG_FLAG_HAS_CPU_ADDR_MIRROR)) {
|
||||
drm.setSharedSystemAllocEnable(true);
|
||||
drm.setPageFaultSupported(true);
|
||||
}
|
||||
|
||||
@@ -180,13 +180,11 @@ uint64_t ProductHelperHw<gfxProduct>::getHostMemCapabilities(const HardwareInfo
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
uint64_t ProductHelperHw<gfxProduct>::getSharedSystemMemCapabilities(const HardwareInfo *hwInfo) const {
|
||||
bool supported = false;
|
||||
|
||||
if (debugManager.flags.EnableSharedSystemUsmSupport.get() != -1) {
|
||||
supported = !!debugManager.flags.EnableSharedSystemUsmSupport.get();
|
||||
if ((debugManager.flags.EnableRecoverablePageFaults.get() == 0) || (debugManager.flags.EnableSharedSystemUsmSupport.get() == 0)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (supported ? (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess) : 0);
|
||||
return (hwInfo->capabilityTable.sharedSystemMemCapabilities);
|
||||
}
|
||||
|
||||
template <PRODUCT_FAMILY gfxProduct>
|
||||
|
||||
@@ -15,5 +15,4 @@ inline constexpr uint64_t access = 1 << 0;
|
||||
inline constexpr uint64_t atomicAccess = 1 << 1;
|
||||
inline constexpr uint64_t concurrentAccess = 1 << 2;
|
||||
inline constexpr uint64_t concurrentAtomicAccess = 1 << 3;
|
||||
inline constexpr uint64_t sharedSystemPageFaultEnabled = 1 << 4;
|
||||
} // namespace UnifiedSharedMemoryFlags
|
||||
|
||||
@@ -37,7 +37,7 @@ TEST(PrefetchManagerTests, givenPrefetchManagerWhenCallingInterfaceFunctionsThen
|
||||
auto &hwInfo = *device->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
|
||||
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
|
||||
sharedSystemMemCapabilities = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::sharedSystemPageFaultEnabled;
|
||||
sharedSystemMemCapabilities = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
|
||||
auto svmData = svmManager->getSVMAlloc(ptr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
||||
@@ -336,7 +336,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, givenSharedSystemAllocationWhenPrefetchMemor
|
||||
auto &hwInfo = *device->getRootDeviceEnvironment().getMutableHardwareInfo();
|
||||
|
||||
VariableBackup<uint64_t> sharedSystemMemCapabilities{&hwInfo.capabilityTable.sharedSystemMemCapabilities};
|
||||
sharedSystemMemCapabilities = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::sharedSystemPageFaultEnabled;
|
||||
sharedSystemMemCapabilities = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
|
||||
csr->setupContext(*device->getDefaultEngine().osContext);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/os_interface/linux/memory_info.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
#include "shared/source/unified_memory/usm_memory_support.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
|
||||
@@ -2783,6 +2784,7 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionConfigFlagHasGpuAddrMirror
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
|
||||
DebugManagerStateRestore restore;
|
||||
debugManager.flags.EnableSharedSystemUsmSupport.set(1);
|
||||
mockIoctl = [](int fileDescriptor, unsigned long int request, void *arg) -> int {
|
||||
if (request == DRM_IOCTL_XE_DEVICE_QUERY) {
|
||||
struct drm_xe_device_query *deviceQuery = static_cast<struct drm_xe_device_query *>(arg);
|
||||
@@ -2802,6 +2804,10 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionConfigFlagHasGpuAddrMirror
|
||||
|
||||
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
|
||||
EXPECT_TRUE(drm->isSharedSystemAllocEnabled());
|
||||
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = caps;
|
||||
drm->adjustSharedSystemMemCapabilities();
|
||||
EXPECT_EQ(caps, drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities);
|
||||
EXPECT_TRUE(drm->hasPageFaultSupport());
|
||||
}
|
||||
|
||||
@@ -2828,6 +2834,10 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndConfigFlagHasGpuAddrMir
|
||||
|
||||
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
|
||||
EXPECT_FALSE(drm->isSharedSystemAllocEnabled());
|
||||
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = caps;
|
||||
drm->adjustSharedSystemMemCapabilities();
|
||||
EXPECT_EQ(0lu, drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndSharedSystemUsmSupportDebugFlagClearThenSharedSystemAllocEnableFalse) {
|
||||
@@ -2854,6 +2864,10 @@ TEST_F(IoctlHelperXeTest, whenQueryDeviceIdAndRevisionAndSharedSystemUsmSupportD
|
||||
|
||||
EXPECT_TRUE(IoctlHelperXe::queryDeviceIdAndRevision(*drm));
|
||||
EXPECT_FALSE(drm->isSharedSystemAllocEnabled());
|
||||
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = caps;
|
||||
drm->adjustSharedSystemMemCapabilities();
|
||||
EXPECT_EQ(0lu, drm->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities);
|
||||
EXPECT_FALSE(drm->hasPageFaultSupport());
|
||||
}
|
||||
|
||||
|
||||
@@ -71,18 +71,27 @@ HWTEST_F(ProductHelperTest, givenDebugFlagSetWhenAskingForHostMemCapabilitesThen
|
||||
HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingSharedSystemMemCapabilitiesThenCorrectValueIsReturned) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
EXPECT_EQ(0u, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
|
||||
uint64_t caps = (UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess);
|
||||
pInHwInfo.capabilityTable.sharedSystemMemCapabilities = caps;
|
||||
EXPECT_EQ(caps, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
|
||||
|
||||
for (auto enable : {-1, 0, 1}) {
|
||||
debugManager.flags.EnableSharedSystemUsmSupport.set(enable);
|
||||
|
||||
if (enable > 0) {
|
||||
auto caps = UnifiedSharedMemoryFlags::access | UnifiedSharedMemoryFlags::atomicAccess | UnifiedSharedMemoryFlags::concurrentAccess | UnifiedSharedMemoryFlags::concurrentAtomicAccess;
|
||||
if (enable != 0) {
|
||||
EXPECT_EQ(caps, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
|
||||
} else {
|
||||
EXPECT_EQ(0u, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
|
||||
}
|
||||
}
|
||||
for (auto enable : {-1, 0, 1}) {
|
||||
debugManager.flags.EnableRecoverablePageFaults.set(enable);
|
||||
if (enable != 0) {
|
||||
EXPECT_EQ(caps, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
|
||||
} else {
|
||||
EXPECT_EQ(0u, productHelper->getSharedSystemMemCapabilities(&pInHwInfo));
|
||||
}
|
||||
}
|
||||
pInHwInfo.capabilityTable.sharedSystemMemCapabilities = caps;
|
||||
}
|
||||
|
||||
HWTEST_F(ProductHelperTest, givenProductHelperWhenAskedIfIsBlitSplitEnqueueWARequiredThenReturnFalse) {
|
||||
@@ -95,7 +104,7 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingMemoryCapabilitiesThenC
|
||||
|
||||
for (auto capabilityBitmask : {0, 0b0001, 0b0010, 0b0100, 0b1000, 0b1111}) {
|
||||
debugManager.flags.EnableUsmConcurrentAccessSupport.set(capabilityBitmask);
|
||||
std::bitset<4> capabilityBitset(capabilityBitmask);
|
||||
std::bitset<5> capabilityBitset(capabilityBitmask);
|
||||
|
||||
auto hostMemCapabilities = productHelper->getHostMemCapabilities(&pInHwInfo);
|
||||
if (hostMemCapabilities > 0) {
|
||||
|
||||
Reference in New Issue
Block a user