static inline void __add_cb_request(GArray *cb_requests, mm_resource_manager_dmn_p mgr,
mm_resource_manager_res_type_e type, mm_resource_manager_res_volume volume);
static void __release_all_resources(mm_resource_manager_dmn_p manager);
-static gboolean __poll(struct pollfd sync);
+static gboolean __poll(struct pollfd sync, mm_resource_manager_id id);
static gboolean __wait_for_release_cb_sync(mm_resource_manager_id id);
mm_resource_manager_error_e _mmrm_dmn_commit(mm_resource_manager_id id,
mm_resource_manager_dmn_res_request_s *releases, mm_resource_manager_dmn_res_request_s *acquires)
{
- mm_resource_manager_dmn_p manager = __search_manager(id);
+ mm_resource_manager_dmn_p mgr = __search_manager(id);
mm_resource_manager_error_e ret = MM_RESOURCE_MANAGER_ERROR_NONE;
mm_resource_manager_dmn_res_request_s *increases = NULL;
GArray *cb_requests;
- MM_RM_RETVM_IF(manager == NULL, MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
+ MM_RM_RETVM_IF(mgr == NULL, MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER,
"Resource manager #%"PRIu64" doesn't exist", _mm_rm_hash64(id));
MM_RM_RETVM_IF((releases == NULL || releases[0].type == MM_RESOURCE_MANAGER_NO_RES) &&
(acquires == NULL || acquires[0].type == MM_RESOURCE_MANAGER_NO_RES),
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER, "Commit request is empty");
- ret = __check_release_requests(manager, releases);
+ MM_RM_INFO("RM #%"PRIu64" mgr [%p] release type (%s) acquires type (%s)", _mm_rm_hash64(mgr->id), mgr,
+ releases[0].type == MM_RESOURCE_MANAGER_NO_RES ? "" : _mm_resource_manager_get_res_str(releases[0].type),
+ acquires[0].type == MM_RESOURCE_MANAGER_NO_RES ? "" : _mm_resource_manager_get_res_str(acquires[0].type));
+
+ ret = __check_release_requests(mgr, releases);
MM_RM_RETVM_IF(ret != MM_RESOURCE_MANAGER_ERROR_NONE, ret, "check_release_requests is failed [0x%x]", ret);
increases = __create_dmn_res_requests(releases, acquires);
MM_RM_RETVM_IF(increases == NULL, MM_RESOURCE_MANAGER_ERROR_INVALID_OPERATION, "create_increase_requests is failed");
- ret = __check_requests_conflict(manager, increases);
+ ret = __check_requests_conflict(mgr, increases);
if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
__sync_increase_acquire_requests(increases, acquires);
g_free(increases);
}
g_free(increases);
- __handle_release_requests(manager, releases);
- cb_requests = __handle_acquire_requests(manager, acquires);
+ __handle_release_requests(mgr, releases);
+ cb_requests = __handle_acquire_requests(mgr, acquires);
MM_RM_RETVM_IF(cb_requests == NULL, MM_RESOURCE_MANAGER_ERROR_NOT_ENOUGH, "not enough free resource volume");
__handle_release_callbacks(cb_requests);
if (!mm_resource_manager_backend_commit_all()) {
int i;
mm_resource_manager_conf_s *conf = mm_resource_manager_get_conf();
mm_resource_manager_res_type_e type = MM_RESOURCE_MANAGER_RES_TYPE_MAX;
+ const char *res_name = NULL;
MM_RM_RETVM_IF(conf == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "conf is null");
MM_RM_RETVM_IF(releases == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "requests is null");
for (; releases->type != MM_RESOURCE_MANAGER_NO_RES; releases++) {
type = releases->type;
- const char *type_s = _mm_resource_manager_get_res_str(type);
+ res_name = _mm_resource_manager_get_res_str(type);
MM_RM_RETVM_IF(manager->resources[type] == NULL,
- MM_RESOURCE_MANAGER_ERROR_NOT_SUPPORTED, "There is no resource %s for the platform", type_s);
+ MM_RESOURCE_MANAGER_ERROR_NOT_SUPPORTED, "There is no resource %s for the platform", res_name);
if (manager->resources[type]->is_acquired) {
if (manager->resources[type]->parts == NULL) {
if (releases->volume != MM_RESOURCE_MANAGER_RES_VOLUME_FULL) {
- MM_RM_ERROR("Resource %s is acquired fully, but a resource part is tried to be released", type_s);
+ MM_RM_ERROR("Resource %s is acquired fully, but a resource part is tried to be released", res_name);
return MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER;
}
} else {
for (i = 0; i < manager->resources[type]->parts->len &&
((mm_resource_manager_res_volume*)manager->resources[type]->parts->data)[i] != releases->volume; i++);
if (i == manager->resources[type]->parts->len) {
- MM_RM_ERROR("Part of %s of volume %d is not acquired", type_s, releases->volume);
+ MM_RM_ERROR("Part of %s of volume %d is not acquired", res_name, releases->volume);
return MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER;
}
}
} else {
- MM_RM_ERROR("Resource %s is not acquired", type_s);
+ MM_RM_ERROR("Resource %s is not acquired", res_name);
return MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER;
}
MM_RM_DEBUG("Release requests are OK type %d available volume %d", type, conf->max_volume[type]);
mm_resource_manager_conf_s *conf = mm_resource_manager_get_conf();
int i, j, len;
mm_resource_manager_res_type_e type = MM_RESOURCE_MANAGER_RES_TYPE_MAX;
+ const char *res_name = NULL;
MM_RM_RETVM_IF(conf == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "conf is null");
MM_RM_RETVM_IF(manager == NULL, MM_RESOURCE_MANAGER_ERROR_NONE, "manager is null");
for (; requests->type != MM_RESOURCE_MANAGER_NO_RES; requests++) {
type = requests->type;
- const char *type_s = _mm_resource_manager_get_res_str(type);
+ res_name = _mm_resource_manager_get_res_str(type);
MM_RM_RETVM_IF(type < MM_RESOURCE_MANAGER_RES_TYPE_VIDEO_DECODER || type >= MM_RESOURCE_MANAGER_RES_TYPE_MAX,
MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER, "wrong type %d", type);
MM_RM_RETVM_IF(manager->resources[type] == NULL, MM_RESOURCE_MANAGER_ERROR_NOT_SUPPORTED,
- "There is no resource %s for the platform", type_s);
+ "There is no resource %s for the platform", res_name);
remaining_volume = conf->max_volume[type];
if (remaining_volume < requests->volume) {
requests->priority_error = TRUE;
MM_RM_DEBUG("Resource conflict. %d of %s are available, but %d required",
- remaining_volume, type_s, requests->volume);
+ remaining_volume, res_name, requests->volume);
return MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY;
}
}
} else {
requests->priority_error = TRUE;
- MM_RM_DEBUG("Resource conflict. %s is already acquired fully", type_s);
+ MM_RM_DEBUG("Resource conflict. %s is already acquired fully", res_name);
return MM_RESOURCE_MANAGER_ERROR_LOW_PRIORITY;
}
}
i_mgr->resources[type]->is_acquired = TRUE;
i_mgr->type = type;
i_mgr->volume = volume;
- MM_RM_INFO("Reset the value of release in RM %"PRIu64" (mgr %p)", _mm_rm_hash64(i_mgr->id), i_mgr);
+ MM_RM_INFO("Reset the value of acquire in RM #%"PRIu64" (type %s mgr %p)", _mm_rm_hash64(i_mgr->id), res_name, i_mgr);
if (conf->max_instance[type] > 0)
res_count[type]++;
continue;
g_array_free(res, TRUE);
i_mgr->resources[type]->parts = NULL;
- MM_RM_WARNING("Resource of %s is conflicted in RM %"PRIu64, res_name, _mm_rm_hash64(i_mgr->id));
+ MM_RM_WARNING("Resource of %s is conflicted in RM #%"PRIu64, res_name, _mm_rm_hash64(i_mgr->id));
} else {
__add_cb_request(cb_requests, i_mgr, type, MM_RESOURCE_MANAGER_RES_VOLUME_FULL);
mm_resource_manager_backend_release(type);
- MM_RM_INFO("Resource %s would be released (is acquired %d) in RM %"PRIu64" available volume %d", res_name,
+ MM_RM_INFO("Resource %s will be released (is acquired %d) in RM #%"PRIu64" available volume %d", res_name,
i_mgr->resources[type]->is_acquired, _mm_rm_hash64(i_mgr->id), conf->max_volume[type]);
}
}
res = i_mgr->resources[type]->parts;
if (res && i_mgr->resources[type]->is_acquired) {
- MM_RM_INFO("[#%d] [#%d / #%d] would be released %s in RM %"PRIu64,
+ MM_RM_INFO("[#%d] [#%d / #%d] will be released %s in RM #%"PRIu64,
managers->len, i + 1, res->len, res_name, _mm_rm_hash64(i_mgr->id));
__add_cb_request(cb_requests, i_mgr, type, g_array_index(res, mm_resource_manager_res_volume, 0));
continue;
acquired_volume += g_array_index(res, mm_resource_manager_res_volume, 0);
- MM_RM_INFO("[#%d] [#%d / #%d] There are %d units of %s in RM %"PRIu64,
+ MM_RM_INFO("[#%d] [#%d / #%d] There are %d units of %s in RM #%"PRIu64,
managers->len, j + 1, res->len, acquired_volume, res_name, _mm_rm_hash64(j_mgr->id));
__add_cb_request(cb_requests, j_mgr, type, g_array_index(res, mm_resource_manager_res_volume, 0));
g_array_append_val(res, requests->volume);
}
}
-
manager->resources[type]->is_acquired = TRUE;
mm_resource_manager_backend_acquire(type);
+ MM_RM_INFO("RM #%"PRIu64" (type %s mgr %p) is acquired", _mm_rm_hash64(i_mgr->id), res_name, i_mgr);
}
return cb_requests;
_mmrm_dmn_dbus_release_callback(id, type, volume);
if (__wait_for_release_cb_sync(id))
- MM_RM_DEBUG("Release callback sync success");
+ MM_RM_INFO("Release callback sync success RM #%"PRIu64, id);
else
- MM_RM_ERROR("Wait for release callback sync failed");
+ MM_RM_ERROR("Wait for release callback sync failed RM #%"PRIu64, id);
if (conf->volume_would_be_checked[type] && volume != MM_RESOURCE_MANAGER_RES_VOLUME_FULL) {
conf->max_volume[type] += volume;
}
mgr->resources[type]->is_acquired = FALSE;
+ MM_RM_INFO("RM #%"PRIu64" (type %s mgr %p) set acquired value as false (%d)",
+ id, _mm_resource_manager_get_res_str(type), mgr, mgr->resources[type]->is_acquired);
}
}
}
}
-static gboolean __poll(struct pollfd sync)
+static gboolean __poll(struct pollfd sync, mm_resource_manager_id id)
{
int errsv = 0;
int try_cnt = 0;
if (ret == -1) {
errsv = errno;
- MM_RM_ERROR("Polling is failed [fd %d errno %d]", sync.fd, errsv);
+ MM_RM_ERROR("Polling is failed [fd %d errno %d] RM #%"PRIu64, sync.fd, errsv, id);
if (errsv == EAGAIN)
continue;
break;
} else if (ret == 0) {
- MM_RM_WARNING("Wait timeout is elapsed [fd %d]", sync.fd);
+ MM_RM_WARNING("Wait timeout is elapsed [fd %d] RM #%"PRIu64 , sync.fd, id);
break;
}
sync.fd = open(RELEASE_CB_SYNC_PATH, O_RDONLY | O_NONBLOCK);
MM_RM_RETVM_IF(sync.fd == -1, FALSE, "Sync FIFO cannot be opened");
- if (!__poll(sync))
+ if (!__poll(sync, id))
goto out;
read_size = read(sync.fd, &recv_id, sizeof(recv_id));
if (id != _mm_rm_hash64(recv_id))
MM_RM_WARNING("Sync is received from wrong client #%"PRIu64, id);
- ret = __poll(sync);
+ ret = __poll(sync, id);
out:
close(sync.fd);
__mm_resource_handles_lock();
g_ptr_array_add(handles, handle);
- MM_RM_INFO("Resource manager #%"PRIu64" is created", _mm_rm_hash64(handle->id));
+ MM_RM_INFO("RM #%"PRIu64" is created", _mm_rm_hash64(handle->id));
__mm_resource_handles_unlock();
return MM_RESOURCE_MANAGER_ERROR_NONE;
id = handle->id;
- MM_RM_INFO("Resource manager #%"PRIu64" would be destroyed", _mm_rm_hash64(id));
+ MM_RM_INFO("RM #%"PRIu64" will be destroyed", _mm_rm_hash64(id));
__mm_resources_lock(handle);
ret = __dbus_destroy(handle);
free(handle);
if (ret == MM_RESOURCE_MANAGER_ERROR_NONE)
- MM_RM_INFO("Resource manager #%"PRIu64" is destroyed", _mm_rm_hash64(id));
+ MM_RM_INFO("RM #%"PRIu64" is destroyed", _mm_rm_hash64(id));
return ret;
}
*resource_h = resource;
- MM_RM_INFO("Resource %p of type %d with volume %d is marked for acquire in resource manager #%"PRIu64,
+ MM_RM_INFO("Resource %p of type %d with volume %d is marked for acquire in RM #%"PRIu64,
*resource_h, type, volume, _mm_rm_hash64(handle->id));
__mm_resources_unlock(handle);
break;
}
- MM_RM_INFO("Resource %p is resized for acquire in resource manager #%"PRIu64, resource_h, _mm_rm_hash64(handle->id));
+ MM_RM_INFO("Resource %p is resized for acquire in RM #%"PRIu64, resource_h, _mm_rm_hash64(handle->id));
__mm_resources_unlock(handle);
return ret;
i--;
}
- MM_RM_INFO("All resources are marked for release in resource manager #%"PRIu64, _mm_rm_hash64(handle->id));
+ MM_RM_INFO("All resources are marked for release in RM #%"PRIu64, _mm_rm_hash64(handle->id));
__mm_resources_unlock(handle);
return MM_RESOURCE_MANAGER_ERROR_NONE;
i = __get_resource_index(handle, resource);
MM_RM_UNLOCK_RETVM_IF(i == MM_RESOURCE_MANAGER_RES_NOT_FOUND, handle->resources_lock,
- MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER, "Invalid resource handle #%"PRIu64"", _mm_rm_hash64(handle->id));
+ MM_RESOURCE_MANAGER_ERROR_INVALID_PARAMETER, "Invalid RM #%"PRIu64"", _mm_rm_hash64(handle->id));
info->type = resource->type;
info->volume = resource->volume;
info->is_acquire_failed = resource->is_acquire_failed;
- MM_RM_INFO("Info structure of resource %p in resource manager #%"PRIu64" is filled", resource_h, _mm_rm_hash64(handle->id));
+ MM_RM_INFO("Info structure of resource %p in RM #%"PRIu64" is filled", resource_h, _mm_rm_hash64(handle->id));
__mm_resources_unlock(handle);
return MM_RESOURCE_MANAGER_ERROR_NONE;
ret = __dbus_commit(handle);
if (ret == MM_RESOURCE_MANAGER_ERROR_NONE)
- MM_RM_INFO("Changes in resource manager #%"PRIu64" have been committed successfully", _mm_rm_hash64(handle->id));
+ MM_RM_INFO("Changes in RM #%"PRIu64" have been committed successfully", _mm_rm_hash64(handle->id));
else
MM_RM_ERROR("Dbus commit request failed");
__mm_resources_unlock(handle);
handle->status_cb.user_data = user_data;
__mm_resources_unlock(handle);
- MM_RM_INFO("Status callback %p in resource manager #%"PRIu64" is set", cb, _mm_rm_hash64(handle->id));
+ MM_RM_INFO("Status callback %p in RM #%"PRIu64" is set", cb, _mm_rm_hash64(handle->id));
return MM_RESOURCE_MANAGER_ERROR_NONE;
}
mm_resource_manager_res_p i_res;
int i;
- MM_RM_INFO("[#%"PRIu64" type : %d] resource (#%d) for the platform", _mm_rm_hash64(rm->id), type, local_volume);
+ MM_RM_INFO("[RM #%"PRIu64" type : %d] resource (#%d) for the platform", _mm_rm_hash64(rm->id), type, local_volume);
if (volume > 0) {
for (i = 0; i < rm->resources->len; i++) {
return i;
}
- MM_RM_WARNING("[%d] Resource %p is marked for release in resource manager #%"PRIu64,
+ MM_RM_WARNING("[%d] Resource %p is marked for release in RM #%"PRIu64,
rm->resources->len, res, _mm_rm_hash64(rm->id));
return MM_RESOURCE_MANAGER_RES_NOT_FOUND;
MM_RM_RETM_IF(sync_fd == -1, "Sync FIFO cannot be opened [errno %d]", errno);
if (write(sync_fd, &id, sizeof(id)) == sizeof(id))
- MM_RM_DEBUG("Sync message is sent successfully");
+ MM_RM_DEBUG("Sync message is sent successfully RM #%"PRIu64, _mm_rm_hash64(id));
else
- MM_RM_ERROR("Sync message cannot be sent");
+ MM_RM_ERROR("Sync message cannot be sent RM #%"PRIu64, _mm_rm_hash64(id));
close(sync_fd);
}
mmresource_manager_call_create_sync(handle->dbus_proxy, app_class, &handle->id, &rm_error, NULL, &error);
MM_RM_RET_IF_GERR(error, "DBus create msg cannot be sent");
- MM_RM_DEBUG("Create returned id - #%"PRIu64", error - %d", _mm_rm_hash64(handle->id), rm_error);
+ MM_RM_DEBUG("Create returned id - RM #%"PRIu64", error - %d", _mm_rm_hash64(handle->id), rm_error);
return rm_error;
}
mmresource_manager_call_destroy_sync(handle->dbus_proxy, handle->id, &rm_error, NULL, &error);
MM_RM_RET_IF_GERR(error, "DBus destroy msg cannot be sent");
- MM_RM_DEBUG("Destroy for id - #%"PRIu64" returned error - %d", _mm_rm_hash64(handle->id), rm_error);
+ MM_RM_DEBUG("Destroy for id - RM #%"PRIu64" returned error - %d", _mm_rm_hash64(handle->id), rm_error);
return MM_RESOURCE_MANAGER_ERROR_NONE;
}
mmresource_manager_call_commit_sync(handle->dbus_proxy, handle->id, release, acquire, &rm_error, &flags_variant, NULL, &error);
MM_RM_RET_IF_GERR(error, "DBus commit msg cannot be sent");
- MM_RM_DEBUG("Commit for id - #%"PRIu64" returned error - %d", _mm_rm_hash64(handle->id), rm_error);
+ MM_RM_DEBUG("Commit for id - RM #%"PRIu64" returned error - %d", _mm_rm_hash64(handle->id), rm_error);
if (rm_error == MM_RESOURCE_MANAGER_ERROR_NONE) {
for (i = 0; i < handle->resources->len; i++) {