11// SPDX-License-Identifier: GPL-2.0-only
22/*
33 * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
4- * Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
54 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
65 */
76
@@ -3239,20 +3238,18 @@ int cam_req_mgr_process_flush_req(void *priv, void *data)
32393238int cam_req_mgr_process_sched_req (void * priv , void * data )
32403239{
32413240 int rc = 0 , i , sync_idx = 0 ;
3242- struct cam_req_mgr_sched_request_v2 * sched_req = NULL ;
3241+ struct cam_req_mgr_core_sched_req * sched_req = NULL ;
32433242 struct cam_req_mgr_core_link * link = NULL ;
32443243 struct cam_req_mgr_req_queue * in_q = NULL ;
32453244 struct cam_req_mgr_slot * slot = NULL ;
3246- struct crm_task_payload * task_data = NULL ;
32473245
32483246 if (!data || !priv ) {
32493247 CAM_ERR (CAM_CRM , "input args NULL %pK %pK" , data , priv );
32503248 rc = - EINVAL ;
32513249 goto end ;
32523250 }
32533251 link = (struct cam_req_mgr_core_link * )priv ;
3254- task_data = (struct crm_task_payload * )data ;
3255- sched_req = (struct cam_req_mgr_sched_request_v2 * )& task_data -> u ;
3252+ sched_req = (struct cam_req_mgr_core_sched_req * )data ;
32563253 in_q = link -> req .in_q ;
32573254
32583255 CAM_DBG (CAM_CRM ,
@@ -5164,8 +5161,7 @@ int cam_req_mgr_schedule_request(
51645161 int rc = 0 ;
51655162 struct cam_req_mgr_core_link * link = NULL ;
51665163 struct cam_req_mgr_core_session * session = NULL ;
5167- struct cam_req_mgr_sched_request_v2 * sched ;
5168- struct crm_task_payload task_data ;
5164+ struct cam_req_mgr_core_sched_req sched ;
51695165
51705166 if (!sched_req ) {
51715167 CAM_ERR (CAM_CRM , "csl_req is NULL" );
@@ -5203,20 +5199,20 @@ int cam_req_mgr_schedule_request(
52035199 CAM_DBG (CAM_CRM , "link 0x%x req %lld, sync_mode %d" ,
52045200 sched_req -> link_hdl , sched_req -> req_id , sched_req -> sync_mode );
52055201
5206- task_data . type = CRM_WORKQ_TASK_SCHED_REQ ;
5207- sched = ( struct cam_req_mgr_sched_request_v2 * ) & task_data . u ;
5208- sched -> req_id = sched_req -> req_id ;
5209- sched -> sync_mode = sched_req -> sync_mode ;
5210- sched -> link_hdl = sched_req -> link_hdl ;
5211- sched -> additional_timeout = sched_req -> additional_timeout ;
5202+ memset ( & sched , 0 , sizeof ( sched )) ;
5203+
5204+ sched . req_id = sched_req -> req_id ;
5205+ sched . sync_mode = sched_req -> sync_mode ;
5206+ sched . link_hdl = sched_req -> link_hdl ;
5207+ sched . additional_timeout = sched_req -> additional_timeout ;
52125208 if (session -> force_err_recovery == AUTO_RECOVERY ) {
5213- sched -> bubble_enable = sched_req -> bubble_enable ;
5209+ sched . bubble_enable = sched_req -> bubble_enable ;
52145210 } else {
5215- sched -> bubble_enable =
5211+ sched . bubble_enable =
52165212 (session -> force_err_recovery == FORCE_ENABLE_RECOVERY ) ? 1 : 0 ;
52175213 }
52185214
5219- rc = cam_req_mgr_process_sched_req (link , & task_data );
5215+ rc = cam_req_mgr_process_sched_req (link , & sched );
52205216
52215217 CAM_DBG (CAM_REQ , "Open req %lld on link 0x%x with sync_mode %d" ,
52225218 sched_req -> req_id , sched_req -> link_hdl , sched_req -> sync_mode );
@@ -5232,12 +5228,10 @@ int cam_req_mgr_schedule_request_v2(
52325228 int rc = 0 ;
52335229 struct cam_req_mgr_core_link * link = NULL ;
52345230 struct cam_req_mgr_core_session * session = NULL ;
5235- struct crm_task_payload task_data ;
5236- struct cam_req_mgr_sched_request_v2 * sched ;
5231+ struct cam_req_mgr_core_sched_req sched ;
52375232 struct cam_req_mgr_core_link * sync_links [MAXIMUM_LINKS_PER_SESSION ];
52385233
52395234 mutex_lock (& g_crm_core_dev -> crm_lock );
5240-
52415235 link = cam_get_link_priv (sched_req -> link_hdl );
52425236 if (!link || (link -> link_hdl != sched_req -> link_hdl )) {
52435237 CAM_ERR (CAM_CRM , "link: %s, sched_req->link_hdl:%x, link->link_hdl:%x" ,
@@ -5269,17 +5263,20 @@ int cam_req_mgr_schedule_request_v2(
52695263 sched_req -> link_hdl , sched_req -> req_id , sched_req -> sync_mode ,
52705264 sched_req -> num_links );
52715265
5272- task_data .type = CRM_WORKQ_TASK_SCHED_REQ ;
5273- sched = (struct cam_req_mgr_sched_request_v2 * )& task_data .u ;
5274- sched -> req_id = sched_req -> req_id ;
5275- sched -> sync_mode = sched_req -> sync_mode ;
5276- sched -> link_hdl = sched_req -> link_hdl ;
5277- sched -> additional_timeout = sched_req -> additional_timeout ;
5266+ memset (& sched , 0 , sizeof (sched ));
5267+
5268+ sched .req_id = sched_req -> req_id ;
5269+ sched .sync_mode = sched_req -> sync_mode ;
5270+ sched .link_hdl = sched_req -> link_hdl ;
5271+ sched .additional_timeout = sched_req -> additional_timeout ;
5272+ sched .num_valid_params = sched_req -> num_valid_params ;
5273+ sched .param_mask = sched_req -> param_mask ;
5274+ sched .params = sched_req -> params ;
52785275
52795276 if (session -> force_err_recovery == AUTO_RECOVERY ) {
5280- sched -> bubble_enable = sched_req -> bubble_enable ;
5277+ sched . bubble_enable = sched_req -> bubble_enable ;
52815278 } else {
5282- sched -> bubble_enable =
5279+ sched . bubble_enable =
52835280 (session -> force_err_recovery == FORCE_ENABLE_RECOVERY ) ? 1 : 0 ;
52845281 }
52855282
@@ -5311,14 +5308,116 @@ int cam_req_mgr_schedule_request_v2(
53115308 rc = - EINVAL ;
53125309 goto end ;
53135310 }
5311+ }
5312+ sched .num_links = sched_req -> num_links ;
5313+ sched .link_hdls = sched_req -> link_hdls ;
5314+ } else
5315+ sched .num_links = 0 ;
5316+
5317+ rc = cam_req_mgr_process_sched_req (link , & sched );
5318+
5319+ CAM_DBG (CAM_REQ , "Open req %lld on link 0x%x with sync_mode %d" ,
5320+ sched_req -> req_id , sched_req -> link_hdl , sched_req -> sync_mode );
5321+ end :
5322+ mutex_unlock (& g_crm_core_dev -> crm_lock );
5323+ return rc ;
5324+ }
5325+
5326+ int cam_req_mgr_schedule_request_v3 (
5327+ struct cam_req_mgr_sched_request_v3 * sched_req )
5328+ {
5329+ int i = 0 ;
5330+ int rc = 0 ;
5331+ struct cam_req_mgr_core_link * link = NULL ;
5332+ struct cam_req_mgr_core_session * session = NULL ;
5333+ struct cam_req_mgr_core_sched_req sched ;
5334+ struct cam_req_mgr_core_link * sync_links [MAXIMUM_LINKS_PER_SESSION ];
5335+
5336+ mutex_lock (& g_crm_core_dev -> crm_lock );
5337+
5338+ link = cam_get_link_priv (sched_req -> link_hdl );
5339+ if (!link || (link -> link_hdl != sched_req -> link_hdl )) {
5340+ CAM_ERR (CAM_CRM , "link: %s, sched_req->link_hdl:%x, link->link_hdl:%x" ,
5341+ CAM_IS_NULL_TO_STR (link ), sched_req -> link_hdl ,
5342+ (!link ) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : link -> link_hdl );
5343+ rc = - EINVAL ;
5344+ goto end ;
5345+ }
5346+
5347+ session = (struct cam_req_mgr_core_session * )link -> parent ;
5348+ if (!session ) {
5349+ CAM_WARN (CAM_CRM , "session ptr NULL %x" , sched_req -> link_hdl );
5350+ rc = - EINVAL ;
5351+ goto end ;
5352+ }
5353+
5354+ if (sched_req -> req_id <= link -> last_flush_id ) {
5355+ CAM_INFO (CAM_CRM ,
5356+ "request %lld is flushed, last_flush_id to flush %d" ,
5357+ sched_req -> req_id , link -> last_flush_id );
5358+ rc = - EBADR ;
5359+ goto end ;
5360+ }
5361+
5362+ if (sched_req -> req_id > link -> last_flush_id )
5363+ link -> last_flush_id = 0 ;
5364+
5365+ CAM_DBG (CAM_CRM , "link 0x%x req %lld, sync_mode %d num_links %d" ,
5366+ sched_req -> link_hdl , sched_req -> req_id , sched_req -> sync_mode ,
5367+ sched_req -> num_links );
5368+
5369+ memset (& sched , 0 , sizeof (sched ));
5370+
5371+ sched .req_id = sched_req -> req_id ;
5372+ sched .sync_mode = sched_req -> sync_mode ;
5373+ sched .link_hdl = sched_req -> link_hdl ;
5374+ sched .additional_timeout = sched_req -> additional_timeout ;
5375+ sched .num_valid_params = sched_req -> num_valid_params ;
5376+ sched .param_mask = sched_req -> param_mask ;
5377+ sched .params = sched_req -> params ;
5378+
5379+ if (session -> force_err_recovery == AUTO_RECOVERY ) {
5380+ sched .bubble_enable = sched_req -> bubble_enable ;
5381+ } else {
5382+ sched .bubble_enable =
5383+ (session -> force_err_recovery == FORCE_ENABLE_RECOVERY ) ? 1 : 0 ;
5384+ }
5385+
5386+ if (sched_req -> sync_mode == CAM_REQ_MGR_SYNC_MODE_SYNC ) {
5387+ if ((sched_req -> num_links <= 0 ) &&
5388+ (sched_req -> num_links > MAXIMUM_LINKS_PER_SESSION )) {
5389+ CAM_ERR (CAM_CRM , "link:0x%x req:%lld invalid num_links:%d" ,
5390+ link -> link_hdl , sched_req -> req_id , sched_req -> num_links );
5391+ rc = - EINVAL ;
5392+ goto end ;
5393+ }
5394+
5395+ for (i = 0 ; i < sched_req -> num_links ; i ++ ) {
5396+ if (!sched_req -> link_hdls [i ]) {
5397+ CAM_ERR (CAM_CRM , "link handle %d in sched_req is null" , i );
5398+ rc = - EINVAL ;
5399+ goto end ;
5400+ }
53145401
5315- sched -> link_hdls [i ] = sched_req -> link_hdls [i ];
5402+ sync_links [i ] = cam_get_link_priv (sched_req -> link_hdls [i ]);
5403+ if (!sync_links [i ] ||
5404+ (sync_links [i ]-> link_hdl != sched_req -> link_hdls [i ])) {
5405+ CAM_ERR (CAM_CRM ,
5406+ "Invalid sync link, sync link[%d]: %s sched_req->link_hdl: %x sync_links->link_hdl: 0x%x" ,
5407+ i , CAM_IS_NULL_TO_STR (sync_links [i ]),
5408+ sched_req -> link_hdls [i ],
5409+ ((!sync_links [i ]) ? CAM_REQ_MGR_DEFAULT_HDL_VAL :
5410+ sync_links [i ]-> link_hdl ));
5411+ rc = - EINVAL ;
5412+ goto end ;
5413+ }
53165414 }
5317- sched -> num_links = sched_req -> num_links ;
5415+ sched .num_links = sched_req -> num_links ;
5416+ sched .link_hdls = sched_req -> link_hdls ;
53185417 } else
5319- sched -> num_links = 0 ;
5418+ sched . num_links = 0 ;
53205419
5321- rc = cam_req_mgr_process_sched_req (link , & task_data );
5420+ rc = cam_req_mgr_process_sched_req (link , & sched );
53225421
53235422 CAM_DBG (CAM_REQ , "Open req %lld on link 0x%x with sync_mode %d" ,
53245423 sched_req -> req_id , sched_req -> link_hdl , sched_req -> sync_mode );
0 commit comments