Service read only memory passed as host_ptr

- read only memory cannot be used for allocation,
Oses cannot create graphics alocation for such memory
- if memory allocation fails for host_ptr passed
to enqueueWrite calls, then try doing new allocation
and copy host_ptr on cpu

Change-Id: I415a4673ae1319ea8f77e53bd8fba7489fe85218
This commit is contained in:
Hoppe, Mateusz
2018-02-28 12:09:48 +01:00
parent d62bd0b687
commit a1a20a3b34
33 changed files with 774 additions and 163 deletions

View File

@@ -36,7 +36,7 @@ class DrmMemoryManager : public MemoryManager {
public:
using MemoryManager::createGraphicsAllocationFromSharedHandle;
DrmMemoryManager(Drm *drm, gemCloseWorkerMode mode, bool forcePinAllowed);
DrmMemoryManager(Drm *drm, gemCloseWorkerMode mode, bool forcePinAllowed, bool validateHostPtrMemory);
~DrmMemoryManager() override;
BufferObject *getPinBB() const;
@@ -64,7 +64,7 @@ class DrmMemoryManager : public MemoryManager {
uint64_t getMaxApplicationAddress() override;
uint64_t getInternalHeapBaseAddress() override;
bool populateOsHandles(OsHandleStorage &handleStorage) override;
AllocationStatus populateOsHandles(OsHandleStorage &handleStorage) override;
void cleanOsHandles(OsHandleStorage &handleStorage) override;
// drm/i915 ioctl wrappers
@@ -74,6 +74,10 @@ class DrmMemoryManager : public MemoryManager {
void push(DrmAllocation *alloc);
DrmAllocation *createGraphicsAllocation(OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) override;
void waitForDeletions() override;
bool isValidateHostMemoryEnabled() const {
return validateHostPtrMemory;
}
protected:
BufferObject *findAndReferenceSharedBufferObject(int boHandle);
@@ -86,6 +90,8 @@ class DrmMemoryManager : public MemoryManager {
Drm *drm;
BufferObject *pinBB;
size_t pinThreshold = 8 * 1024 * 1024;
bool forcePinEnabled = false;
const bool validateHostPtrMemory;
std::unique_ptr<DrmGemCloseWorker> gemCloseWorker;
decltype(&lseek) lseekFunction = lseek;
decltype(&mmap) mmapFunction = mmap;