feature: Add ioctl helper function to get fence address

Related-To: NEO-11817

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2024-09-20 17:16:45 +00:00
committed by Compute-Runtime-Automation
parent ec75f8f686
commit 354bef70ac
4 changed files with 29 additions and 4 deletions

View File

@@ -1272,11 +1272,11 @@ unsigned int Drm::bindDrmContext(uint32_t drmContextId, uint32_t deviceIndex, au
}
void Drm::waitForBind(uint32_t vmHandleId) {
if (pagingFence[vmHandleId] >= fenceVal[vmHandleId]) {
if (*ioctlHelper->getPagingFenceAddress(vmHandleId, nullptr) >= fenceVal[vmHandleId]) {
return;
}
auto lock = this->lockBindFenceMutex();
auto fenceAddress = castToUint64(&this->pagingFence[vmHandleId]);
auto fenceAddress = castToUint64(ioctlHelper->getPagingFenceAddress(vmHandleId, nullptr));
auto fenceValue = this->fenceVal[vmHandleId];
lock.unlock();
@@ -1401,10 +1401,10 @@ void programUserFence(Drm *drm, OsContext *osContext, BufferObject *bo, VmBindEx
if (drm->isPerContextVMRequired()) {
auto osContextLinux = static_cast<OsContextLinux *>(osContext);
address = castToUint64(osContextLinux->getFenceAddr(vmHandleId));
address = castToUint64(ioctlHelper->getPagingFenceAddress(vmHandleId, osContextLinux));
value = osContextLinux->getNextFenceVal(vmHandleId);
} else {
address = castToUint64(drm->getFenceAddr(vmHandleId));
address = castToUint64(ioctlHelper->getPagingFenceAddress(vmHandleId, nullptr));
value = drm->getNextFenceVal(vmHandleId);
}

View File

@@ -13,6 +13,7 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/drm_wrappers.h"
#include "shared/source/os_interface/linux/os_context_linux.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "drm.h"
@@ -79,4 +80,13 @@ std::string IoctlHelper::getIoctlStringBase(DrmIoctl ioctlRequest) const {
bool IoctlHelper::checkIfIoctlReinvokeRequired(int error, DrmIoctl ioctlRequest) const {
return (error == EINTR || error == EAGAIN || error == EBUSY || error == -EBUSY);
}
uint64_t *IoctlHelper::getPagingFenceAddress(uint32_t vmHandleId, OsContextLinux *osContext) {
if (osContext) {
return osContext->getFenceAddr(vmHandleId);
} else {
return drm.getFenceAddr(vmHandleId);
}
}
} // namespace NEO

View File

@@ -221,6 +221,8 @@ class IoctlHelper {
virtual bool allocateInterrupt(uint32_t &outHandle) { return false; }
virtual bool releaseInterrupt(uint32_t handle) { return false; }
virtual uint64_t *getPagingFenceAddress(uint32_t vmHandleId, OsContextLinux *osContext);
protected:
Drm &drm;
ExternalCtx *externalCtx = nullptr;

View File

@@ -2459,3 +2459,16 @@ TEST(IoctlHelperXeTest, givenL3BankWhenGetTopologyDataAndMapThenResultsAreCorrec
// verify topology data
EXPECT_EQ(12, topologyData.numL3Banks);
}
TEST(IoctlHelperXeTest, givenIoctlHelperWhenGettingFenceAddressThenReturnCorrectValue) {
MockExecutionEnvironment executionEnvironment{};
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
IoctlHelperXe ioctlHelper{*drm};
auto fenceAddr = ioctlHelper.getPagingFenceAddress(0, nullptr);
EXPECT_EQ(drm->getFenceAddr(0), fenceAddr);
OsContextLinux osContext(*drm, 0, 5u, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_CCS, EngineUsage::lowPriority}));
fenceAddr = ioctlHelper.getPagingFenceAddress(0, &osContext);
EXPECT_EQ(osContext.getFenceAddr(0), fenceAddr);
}