gralloc: Clean pmem caches after memset

Change-Id: If403dde70863e0d6ea221f2a105b86bdec134261
This commit is contained in:
Naseer Ahmed 2011-07-07 18:03:47 +05:30
parent 727d46f18b
commit feb462cf01
3 changed files with 11 additions and 0 deletions

View File

@ -112,6 +112,14 @@ class PmemAllocatorDepsDeviceImpl : public PmemUserspaceAllocator::Deps,
return ioctl(fd, PMEM_UNMAP, &sub);
}
virtual int cleanPmem(int fd, unsigned long base, int offset, size_t size) {
struct pmem_addr pmem_addr;
pmem_addr.vaddr = base;
pmem_addr.offset = offset;
pmem_addr.length = size;
return ioctl(fd, PMEM_CLEAN_INV_CACHES, &pmem_addr);
}
virtual int getErrno() {
return errno;
}

View File

@ -181,6 +181,8 @@ int PmemUserspaceAllocator::alloc_pmem_buffer(size_t size, int usage,
} else {
LOGV("%s: mapped fd %d at offset %d, size %d", pmemdev, fd, offset, size);
memset((char*)base + offset, 0, size);
//Clean cache before flushing to ensure pmem is properly flushed
deps.cleanPmem(fd, (unsigned long) base, offset, size);
#ifdef HOST
cacheflush(intptr_t(base) + offset, intptr_t(base) + offset + size, 0);
#endif

View File

@ -69,6 +69,7 @@ class PmemUserspaceAllocator: public PmemAllocator {
virtual int connectPmem(int fd, int master_fd) = 0;
virtual int mapPmem(int fd, int offset, size_t size) = 0;
virtual int unmapPmem(int fd, int offset, size_t size) = 0;
virtual int cleanPmem(int fd, unsigned long base, int offset, size_t size) = 0;
// C99
virtual int getErrno() = 0;