Set PAT programming support during VmBind support query

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2022-05-04 13:59:12 +00:00
committed by Compute-Runtime-Automation
parent 2b55ca76b8
commit 4f7a225baf
5 changed files with 22 additions and 6 deletions

View File

@ -4444,6 +4444,7 @@ TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsNotSetThenReturnFa
TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenReturnTrue) {
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.queryAndSetVmBindPatIndexProgrammingSupport();
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::LocalMemory);
@ -4458,6 +4459,7 @@ TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThe
TEST_F(DrmAllocationTests, givenDrmAllocationWhenCacheRegionIsSetSuccessfullyThenSetRegionInBufferObject) {
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
drm.queryAndSetVmBindPatIndexProgrammingSupport();
drm.cacheInfo.reset(new MockCacheInfo(drm, 32 * MemoryConstants::kiloByte, 2, 32));
MockBufferObject bo(&drm, 3, 0, 0, 1);
@ -5479,7 +5481,11 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenPatIndex
auto drmAllocation = static_cast<DrmAllocation *>(allocation);
ASSERT_NE(nullptr, drmAllocation->getBO());
if (HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported()) {
auto isVmBindPatIndexProgrammingSupported = HwInfoConfig::get(defaultHwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported();
EXPECT_EQ(isVmBindPatIndexProgrammingSupported, mock->isVmBindPatIndexProgrammingSupported());
if (isVmBindPatIndexProgrammingSupported) {
auto expectedIndex = mock->getPatIndex(allocation->getDefaultGmm(), allocation->getAllocationType(), CacheRegion::Default, CachePolicy::WriteBack, false);
EXPECT_NE(CommonConstants::unsupportedPatIndex, drmAllocation->getBO()->peekPatIndex());

View File

@ -205,6 +205,12 @@ Drm::Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &r
fenceVal.fill(0u);
}
void Drm::queryAndSetVmBindPatIndexProgrammingSupport() {
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
this->vmBindPatIndexProgrammingSupported = HwInfoConfig::get(hwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported();
}
int Drm::ioctl(unsigned long request, void *arg) {
int ret;
int returnedErrno;
@ -1339,6 +1345,8 @@ bool Drm::isVmBindAvailable() {
bindAvailable = ret;
Drm::overrideBindSupport(bindAvailable);
queryAndSetVmBindPatIndexProgrammingSupport();
});
return bindAvailable;
@ -1351,7 +1359,7 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
if (!HwInfoConfig::get(hwInfo->platform.eProductFamily)->isVmBindPatIndexProgrammingSupported()) {
if (!this->vmBindPatIndexProgrammingSupported) {
return CommonConstants::unsupportedPatIndex;
}
@ -1411,9 +1419,6 @@ int changeBufferObjectBinding(Drm *drm, OsContext *osContext, uint32_t vmHandleI
bindIterations = 1;
}
auto hwInfo = drm->getRootDeviceEnvironment().getHardwareInfo();
auto hwInfoConfig = HwInfoConfig::get(hwInfo->platform.eProductFamily);
int ret = 0;
for (size_t i = 0; i < bindIterations; i++) {
@ -1433,7 +1438,7 @@ int changeBufferObjectBinding(Drm *drm, OsContext *osContext, uint32_t vmHandleI
VmBindExtSetPatT vmBindExtSetPat{};
if (hwInfoConfig->isVmBindPatIndexProgrammingSupported()) {
if (drm->isVmBindPatIndexProgrammingSupported()) {
UNRECOVERABLE_IF(bo->peekPatIndex() == CommonConstants::unsupportedPatIndex);
ioctlHelper->fillVmBindExtSetPat(vmBindExtSetPat, bo->peekPatIndex(), castToUint64(extensions.get()));
vmBind.extensions = castToUint64(vmBindExtSetPat);

View File

@ -259,6 +259,7 @@ class Drm : public DriverModel {
MOCKABLE_VIRTUAL void notifyLastCommandQueueDestroyed(uint32_t handle);
uint64_t getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion cacheRegion, CachePolicy cachePolicy, bool closEnabled) const;
bool isVmBindPatIndexProgrammingSupported() const { return vmBindPatIndexProgrammingSupported; }
protected:
Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
@ -271,6 +272,7 @@ class Drm : public DriverModel {
std::vector<uint8_t> query(uint32_t queryId, uint32_t queryItemFlags);
void printIoctlStatistics();
void setupIoctlHelper(const PRODUCT_FAMILY productFamily);
void queryAndSetVmBindPatIndexProgrammingSupport();
#pragma pack(1)
struct PCIConfig {
@ -344,6 +346,7 @@ class Drm : public DriverModel {
bool contextDebugSupported = false;
bool pageFaultSupported = false;
bool completionFenceSupported = false;
bool vmBindPatIndexProgrammingSupported = false;
private:
int getParamIoctl(int param, int *dstValue);

View File

@ -45,6 +45,7 @@ class DrmMock : public Drm {
using Drm::pagingFence;
using Drm::preemptionSupported;
using Drm::query;
using Drm::queryAndSetVmBindPatIndexProgrammingSupport;
using Drm::requirePerContextVM;
using Drm::setupIoctlHelper;
using Drm::sliceCountChangeSupported;

View File

@ -290,6 +290,7 @@ TEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenBindingWithinCopyEngi
HWTEST_F(DrmDebugPrelimTest, givenAddedBindExtHandlesInBoWhenUnbindingThenExtensionsAreNotSet) {
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
drm.queryAndSetVmBindPatIndexProgrammingSupport();
MockBufferObject bo(&drm, 3, 0, 0, 1);
bo.addBindExtHandle(4);