Skip to content

Commit 4f7a225

Browse files
Set PAT programming support during VmBind support query
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 2b55ca7 commit 4f7a225

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4444,6 +4444,7 @@ TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsNotSetThenReturnFa
44444444

44454445
TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenReturnTrue) {
44464446
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
4447+
drm.queryAndSetVmBindPatIndexProgrammingSupport();
44474448
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
44484449

44494450
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
@@ -4458,6 +4459,7 @@ TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThe
44584459

44594460
TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSetRegionInBufferObject) {
44604461
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
4462+
drm.queryAndSetVmBindPatIndexProgrammingSupport();
44614463
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
44624464

44634465
MockBufferObject bo(&drm, 3, 0, 0, 1);
@@ -5479,7 +5481,11 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenPatIndex
54795481
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
54805482
ASSERT_NE(nullptr, drmAllocation->getBO());
54815483

5482-
if (HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported()) {
5484+
auto isVmBindPatIndexProgrammingSupported = HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported();
5485+
5486+
EXPECT_EQ(isVmBindPatIndexProgrammingSupported, mock->isVmBindPatIndexProgrammingSupported());
5487+
5488+
if (isVmBindPatIndexProgrammingSupported) {
54835489
auto expectedIndex = mock->getPatIndex(allocation->getDefaultGmm(), allocation->getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false);
54845490

54855491
EXPECT_NE(CommonConstants::unsupportedPatIndex, drmAllocation->getBO()->peekPatIndex());

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ Drm::Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &r
205205
fenceVal.fill(0u);
206206
}
207207

208+
void Drm::queryAndSetVmBindPatIndexProgrammingSupport() {
209+
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
210+
211+
this->vmBindPatIndexProgrammingSupported = HwInfoConfig::get(hwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported();
212+
}
213+
208214
int Drm::ioctl(unsigned long request, void *arg) {
209215
int ret;
210216
int returnedErrno;
@@ -1339,6 +1345,8 @@ bool Drm::isVmBindAvailable() {
13391345
bindAvailable = ret;
13401346

13411347
Drm::overrideBindSupport(bindAvailable);
1348+
1349+
queryAndSetVmBindPatIndexProgrammingSupport();
13421350
});
13431351

13441352
return bindAvailable;
@@ -1351,7 +1359,7 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c
13511359

13521360
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
13531361

1354-
if (!HwInfoConfig::get(hwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported()) {
1362+
if (!this->vmBindPatIndexProgrammingSupported) {
13551363
return CommonConstants::unsupportedPatIndex;
13561364
}
13571365

@@ -1411,9 +1419,6 @@ int changeBufferObjectBinding(Drm *drm, OsContext *osContext, uint32_t vmHandleI
14111419
bindIterations = 1;
14121420
}
14131421

1414-
auto hwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
1415-
auto hwInfoConfig = HwInfoConfig::get(hwInfo->platform.eProductFamily);
1416-
14171422
int ret = 0;
14181423
for (size_t i = 0; i < bindIterations; i++) {
14191424

@@ -1433,7 +1438,7 @@ int changeBufferObjectBinding(Drm *drm, OsContext *osContext, uint32_t vmHandleI
14331438

14341439
VmBindExtSetPatT vmBindExtSetPat{};
14351440

1436-
if (hwInfoConfig->isVmBindPatIndexProgrammingSupported()) {
1441+
if (drm->isVmBindPatIndexProgrammingSupported()) {
14371442
UNRECOVERABLE_IF(bo->peekPatIndex() == CommonConstants::unsupportedPatIndex);
14381443
ioctlHelper->fillVmBindExtSetPat(vmBindExtSetPat, bo->peekPatIndex(), castToUint64(extensions.get()));
14391444
vmBind.extensions = castToUint64(vmBindExtSetPat);

shared/source/os_interface/linux/drm_neo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ class Drm : public DriverModel {
259259
MOCKABLE_VIRTUAL void notifyLastCommandQueueDestroyed(uint32_t handle);
260260

261261
uint64_t getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion cacheRegion, CachePolicy cachePolicy, bool closEnabled) const;
262+
bool isVmBindPatIndexProgrammingSupported() const { return vmBindPatIndexProgrammingSupported; }
262263

263264
protected:
264265
Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
@@ -271,6 +272,7 @@ class Drm : public DriverModel {
271272
std::vector<uint8_t> query(uint32_t queryId, uint32_t queryItemFlags);
272273
void printIoctlStatistics();
273274
void setupIoctlHelper(const PRODUCT_FAMILY productFamily);
275+
void queryAndSetVmBindPatIndexProgrammingSupport();
274276

275277
#pragma pack(1)
276278
struct PCIConfig {
@@ -344,6 +346,7 @@ class Drm : public DriverModel {
344346
bool contextDebugSupported = false;
345347
bool pageFaultSupported = false;
346348
bool completionFenceSupported = false;
349+
bool vmBindPatIndexProgrammingSupported = false;
347350

348351
private:
349352
int getParamIoctl(int param, int *dstValue);

shared/test/common/libult/linux/drm_mock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class DrmMock : public Drm {
4545
using Drm::pagingFence;
4646
using Drm::preemptionSupported;
4747
using Drm::query;
48+
using Drm::queryAndSetVmBindPatIndexProgrammingSupport;
4849
using Drm::requirePerContextVM;
4950
using Drm::setupIoctlHelper;
5051
using Drm::sliceCountChangeSupported;

shared/test/unit_test/os_interface/linux/drm_debug_prelim_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinCopyEngi
290290

291291
HWTEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenUnbindingThenExtensionsAreNotSet) {
292292
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
293+
drm.queryAndSetVmBindPatIndexProgrammingSupport();
293294

294295
MockBufferObject bo(&drm, 3, 0, 0, 1);
295296
bo.addBindExtHandle(4);

0 commit comments

Comments
 (0)