diff --git a/libdmabufheap/include/dmabuf_alloc.h b/libdmabufheap/include/dmabuf_alloc.h index abec18f59d6c56f8330e91033ba40670a17aa049..a8eefbac88f4e1e8ca6eb50db05f6939446b95ec 100644 --- a/libdmabufheap/include/dmabuf_alloc.h +++ b/libdmabufheap/include/dmabuf_alloc.h @@ -21,7 +21,6 @@ #include #undef LOG_TAG -#define LOG_TAG "dmabufheap" #ifdef __cplusplus #if __cplusplus @@ -38,18 +37,9 @@ typedef enum { typedef struct { unsigned int fd; size_t size; - __u64 heapFlags; + unsigned int heapFlags; } DmabufHeapBuffer; -enum DmaHeapFlagOwnerId { - DMA_OWNER_DEFAULT, - DMA_OWNER_GPU, - DMA_OWNER_MEDIA_CODEC, - COUNT_DMA_OWNER, -}; - -void SetOwnerIdForHeapFlags(DmabufHeapBuffer *buffer, enum DmaHeapFlagOwnerId ownerId); - int DmabufHeapOpen(const char *heapName); int DmabufHeapClose(unsigned int fd); @@ -68,4 +58,4 @@ int DmabufHeapBufferSyncEnd(unsigned int bufferFd, DmabufHeapBufferSyncType sync #endif /* End of #if __cplusplus */ #endif /* End of #ifdef __cplusplus */ -#endif /* LIB_DMA_BUF_HEAP_H */ \ No newline at end of file +#endif /* LIB_DMA_BUF_HEAP_H */ diff --git a/libdmabufheap/src/dmabuf_alloc.c b/libdmabufheap/src/dmabuf_alloc.c index 79e7d539e560f75905204ebe2ceef9be026baff8..05ace67bb6d1802e0fc999496b88437cc4647007 100644 --- a/libdmabufheap/src/dmabuf_alloc.c +++ b/libdmabufheap/src/dmabuf_alloc.c @@ -21,14 +21,18 @@ #include #include #include "securec.h" -#include "hilog/log.h" #include "dmabuf_alloc.h" +#include "memory_trace.h" #define DMA_BUF_HEAP_ROOT "/dev/dma_heap/" #define HEAP_ROOT_LEN strlen(DMA_BUF_HEAP_ROOT) #define HEAP_NAME_MAX_LEN 128 #define HEAP_PATH_LEN (HEAP_ROOT_LEN + HEAP_NAME_MAX_LEN + 1) +#define LOG_DOMAIN 0xD002D0A +#define LOG_TAG "BacktraceTest" + +#include "hilog/log.h" static bool IsHeapNameValid(const char *heapName) { if ((heapName == NULL) || (strlen(heapName) == 0) || @@ -51,32 +55,28 @@ static bool IsSyncTypeValid(DmabufHeapBufferSyncType syncType) } } -void SetOwnerIdForHeapFlags(DmabufHeapBuffer *buffer, enum DmaHeapFlagOwnerId ownerId) -{ - if (buffer) { - set_owner_id_for_heap_flags(&buffer->heapFlags, ownerId); - } -} - int DmabufHeapOpen(const char *heapName) { if (!IsHeapNameValid(heapName)) { HILOG_ERROR(LOG_CORE, "heapName is wrong, name = %s.", (heapName == NULL) ? "NULL" : heapName); return -EINVAL; } - char heapPath[HEAP_PATH_LEN] = DMA_BUF_HEAP_ROOT; errno_t ret = strcat_s(heapPath, HEAP_PATH_LEN, heapName); if (ret != EOK) { HILOG_ERROR(LOG_CORE, "strcat_s is wrong, heapName = %s, ret = %d.", heapName, ret); return -EINVAL; } - - return open(heapPath, O_RDONLY | O_CLOEXEC); + int fd = open(heapPath, O_RDONLY | O_CLOEXEC); + long newFd = fd; + memtrace((void *)newFd, 128, "DmabufHeap", true); + return fd; } int DmabufHeapClose(unsigned int fd) { + long newFd = fd; + memtrace((void *)newFd, 128, "DmabufHeap", false); return close(fd); } @@ -97,13 +97,14 @@ int DmabufHeapBufferAlloc(unsigned int heapFd, DmabufHeapBuffer *buffer) HILOG_ERROR(LOG_CORE, "alloc buffer failed, size = %zu, ret = %d.", buffer->size, ret); return ret; } - + memtrace((void *)buffer, buffer->size, "DmabufHeap", true); buffer->fd = data.fd; return ret; } int DmabufHeapBufferFree(DmabufHeapBuffer *buffer) { + memtrace((void *)buffer, buffer->size, "DmabufHeap", false); return close(buffer->fd); }