gralloc\memalloc: Add traces
Add traces to gralloc (mapper) and memalloc (ionalloc) functions
Change-Id: Ia980b8fce92659a8b72a37ef129f20eb01fe2b43
diff --git a/libgralloc/ionalloc.cpp b/libgralloc/ionalloc.cpp
index ccf6ed5..73bbe23 100644
--- a/libgralloc/ionalloc.cpp
+++ b/libgralloc/ionalloc.cpp
@@ -34,12 +34,14 @@
#include <fcntl.h>
#include <cutils/log.h>
#include <errno.h>
+#include <utils/Trace.h>
#include "gralloc_priv.h"
#include "ionalloc.h"
using gralloc::IonAlloc;
#define ION_DEVICE "/dev/ion"
+#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
int IonAlloc::open_device()
{
@@ -64,6 +66,7 @@
int IonAlloc::alloc_buffer(alloc_data& data)
{
+ ATRACE_CALL();
Locker::Autolock _l(mLock);
int err = 0;
struct ion_handle_data handle_data;
@@ -123,6 +126,7 @@
int IonAlloc::free_buffer(void* base, unsigned int size, unsigned int offset,
int fd)
{
+ ATRACE_CALL();
Locker::Autolock _l(mLock);
ALOGD_IF(DEBUG, "ion: Freeing buffer base:%p size:%u fd:%d",
base, size, fd);
@@ -140,6 +144,7 @@
int IonAlloc::map_buffer(void **pBase, unsigned int size, unsigned int offset,
int fd)
{
+ ATRACE_CALL();
int err = 0;
void *base = 0;
// It is a (quirky) requirement of ION to have opened the
@@ -165,6 +170,7 @@
int IonAlloc::unmap_buffer(void *base, unsigned int size,
unsigned int /*offset*/)
{
+ ATRACE_CALL();
ALOGD_IF(DEBUG, "ion: Unmapping buffer base:%p size:%u", base, size);
int err = 0;
if(munmap(base, size)) {
@@ -178,6 +184,8 @@
int IonAlloc::clean_buffer(void *base, unsigned int size, unsigned int offset,
int fd, int op)
{
+ ATRACE_CALL();
+ ATRACE_INT("operation id", op);
struct ion_flush_data flush_data;
struct ion_fd_data fd_data;
struct ion_handle_data handle_data;
diff --git a/libgralloc/mapper.cpp b/libgralloc/mapper.cpp
index 2f2ddc1..13e662a 100644
--- a/libgralloc/mapper.cpp
+++ b/libgralloc/mapper.cpp
@@ -29,6 +29,7 @@
#include <cutils/log.h>
#include <cutils/atomic.h>
+#include <utils/Trace.h>
#include <hardware/hardware.h>
#include <hardware/gralloc.h>
@@ -39,6 +40,8 @@
#include "memalloc.h"
#include <qdMetaData.h>
+#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
+
using namespace gralloc;
/*****************************************************************************/
@@ -55,6 +58,7 @@
static int gralloc_map(gralloc_module_t const* module,
buffer_handle_t handle)
{
+ ATRACE_CALL();
if(!module)
return -EINVAL;
@@ -92,6 +96,7 @@
static int gralloc_unmap(gralloc_module_t const* module,
buffer_handle_t handle)
{
+ ATRACE_CALL();
if(!module)
return -EINVAL;
@@ -130,6 +135,7 @@
int gralloc_register_buffer(gralloc_module_t const* module,
buffer_handle_t handle)
{
+ ATRACE_CALL();
if (!module || private_handle_t::validate(handle) < 0)
return -EINVAL;
@@ -157,6 +163,7 @@
int gralloc_unregister_buffer(gralloc_module_t const* module,
buffer_handle_t handle)
{
+ ATRACE_CALL();
if (!module || private_handle_t::validate(handle) < 0)
return -EINVAL;
@@ -179,6 +186,7 @@
int terminateBuffer(gralloc_module_t const* module,
private_handle_t* hnd)
{
+ ATRACE_CALL();
if(!module)
return -EINVAL;
@@ -207,6 +215,7 @@
static int gralloc_map_and_invalidate (gralloc_module_t const* module,
buffer_handle_t handle, int usage)
{
+ ATRACE_CALL();
if (!module || private_handle_t::validate(handle) < 0)
return -EINVAL;
@@ -243,6 +252,7 @@
int /*l*/, int /*t*/, int /*w*/, int /*h*/,
void** vaddr)
{
+ ATRACE_CALL();
private_handle_t* hnd = (private_handle_t*)handle;
int err = gralloc_map_and_invalidate(module, handle, usage);
if(!err)
@@ -255,6 +265,7 @@
int /*l*/, int /*t*/, int /*w*/, int /*h*/,
struct android_ycbcr *ycbcr)
{
+ ATRACE_CALL();
private_handle_t* hnd = (private_handle_t*)handle;
int err = gralloc_map_and_invalidate(module, handle, usage);
if(!err)
@@ -265,6 +276,7 @@
int gralloc_unlock(gralloc_module_t const* module,
buffer_handle_t handle)
{
+ ATRACE_CALL();
if (!module || private_handle_t::validate(handle) < 0)
return -EINVAL;