diff options
author | Changyeon Lee <cyeon.lee@samsung.com> | 2023-07-18 14:38:32 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2023-07-18 14:39:17 +0900 |
commit | 24af5bc27fb87b63b3ffd7297210a9ec83b944c7 (patch) | |
tree | 34284f01e3b4710d17ab6eedc9fc1b90f9923879 | |
parent | 3e6b5a8020a8d4671522c1d4711c31474087c46c (diff) | |
download | libtbm-dumb-24af5bc27fb87b63b3ffd7297210a9ec83b944c7.tar.gz libtbm-dumb-24af5bc27fb87b63b3ffd7297210a9ec83b944c7.tar.bz2 libtbm-dumb-24af5bc27fb87b63b3ffd7297210a9ec83b944c7.zip |
Get size of dma buf with gem_open only when lseek is failed
Change-Id: I889d175c61d1b58c7503ccbe902cc3eca3eea184
-rw-r--r-- | src/tbm_backend_dumb.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/tbm_backend_dumb.c b/src/tbm_backend_dumb.c index d8c91cb..931d71e 100644 --- a/src/tbm_backend_dumb.c +++ b/src/tbm_backend_dumb.c @@ -755,28 +755,28 @@ tbm_dumb_bufmgr_import_fd(hal_tbm_bufmgr *bufmgr, hal_tbm_fd key, hal_tbm_error * kernels will just fail, in which case we fall back to the * provided (estimated or guess size). */ real_size = lseek(key, 0, SEEK_END); + if (real_size == -1) { + /* 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("fail to DRM_IOCTL_GEM_OPEN gem:%d name:%d (%m)", + gem, name); + if (error) + *error = HAL_TBM_ERROR_INVALID_OPERATION; + return NULL; + } - /* 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("fail to DRM_IOCTL_GEM_OPEN gem:%d name:%d (%m)", - gem, name); - if (error) - *error = HAL_TBM_ERROR_INVALID_OPERATION; - return NULL; - } - - /* Free gem handle to avoid a memory leak*/ - close_arg.handle = open_arg.handle; - if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_CLOSE, &close_arg)) { - 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; - } + /* Free gem handle to avoid a memory leak*/ + close_arg.handle = open_arg.handle; + if (drmIoctl(bufmgr_data->fd, DRM_IOCTL_GEM_CLOSE, &close_arg)) { + 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; + } - if (real_size == -1) real_size = open_arg.size; + } bo_data = calloc(1, sizeof(struct _tbm_dumb_bo)); if (!bo_data) { |