Skip to content

Commit ebf3a6a

Browse files
Camera Software IntegrationGerrit - the friendly Code Review server
authored andcommitted
Merge "Merge tag 'camera-kernel.qclinux.1.0-251220' into 0.0" into camera-kernel.qclinux.0.0
2 parents 69b4d39 + af22dea commit ebf3a6a

7 files changed

Lines changed: 151 additions & 54 deletions

File tree

camera_kt/drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
33
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
55
*/
66

77
#include <linux/module.h>
@@ -155,14 +155,16 @@ static int cam_fd_mgr_util_get_ctx(
155155

156156
static int cam_fd_mgr_util_put_frame_req(
157157
struct list_head *src_list,
158-
struct cam_fd_mgr_frame_request **frame_req)
158+
struct cam_fd_mgr_frame_request **frame_req, bool free_buffer)
159159
{
160160
int rc = 0;
161161
struct cam_fd_mgr_frame_request *req_ptr = NULL;
162162

163163
mutex_lock(&g_fd_hw_mgr.frame_req_mutex);
164164
req_ptr = *frame_req;
165165
if (req_ptr) {
166+
if (free_buffer)
167+
cam_mem_put_cpu_buf(req_ptr->hw_update_entries[0].handle);
166168
list_del_init(&req_ptr->list);
167169
list_add_tail(&req_ptr->list, src_list);
168170
}
@@ -951,7 +953,7 @@ static int cam_fd_mgr_util_submit_frame(void *priv, void *data)
951953

952954
return rc;
953955
put_req_into_free_list:
954-
cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &frame_req);
956+
cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list, &frame_req, true);
955957

956958
return rc;
957959
}
@@ -1096,7 +1098,7 @@ static int32_t cam_fd_mgr_workq_irq_cb(void *priv, void *data)
10961098

10971099
put_req_in_free_list:
10981100
rc = cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
1099-
&frame_req);
1101+
&frame_req, true);
11001102
if (rc) {
11011103
CAM_ERR(CAM_FD, "Failed in putting frame req in free list");
11021104
/* continue */
@@ -1445,7 +1447,7 @@ static int cam_fd_mgr_hw_flush_req(void *hw_mgr_priv,
14451447
flush_req = (struct cam_fd_mgr_frame_request *)
14461448
flush_args->flush_req_pending[i];
14471449
cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
1448-
&flush_req);
1450+
&flush_req, true);
14491451
}
14501452

14511453
return rc;
@@ -1530,15 +1532,15 @@ static int cam_fd_mgr_hw_flush_ctx(void *hw_mgr_priv,
15301532
CAM_DBG(CAM_FD, "flush pending req %llu",
15311533
flush_req->request_id);
15321534
cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
1533-
&flush_req);
1535+
&flush_req, true);
15341536
}
15351537

15361538
for (i = 0; i < flush_args->num_req_active; i++) {
15371539
flush_req = (struct cam_fd_mgr_frame_request *)
15381540
flush_args->flush_req_active[i];
15391541
CAM_DBG(CAM_FD, "flush active req %llu", flush_req->request_id);
15401542
cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
1541-
&flush_req);
1543+
&flush_req, true);
15421544
}
15431545

15441546
return rc;
@@ -1921,11 +1923,11 @@ static int cam_fd_mgr_hw_config(void *hw_mgr_priv, void *hw_config_args)
19211923
if (hw_ctx->priority == CAM_FD_PRIORITY_HIGH) {
19221924
CAM_DBG(CAM_FD, "Insert frame into prio0 queue");
19231925
rc = cam_fd_mgr_util_put_frame_req(
1924-
&hw_mgr->frame_pending_list_high, &frame_req);
1926+
&hw_mgr->frame_pending_list_high, &frame_req, false);
19251927
} else {
19261928
CAM_DBG(CAM_FD, "Insert frame into prio1 queue");
19271929
rc = cam_fd_mgr_util_put_frame_req(
1928-
&hw_mgr->frame_pending_list_normal, &frame_req);
1930+
&hw_mgr->frame_pending_list_normal, &frame_req, false);
19291931
}
19301932
if (rc) {
19311933
CAM_ERR(CAM_FD, "Failed in queuing frame req, rc=%d", rc);
@@ -1964,7 +1966,7 @@ static int cam_fd_mgr_hw_config(void *hw_mgr_priv, void *hw_config_args)
19641966
mutex_unlock(&g_fd_hw_mgr.frame_req_mutex);
19651967
put_free_list:
19661968
cam_fd_mgr_util_put_frame_req(&hw_mgr->frame_free_list,
1967-
&frame_req);
1969+
&frame_req, true);
19681970

19691971
return rc;
19701972
}

camera_kt/drivers/cam_isp/cam_isp_context.c

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,32 @@ static const char *__cam_isp_evt_val_to_type(
6060
}
6161
}
6262

63+
static inline void __cam_isp_ctx_move_req_to_free_list(
64+
struct cam_context *ctx, struct cam_ctx_request *req)
65+
{
66+
struct cam_isp_ctx_req *req_isp;
67+
struct cam_kmd_buf_info *kmd_cmd_buff_info;
68+
int32_t handle;
69+
70+
if (!req || !ctx) {
71+
CAM_ERR(CAM_ISP, "Invalid args");
72+
return;
73+
}
74+
75+
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
76+
kmd_cmd_buff_info = &(req_isp->hw_update_data.kmd_cmd_buff_info);
77+
handle = kmd_cmd_buff_info->handle;
78+
79+
CAM_DBG(CAM_ISP,
80+
"Free req id: %lld, ctx_idx: %u, link: 0x%x",
81+
req->request_id, ctx->ctx_id, ctx->link_hdl);
82+
83+
if (handle > 0)
84+
cam_mem_put_kref(handle);
85+
86+
list_add_tail(&req->list, &ctx->free_req_list);
87+
}
88+
6389
static void __cam_isp_ctx_update_event_record(
6490
struct cam_isp_context *ctx_isp,
6591
enum cam_isp_ctx_event event,
@@ -511,7 +537,7 @@ static int __cam_isp_ctx_enqueue_init_request(
511537

512538
req_old->request_id = req->request_id;
513539

514-
list_add_tail(&req->list, &ctx->free_req_list);
540+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
515541
}
516542
} else {
517543
CAM_WARN(CAM_ISP,
@@ -842,7 +868,7 @@ static int __cam_isp_ctx_handle_buf_done_for_req_list(
842868
CAM_SYNC_STATE_SIGNALED_ERROR,
843869
CAM_SYNC_ISP_EVENT_BUBBLE);
844870

845-
list_add_tail(&req->list, &ctx->free_req_list);
871+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
846872
CAM_DBG(CAM_REQ,
847873
"Move active request %lld to free list(cnt = %d) [flushed], ctx %u",
848874
buf_done_req_id, ctx_isp->active_req_cnt,
@@ -865,7 +891,7 @@ static int __cam_isp_ctx_handle_buf_done_for_req_list(
865891
}
866892
}
867893
list_del_init(&req->list);
868-
list_add_tail(&req->list, &ctx->free_req_list);
894+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
869895
req_isp->reapply = false;
870896
req_isp->cdm_reset_before_apply = false;
871897
req_isp->num_acked = 0;
@@ -1818,7 +1844,7 @@ static int __cam_isp_ctx_reg_upd_in_applied_state(
18181844
CAM_ISP_CTX_EVENT_RUP, req);
18191845
} else {
18201846
/* no io config, so the request is completed. */
1821-
list_add_tail(&req->list, &ctx->free_req_list);
1847+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
18221848
CAM_DBG(CAM_ISP,
18231849
"move active request %lld to free list(cnt = %d), ctx %u",
18241850
req->request_id, ctx_isp->active_req_cnt, ctx->ctx_id);
@@ -2105,7 +2131,7 @@ static int __cam_isp_ctx_reg_upd_in_sof(struct cam_isp_context *ctx_isp,
21052131
list_del_init(&req->list);
21062132
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
21072133
if (req_isp->num_fence_map_out == req_isp->num_acked)
2108-
list_add_tail(&req->list, &ctx->free_req_list);
2134+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
21092135
else
21102136
CAM_ERR(CAM_ISP,
21112137
"receive rup in unexpected state");
@@ -2622,7 +2648,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
26222648
}
26232649
}
26242650
list_del_init(&req->list);
2625-
list_add_tail(&req->list, &ctx->free_req_list);
2651+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
26262652
ctx_isp->active_req_cnt--;
26272653
} else {
26282654
found = 1;
@@ -2654,7 +2680,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
26542680
}
26552681
}
26562682
list_del_init(&req->list);
2657-
list_add_tail(&req->list, &ctx->free_req_list);
2683+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
26582684
ctx_isp->active_req_cnt--;
26592685
} else {
26602686
found = 1;
@@ -2717,7 +2743,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
27172743
req_isp->fence_map_out[i].sync_id = -1;
27182744
}
27192745
list_del_init(&req->list);
2720-
list_add_tail(&req->list, &ctx->free_req_list);
2746+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
27212747

27222748
} while (req->request_id < ctx_isp->last_applied_req_id);
27232749

@@ -2926,7 +2952,7 @@ static int __cam_isp_ctx_fs2_reg_upd_in_sof(struct cam_isp_context *ctx_isp,
29262952
list_del_init(&req->list);
29272953
req_isp = (struct cam_isp_ctx_req *) req->req_priv;
29282954
if (req_isp->num_fence_map_out == req_isp->num_acked)
2929-
list_add_tail(&req->list, &ctx->free_req_list);
2955+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
29302956
else
29312957
CAM_ERR(CAM_ISP,
29322958
"receive rup in unexpected state");
@@ -2966,7 +2992,7 @@ static int __cam_isp_ctx_fs2_reg_upd_in_applied_state(
29662992
req->request_id, ctx_isp->active_req_cnt);
29672993
} else {
29682994
/* no io config, so the request is completed. */
2969-
list_add_tail(&req->list, &ctx->free_req_list);
2995+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
29702996
}
29712997

29722998
/*
@@ -3745,7 +3771,7 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
37453771
req_isp->reapply = false;
37463772
req_isp->cdm_reset_before_apply = false;
37473773
list_del_init(&req->list);
3748-
list_add_tail(&req->list, &ctx->free_req_list);
3774+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
37493775
}
37503776

37513777
return 0;
@@ -4283,7 +4309,7 @@ static int __cam_isp_ctx_rdi_only_sof_in_bubble_state(
42834309
CAM_SYNC_STATE_SIGNALED_ERROR,
42844310
CAM_SYNC_ISP_EVENT_BUBBLE);
42854311
}
4286-
list_add_tail(&req->list, &ctx->free_req_list);
4312+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
42874313
ctx_isp->active_req_cnt--;
42884314
}
42894315

@@ -4375,7 +4401,7 @@ static int __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state(
43754401
request_id = req->request_id;
43764402
} else {
43774403
/* no io config, so the request is completed. */
4378-
list_add_tail(&req->list, &ctx->free_req_list);
4404+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
43794405
CAM_DBG(CAM_ISP,
43804406
"move active req %lld to free list(cnt=%d)",
43814407
req->request_id, ctx_isp->active_req_cnt);
@@ -4456,7 +4482,7 @@ static int __cam_isp_ctx_rdi_only_reg_upd_in_applied_state(
44564482
CAM_ISP_CTX_EVENT_RUP, req);
44574483
} else {
44584484
/* no io config, so the request is completed. */
4459-
list_add_tail(&req->list, &ctx->free_req_list);
4485+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
44604486
CAM_DBG(CAM_ISP,
44614487
"move active request %lld to free list(cnt = %d), ctx %u",
44624488
req->request_id, ctx_isp->active_req_cnt, ctx->ctx_id);
@@ -4956,7 +4982,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
49564982
}
49574983
free_req:
49584984
spin_lock_bh(&ctx->lock);
4959-
list_add_tail(&req->list, &ctx->free_req_list);
4985+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
49604986
spin_unlock_bh(&ctx->lock);
49614987

49624988
cam_mem_put_cpu_buf((int32_t) cmd->packet_handle);
@@ -5673,7 +5699,7 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
56735699
list_del_init(&req->list);
56745700

56755701
if (ctx_isp->offline_context && !req_isp->num_fence_map_out) {
5676-
list_add_tail(&req->list, &ctx->free_req_list);
5702+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
56775703
atomic_set(&ctx_isp->rxd_epoch, 1);
56785704
CAM_DBG(CAM_REQ,
56795705
"Move pending req: %lld to free list(cnt: %d) offline ctx %u",
@@ -5792,7 +5818,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
57925818
CAM_SYNC_STATE_SIGNALED_CANCEL,
57935819
CAM_SYNC_ISP_EVENT_HW_STOP);
57945820
}
5795-
list_add_tail(&req->list, &ctx->free_req_list);
5821+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
57965822
}
57975823

57985824
while (!list_empty(&ctx->wait_req_list)) {
@@ -5809,7 +5835,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
58095835
CAM_SYNC_STATE_SIGNALED_CANCEL,
58105836
CAM_SYNC_ISP_EVENT_HW_STOP);
58115837
}
5812-
list_add_tail(&req->list, &ctx->free_req_list);
5838+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
58135839
}
58145840

58155841
while (!list_empty(&ctx->active_req_list)) {
@@ -5826,7 +5852,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
58265852
CAM_SYNC_STATE_SIGNALED_CANCEL,
58275853
CAM_SYNC_ISP_EVENT_HW_STOP);
58285854
}
5829-
list_add_tail(&req->list, &ctx->free_req_list);
5855+
__cam_isp_ctx_move_req_to_free_list(ctx, req);
58305856
}
58315857

58325858
ctx_isp->frame_id = 0;

camera_kt/drivers/cam_isp/isp_hw_mgr/include/cam_isp_hw_mgr_intf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
33
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
4+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
45
*/
56

67
#ifndef _CAM_ISP_HW_MGR_INTF_H_
@@ -11,6 +12,7 @@
1112
#include <linux/list.h>
1213
#include <media/cam_isp.h>
1314
#include "cam_hw_mgr_intf.h"
15+
#include "cam_packet_util.h"
1416

1517
/* MAX IFE instance */
1618
#define CAM_IFE_HW_NUM_MAX 7
@@ -134,6 +136,7 @@ struct cam_isp_bw_config_internal {
134136
* @reg_dump_buf_desc: cmd buffer descriptors for reg dump
135137
* @num_reg_dump_buf: Count of descriptors in reg_dump_buf_desc
136138
* @packet CSL packet from user mode driver
139+
* @kmd_cmd_buff_info: reference to kmd buffer
137140
*
138141
*/
139142
struct cam_isp_prepare_hw_update_data {
@@ -150,6 +153,7 @@ struct cam_isp_prepare_hw_update_data {
150153
CAM_REG_DUMP_MAX_BUF_ENTRIES];
151154
uint32_t num_reg_dump_buf;
152155
struct cam_packet *packet;
156+
struct cam_kmd_buf_info kmd_cmd_buff_info;
153157
};
154158

155159

0 commit comments

Comments
 (0)