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:
committed by
Mitchel Humpherys
parent
ece296ec98
commit
d95c4083cc
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user