diff options
author | Changyeon Lee <cyeon.lee@samsung.com> | 2023-07-12 16:07:43 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2023-07-12 16:42:12 +0900 |
commit | f2f476c1ec9f34a0ddb217db6872a4dfb2e1192c (patch) | |
tree | 79322051c78d65a4dabd90a3889283e99a9f913d | |
parent | 62983150e475084bc531d1b3fde62088c0af1f9b (diff) | |
download | libtbm-dumb-f2f476c1ec9f34a0ddb217db6872a4dfb2e1192c.tar.gz libtbm-dumb-f2f476c1ec9f34a0ddb217db6872a4dfb2e1192c.tar.bz2 libtbm-dumb-f2f476c1ec9f34a0ddb217db6872a4dfb2e1192c.zip |
Refactor log format
Change-Id: Ic21d614006ff54fdde494c1f1f623927270c85b0
-rw-r--r-- | src/tbm_backend_dumb.c | 195 |
1 files changed, 104 insertions, 91 deletions
diff --git a/src/tbm_backend_dumb.c b/src/tbm_backend_dumb.c index cdfe526..fb9f73d 100644 --- a/src/tbm_backend_dumb.c +++ b/src/tbm_backend_dumb.c @@ -137,7 +137,7 @@ _tbm_dumb_is_kms(struct udev_device *device) fd = open(file_name, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_BACKEND_ERR("Cannot open drm device(%s)", file_name); + TBM_BACKEND_ERR("fail to open drm device:%s", file_name); return 0; } @@ -243,11 +243,11 @@ _tbm_dumb_open_drm(void) fd = open(file_name, O_RDWR | O_CLOEXEC); if (fd < 0) { - TBM_BACKEND_ERR("Cannot open drm device(%s)", file_name); + TBM_BACKEND_ERR("fail to open drm device:%s", file_name); goto ret; } - TBM_BACKEND_INFO("open drm device (name:%s, fd:%d)", file_name, fd); + TBM_BACKEND_INFO("open drm device (name:%s fd:%d)", file_name, fd); ret: if (drm_device) udev_device_unref(drm_device); @@ -305,14 +305,15 @@ _dumb_bo_handle(tbm_dumb_bo *bo_data, int device) arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg)) { - TBM_BACKEND_ERR("Cannot map_ gem=%d", bo_data->gem); + TBM_BACKEND_ERR("fail to DRM_IOCTL_MODE_MAP_DUMB bo_data:%p gem:%d", + bo_data->gem); return (hal_tbm_bo_handle) NULL; } map = mmap(NULL, bo_data->size, PROT_READ | PROT_WRITE, MAP_SHARED, bo_data->fd, arg.offset); if (map == MAP_FAILED) { - TBM_BACKEND_ERR("Cannot usrptr gem=%d", bo_data->gem); + TBM_BACKEND_ERR("fail to mmap bo_data:%p gem:%d", bo_data, bo_data->gem); return (hal_tbm_bo_handle) NULL; } bo_data->pBase = map; @@ -325,7 +326,8 @@ _dumb_bo_handle(tbm_dumb_bo *bo_data, int device) arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_BACKEND_ERR("Cannot dmabuf=%d", bo_data->gem); + TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:%d", + bo_data, bo_data->gem); return (hal_tbm_bo_handle) NULL; } bo_data->dmabuf = arg.fd; @@ -339,7 +341,8 @@ _dumb_bo_handle(tbm_dumb_bo *bo_data, int device) arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_BACKEND_ERR("Cannot dmabuf=%d", bo_data->gem); + TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:%d", + bo_data, bo_data->gem); return (hal_tbm_bo_handle) NULL; } bo_data->dmabuf = arg.fd; @@ -680,8 +683,8 @@ tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, arg.width = size; arg.flags = dumb_flags; if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg)) { - TBM_BACKEND_ERR("Cannot create bo_data(flag:%x, size:%d)", arg.flags, - (unsigned int)size); + TBM_BACKEND_ERR("fail to DRM_IOCTL_MODE_CREATE_DUMB flag:%x size:%d", + arg.flags, (unsigned int)size); free(bo_data); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; @@ -699,13 +702,15 @@ tbm_dumb_bufmgr_alloc_bo(hal_tbm_bufmgr *bufmgr, unsigned int size, /* add bo to hash */ if (drmHashInsert(bufmgr_data->hashBos, bo_data->name, (void *)bo_data) < 0) - TBM_BACKEND_ERR("error Cannot insert bo to Hash(%d)", bo_data->name); + TBM_BACKEND_ERR("fail to insert bo_data to Hash:%d bo_data:%p gem:%d", + bo_data->name, bo_data, bo_data->gem); - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), flags:%d(%d), size:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->flags_tbm, - bo_data->size);; + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d flags:%d size:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->flags_tbm, + bo_data->size); if (error) *error = HAL_TBM_ERROR_NONE; @@ -735,8 +740,8 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error arg.fd = key; arg.flags = 0; if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &arg)) { - TBM_BACKEND_ERR("Cannot get gem handle from fd:%d (%m)", - arg.fd); + TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_FD_TO_HANDLE key:%d (%m)", + arg.fd); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return NULL; @@ -745,8 +750,7 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error name = _get_name(bufmgr_data->fd, gem); if (name == 0) { - TBM_BACKEND_ERR("Cannot get name from gem:%d, fd:%d (%m)", - gem, key); + TBM_BACKEND_ERR("fail to get name gem:%d (%m)", gem); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return NULL; @@ -774,8 +778,8 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error /* Open the same GEM object only for finding out its size */ open_arg.name = name; if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) { - TBM_BACKEND_ERR("Cannot get gem info from gem:%d, fd:%d (%m)", - gem, key); + TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_OPEN gem:%d name:%d (%m)", + gem, name); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return NULL; @@ -785,7 +789,7 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error struct drm_gem_close gem_close; gem_close.handle = open_arg.handle; if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_CLOSE, &gem_close)) { - TBM_BACKEND_ERR("Cannot close gem_handle (%m)"); + TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_CLOSE gem:%d (%m)", open_arg.handle); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return NULL; @@ -796,7 +800,7 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error bo_data = calloc(1, sizeof(struct _tbm_dumb_bo)); if (!bo_data) { - TBM_BACKEND_ERR("bo_data:%p fail to allocate the bo_data", bo_data); + TBM_BACKEND_ERR("fail to allocate the bo_data private"); if (error) *error = HAL_TBM_ERROR_OUT_OF_MEMORY; return NULL; @@ -813,16 +817,17 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error /* add bo_data to hash */ if (drmHashInsert(bufmgr_data->hashBos, bo_data->name, (void *)bo_data) < 0) - TBM_BACKEND_ERR("bo_data:%p Cannot insert bo_data to Hash(%d) from gem:%d, fd:%d", - bo_data, bo_data->name, gem, key); - - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d, size:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - key, - bo_data->flags_tbm, - bo_data->size); + TBM_BACKEND_ERR("fail to insert bo_data to Hash:%d bo_data:%p gem:%d fd:%d", + bo_data->name, bo_data, gem, key); + + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d key_fd:%d flags:%d size:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + key, + bo_data->flags_tbm, + bo_data->size); if (error) *error = HAL_TBM_ERROR_NONE; @@ -855,7 +860,7 @@ tbm_dumb_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_erro arg.name = key; if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_OPEN, &arg)) { - TBM_BACKEND_ERR("Cannot open gem name=%d", key); + TBM_BACKEND_ERR("fail to DRM_IOCTL_GEM_OPEN name:%d", key); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return NULL; @@ -882,7 +887,8 @@ tbm_dumb_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_erro arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg)) { - TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD gem=%d", bo_data->gem); + TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:d%d", + bo_data, bo_data->gem); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; free(bo_data); @@ -893,14 +899,15 @@ tbm_dumb_bufmgr_import_key(hal_tbm_bufmgr *bufmgr, hal_tbm_key key, hal_tbm_erro /* add bo to hash */ if (drmHashInsert(bufmgr_data->hashBos, bo_data->name, (void *)bo_data) < 0) - TBM_BACKEND_ERR("Cannot insert bo_data to Hash(%d)", bo_data->name); + TBM_BACKEND_ERR("fail to insert bo_data:%p to Hash:%d", bo_data, bo_data->name); - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d, flags:%d(%d), size:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - bo_data->flags_tbm, - bo_data->size); + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d flags:%d size:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + bo_data->flags_tbm, + bo_data->size); if (error) *error = HAL_TBM_ERROR_NONE; @@ -923,16 +930,17 @@ tbm_dumb_bo_free(hal_tbm_bo *bo) if (!bufmgr_data) return; - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d, size:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - bo_data->size); + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d size:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + bo_data->size); if (bo_data->pBase) { if (munmap(bo_data->pBase, bo_data->size) == -1) { - TBM_BACKEND_ERR("bo_data:%p fail to munmap (%m)", - bo_data); + TBM_BACKEND_ERR("fail to munmap bo_data:%p (%m)", + bo_data); } } @@ -947,7 +955,7 @@ tbm_dumb_bo_free(hal_tbm_bo *bo) if (ret == 0) drmHashDelete(bufmgr_data->hashBos, bo_data->name); else - TBM_BACKEND_ERR("Cannot find bo_data to Hash(%d), ret=%d", bo_data->name, ret); + TBM_BACKEND_ERR("fail to find bo_data to Hash:%d, ret:%d", bo_data->name, ret); if (temp != bo_data) TBM_BACKEND_ERR("hashBos probably has several BOs with same name!!!"); @@ -958,8 +966,8 @@ tbm_dumb_bo_free(hal_tbm_bo *bo) memset(&arg, 0, sizeof(arg)); arg.handle = bo_data->gem; if (drmIoctl(bo_data->fd, DRM_IOCTL_GEM_CLOSE, &arg)) - TBM_BACKEND_ERR("bo_data:%p fail to gem close (%m)", - bo_data); + TBM_BACKEND_ERR("fail to gem close bo_data:%p gem:%d (%m)", + bo_data, bo_data->gem); free(bo_data); } @@ -1011,25 +1019,26 @@ tbm_dumb_bo_get_handle(hal_tbm_bo *bo, hal_tbm_bo_device_type device, hal_tbm_er } if (!bo_data->gem) { - TBM_BACKEND_ERR("Cannot map gem=%d", bo_data->gem); + TBM_BACKEND_ERR("invalid gem bo_data:%p", bo_data); if (error) *error = HAL_TBM_ERROR_INVALID_PARAMETER; return (hal_tbm_bo_handle) NULL; } - TBM_BACKEND_DBG("bo_data:%p, gem:%d(%d), fd:%d, flags:%d, size:%d, %s", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - bo_data->flags_tbm, - bo_data->size, - STR_DEVICE[device]); + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d flags:%d size:%d %s", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + bo_data->flags_tbm, + bo_data->size, + STR_DEVICE[device]); /*Get mapped bo_handle*/ bo_handle = _dumb_bo_handle(bo_data, device); if (bo_handle.ptr == NULL) { - TBM_BACKEND_ERR("Cannot get handle: gem:%d, device:%d", - bo_data->gem, device); + TBM_BACKEND_ERR("fail to get handle bo_data:%p gem:%d device:%d", + bo_data, bo_data->gem, device); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return (hal_tbm_bo_handle) NULL; @@ -1063,24 +1072,25 @@ tbm_dumb_bo_map(hal_tbm_bo *bo, hal_tbm_bo_device_type device, } if (!bo_data->gem) { - TBM_BACKEND_ERR("Cannot map gem=%d", bo_data->gem); + TBM_BACKEND_ERR("invalid gem bo_data:%p", bo_data); if (error) *error = HAL_TBM_ERROR_INVALID_PARAMETER; return (hal_tbm_bo_handle) NULL; } - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d, %s, %s", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - STR_DEVICE[device], - STR_OPT[opt]); + TBM_BACKEND_DBG("bo_data:%p, gem:%d name:%d fd:%d %s %s", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + STR_DEVICE[device], + STR_OPT[opt]); /*Get mapped bo_handle*/ bo_handle = _dumb_bo_handle(bo_data, device); if (bo_handle.ptr == NULL) { - TBM_BACKEND_ERR("Cannot get handle: gem:%d, device:%d, opt:%d", - bo_data->gem, device, opt); + TBM_BACKEND_ERR("fail to get handle gem:%d device:%d opt:%d", + bo_data->gem, device, opt); if (error) *error = HAL_TBM_ERROR_INVALID_PARAMETER; return (hal_tbm_bo_handle) NULL; @@ -1108,10 +1118,11 @@ tbm_dumb_bo_unmap(hal_tbm_bo *bo) if (!bo_data->gem) return HAL_TBM_ERROR_INVALID_PARAMETER; - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf); + TBM_BACKEND_DBG("bo_data:%p, gem:%d name:%d fd:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf); return HAL_TBM_ERROR_NONE; } @@ -1133,20 +1144,21 @@ tbm_dumb_bo_export_fd(hal_tbm_bo *bo, hal_tbm_error *error) arg.handle = bo_data->gem; ret = drmIoctl(bo_data->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &arg); if (ret) { - TBM_BACKEND_ERR("bo_data:%p Cannot dmabuf=%d (%m)", - bo_data, bo_data->gem); + TBM_BACKEND_ERR("fail to DRM_IOCTL_PRIME_HANDLE_TO_FD bo_data:%p gem:%d (%m)", + bo_data, bo_data->gem); if (error) *error = HAL_TBM_ERROR_INVALID_OPERATION; return (hal_tbm_fd)ret; } - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d, key_fd:%d, flags:%d, size:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - arg.fd, - bo_data->flags_tbm, - bo_data->size); + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d key_fd:%d flags:%d size:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + arg.fd, + bo_data->flags_tbm, + bo_data->size); if (error) *error = HAL_TBM_ERROR_NONE; @@ -1168,19 +1180,20 @@ tbm_dumb_bo_export_key(hal_tbm_bo *bo, hal_tbm_error *error) if (!bo_data->name) { bo_data->name = _get_name(bo_data->fd, bo_data->gem); if (!bo_data->name) { - TBM_BACKEND_ERR("error Cannot get name"); + TBM_BACKEND_ERR("fail to get name bo_data:%p", bo_data); if (error) *error = HAL_TBM_ERROR_INVALID_PARAMETER; return 0; } } - TBM_BACKEND_DBG(" bo_data:%p, gem:%d(%d), fd:%d, flags:%d, size:%d", - bo_data, - bo_data->gem, bo_data->name, - bo_data->dmabuf, - bo_data->flags_tbm, - bo_data->size); + TBM_BACKEND_DBG("bo_data:%p gem:%d name:%d fd:%d flags:%d size:%d", + bo_data, + bo_data->gem, + bo_data->name, + bo_data->dmabuf, + bo_data->flags_tbm, + bo_data->size); if (error) *error = HAL_TBM_ERROR_NONE; |