diff --git a/libgralloc-qsd8k/gpu.cpp b/libgralloc-qsd8k/gpu.cpp index 85680b8..9f70fbe 100755 --- a/libgralloc-qsd8k/gpu.cpp +++ b/libgralloc-qsd8k/gpu.cpp @@ -169,7 +169,7 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, buffer_handle_t* // the PmemAllocator rather than getting the base & offset separately int offset = 0; int lockState = 0; - int masterFd = -1; + size = roundUpToPageSize(size); #ifndef USE_ASHMEM if (usage & GRALLOC_USAGE_HW_TEXTURE) { @@ -219,7 +219,7 @@ int gpu_context_t::gralloc_alloc_buffer(size_t size, int usage, buffer_handle_t* // PMEM buffers are always mmapped lockState |= private_handle_t::LOCK_STATE_MAPPED; - err = pma->alloc_pmem_buffer(size, usage, &base, &offset, &fd, &masterFd, format); + err = pma->alloc_pmem_buffer(size, usage, &base, &offset, &fd, format); if (err < 0) { if (((usage & GRALLOC_USAGE_HW_MASK) == 0) && ((usage & GRALLOC_USAGE_PRIVATE_PMEM_ADSP) == 0)) { @@ -245,7 +245,6 @@ try_ashmem: hnd->offset = offset; hnd->base = int(base)+offset; hnd->lockState = lockState; - hnd->masterFd = masterFd; *pHandle = hnd; } @@ -394,9 +393,6 @@ int gpu_context_t::free_impl(private_handle_t const* hnd) { } deps.close(hnd->fd); - if (hnd->masterFd != -1) { - deps.close(hnd->masterFd); - } delete hnd; // XXX JMG: move this to the deps return 0; } diff --git a/libgralloc-qsd8k/gralloc_priv.h b/libgralloc-qsd8k/gralloc_priv.h index 228b6be..6804c41 100755 --- a/libgralloc-qsd8k/gralloc_priv.h +++ b/libgralloc-qsd8k/gralloc_priv.h @@ -283,17 +283,16 @@ struct private_handle_t { int format; int width; int height; - int masterFd; #ifdef __cplusplus - static const int sNumInts = 14; + static const int sNumInts = 13; static const int sNumFds = 1; static const int sMagic = 'gmsm'; private_handle_t(int fd, int size, int flags, int bufferType, int format, int width, int height) : fd(fd), magic(sMagic), flags(flags), size(size), offset(0), bufferType(bufferType), base(0), lockState(0), writeOwner(0), gpuaddr(0), pid(getpid()), format(format), width(width), - height(height), masterFd(-1) + height(height) { version = sizeof(native_handle); numInts = sNumInts; diff --git a/libgralloc-qsd8k/pmemalloc.cpp b/libgralloc-qsd8k/pmemalloc.cpp index 6604e25..126004d 100755 --- a/libgralloc-qsd8k/pmemalloc.cpp +++ b/libgralloc-qsd8k/pmemalloc.cpp @@ -143,7 +143,7 @@ int PmemUserspaceAllocator::init_pmem_area() int PmemUserspaceAllocator::alloc_pmem_buffer(size_t size, int usage, - void** pBase, int* pOffset, int* pFd, int* masterFd, int format) + void** pBase, int* pOffset, int* pFd, int format) { BEGIN_FUNC; int err = init_pmem_area(); @@ -187,7 +187,6 @@ int PmemUserspaceAllocator::alloc_pmem_buffer(size_t size, int usage, *pBase = base; *pOffset = offset; *pFd = fd; - *masterFd = -1; } //LOGD_IF(!err, "%s: allocating pmem size=%d, offset=%d", pmemdev, size, offset); } @@ -262,7 +261,7 @@ static unsigned clp2(unsigned x) { int PmemKernelAllocator::alloc_pmem_buffer(size_t size, int usage, - void** pBase,int* pOffset, int* pFd, int* masterFd, int format) + void** pBase,int* pOffset, int* pFd, int format) { BEGIN_FUNC; @@ -283,8 +282,8 @@ int PmemKernelAllocator::alloc_pmem_buffer(size_t size, int usage, return -EINVAL; } - int master_fd = deps.open(device, openFlags, 0); - if (master_fd < 0) { + int fd = deps.open(device, openFlags, 0); + if (fd < 0) { err = -deps.getErrno(); END_FUNC; LOGE("Error opening %s", device); @@ -296,49 +295,26 @@ int PmemKernelAllocator::alloc_pmem_buffer(size_t size, int usage, if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED) { // Tile format buffers need physical alignment to 8K - err = deps.alignPmem(master_fd, size, 8192); + err = deps.alignPmem(fd, size, 8192); if (err < 0) { LOGE("alignPmem failed"); } } - void* base = deps.mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, master_fd, 0); + void* base = deps.mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (base == MAP_FAILED) { LOGE("%s: failed to map pmem fd: %s", device, strerror(deps.getErrno())); err = -deps.getErrno(); - deps.close(master_fd); + deps.close(fd); END_FUNC; return err; } memset(base, 0, size); - - // Connect and map the PMEM region to give to the client process - int fd = deps.open(device, O_RDWR, 0); - err = fd < 0 ? fd : 0; - // and connect to it - if (err == 0) { - err = deps.connectPmem(fd, master_fd); - } - - // and make it available to the client process - if (err == 0) { - err = deps.mapPmem(fd, offset, size); - } - - if (err == 0) { - *pBase = base; - *pOffset = 0; - *pFd = fd; - *masterFd = master_fd; - } else { - deps.munmap(base, size); - deps.unmapPmem(fd, offset, size); - deps.close(fd); - deps.close(master_fd); - return err; - } + *pBase = base; + *pOffset = 0; + *pFd = fd; END_FUNC; return 0; @@ -352,7 +328,7 @@ int PmemKernelAllocator::free_pmem_buffer(size_t size, void* base, int offset, i // like we did when allocating. //size = clp2(size); - int err = deps.unmapPmem(fd, offset, size); + int err = deps.munmap(base, size); if (err < 0) { err = deps.getErrno(); LOGW("error unmapping pmem fd: %s", strerror(err)); diff --git a/libgralloc-qsd8k/pmemalloc.h b/libgralloc-qsd8k/pmemalloc.h index a6d98b8..c64d9be 100755 --- a/libgralloc-qsd8k/pmemalloc.h +++ b/libgralloc-qsd8k/pmemalloc.h @@ -36,7 +36,7 @@ class PmemAllocator { virtual void* get_base_address() = 0; virtual int alloc_pmem_buffer(size_t size, int usage, void** pBase, - int* pOffset, int* pFd, int* masterFd, int format) = 0; + int* pOffset, int* pFd, int format) = 0; virtual int free_pmem_buffer(size_t size, void* base, int offset, int fd) = 0; }; @@ -89,7 +89,7 @@ class PmemUserspaceAllocator: public PmemAllocator { virtual int init_pmem_area_locked(); virtual int init_pmem_area(); virtual int alloc_pmem_buffer(size_t size, int usage, void** pBase, - int* pOffset, int* pFd, int* masterFd, int format); + int* pOffset, int* pFd, int format); virtual int free_pmem_buffer(size_t size, void* base, int offset, int fd); #ifndef ANDROID_OS @@ -139,9 +139,6 @@ class PmemKernelAllocator: public PmemAllocator { virtual int munmap(void* start, size_t length) = 0; virtual int open(const char* pathname, int flags, int mode) = 0; virtual int close(int fd) = 0; - 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 alignPmem(int fd, size_t size, int align) = 0; }; @@ -152,7 +149,7 @@ class PmemKernelAllocator: public PmemAllocator { virtual void* get_base_address(); virtual int alloc_pmem_buffer(size_t size, int usage, void** pBase, - int* pOffset, int* pFd, int* masterFd, int format); + int* pOffset, int* pFd, int format); virtual int free_pmem_buffer(size_t size, void* base, int offset, int fd); private: