libgralloc: Change ion_allocation_data fields.

Change ioc_allocation_data structure fields as per changes in kernel.
The 'heap_mask' feild will hold what the older flags field held.
The 'flags' field will hold the caching information.

Change-Id: Id3b2e8a4d1ba370e0f982860fdb32b56227e2e43
This commit is contained in:
Saurabh Shah
2012-09-14 14:18:21 -07:00
committed by Mitchel Humpherys
parent ece296ec98
commit d95c4083cc

View File

@@ -66,8 +66,6 @@ int IonAlloc::alloc_buffer(alloc_data& data)
{ {
Locker::Autolock _l(mLock); Locker::Autolock _l(mLock);
int err = 0; int err = 0;
int ionSyncFd = FD_INIT;
int iFd = FD_INIT;
struct ion_handle_data handle_data; struct ion_handle_data handle_data;
struct ion_fd_data fd_data; struct ion_fd_data fd_data;
struct ion_allocation_data ionAllocData; struct ion_allocation_data ionAllocData;
@@ -76,45 +74,26 @@ int IonAlloc::alloc_buffer(alloc_data& data)
ionAllocData.len = data.size; ionAllocData.len = data.size;
ionAllocData.align = data.align; ionAllocData.align = data.align;
ionAllocData.flags = data.flags; ionAllocData.heap_mask = data.flags;
ionAllocData.flags = data.uncached ? 0 : ION_FLAG_CACHED;
err = open_device(); err = open_device();
if (err) if (err)
return err; return err;
if(data.uncached) { if(ioctl(mIonFd, ION_IOC_ALLOC, &ionAllocData)) {
// 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)) {
err = -errno; err = -errno;
ALOGE("ION_IOC_ALLOC failed with error - %s", strerror(errno)); ALOGE("ION_IOC_ALLOC failed with error - %s", strerror(errno));
if(ionSyncFd >= 0)
close(ionSyncFd);
ionSyncFd = FD_INIT;
return err; return err;
} }
fd_data.handle = ionAllocData.handle; fd_data.handle = ionAllocData.handle;
handle_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; err = -errno;
ALOGE("%s: ION_IOC_MAP failed with error - %s", ALOGE("%s: ION_IOC_MAP failed with error - %s",
__FUNCTION__, strerror(errno)); __FUNCTION__, strerror(errno));
ioctl(mIonFd, ION_IOC_FREE, &handle_data); ioctl(mIonFd, ION_IOC_FREE, &handle_data);
if(ionSyncFd >= 0)
close(ionSyncFd);
ionSyncFd = FD_INIT;
return err; return err;
} }
@@ -126,7 +105,6 @@ int IonAlloc::alloc_buffer(alloc_data& data)
ALOGE("%s: Failed to map the allocated memory: %s", ALOGE("%s: Failed to map the allocated memory: %s",
__FUNCTION__, strerror(errno)); __FUNCTION__, strerror(errno));
ioctl(mIonFd, ION_IOC_FREE, &handle_data); ioctl(mIonFd, ION_IOC_FREE, &handle_data);
ionSyncFd = FD_INIT;
return err; return err;
} }
memset(base, 0, ionAllocData.len); 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); 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.base = base;
data.fd = fd_data.fd; data.fd = fd_data.fd;
ioctl(mIonFd, ION_IOC_FREE, &handle_data); ioctl(mIonFd, ION_IOC_FREE, &handle_data);