From 5ae1396df688ff3d3bfe6a70bf601d327d99716b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Thu, 24 Nov 2016 15:22:32 +0900 Subject: [PATCH] Revert "Revert "refactor the sprd log"" This reverts commit c05a617dc5d39c556a8995289202d7f2c9630198. Change-Id: Ib4cb9b5b0449d465a42e75424a72c46af156e122 --- src/tbm_bufmgr_sprd.c | 352 +++++++++++++++++++------------------------------- 1 file changed, 132 insertions(+), 220 deletions(-) diff --git a/src/tbm_bufmgr_sprd.c b/src/tbm_bufmgr_sprd.c index 1db8ac5..6866db9 100644 --- a/src/tbm_bufmgr_sprd.c +++ b/src/tbm_bufmgr_sprd.c @@ -102,11 +102,12 @@ _target_name(void) return app_name; } -#define TBM_SPRD_LOG(fmt, args...) LOGE("\033[31m" "[%s]" fmt "\033[0m", _target_name(), ##args) -#define DBG(fmt, args...) if (bDebug&01) LOGE("[%s]" fmt, _target_name(), ##args) + +#define TBM_SPRD_ERROR(fmt, args...) LOGE("\033[31m" "[%s] " fmt "\033[0m", _target_name(), ##args) +#define TBM_SPRD_DEBUG(fmt, args...) if (bDebug&01) LOGD("[%s] " fmt, _target_name(), ##args) #else -#define TBM_SPRD_LOG(...) -#define DBG(...) +#define TBM_SPRD_ERROR(...) +#define TBM_SPRD_DEBUG(...) #endif #define SIZE_ALIGN(value, base) (((value) + ((base) - 1)) & ~((base) - 1)) @@ -119,13 +120,13 @@ _target_name(void) /* check condition */ #define SPRD_RETURN_IF_FAIL(cond) {\ if (!(cond)) {\ - TBM_SPRD_LOG("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ + TBM_SPRD_ERROR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ return;\ } \ } #define SPRD_RETURN_VAL_IF_FAIL(cond, val) {\ if (!(cond)) {\ - TBM_SPRD_LOG("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ + TBM_SPRD_ERROR("[%s] : '%s' failed.\n", __FUNCTION__, #cond);\ return val;\ } \ } @@ -261,13 +262,11 @@ _tgl_get_version(int fd) err = ioctl(fd, TGL_IOCTL_GET_VERSION, &data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d\n", - getpid(), strerror(errno), __func__, __LINE__); + TBM_SPRD_ERROR("error(%s) %s:%d\n", strerror(errno)); return 0; } - TBM_SPRD_LOG("[libtbm-sprd:%d] %s:%d tgl version is (%u, %u).\n", - getpid(), __func__, __LINE__, data.major, data.minor); + TBM_SPRD_DEBUG("tgl version is (%u, %u).\n", data.major, data.minor); return 1; } @@ -284,8 +283,7 @@ _tgl_init(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_REGISTER, &data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); + TBM_SPRD_ERROR("error(%s) key:%d\n", strerror(errno), key); return 0; } @@ -301,8 +299,7 @@ _tgl_destroy(int fd, unsigned int key) data.key = key; err = ioctl(fd, TGL_IOCTL_UNREGISTER, &data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); + TBM_SPRD_ERROR("error(%s) key:%d\n", strerror(errno), key); return 0; } @@ -333,8 +330,8 @@ _tgl_lock(int fd, unsigned int key, int opt) err = ioctl(fd, TGL_IOCTL_LOCK, data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d key:%d opt:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key, opt); + TBM_SPRD_ERROR("error(%s) key:%d opt:%d\n", + strerror(errno), key, opt); return 0; } @@ -352,8 +349,8 @@ _tgl_unlock(int fd, unsigned int key) err = ioctl(fd, TGL_IOCTL_UNLOCK, data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); + TBM_SPRD_ERROR("error(%s) key:%d\n", + strerror(errno), key); return 0; } @@ -372,8 +369,8 @@ _tgl_set_data(int fd, unsigned int key, unsigned int val) err = ioctl(fd, TGL_IOCTL_SET_DATA, &data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); + TBM_SPRD_ERROR("error(%s) key:%d\n", + strerror(errno), key); return 0; } @@ -390,8 +387,8 @@ _tgl_get_data(int fd, unsigned int key, unsigned int *locked) err = ioctl(fd, TGL_IOCTL_GET_DATA, &data); if (err) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error(%s) %s:%d key:%d\n", - getpid(), strerror(errno), __func__, __LINE__, key); + TBM_SPRD_ERROR("error(%s) key:%d\n", + strerror(errno), key); return 0; } @@ -420,13 +417,11 @@ _tbm_sprd_open_drm(void) return fd; #ifdef HAVE_UDEV - TBM_SPRD_LOG("[libtbm-sprd:%d] warning %s:%d fail to open drm, " - "so search drm-device by udev\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_DEBUG("warning fail to open drm. search drm-device by udev\n"); udev = udev_new(); if (!udev) { - TBM_SPRD_LOG("udev_new() failed.\n"); + TBM_SPRD_ERROR("udev_new() failed.\n"); return -1; } @@ -445,8 +440,7 @@ _tbm_sprd_open_drm(void) if (device_parent) { if (strcmp(udev_device_get_sysname(device_parent), "sprd-drm") == 0) { drm_device = device; - DBG("[%s] Found render device: '%s' (%s)\n", - _target_name(), + TBM_SPRD_DEBUG("Found render device: '%s' (%s)\n", udev_device_get_syspath(drm_device), udev_device_get_sysname(device_parent)); break; @@ -460,7 +454,7 @@ _tbm_sprd_open_drm(void) /* Get device file path. */ filepath = udev_device_get_devnode(drm_device); if (!filepath) { - TBM_SPRD_LOG("udev_device_get_devnode() failed.\n"); + TBM_SPRD_ERROR("udev_device_get_devnode() failed.\n"); udev_device_unref(drm_device); udev_unref(udev); return -1; @@ -472,18 +466,18 @@ _tbm_sprd_open_drm(void) /* Open DRM device file and check validity. */ fd = open(filepath, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_SPRD_LOG("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); + TBM_SPRD_ERROR("open(%s, O_RDWR | O_CLOEXEC) failed.\n"); return -1; } if (fstat(fd, &s)) { - TBM_SPRD_LOG("fstat() failed %s.\n"); + TBM_SPRD_ERROR("fstat() failed %s.\n"); close(fd); return -1; } #else - TBM_SPRD_LOG("[libtbm-sprd:%d] warning %s:%d fail to open drm\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("warning fail to open drm\n", + ); #endif return fd; @@ -534,11 +528,9 @@ _sprd_bo_cache_flush(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int flags cache_op.flags |= SPRD_DRM_ALL_CACHES_CORES; ret = drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CACHE_OP, &cache_op, - sizeof(cache_op)); + sizeof(cache_op)); if (ret) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d fail to flush the cache.\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error fail to flush the cache.\n"); return 0; } #endif @@ -627,8 +619,7 @@ _bo_set_cache_state(tbm_bufmgr_sprd bufmgr_sprd, tbm_bo_sprd bo_sprd, int device /* call cache flush */ _sprd_bo_cache_flush(bufmgr_sprd, bo_sprd, need_flush); - DBG("[libtbm:%d] \tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", - getpid(), + TBM_SPRD_DEBUG("\tcache(%d,%d)....flush:0x%x, cntFlush(%d)\n", bo_sprd->cache_state.data.isCached, bo_sprd->cache_state.data.isDirtied, need_flush, @@ -685,26 +676,19 @@ _bufmgr_init_cache_state(tbm_bufmgr_sprd bufmgr_sprd) /* open tgl fd for saving cache flush data */ bufmgr_sprd->tgl_fd = open(tgl_devfile, O_RDWR); if (bufmgr_sprd->tgl_fd < 0) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to open global_lock:%s\n", - getpid(), tgl_devfile); + TBM_SPRD_ERROR("fail to open global_lock:%s\n", tgl_devfile); return 0; } if (!_tgl_get_version(bufmgr_sprd->tgl_fd)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error: fail to get tgl_version. tgl init failed.\n", - getpid()); - + TBM_SPRD_ERROR("fail to get tgl_version. tgl init failed.\n"); close(bufmgr_sprd->tgl_fd); return 0; } #ifdef USE_CACHE if (!_tgl_init(bufmgr_sprd->tgl_fd, GLOBAL_KEY)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error: Fail to initialize the tgl\n", - getpid()); - + TBM_SPRD_ERROR("fail to initialize the tgl\n"); close(bufmgr_sprd->tgl_fd); return 0; } @@ -779,9 +763,7 @@ _get_name(int fd, unsigned int gem) arg.handle = gem; if (drmIoctl(fd, DRM_IOCTL_GEM_FLINK, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d fail to get flink gem=%d\n", - getpid(), __FUNCTION__, __LINE__, gem); + TBM_SPRD_ERROR("error fail to get flink gem=%d\n", gem); return 0; } @@ -806,9 +788,7 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) arg.handle = bo_sprd->gem; arg.size = bo_sprd->size; if (drmCommandWriteRead(bo_sprd->fd, DRM_SPRD_GEM_MMAP, &arg, sizeof(arg))) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot usrptr gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot usrptr gem=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } bo_sprd->pBase = (void *)((uint32_t)arg.mapped); @@ -822,9 +802,7 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } bo_sprd->dmabuf = arg.fd; @@ -838,19 +816,14 @@ _sprd_bo_handle(tbm_bo_sprd bo_sprd, int device) case TBM_DEVICE_MM: #ifdef USE_HEAP_ID //TODO : Add ioctl for GSP MAP once available. - DBG("[libtbm-sprd:%d] %s In case TBM_DEVICE_MM: \n", getpid(), - __FUNCTION_); - _ - + TBM_SPRD_DEBUG("%s In case TBM_DEVICE_MM: \n", __FUNCTION_); #else if (!bo_sprd->dmabuf) { struct drm_prime_handle arg = {0, }; arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } bo_sprd->dmabuf = arg.fd; @@ -894,9 +867,7 @@ tbm_sprd_bo_alloc(tbm_bo bo, int size, int flags) bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d fail to allocate the bo private\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error fail to allocate the bo private\n"); return 0; } @@ -914,9 +885,8 @@ tbm_sprd_bo_alloc(tbm_bo bo, int size, int flags) arg.flags = sprd_flags; if (drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CREATE, &arg, sizeof(arg))) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot create bo(flag:%x, size:%d)\n", - getpid(), __FUNCTION__, __LINE__, arg.flags, (unsigned int)arg.size); + TBM_SPRD_ERROR("error Cannot create bo(flag:%x, size:%d)\n", + arg.flags, (unsigned int)arg.size); free(bo_sprd); return 0; } @@ -929,7 +899,7 @@ tbm_sprd_bo_alloc(tbm_bo bo, int size, int flags) bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem); if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 0)) { - TBM_SPRD_LOG("error fail init cache state(%d)\n", bo_sprd->name); + TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name); free(bo_sprd); return 0; } @@ -942,9 +912,7 @@ tbm_sprd_bo_alloc(tbm_bo bo, int size, int flags) arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); free(bo_sprd); return 0; } @@ -954,25 +922,20 @@ tbm_sprd_bo_alloc(tbm_bo bo, int size, int flags) /* add bo to hash */ PrivGem *privGem = calloc(1, sizeof(PrivGem)); if (!privGem) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Fail to calloc PrivGem\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error Fail to calloc PrivGem\n"); free(bo_sprd); return 0; } privGem->ref_count = 1; privGem->bo_priv = bo_sprd; - if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->name); - } + if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) + TBM_SPRD_ERROR("error Cannot insert bo to Hash(%d)\n", bo_sprd->name); - DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_sprd->size, - bo_sprd->gem, bo_sprd->name, - flags, sprd_flags); + TBM_SPRD_DEBUG("%s size:%d, gem:%d(%d), flags:%d(%d)\n", + __FUNCTION__, bo_sprd->size, + bo_sprd->gem, bo_sprd->name, + flags, sprd_flags); return (void *)bo_sprd; } @@ -992,15 +955,12 @@ tbm_sprd_bo_free(tbm_bo bo) bo_sprd = (tbm_bo_sprd)tbm_backend_get_bo_priv(bo); SPRD_RETURN_IF_FAIL(bo_sprd != NULL); - DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d)\n", - getpid(), __FUNCTION__, bo_sprd->size, bo_sprd->gem, bo_sprd->name); + TBM_SPRD_DEBUG("size:%d, gem:%d(%d)\n", + bo_sprd->size, bo_sprd->gem, bo_sprd->name); if (bo_sprd->pBase) { - if (munmap(bo_sprd->pBase, bo_sprd->size) == -1) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d\n", - getpid(), __FUNCTION__, __LINE__); - } + if (munmap(bo_sprd->pBase, bo_sprd->size) == -1) + TBM_SPRD_ERROR("error fail to munmap.\n"); } /* closedmabuf */ @@ -1022,9 +982,7 @@ tbm_sprd_bo_free(tbm_bo bo) privGem = NULL; } } else { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "warning %s:%d Cannot find bo to Hash(%d), ret=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->name, ret); + TBM_SPRD_DEBUG("warning Cannot find bo to Hash(%d), ret=%d\n", bo_sprd->name, ret); } _bo_destroy_cache_state(bufmgr_sprd, bo_sprd); @@ -1033,11 +991,8 @@ tbm_sprd_bo_free(tbm_bo bo) struct drm_gem_close arg = {0, }; memset(&arg, 0, sizeof(arg)); arg.handle = bo_sprd->gem; - if (drmIoctl(bo_sprd->fd, DRM_IOCTL_GEM_CLOSE, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d\n", - getpid(), __FUNCTION__, __LINE__); - } + if (drmIoctl(bo_sprd->fd, DRM_IOCTL_GEM_CLOSE, &arg)) + TBM_SPRD_ERROR("error fail to DRM_IOCTL_GEM_CLOSE\n"); free(bo_sprd); } @@ -1065,9 +1020,7 @@ tbm_sprd_bo_import(tbm_bo bo, unsigned int key) arg.name = key; if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot open gem name=%d\n", - getpid(), __FUNCTION__, __LINE__, key); + TBM_SPRD_ERROR("error Cannot open gem name=%d\n", key); return NULL; } @@ -1076,17 +1029,13 @@ tbm_sprd_bo_import(tbm_bo bo, unsigned int key) DRM_SPRD_GEM_GET, &info, sizeof(struct drm_sprd_gem_info))) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot get gem info=%d\n", - getpid(), __FUNCTION__, __LINE__, key); + TBM_SPRD_ERROR("error Cannot get gem info=%d\n", key); goto fail_get_gem; } bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d fail to allocate the bo private\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error fail to allocate the bo private\n"); goto fail_alloc_bo; } @@ -1103,7 +1052,7 @@ tbm_sprd_bo_import(tbm_bo bo, unsigned int key) #endif if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) { - TBM_SPRD_LOG("error fail init cache state(%d)\n", bo_sprd->name); + TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name); goto fail_init_cache; } @@ -1112,9 +1061,7 @@ tbm_sprd_bo_import(tbm_bo bo, unsigned int key) arg.handle = bo_sprd->gem; if (drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot dmabuf=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot dmabuf=%d\n", bo_sprd->gem); goto fail_prime_handle_to_fd; } bo_sprd->dmabuf = arg.fd; @@ -1123,23 +1070,18 @@ tbm_sprd_bo_import(tbm_bo bo, unsigned int key) /* add bo to hash */ privGem = calloc(1, sizeof(PrivGem)); if (!privGem) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error %s:%d Fail to alloc\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error Fail to alloc\n"); goto fail_alloc_gem_priv; } privGem->ref_count = 1; privGem->bo_priv = bo_sprd; - if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot insert bo to Hash(%d)\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->name); - } + if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) + TBM_SPRD_ERROR("error Cannot insert bo to Hash(%d)\n", bo_sprd->name); - DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_sprd->size, - bo_sprd->gem, bo_sprd->name, - bo_sprd->flags_tbm, bo_sprd->flags_sprd); + TBM_SPRD_DEBUG("size:%d, gem:%d(%d), flags:%d(%d)\n", + bo_sprd->size, bo_sprd->gem, bo_sprd->name, + bo_sprd->flags_tbm, bo_sprd->flags_sprd); return (void *)bo_sprd; @@ -1178,16 +1120,16 @@ tbm_sprd_bo_import_fd(tbm_bo bo, tbm_fd key) arg.fd = key; if (drmIoctl(bufmgr_sprd->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_SPRD_LOG("error bo:%p Cannot get gem handle from fd:%d (%s)\n", - bo, arg.fd, strerror(errno)); + TBM_SPRD_ERROR("error bo:%p Cannot get gem handle from fd:%d (%s)\n", + bo, arg.fd, strerror(errno)); return NULL; } gem = arg.handle; name = _get_name(bufmgr_sprd->fd, gem); if (!name) { - TBM_SPRD_LOG("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", - bo, gem, key, strerror(errno)); + TBM_SPRD_ERROR("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", + bo, gem, key, strerror(errno)); return NULL; } @@ -1211,8 +1153,8 @@ tbm_sprd_bo_import_fd(tbm_bo bo, tbm_fd key) DRM_SPRD_GEM_GET, &info, sizeof(struct drm_sprd_gem_info))) { - TBM_SPRD_LOG("error bo:%p Cannot get gem info from gem:%d, fd:%d (%s)\n", - bo, gem, key, strerror(errno)); + TBM_SPRD_ERROR("error bo:%p Cannot get gem info from gem:%d, fd:%d (%s)\n", + bo, gem, key, strerror(errno)); return NULL; } @@ -1221,7 +1163,7 @@ tbm_sprd_bo_import_fd(tbm_bo bo, tbm_fd key) bo_sprd = calloc(1, sizeof(struct _tbm_bo_sprd)); if (!bo_sprd) { - TBM_SPRD_LOG("error bo:%p fail to allocate the bo private\n", bo); + TBM_SPRD_ERROR("error bo:%p fail to allocate the bo private\n", bo); return NULL; } @@ -1233,34 +1175,31 @@ tbm_sprd_bo_import_fd(tbm_bo bo, tbm_fd key) bo_sprd->name = name; if (!bo_sprd->name) { - TBM_SPRD_LOG("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", - bo, gem, key, strerror(errno)); + TBM_SPRD_ERROR("error bo:%p Cannot get name from gem:%d, fd:%d (%s)\n", + bo, gem, key, strerror(errno)); goto fail_check_name; } if (!_bo_init_cache_state(bufmgr_sprd, bo_sprd, 1)) { - TBM_SPRD_LOG("error fail init cache state(%d)\n", bo_sprd->name); + TBM_SPRD_ERROR("error fail init cache state(%d)\n", bo_sprd->name); goto fail_init_cache; } /* add bo to hash */ privGem = calloc(1, sizeof(PrivGem)); if (!privGem) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Fail to callocprivGem\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error Fail to callocprivGem\n"); goto fail_alloc_gem_priv; } privGem->ref_count = 1; privGem->bo_priv = bo_sprd; if (drmHashInsert(bufmgr_sprd->hashBos, bo_sprd->name, (void *)privGem) < 0) { - TBM_SPRD_LOG("error bo:%p Cannot insert bo to Hash(%d) from gem:%d, fd:%d\n", - bo, bo_sprd->name, gem, key); + TBM_SPRD_ERROR("error bo:%p Cannot insert bo to Hash(%d) from gem:%d, fd:%d\n", + bo, bo_sprd->name, gem, key); } - DBG(" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", - _target_name(), + TBM_SPRD_DEBUG("bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", bo, bo_sprd->gem, bo_sprd->name, bo_sprd->dmabuf, @@ -1291,17 +1230,14 @@ tbm_sprd_bo_export(tbm_bo bo) if (!bo_sprd->name) { bo_sprd->name = _get_name(bo_sprd->fd, bo_sprd->gem); if (!bo_sprd->name) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot get name\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error Cannot get name\n"); return 0; } } - DBG("[libtbm-sprd:%d] %s size:%d, gem:%d(%d), flags:%d(%d)\n", getpid(), - __FUNCTION__, bo_sprd->size, - bo_sprd->gem, bo_sprd->name, - bo_sprd->flags_tbm, bo_sprd->flags_sprd); + TBM_SPRD_DEBUG("size:%d, gem:%d(%d), flags:%d(%d)\n", + bo_sprd->size, bo_sprd->gem, bo_sprd->name, + bo_sprd->flags_tbm, bo_sprd->flags_sprd); return (unsigned int)bo_sprd->name; } @@ -1322,19 +1258,18 @@ tbm_sprd_bo_export_fd(tbm_bo bo) arg.handle = bo_sprd->gem; ret = drmIoctl(bo_sprd->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); if (ret) { - TBM_SPRD_LOG("error bo:%p Cannot dmabuf=%d (%s)\n", - bo, bo_sprd->gem, strerror(errno)); + TBM_SPRD_ERROR("error bo:%p Cannot dmabuf=%d (%s)\n", + bo, bo_sprd->gem, strerror(errno)); return (tbm_fd) ret; } - DBG(" [%s] bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", - _target_name(), - bo, - bo_sprd->gem, bo_sprd->name, - bo_sprd->dmabuf, - arg.fd, - bo_sprd->flags_tbm, bo_sprd->flags_sprd, - bo_sprd->size); + TBM_SPRD_DEBUG("bo:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d(%d), size:%d\n", + bo, + bo_sprd->gem, bo_sprd->name, + bo_sprd->dmabuf, + arg.fd, + bo_sprd->flags_tbm, bo_sprd->flags_sprd, + bo_sprd->size); return (tbm_fd)arg.fd; } @@ -1352,21 +1287,18 @@ tbm_sprd_bo_get_handle(tbm_bo bo, int device) SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, (tbm_bo_handle) NULL); if (!bo_sprd->gem) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot map gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot map gem=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } - DBG("[libtbm-sprd:%d] %s gem:%d(%d), %s\n", getpid(), - __FUNCTION__, bo_sprd->gem, bo_sprd->name, STR_DEVICE[device]); + TBM_SPRD_DEBUG("gem:%d(%d), %s\n", + bo_sprd->gem, bo_sprd->name, STR_DEVICE[device]); /*Get mapped bo_handle*/ bo_handle = _sprd_bo_handle(bo_sprd, device); if (bo_handle.ptr == NULL) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot get handle: gem:%d, device:%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem, device); + TBM_SPRD_ERROR("error Cannot get handle: gem:%d, device:%d\n", + bo_sprd->gem, device); return (tbm_bo_handle) NULL; } @@ -1389,21 +1321,18 @@ tbm_sprd_bo_map(tbm_bo bo, int device, int opt) SPRD_RETURN_VAL_IF_FAIL(bo_sprd != NULL, (tbm_bo_handle) NULL); if (!bo_sprd->gem) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot map gem=%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem); + TBM_SPRD_ERROR("error Cannot map gem=%d\n", bo_sprd->gem); return (tbm_bo_handle) NULL; } - DBG("[libtbm-sprd:%d] %s gem:%d(%d), %s, %s\n", getpid(), - __FUNCTION__, bo_sprd->gem, bo_sprd->name, STR_DEVICE[device], STR_OPT[opt]); + TBM_SPRD_DEBUG("%s gem:%d(%d), %s, %s\n", + __FUNCTION__, bo_sprd->gem, bo_sprd->name, STR_DEVICE[device], STR_OPT[opt]); /*Get mapped bo_handle*/ bo_handle = _sprd_bo_handle(bo_sprd, device); if (bo_handle.ptr == NULL) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Cannot get handle: gem:%d, device:%d, opt:%d\n", - getpid(), __FUNCTION__, __LINE__, bo_sprd->gem, device, opt); + TBM_SPRD_ERROR("error Cannot get handle: gem:%d, device:%d, opt:%d\n", + bo_sprd->gem, device, opt); return (tbm_bo_handle) NULL; } @@ -1437,8 +1366,7 @@ tbm_sprd_bo_unmap(tbm_bo bo) if (bo_sprd->map_cnt == 0) _bo_save_cache_state(bufmgr_sprd, bo_sprd); - DBG("[libtbm-sprd:%d] %s gem:%d(%d) \n", getpid(), - __FUNCTION__, bo_sprd->gem, bo_sprd->name); + TBM_SPRD_DEBUG("gem:%d(%d) \n", bo_sprd->gem, bo_sprd->name); return 1; } @@ -1472,8 +1400,7 @@ tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) else if (device == TBM_DEVICE_3D) fence.type = DMA_BUF_ACCESS_WRITE | DMA_BUF_ACCESS_DMA; else { - DBG("[libtbm-sprd:%d] %s GET_FENCE is ignored(device type is not 3D/CPU),\n", - getpid(), __FUNCTION__); + TBM_SPRD_DEBUG("GET_FENCE is ignored(device type is not 3D/CPU),\n"); return 0; } } else if (opt & TBM_OPTION_READ) { @@ -1482,21 +1409,17 @@ tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) else if (device == TBM_DEVICE_3D) fence.type = DMA_BUF_ACCESS_READ | DMA_BUF_ACCESS_DMA; else { - DBG("[libtbm-sprd:%d] %s GET_FENCE is ignored(device type is not 3D/CPU),\n", - getpid(), __FUNCTION__); + TBM_SPRD_DEBUG("GET_FENCE is ignored(device type is not 3D/CPU),\n"); return 0; } } else { - TBM_SPRD_LOG("[libtbm-sprd:%d] error %s:%d Invalid argument\n", getpid(), - __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error Invalid argument\n"); return 0; } ret = ioctl(bo_sprd->dmabuf, DMABUF_IOCTL_GET_FENCE, &fence); if (ret < 0) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Can not set GET FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno)); + TBM_SPRD_ERROR("error Can not set GET FENCE(%s)\n", strerror(errno)); return 0; } @@ -1511,20 +1434,16 @@ tbm_sprd_bo_lock(tbm_bo bo, int device, int opt) } if (i == DMA_FENCE_LIST_MAX) { //TODO: if dma_fence list is full, it needs realloc. I will fix this. by minseok3.kim - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d fence list is full\n", - getpid(), __FUNCTION__, __LINE__); + TBM_SPRD_ERROR("error fence list is full\n"); } pthread_mutex_unlock(&bo_sprd->mutex); - DBG("[libtbm-sprd:%d] %s DMABUF_IOCTL_GET_FENCE! flink_id=%d dmabuf=%d\n", - getpid(), - __FUNCTION__, bo_sprd->name, bo_sprd->dmabuf); + TBM_SPRD_DEBUG("DMABUF_IOCTL_GET_FENCE! flink_id=%d dmabuf=%d\n", + bo_sprd->name, bo_sprd->dmabuf); } else { ret = _tgl_lock(bufmgr_sprd->tgl_fd, bo_sprd->name, opt); - DBG("[libtbm-sprd:%d] lock tgl flink_id:%d\n", - getpid(), __FUNCTION__, bo_sprd->name); + TBM_SPRD_DEBUG("lock tgl flink_id:%d\n", bo_sprd->name); return ret; } @@ -1554,14 +1473,12 @@ tbm_sprd_bo_unlock(tbm_bo bo) struct dma_buf_fence fence; if (!bo_sprd->dma_fence[0].ctx) { - DBG("[libtbm-sprd:%d] %s FENCE not support or ignored,\n", getpid(), - __FUNCTION__); + TBM_SPRD_DEBUG("FENCE not support or ignored,\n"; return 0; } if (!bo_sprd->dma_fence[0].type) { - DBG("[libtbm-sprd:%d] %s device type is not 3D/CPU,\n", getpid(), - __FUNCTION__); + TBM_SPRD_DEBUG("device type is not 3D/CPU,\n"); return 0; } @@ -1579,20 +1496,16 @@ tbm_sprd_bo_unlock(tbm_bo bo) ret = ioctl(bo_sprd->dmabuf, DMABUF_IOCTL_PUT_FENCE, &fence); if (ret < 0) { - TBM_SPRD_LOG("[libtbm-sprd:%d] " - "error %s:%d Can not set PUT FENCE(%s)\n", - getpid(), __FUNCTION__, __LINE__, strerror(errno)); + TBM_SPRD_ERROR("error Can not set PUT FENCE(%s)\n", strerror(errno)); return 0; } - DBG("[libtbm-sprd:%d] %s DMABUF_IOCTL_PUT_FENCE! flink_id=%d dmabuf=%d\n", - getpid(), - __FUNCTION__, bo_sprd->name, bo_sprd->dmabuf); + TBM_SPRD_DEBUG("DMABUF_IOCTL_PUT_FENCE! flink_id=%d dmabuf=%d\n", + bo_sprd->name, bo_sprd->dmabuf); } else { ret = _tgl_unlock(bufmgr_sprd->tgl_fd, bo_sprd->name); - DBG("[libtbm-sprd:%d] unlock tgl flink_id:%d\n", - getpid(), __FUNCTION__, bo_sprd->name); + TBM_SPRD_DEBUG("unlock tgl flink_id:%d\n", bo_sprd->name); return ret; } @@ -1935,7 +1848,7 @@ tbm_sprd_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *NativeDisplay) if (!tbm_drm_helper_wl_auth_server_init(NativeDisplay, bufmgr_sprd->fd, bufmgr_sprd->device_name, 0)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error:Fail to tbm_drm_helper_wl_server_init\n"); + TBM_SPRD_ERROR("fail to tbm_drm_helper_wl_server_init\n"); return 0; } @@ -1966,7 +1879,7 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) bufmgr_sprd = calloc(1, sizeof(struct _tbm_bufmgr_sprd)); if (!bufmgr_sprd) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to alloc bufmgr_sprd!\n", getpid()); + TBM_SPRD_ERROR("fail to alloc bufmgr_sprd!\n"); return 0; } @@ -1975,7 +1888,7 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) if (bufmgr_sprd->fd < 0) { bufmgr_sprd->fd = _tbm_sprd_open_drm(); if (bufmgr_sprd->fd < 0) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to open drm!\n", getpid()); + TBM_SPRD_ERROR("fail to open drm!\n"); goto fail_open_drm; } } @@ -1984,13 +1897,13 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) bufmgr_sprd->device_name = drmGetDeviceNameFromFd(bufmgr_sprd->fd); if (!bufmgr_sprd->device_name) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to get device name!\n", getpid()); + TBM_SPRD_ERROR("fail to get device name!\n"); tbm_drm_helper_unset_tbm_master_fd(); goto fail_get_device_name; } } else { if (!tbm_drm_helper_get_auth_info(&(bufmgr_sprd->fd), &(bufmgr_sprd->device_name), NULL)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to get auth drm info!\n", getpid()); + TBM_SPRD_ERROR("fail to get auth drm info!\n"); goto fail_get_auth_info; } } @@ -2011,13 +1924,13 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) } if (!_bufmgr_init_cache_state(bufmgr_sprd)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to init bufmgr cache state\n", getpid()); + TBM_SPRD_ERROR("fail to init bufmgr cache state\n"); goto fail_init_cache_state; } bufmgr_backend = tbm_backend_alloc(); if (!bufmgr_backend) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to alloc backend!\n", getpid()); + TBM_SPRD_ERROR("fail to alloc backend!\n"); goto fail_alloc_backend; } @@ -2041,7 +1954,7 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) bufmgr_backend->bufmgr_bind_native_display = tbm_sprd_bufmgr_bind_native_display; if (!tbm_backend_init(bufmgr, bufmgr_backend)) { - TBM_SPRD_LOG("[libtbm-sprd:%d] error: Fail to init backend!\n", getpid()); + TBM_SPRD_ERROR("fail to init backend!\n"); goto fail_init_backend; } @@ -2052,16 +1965,15 @@ init_tbm_bufmgr_priv(tbm_bufmgr bufmgr, int fd) env = getenv("TBM_SPRD_DEBUG"); if (env) { bDebug = atoi(env); - TBM_SPRD_LOG("TBM_SPRD_DEBUG=%s\n", env); + TBM_SPRD_ERROR("TBM_SPRD_DEBUG=%s\n", env); } else bDebug = 0; } #endif - DBG("[libtbm-sprd:%d] %s DMABUF FENCE is %s\n", getpid(), - __FUNCTION__, bufmgr_sprd->use_dma_fence ? "supported!" : "NOT supported!"); - DBG("[libtbm-sprd:%d] %s fd:%d\n", getpid(), - __FUNCTION__, bufmgr_sprd->fd); + TBM_SPRD_DEBUG("DMABUF FENCE is %s\n", + bufmgr_sprd->use_dma_fence ? "supported!" : "NOT supported!"); + TBM_SPRD_DEBUG("fd:%d\n", bufmgr_sprd->fd); return 1; -- 2.7.4