Refactor duplicate Linux code.

Related-To: NEO-3008

Change-Id: Ia920fc9e4b948fb73fe6c6abc7d2c35f1814dc85
Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
This commit is contained in:
Piotr Fusik
2019-07-17 15:38:14 +02:00
parent 00cb778553
commit ca26cb7044
10 changed files with 45 additions and 78 deletions

View File

@@ -176,8 +176,7 @@ NEO::BufferObject *DrmMemoryManager::allocUserptr(uintptr_t address, size_t size
void DrmMemoryManager::emitPinningRequest(BufferObject *bo, const AllocationData &allocationData) const {
if (forcePinEnabled && pinBB != nullptr && allocationData.flags.forcePin && allocationData.size >= this->pinThreshold) {
auto &osContextLinux = static_cast<OsContextLinux &>(getDefaultCommandStreamReceiver(0)->getOsContext());
pinBB->pin(&bo, 1, osContextLinux.getDrmContextId());
pinBB->pin(&bo, 1, getDefaultDrmContextId());
}
}
@@ -600,8 +599,7 @@ MemoryManager::AllocationStatus DrmMemoryManager::populateOsHandles(OsHandleStor
}
if (validateHostPtrMemory) {
auto &osContextLinux = static_cast<OsContextLinux &>(getDefaultCommandStreamReceiver(0)->getOsContext());
int result = pinBB->pin(allocatedBos, numberOfBosAllocated, osContextLinux.getDrmContextId());
int result = pinBB->pin(allocatedBos, numberOfBosAllocated, getDefaultDrmContextId());
if (result == EFAULT) {
for (uint32_t i = 0; i < numberOfBosAllocated; i++) {
@@ -723,4 +721,9 @@ int DrmMemoryManager::obtainFdFromHandle(int boHandle) {
return openFd.fd;
}
uint32_t DrmMemoryManager::getDefaultDrmContextId() const {
auto &osContextLinux = static_cast<OsContextLinux &>(getDefaultCommandStreamReceiver(0)->getOsContext());
return osContextLinux.getDrmContextIds()[0];
}
} // namespace NEO