Remove root device index from buffer object.

Graphics allocation is responsible for holding this information.
Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>

Change-Id: I5cf6fa7e92a7c716308213509aab5e446b5ef680
This commit is contained in:
Michal Mrozek
2020-03-19 10:41:35 +01:00
committed by sys_ocldev
parent d1b29496fa
commit 1ce4f56c9f
8 changed files with 25 additions and 12 deletions

View File

@@ -29,13 +29,11 @@
namespace NEO {
BufferObject::BufferObject(Drm *drm, int handle, size_t size, uint32_t rootDeviceIndex) : drm(drm), refCount(1), handle(handle), size(size), rootDeviceIndex(rootDeviceIndex), isReused(false) {
BufferObject::BufferObject(Drm *drm, int handle, size_t size) : drm(drm), refCount(1), handle(handle), size(size), isReused(false) {
this->tiling_mode = I915_TILING_NONE;
this->lockedAddress = nullptr;
}
BufferObject::BufferObject(Drm *drm, int handle, uint32_t rootDeviceIndex) : BufferObject(drm, handle, 0, rootDeviceIndex) {}
uint32_t BufferObject::getRefCount() const {
return this->refCount.load();
}

View File

@@ -22,8 +22,8 @@ class BufferObject {
friend DrmMemoryManager;
public:
BufferObject(Drm *drm, int handle, uint32_t rootDeviceIndex);
BufferObject(Drm *drm, int handle, size_t size, uint32_t rootDeviceIndex);
BufferObject(Drm *drm, int handle);
BufferObject(Drm *drm, int handle, size_t size);
MOCKABLE_VIRTUAL ~BufferObject(){};
bool setTiling(uint32_t mode, uint32_t stride);
@@ -49,7 +49,6 @@ class BufferObject {
void setUnmapSize(uint64_t unmapSize) { this->unmapSize = unmapSize; }
uint64_t peekUnmapSize() const { return unmapSize; }
bool peekIsReusableAllocation() const { return this->isReused; }
uint32_t peekRootDeviceIndex() { return rootDeviceIndex; }
protected:
Drm *drm = nullptr;
@@ -58,7 +57,6 @@ class BufferObject {
int handle; // i915 gem object handle
uint64_t size;
uint32_t rootDeviceIndex = 0;
bool isReused;
//Tiling

View File

@@ -84,7 +84,7 @@ void DrmMemoryManager::commonCleanup() {
void DrmMemoryManager::eraseSharedBufferObject(NEO::BufferObject *bo) {
auto it = std::find(sharingBufferObjects.begin(), sharingBufferObjects.end(), bo);
DEBUG_BREAK_IF(it == sharingBufferObjects.end());
releaseGpuRange(reinterpret_cast<void *>((*it)->gpuAddress), (*it)->peekUnmapSize(), (*it)->peekRootDeviceIndex());
releaseGpuRange(reinterpret_cast<void *>((*it)->gpuAddress), (*it)->peekUnmapSize(), this->getRootDeviceIndex(bo->drm));
sharingBufferObjects.erase(it);
}
@@ -736,4 +736,15 @@ Drm &DrmMemoryManager::getDrm(uint32_t rootDeviceIndex) const {
return *this->executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getDrm();
}
uint32_t DrmMemoryManager::getRootDeviceIndex(const Drm *drm) {
auto rootDeviceCount = this->executionEnvironment.rootDeviceEnvironments.size();
for (auto rootDeviceIndex = 0u; rootDeviceIndex < rootDeviceCount; rootDeviceIndex++) {
if (&getDrm(rootDeviceIndex) == drm) {
return rootDeviceIndex;
}
}
return std::numeric_limits<uint32_t>::max();
}
} // namespace NEO

View File

@@ -13,12 +13,14 @@
#include "drm_gem_close_worker.h"
#include <limits>
#include <map>
#include <sys/mman.h>
namespace NEO {
class BufferObject;
class Drm;
constexpr uint32_t invalidRootDeviceIndex = std::numeric_limits<uint32_t>::max();
class DrmMemoryManager : public MemoryManager {
public:
@@ -84,6 +86,7 @@ class DrmMemoryManager : public MemoryManager {
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override;
Drm &getDrm(uint32_t rootDeviceIndex) const;
uint32_t getRootDeviceIndex(const Drm *drm);
std::vector<BufferObject *> pinBBs;
std::vector<void *> memoryForPinBBs;