From 6ba68100a804f9e82f8129c0a6fda3a7a718c79e Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Tue, 18 Feb 2025 14:09:21 +0900 Subject: [PATCH] bufmgr: Remove tbm_bufmgr_bo_lock_type Change-Id: Iba73130aef2efc5e97a82aec2141bdf8f0163600 --- haltests/tc_tbm_bo.cpp | 77 ----------------------------------- haltests/tc_tbm_bufmgr.cpp | 30 -------------- include/tbm_bufmgr_internal.h | 15 ------- src/tbm_bo.c | 65 ++++------------------------- src/tbm_bufmgr.c | 43 ------------------- src/tbm_bufmgr_int.h | 1 - 6 files changed, 8 insertions(+), 223 deletions(-) diff --git a/haltests/tc_tbm_bo.cpp b/haltests/tc_tbm_bo.cpp index f63c8c1..1ebcf27 100644 --- a/haltests/tc_tbm_bo.cpp +++ b/haltests/tc_tbm_bo.cpp @@ -720,83 +720,6 @@ TEST_F(TBMBo, BoLockedWithBoParamTest) EXPECT_EQ(ret, 0); EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER)); } - -#if 0 -TEST_F(TBMBo, BoLockedOnce) -{ - // TODO: need to be fixed. use tbm_bufmgr_set_bo_lock_type instead of BUFMGR_LOCK_TYPE - tbm_bo_handle bo_handle1, bo_handle2; - tbm_bo bo; - int ret_locked; - - setenv("BUFMGR_LOCK_TYPE", "once", 1); - - bo = tbm_bo_alloc(bufmgr, TBM_UT_BO_SIZE, TBM_BO_DEFAULT); - EXPECT_NE(nullptr, bo); - - bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - bo_handle2 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - (void) bo_handle1; - (void) bo_handle2; - - tbm_bo_unmap(bo); - - ret_locked = tbm_bo_locked(bo); - - tbm_bo_unmap(bo); - - EXPECT_EQ(ret_locked, 0); -} - -TEST_F(TBMBo, BoLockedAlways) -{ - // TODO: need to be fixed. use tbm_bufmgr_set_bo_lock_type instead of BUFMGR_LOCK_TYPE - tbm_bo_handle bo_handle1, bo_handle2; - tbm_bo bo; - int ret_locked; - - setenv("BUFMGR_LOCK_TYPE", "always", 1); - - bo = tbm_bo_alloc(bufmgr, TBM_UT_BO_SIZE, TBM_BO_DEFAULT); - EXPECT_NE(nullptr, bo); - - bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - bo_handle2 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - (void) bo_handle1; - (void) bo_handle2; - - tbm_bo_unmap(bo); - - ret_locked = tbm_bo_locked(bo); - - tbm_bo_unmap(bo); - - EXPECT_EQ(ret_locked, 1); -} - -TEST_F(TBMBo, BoLockedNone) -{ - // TODO: need to be fixed. use tbm_bufmgr_set_bo_lock_type instead of BUFMGR_LOCK_TYPE - tbm_bo_handle bo_handle1; - tbm_bo bo; - int ret_locked; - - setenv("BUFMGR_LOCK_TYPE", "none", 1); - - bo = tbm_bo_alloc(bufmgr, TBM_UT_BO_SIZE, TBM_BO_DEFAULT); - EXPECT_NE(nullptr, bo); - - bo_handle1 = tbm_bo_map(bo, TBM_DEVICE_2D, TBM_OPTION_READ | TBM_OPTION_WRITE); - (void) bo_handle1; - - ret_locked = tbm_bo_locked(bo); - - tbm_bo_unmap(bo); - - EXPECT_EQ(ret_locked, 0); -} -#endif - /* tbm_bo_swap() */ TEST_F(TBMBo, BoSwap) diff --git a/haltests/tc_tbm_bufmgr.cpp b/haltests/tc_tbm_bufmgr.cpp index 2faf9e3..ebb670e 100644 --- a/haltests/tc_tbm_bufmgr.cpp +++ b/haltests/tc_tbm_bufmgr.cpp @@ -56,9 +56,6 @@ void TBMBufmgr::TearDown() TBMEnv::TearDown(); } -static int memory_for_invalid_param; -static tbm_bufmgr invalid_bufmgr = (tbm_bufmgr)&memory_for_invalid_param; - /* tbm_bufmgr_get_capability() */ TEST_F(TBMBufmgr, BufmgrGetCapability) { @@ -118,33 +115,6 @@ TEST_F(TBMBufmgr, BufmgrBindNativeDisplayWithWrongBufmgr) } #endif -/* tbm_bufmgr_set_bo_lock_type() */ -TEST_F(TBMBufmgr, BufmgrSetBoLockType) -{ - int ret; - - ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER); - EXPECT_EQ(ret, 1); - EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE)); - ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ONCE); - EXPECT_EQ(ret, 1); - EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE)); - ret = tbm_bufmgr_set_bo_lock_type(bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS); - EXPECT_EQ(ret, 1); - EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_NONE)); -} - -TEST_F(TBMBufmgr, BufmgrSetBoLockTypeWithBufmgrParamTest) -{ - int ret; - - ret = tbm_bufmgr_set_bo_lock_type(NULL, TBM_BUFMGR_BO_LOCK_TYPE_NEVER); - EXPECT_EQ(ret, 0); - ret = tbm_bufmgr_set_bo_lock_type(invalid_bufmgr, TBM_BUFMGR_BO_LOCK_TYPE_NEVER); - EXPECT_EQ(ret, 0); - EXPECT_STREQ(tbm_error_str(tbm_get_last_error()), tbm_error_str(TBM_ERROR_INVALID_PARAMETER)); -} - // TODO:::: /* tbm_bufmgr_debug_show() */ /* tbm_bufmgr_debug_tbm_info_get() */ diff --git a/include/tbm_bufmgr_internal.h b/include/tbm_bufmgr_internal.h index 2064b93..5c3a803 100644 --- a/include/tbm_bufmgr_internal.h +++ b/include/tbm_bufmgr_internal.h @@ -42,15 +42,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * \brief Tizen Buffer Manager Internal */ -/** - * @brief Enumeration of buffer manager lock try for bo - * @since_tizen 5.0 - */ -typedef enum { - TBM_BUFMGR_BO_LOCK_TYPE_NEVER = 0, /**< the bufmgr do not try to lock the bos when the tbm_bo_map is called. */ - TBM_BUFMGR_BO_LOCK_TYPE_ONCE, /**< the bufmgr tries to lock the bos only once when the tbm_bo_map is called. */ - TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS, /**< the bufmgr always tries to lock the bos when the tbm_bo_map is called. */ -} tbm_bufmgr_bo_lock_type; #ifdef __cplusplus extern "C" { @@ -71,12 +62,6 @@ int tbm_bufmgr_bind_native_display(tbm_bufmgr bufmgr, void *native_display); */ tbm_bufmgr tbm_bufmgr_server_init(void); -/** - * @brief Set the bo_lock_type of the bufffer manager. - * @details set the bo_lock_type - * @since_tizen 5.0 - */ -int tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type); #ifdef __cplusplus } diff --git a/src/tbm_bo.c b/src/tbm_bo.c index 29fd6bf..e50ab3a 100644 --- a/src/tbm_bo.c +++ b/src/tbm_bo.c @@ -189,10 +189,6 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt) if (!bo) return 0; - /* do not try to lock the bo */ - if (bo->bufmgr->bo_lock_type == TBM_BUFMGR_BO_LOCK_TYPE_NEVER) - return 1; - if (bo->lock_cnt < 0) { TBM_ERR("error bo:%p LOCK_CNT=%d", bo, bo->lock_cnt); @@ -201,30 +197,11 @@ _tbm_bo_lock(tbm_bo bo, int device, int opt) old = bo->lock_cnt; - switch (bo->bufmgr->bo_lock_type) { - case TBM_BUFMGR_BO_LOCK_TYPE_ONCE: - if (bo->lock_cnt == 0) { - _tbm_bufmgr_mutex_unlock(); - ret = _bo_lock(bo, device, opt); - _tbm_bufmgr_mutex_lock(); - if (ret) - bo->lock_cnt++; - } else - ret = 1; - break; - case TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS: - _tbm_bufmgr_mutex_unlock(); - ret = _bo_lock(bo, device, opt); - _tbm_bufmgr_mutex_lock(); - if (ret) - bo->lock_cnt++; - break; - default: - TBM_ERR("error bo:%p bo_lock_type[%d] is wrong.", - bo, bo->bufmgr->bo_lock_type); - ret = 0; - break; - } + _tbm_bufmgr_mutex_unlock(); + ret = _bo_lock(bo, device, opt); + _tbm_bufmgr_mutex_lock(); + + if (ret) bo->lock_cnt++; TBM_DBG(">> LOCK bo:%p(%d->%d)", bo, old, bo->lock_cnt); @@ -236,30 +213,11 @@ _tbm_bo_unlock(tbm_bo bo) { int old; - /* do not try to unlock the bo */ - if (bo->bufmgr->bo_lock_type == TBM_BUFMGR_BO_LOCK_TYPE_NEVER) - return; - old = bo->lock_cnt; - switch (bo->bufmgr->bo_lock_type) { - case TBM_BUFMGR_BO_LOCK_TYPE_ONCE: - if (bo->lock_cnt > 0) { - bo->lock_cnt--; - if (bo->lock_cnt == 0) - _bo_unlock(bo); - } - break; - case TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS: - if (bo->lock_cnt > 0) { - bo->lock_cnt--; - _bo_unlock(bo); - } - break; - default: - TBM_ERR("error bo:%p bo_lock_type[%d] is wrong.", - bo, bo->bufmgr->bo_lock_type); - break; + if (bo->lock_cnt > 0) { + bo->lock_cnt--; + _bo_unlock(bo); } if (bo->lock_cnt < 0) @@ -573,13 +531,6 @@ tbm_bo_locked(tbm_bo bo) TBM_BO_RETURN_VAL_IF_FAIL(_tbm_bo_is_valid(bo), 0); - if (bo->bufmgr->bo_lock_type == TBM_BUFMGR_BO_LOCK_TYPE_NEVER) { - TBM_ERR("bo(%p) lock_cnt(%d)", bo, bo->lock_cnt); - _tbm_set_last_result(TBM_ERROR_INVALID_OPERATION); - _tbm_bufmgr_mutex_unlock(); - return 0; - } - if (bo->lock_cnt > 0) { TBM_TRACE_BO("error: bo(%p) lock_cnt(%d)", bo, bo->lock_cnt); _tbm_bufmgr_mutex_unlock(); diff --git a/src/tbm_bufmgr.c b/src/tbm_bufmgr.c index a069fab..4acef48 100644 --- a/src/tbm_bufmgr.c +++ b/src/tbm_bufmgr.c @@ -218,7 +218,6 @@ _tbm_bufmgr_init(int fd, int server) #ifdef TBM_BUFMGR_INIT_TIME struct timeval start_tv, end_tv; #endif - char *env; #ifdef TBM_BUFMGR_INIT_TIME /* get the start tv */ @@ -315,19 +314,6 @@ _tbm_bufmgr_init(int fd, int server) TBM_INFO("create tizen bufmgr:%p ref_count:%d", gBufMgr, gBufMgr->ref_count); - /* setup the bo_lock_type */ - env = getenv("BUFMGR_LOCK_TYPE"); - if (env && !strcmp(env, "always")) - gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS; - else if (env && !strcmp(env, "none")) - gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_NEVER; - else if (env && !strcmp(env, "once")) - gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_ONCE; - else - gBufMgr->bo_lock_type = TBM_BUFMGR_BO_LOCK_TYPE_ALWAYS; - - TBM_DBG("BUFMGR_LOCK_TYPE=%s", env ? env : "default:once"); - /* intialize bo_list */ LIST_INITHEAD(&gBufMgr->bo_list); @@ -830,35 +816,6 @@ tbm_bufmgr_server_init(void) return bufmgr; } -int -tbm_bufmgr_set_bo_lock_type(tbm_bufmgr bufmgr, tbm_bufmgr_bo_lock_type bo_lock_type) -{ - pthread_mutex_lock(&gLock); - _tbm_bufmgr_mutex_lock(); - - _tbm_set_last_result(TBM_ERROR_NONE); - - TBM_GOTO_VAL_IF_FAIL(TBM_BUFMGR_IS_VALID(gBufMgr), failed); - TBM_GOTO_VAL_IF_FAIL(bufmgr == gBufMgr, failed); - - gBufMgr->bo_lock_type = bo_lock_type; - - TBM_INFO("The bo_lock_type of the bo is %d\n", bo_lock_type); - - _tbm_bufmgr_mutex_unlock(); - pthread_mutex_unlock(&gLock); - - return 1; - -failed: - _tbm_set_last_result(TBM_ERROR_INVALID_PARAMETER); - _tbm_bufmgr_mutex_unlock(); - pthread_mutex_unlock(&gLock); - - return 0; -} - - int tbm_bufmgr_get_fd_limit(void) { struct rlimit lim; diff --git a/src/tbm_bufmgr_int.h b/src/tbm_bufmgr_int.h index f8e79f7..24ffe9c 100644 --- a/src/tbm_bufmgr_int.h +++ b/src/tbm_bufmgr_int.h @@ -200,7 +200,6 @@ struct _tbm_bo { struct _tbm_bufmgr { int ref_count; /* reference count */ int fd; /* bufmgr fd */ - tbm_bufmgr_bo_lock_type bo_lock_type; /* lock_type of bufmgr */ int capabilities; /* capabilities of bufmgr */ int display_server; /* used by display server */ unsigned int bo_cnt; /* number of bos */ -- 2.34.1