diff --git a/libgralloc/ionalloc.cpp b/libgralloc/ionalloc.cpp index edfd96a4..b9b97178 100644 --- a/libgralloc/ionalloc.cpp +++ b/libgralloc/ionalloc.cpp @@ -66,8 +66,6 @@ int IonAlloc::alloc_buffer(alloc_data& data) { Locker::Autolock _l(mLock); int err = 0; - int ionSyncFd = FD_INIT; - int iFd = FD_INIT; struct ion_handle_data handle_data; struct ion_fd_data fd_data; struct ion_allocation_data ionAllocData; @@ -76,45 +74,26 @@ int IonAlloc::alloc_buffer(alloc_data& data) ionAllocData.len = data.size; ionAllocData.align = data.align; - ionAllocData.flags = data.flags; + ionAllocData.heap_mask = data.flags; + ionAllocData.flags = data.uncached ? 0 : ION_FLAG_CACHED; err = open_device(); if (err) return err; - if(data.uncached) { - // Use the sync FD to alloc and map - // when we need uncached memory - ionSyncFd = open(ION_DEVICE, O_RDONLY|O_DSYNC); - if(ionSyncFd < 0) { - ALOGE("%s: Failed to open ion device - %s", - __FUNCTION__, strerror(errno)); - return -errno; - } - iFd = ionSyncFd; - } else { - iFd = mIonFd; - } - - if(ioctl(iFd, ION_IOC_ALLOC, &ionAllocData)) { + if(ioctl(mIonFd, ION_IOC_ALLOC, &ionAllocData)) { err = -errno; ALOGE("ION_IOC_ALLOC failed with error - %s", strerror(errno)); - if(ionSyncFd >= 0) - close(ionSyncFd); - ionSyncFd = FD_INIT; return err; } fd_data.handle = ionAllocData.handle; handle_data.handle = ionAllocData.handle; - if(ioctl(iFd, ION_IOC_MAP, &fd_data)) { + if(ioctl(mIonFd, ION_IOC_MAP, &fd_data)) { err = -errno; ALOGE("%s: ION_IOC_MAP failed with error - %s", __FUNCTION__, strerror(errno)); ioctl(mIonFd, ION_IOC_FREE, &handle_data); - if(ionSyncFd >= 0) - close(ionSyncFd); - ionSyncFd = FD_INIT; return err; } @@ -126,7 +105,6 @@ int IonAlloc::alloc_buffer(alloc_data& data) ALOGE("%s: Failed to map the allocated memory: %s", __FUNCTION__, strerror(errno)); ioctl(mIonFd, ION_IOC_FREE, &handle_data); - ionSyncFd = FD_INIT; return err; } memset(base, 0, ionAllocData.len); @@ -134,11 +112,6 @@ int IonAlloc::alloc_buffer(alloc_data& data) clean_buffer(base, data.size, data.offset, fd_data.fd); } - //Close the uncached FD since we no longer need it; - if(ionSyncFd >= 0) - close(ionSyncFd); - ionSyncFd = FD_INIT; - data.base = base; data.fd = fd_data.fd; ioctl(mIonFd, ION_IOC_FREE, &handle_data);