Refactor waitOnCompletionFence method in DrmMemoryManager

get completion address and value from command stream receiver

Related-To: NEO-6643

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-03-30 12:40:09 +00:00
committed by Compute-Runtime-Automation
parent e32f624bf4
commit 9d502dea25
9 changed files with 59 additions and 35 deletions

View File

@@ -319,6 +319,14 @@ class CommandStreamReceiver {
MOCKABLE_VIRTUAL bool isGpuHangDetected() const;
virtual uint64_t getCompletionAddress() {
return 0;
}
virtual uint32_t getCompletionValue(const GraphicsAllocation &gfxAllocation) {
return 0;
}
protected:
void cleanupResources();
void printDeviceIndex();

View File

@@ -62,6 +62,10 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
gemCloseWorkerOperationMode = gemCloseWorkerMode::gemCloseWorkerInactive;
}
uint64_t getCompletionAddress() override;
uint32_t getCompletionValue(const GraphicsAllocation &gfxAllocation) override;
void printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation);
using CommandStreamReceiver::pageTableManager;

View File

@@ -316,4 +316,16 @@ inline bool DrmCommandStreamReceiver<GfxFamily>::isUserFenceWaitActive() {
return (this->drm->isVmBindAvailable() && useUserFenceWait);
}
template <typename GfxFamily>
uint64_t DrmCommandStreamReceiver<GfxFamily>::getCompletionAddress() {
uint64_t completionFenceAddress = castToUint64(const_cast<uint32_t *>(getTagAddress()));
completionFenceAddress += Drm::completionFenceOffset;
return completionFenceAddress;
}
template <typename GfxFamily>
uint32_t DrmCommandStreamReceiver<GfxFamily>::getCompletionValue(const GraphicsAllocation &gfxAllocation) {
auto osContextId = osContext->getContextId();
return gfxAllocation.getTaskCount(osContextId);
}
} // namespace NEO

View File

@@ -1526,14 +1526,13 @@ void DrmMemoryManager::waitOnCompletionFence(GraphicsAllocation *allocation) {
uint32_t activeHwContexts = csr->getActivePartitions();
auto osContextId = osContext->getContextId();
auto allocationTaskCount = allocation->getTaskCount(osContextId);
uint64_t completionFenceAddress = castToUint64(const_cast<uint32_t *>(csr->getTagAddress()));
auto allocationTaskCount = csr->getCompletionValue(*allocation);
uint64_t completionFenceAddress = csr->getCompletionAddress();
if (completionFenceAddress == 0) {
continue;
}
if (allocation->isUsedByOsContext(osContextId)) {
completionFenceAddress += Drm::completionFenceOffset;
Drm &drm = getDrm(csr->getRootDeviceIndex());
auto &ctxVector = static_cast<const OsContextLinux *>(osContext)->getDrmContextIds();