gralloc: Add locking to alloc and free in ION

Change-Id: I16e24e3d366b15a458b19983827233a7bd27d9f7
(cherry picked from commit edad58e17deb0cb1d9ff4754fbac511eea8e4ecf)
This commit is contained in:
Naseer Ahmed 2012-04-23 17:28:27 -04:00 committed by Andrew Sutherland
parent a7dbdc7072
commit d6ffef4cef
3 changed files with 6 additions and 1 deletions

View File

@ -264,12 +264,12 @@ int gpu_context_t::free_impl(private_handle_t const* hnd) {
int index = (hnd->base - m->framebuffer->base) / bufferSize;
m->bufferMask &= ~(1<<index);
} else {
terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd));
sp<IMemAlloc> memalloc = mAllocCtrl->getAllocator(hnd->flags);
int err = memalloc->free_buffer((void*)hnd->base, (size_t) hnd->size,
hnd->offset, hnd->fd);
if(err)
return err;
terminateBuffer(&m->base, const_cast<private_handle_t*>(hnd));
}
// Release the genlock

View File

@ -64,6 +64,7 @@ void IonAlloc::close_device()
int IonAlloc::alloc_buffer(alloc_data& data)
{
Locker::Autolock _l(mLock);
int err = 0;
int ionSyncFd = FD_INIT;
int iFd = FD_INIT;
@ -151,6 +152,7 @@ int IonAlloc::alloc_buffer(alloc_data& data)
int IonAlloc::free_buffer(void* base, size_t size, int offset, int fd)
{
Locker::Autolock _l(mLock);
LOGD("ion: Freeing buffer base:%p size:%d fd:%d",
base, size, fd);
int err = 0;

View File

@ -31,6 +31,7 @@
#define GRALLOC_IONALLOC_H
#include "memalloc.h"
#include "gr.h"
#include <linux/ion.h>
namespace gralloc {
@ -63,6 +64,8 @@ namespace gralloc {
void close_device();
mutable Locker mLock;
};
}