Loading drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c +47 −12 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,32 @@ #include "cam_req_mgr_dev.h" #include "cam_req_mgr_dev.h" static struct cam_req_mgr_core_device *g_crm_core_dev; static struct cam_req_mgr_core_device *g_crm_core_dev; static struct cam_req_mgr_core_link g_links[MAXIMUM_LINKS_PER_SESSION]; static void cam_req_mgr_core_link_reset(struct cam_req_mgr_core_link *link) { link->link_hdl = 0; link->num_devs = 0; link->max_delay = CAM_PIPELINE_DELAY_0; link->workq = NULL; link->pd_mask = 0; link->l_dev = NULL; link->req.in_q = NULL; link->req.l_tbl = NULL; link->req.num_tbl = 0; link->watchdog = NULL; link->state = CAM_CRM_LINK_STATE_AVAILABLE; link->parent = NULL; link->subscribe_event = 0; link->trigger_mask = 0; link->sync_link = NULL; link->sof_counter = 0; link->sync_self_ref = 0; link->frame_skip_flag = false; link->sync_link_sof_skip = false; link->open_req_cnt = 0; link->last_flush_id = 0; } void cam_req_mgr_handle_core_shutdown(void) void cam_req_mgr_handle_core_shutdown(void) { { Loading Loading @@ -1330,25 +1356,25 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link( session->num_links, MAXIMUM_LINKS_PER_SESSION); session->num_links, MAXIMUM_LINKS_PER_SESSION); return NULL; return NULL; } } for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) { link = (struct cam_req_mgr_core_link *) if (!atomic_cmpxchg(&g_links[i].is_used, 0, 1)) { kzalloc(sizeof(struct cam_req_mgr_core_link), GFP_KERNEL); link = &g_links[i]; if (!link) { CAM_DBG(CAM_CRM, "alloc link index %d", i); CAM_ERR(CAM_CRM, "failed to create link, no mem"); cam_req_mgr_core_link_reset(link); return NULL; break; } } } if (i == MAXIMUM_LINKS_PER_SESSION) return NULL; in_q = (struct cam_req_mgr_req_queue *) in_q = (struct cam_req_mgr_req_queue *) kzalloc(sizeof(struct cam_req_mgr_req_queue), GFP_KERNEL); kzalloc(sizeof(struct cam_req_mgr_req_queue), GFP_KERNEL); if (!in_q) { if (!in_q) { CAM_ERR(CAM_CRM, "failed to create input queue, no mem"); CAM_ERR(CAM_CRM, "failed to create input queue, no mem"); kfree(link); return NULL; return NULL; } } mutex_init(&link->lock); spin_lock_init(&link->link_state_spin_lock); mutex_lock(&link->lock); mutex_lock(&link->lock); link->state = CAM_CRM_LINK_STATE_AVAILABLE; link->num_devs = 0; link->num_devs = 0; link->max_delay = 0; link->max_delay = 0; memset(in_q->slot, 0, memset(in_q->slot, 0, Loading Loading @@ -1385,7 +1411,6 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link( return link; return link; error: error: mutex_unlock(&session->lock); mutex_unlock(&session->lock); kfree(link); kfree(in_q); kfree(in_q); return NULL; return NULL; } } Loading @@ -1400,9 +1425,12 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link( */ */ static void __cam_req_mgr_free_link(struct cam_req_mgr_core_link *link) static void __cam_req_mgr_free_link(struct cam_req_mgr_core_link *link) { { ptrdiff_t i; kfree(link->req.in_q); kfree(link->req.in_q); link->req.in_q = NULL; link->req.in_q = NULL; kfree(link); i = link - g_links; CAM_DBG(CAM_CRM, "free link index %d", i); atomic_set(&g_links[i].is_used, 0); } } /** /** Loading Loading @@ -2849,6 +2877,7 @@ int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control) int cam_req_mgr_core_device_init(void) int cam_req_mgr_core_device_init(void) { { int i; CAM_DBG(CAM_CRM, "Enter g_crm_core_dev %pK", g_crm_core_dev); CAM_DBG(CAM_CRM, "Enter g_crm_core_dev %pK", g_crm_core_dev); if (g_crm_core_dev) { if (g_crm_core_dev) { Loading @@ -2865,6 +2894,12 @@ int cam_req_mgr_core_device_init(void) mutex_init(&g_crm_core_dev->crm_lock); mutex_init(&g_crm_core_dev->crm_lock); cam_req_mgr_debug_register(g_crm_core_dev); cam_req_mgr_debug_register(g_crm_core_dev); for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) { mutex_init(&g_links[i].lock); spin_lock_init(&g_links[i].link_state_spin_lock); atomic_set(&g_links[i].is_used, 0); cam_req_mgr_core_link_reset(&g_links[i]); } return 0; return 0; } } Loading drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -310,6 +310,8 @@ struct cam_req_mgr_connected_device { * frame in sync link as well. * frame in sync link as well. * @open_req_cnt : Counter to keep track of open requests that are yet * @open_req_cnt : Counter to keep track of open requests that are yet * to be serviced in the kernel. * to be serviced in the kernel. * @last_flush_id : Last request to flush * @is_used : 1 if link is in use else 0 * * */ */ struct cam_req_mgr_core_link { struct cam_req_mgr_core_link { Loading @@ -334,6 +336,8 @@ struct cam_req_mgr_core_link { bool frame_skip_flag; bool frame_skip_flag; bool sync_link_sof_skip; bool sync_link_sof_skip; int32_t open_req_cnt; int32_t open_req_cnt; uint32_t last_flush_id; atomic_t is_used; }; }; /** /** Loading Loading
drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.c +47 −12 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,32 @@ #include "cam_req_mgr_dev.h" #include "cam_req_mgr_dev.h" static struct cam_req_mgr_core_device *g_crm_core_dev; static struct cam_req_mgr_core_device *g_crm_core_dev; static struct cam_req_mgr_core_link g_links[MAXIMUM_LINKS_PER_SESSION]; static void cam_req_mgr_core_link_reset(struct cam_req_mgr_core_link *link) { link->link_hdl = 0; link->num_devs = 0; link->max_delay = CAM_PIPELINE_DELAY_0; link->workq = NULL; link->pd_mask = 0; link->l_dev = NULL; link->req.in_q = NULL; link->req.l_tbl = NULL; link->req.num_tbl = 0; link->watchdog = NULL; link->state = CAM_CRM_LINK_STATE_AVAILABLE; link->parent = NULL; link->subscribe_event = 0; link->trigger_mask = 0; link->sync_link = NULL; link->sof_counter = 0; link->sync_self_ref = 0; link->frame_skip_flag = false; link->sync_link_sof_skip = false; link->open_req_cnt = 0; link->last_flush_id = 0; } void cam_req_mgr_handle_core_shutdown(void) void cam_req_mgr_handle_core_shutdown(void) { { Loading Loading @@ -1330,25 +1356,25 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link( session->num_links, MAXIMUM_LINKS_PER_SESSION); session->num_links, MAXIMUM_LINKS_PER_SESSION); return NULL; return NULL; } } for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) { link = (struct cam_req_mgr_core_link *) if (!atomic_cmpxchg(&g_links[i].is_used, 0, 1)) { kzalloc(sizeof(struct cam_req_mgr_core_link), GFP_KERNEL); link = &g_links[i]; if (!link) { CAM_DBG(CAM_CRM, "alloc link index %d", i); CAM_ERR(CAM_CRM, "failed to create link, no mem"); cam_req_mgr_core_link_reset(link); return NULL; break; } } } if (i == MAXIMUM_LINKS_PER_SESSION) return NULL; in_q = (struct cam_req_mgr_req_queue *) in_q = (struct cam_req_mgr_req_queue *) kzalloc(sizeof(struct cam_req_mgr_req_queue), GFP_KERNEL); kzalloc(sizeof(struct cam_req_mgr_req_queue), GFP_KERNEL); if (!in_q) { if (!in_q) { CAM_ERR(CAM_CRM, "failed to create input queue, no mem"); CAM_ERR(CAM_CRM, "failed to create input queue, no mem"); kfree(link); return NULL; return NULL; } } mutex_init(&link->lock); spin_lock_init(&link->link_state_spin_lock); mutex_lock(&link->lock); mutex_lock(&link->lock); link->state = CAM_CRM_LINK_STATE_AVAILABLE; link->num_devs = 0; link->num_devs = 0; link->max_delay = 0; link->max_delay = 0; memset(in_q->slot, 0, memset(in_q->slot, 0, Loading Loading @@ -1385,7 +1411,6 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link( return link; return link; error: error: mutex_unlock(&session->lock); mutex_unlock(&session->lock); kfree(link); kfree(in_q); kfree(in_q); return NULL; return NULL; } } Loading @@ -1400,9 +1425,12 @@ static struct cam_req_mgr_core_link *__cam_req_mgr_reserve_link( */ */ static void __cam_req_mgr_free_link(struct cam_req_mgr_core_link *link) static void __cam_req_mgr_free_link(struct cam_req_mgr_core_link *link) { { ptrdiff_t i; kfree(link->req.in_q); kfree(link->req.in_q); link->req.in_q = NULL; link->req.in_q = NULL; kfree(link); i = link - g_links; CAM_DBG(CAM_CRM, "free link index %d", i); atomic_set(&g_links[i].is_used, 0); } } /** /** Loading Loading @@ -2849,6 +2877,7 @@ int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control) int cam_req_mgr_core_device_init(void) int cam_req_mgr_core_device_init(void) { { int i; CAM_DBG(CAM_CRM, "Enter g_crm_core_dev %pK", g_crm_core_dev); CAM_DBG(CAM_CRM, "Enter g_crm_core_dev %pK", g_crm_core_dev); if (g_crm_core_dev) { if (g_crm_core_dev) { Loading @@ -2865,6 +2894,12 @@ int cam_req_mgr_core_device_init(void) mutex_init(&g_crm_core_dev->crm_lock); mutex_init(&g_crm_core_dev->crm_lock); cam_req_mgr_debug_register(g_crm_core_dev); cam_req_mgr_debug_register(g_crm_core_dev); for (i = 0; i < MAXIMUM_LINKS_PER_SESSION; i++) { mutex_init(&g_links[i].lock); spin_lock_init(&g_links[i].link_state_spin_lock); atomic_set(&g_links[i].is_used, 0); cam_req_mgr_core_link_reset(&g_links[i]); } return 0; return 0; } } Loading
drivers/media/platform/msm/camera/cam_req_mgr/cam_req_mgr_core.h +4 −0 Original line number Original line Diff line number Diff line Loading @@ -310,6 +310,8 @@ struct cam_req_mgr_connected_device { * frame in sync link as well. * frame in sync link as well. * @open_req_cnt : Counter to keep track of open requests that are yet * @open_req_cnt : Counter to keep track of open requests that are yet * to be serviced in the kernel. * to be serviced in the kernel. * @last_flush_id : Last request to flush * @is_used : 1 if link is in use else 0 * * */ */ struct cam_req_mgr_core_link { struct cam_req_mgr_core_link { Loading @@ -334,6 +336,8 @@ struct cam_req_mgr_core_link { bool frame_skip_flag; bool frame_skip_flag; bool sync_link_sof_skip; bool sync_link_sof_skip; int32_t open_req_cnt; int32_t open_req_cnt; uint32_t last_flush_id; atomic_t is_used; }; }; /** /** Loading