Skip to content

Commit 163b184

Browse files
Camera Software IntegrationGerrit - the friendly Code Review server
authored andcommitted
Merge "msm: camera: tpg: fix issue when create debugfs for tpg" into camera-kernel.qclinux.1.0
2 parents 3fa905f + 1b69df1 commit 163b184

5 files changed

Lines changed: 99 additions & 34 deletions

File tree

camera/drivers/cam_sensor_module/cam_tpg/cam_tpg_dev.c

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,32 @@ static int tpg_register_cpas_client(struct cam_tpg_device *tpg_dev,
252252
return rc;
253253
}
254254

255+
static int cam_tpg_hw_queue_init(struct cam_tpg_device *tpg_dev)
256+
{
257+
/* Initialize only the essential components needed for safe operation */
258+
259+
/* Initialize locks */
260+
spin_lock_init(&tpg_dev->tpg_hw.hw_state_lock);
261+
mutex_init(&tpg_dev->tpg_hw.mutex);
262+
263+
/* Set TPG initial state */
264+
tpg_dev->tpg_hw.state = TPG_HW_STATE_HW_DISABLED;
265+
266+
/* Initialize completion */
267+
init_completion(&tpg_dev->tpg_hw.complete_rup);
268+
269+
/* Initialize queues */
270+
INIT_LIST_HEAD(&(tpg_dev->tpg_hw.waiting_request_q));
271+
INIT_LIST_HEAD(&(tpg_dev->tpg_hw.active_request_q));
272+
tpg_dev->tpg_hw.waiting_request_q_depth = 0;
273+
tpg_dev->tpg_hw.active_request_q_depth = 0;
274+
tpg_dev->tpg_hw.settings_update = 0;
275+
tpg_dev->tpg_hw.tpg_clock = 0;
276+
277+
return 0;
278+
}
279+
280+
255281
static int cam_tpg_hw_layer_init(struct cam_tpg_device *tpg_dev,
256282
struct device *dev)
257283
{
@@ -270,17 +296,8 @@ static int cam_tpg_hw_layer_init(struct cam_tpg_device *tpg_dev,
270296
tpg_dev->tpg_hw.hw_info = (struct tpg_hw_info *)match_dev->data;
271297
tpg_dev->tpg_hw.soc_info = &tpg_dev->soc_info;
272298
tpg_dev->tpg_hw.cpas_handle = tpg_dev->cpas_handle;
273-
spin_lock_init(&tpg_dev->tpg_hw.hw_state_lock);
274-
tpg_dev->tpg_hw.state = TPG_HW_STATE_HW_DISABLED;
275-
mutex_init(&tpg_dev->tpg_hw.mutex);
276-
init_completion(&tpg_dev->tpg_hw.complete_rup);
277-
/*Initialize the waiting queue and active queues*/
278-
INIT_LIST_HEAD(&(tpg_dev->tpg_hw.waiting_request_q));
279-
INIT_LIST_HEAD(&(tpg_dev->tpg_hw.active_request_q));
280-
tpg_dev->tpg_hw.waiting_request_q_depth = 0;
281-
tpg_dev->tpg_hw.active_request_q_depth = 0;
282-
tpg_dev->tpg_hw.settings_update = 0;
283-
tpg_dev->tpg_hw.tpg_clock = 0;
299+
300+
/* Call layer_init */
284301
tpg_dev->tpg_hw.hw_info->layer_init(&tpg_dev->tpg_hw);
285302
return 0;
286303
}
@@ -305,9 +322,9 @@ static int cam_tpg_component_bind(struct device *dev,
305322
tpg_dev->tpg_subdev.pdev = pdev;
306323
tpg_dev->state = CAM_TPG_STATE_INIT;
307324

308-
rc = cam_tpg_hw_layer_init(tpg_dev, dev);
325+
rc = cam_tpg_hw_queue_init(tpg_dev);
309326
if (rc < 0) {
310-
CAM_ERR(CAM_TPG, "Hw layer init failed");
327+
CAM_ERR(CAM_TPG, "Mutex and queue init failed");
311328
goto bind_error_exit;
312329
}
313330

@@ -328,8 +345,15 @@ static int cam_tpg_component_bind(struct device *dev,
328345
CAM_ERR(CAM_TPG, "cpas register failed");
329346
goto release_subdev;
330347
}
348+
331349
tpg_crm_intf_init(tpg_dev);
332350

351+
rc = cam_tpg_hw_layer_init(tpg_dev, dev);
352+
if (rc < 0) {
353+
CAM_ERR(CAM_TPG, "Hw layer init failed");
354+
goto release_subdev;
355+
}
356+
333357
platform_set_drvdata(pdev, tpg_dev);
334358

335359
return rc;
@@ -354,6 +378,9 @@ static void cam_tpg_component_unbind(struct device *dev,
354378
return;
355379
}
356380

381+
/* Clean up debugfs entries */
382+
tpg_hw_debugfs_cleanup(&tpg_dev->tpg_hw);
383+
357384
CAM_INFO(CAM_TPG, "Unbind TPG component");
358385
cam_cpas_unregister_client(tpg_dev->cpas_handle);
359386
cam_soc_util_release_platform_resource(&tpg_dev->soc_info);

camera/drivers/cam_sensor_module/cam_tpg/tpg_hw/tpg_hw.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
44
* Copyright (c) 2021-2024, Qualcomm Innovation Center, Inc. All rights reserved.
5+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
56
*/
67

78
#include "tpg_hw.h"
@@ -1454,3 +1455,19 @@ int tpg_hw_add_stream_v3(
14541455
return rc;
14551456
}
14561457

1458+
int tpg_hw_debugfs_cleanup(struct tpg_hw *hw)
1459+
{
1460+
if (!hw) {
1461+
CAM_ERR(CAM_TPG, "Invalid hw pointer");
1462+
return -EINVAL;
1463+
}
1464+
1465+
if (hw->debugfs_root) {
1466+
CAM_INFO(CAM_TPG, "Removing debugfs directory for tpg%d", hw->hw_idx);
1467+
debugfs_remove_recursive(hw->debugfs_root);
1468+
hw->debugfs_root = NULL;
1469+
}
1470+
1471+
return 0;
1472+
}
1473+

camera/drivers/cam_sensor_module/cam_tpg/tpg_hw/tpg_hw.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33
* Copyright (c) 2021, The Linux Foundation. All rights reserved.
44
* Copyright (c) 2021-2024, Qualcomm Innovation Center, Inc. All rights reserved.
5+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
56
*/
67

78
#ifndef __TPG_HW_H__
@@ -204,6 +205,8 @@ struct tpg_hw {
204205
uint32_t active_request_q_depth;
205206
uint32_t waiting_request_q_depth;
206207
uint32_t settings_update;
208+
/* debugfs root directory */
209+
struct dentry *debugfs_root;
207210
};
208211

209212
/**
@@ -533,4 +536,13 @@ int tpg_hw_request_set_opcode(
533536
*/
534537
int tpg_hw_copy_settings_config(struct tpg_hw *hw, struct tpg_settings_config_t *settings);
535538

539+
/**
540+
* @brief : cleanup debugfs entries for tpg hw
541+
*
542+
* @param hw: tpg hw instance
543+
*
544+
* @return : 0 on success
545+
*/
546+
int tpg_hw_debugfs_cleanup(struct tpg_hw *hw);
547+
536548
#endif

camera/drivers/cam_sensor_module/cam_tpg/tpg_hw/tpg_hw_v_1_3/tpg_hw_v_1_3.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
44
* Copyright (c) 2021-2024, Qualcomm Innovation Center, Inc. All rights reserved.
5+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
56
*/
67

78
#include "tpg_hw_v_1_3.h"
@@ -864,27 +865,31 @@ DEFINE_SIMPLE_ATTRIBUTE(tpg_1_3_shdr_line_offset1,
864865
int tpg_1_3_layer_init(struct tpg_hw *hw)
865866
{
866867
int rc = 0;
867-
struct dentry *dbgfileptr_parent = NULL;
868868
char dir_name[160];
869869

870870
snprintf(dir_name, sizeof(dir_name), "tpg%d",
871871
hw->hw_idx);
872872

873-
dbgfileptr_parent = debugfs_create_dir(dir_name, NULL);
874-
if (!dbgfileptr_parent) {
875-
CAM_ERR(CAM_TPG, "Debug fs could not create directory");
876-
rc = -ENOENT;
873+
/* Store the debugfs root directory */
874+
hw->debugfs_root = debugfs_create_dir(dir_name, NULL);
875+
if (!hw->debugfs_root) {
876+
CAM_ERR(CAM_TPG, "Debugfs could not create directory '%s'", dir_name);
877+
return -ENOENT;
877878
}
879+
880+
/* Create debugfs entries */
878881
debugfs_create_file("tpg_xcfa_test", 0644,
879-
dbgfileptr_parent, hw, &tpg_1_3_xcfa_test);
882+
hw->debugfs_root, hw, &tpg_1_3_xcfa_test);
880883
debugfs_create_file("tpg_shdr_overlap_test", 0644,
881-
dbgfileptr_parent, hw, &tpg_1_3_shdr_overlap_test);
884+
hw->debugfs_root, hw, &tpg_1_3_shdr_overlap_test);
882885
debugfs_create_file("tpg_shdr_offset_num_batch", 0644,
883-
dbgfileptr_parent, hw, &tpg_1_3_shdr_offset_num_batch);
886+
hw->debugfs_root, hw, &tpg_1_3_shdr_offset_num_batch);
884887
debugfs_create_file("tpg_shdr_line_offset0", 0644,
885-
dbgfileptr_parent, hw, &tpg_1_3_shdr_line_offset0);
888+
hw->debugfs_root, hw, &tpg_1_3_shdr_line_offset0);
886889
debugfs_create_file("tpg_shdr_line_offset1", 0644,
887-
dbgfileptr_parent, hw, &tpg_1_3_shdr_line_offset1);
890+
hw->debugfs_root, hw, &tpg_1_3_shdr_line_offset1);
891+
888892
CAM_INFO(CAM_TPG, "Layer init called");
893+
889894
return rc;
890895
}

camera/drivers/cam_sensor_module/cam_tpg/tpg_hw/tpg_hw_v_1_4/tpg_hw_v_1_4.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/*
33
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
44
* Copyright (c) 2021-2024, Qualcomm Innovation Center, Inc. All rights reserved.
5+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
56
*/
67

78
#include "tpg_hw_v_1_4.h"
@@ -931,28 +932,31 @@ DEFINE_SIMPLE_ATTRIBUTE(tpg_1_4_shdr_line_offset1,
931932
int tpg_1_4_layer_init(struct tpg_hw *hw)
932933
{
933934
int rc = 0;
934-
struct dentry *dbgfileptr_parent = NULL;
935935
char dir_name[160];
936936

937937
snprintf(dir_name, sizeof(dir_name), "tpg%d",
938938
hw->hw_idx);
939939

940-
dbgfileptr_parent = debugfs_create_dir(dir_name, NULL);
941-
if (!dbgfileptr_parent) {
942-
CAM_ERR(CAM_TPG, "Debug fs could not create directory");
943-
rc = -ENOENT;
944-
return rc;
940+
/* Store the debugfs root directory */
941+
hw->debugfs_root = debugfs_create_dir(dir_name, NULL);
942+
if (!hw->debugfs_root) {
943+
CAM_ERR(CAM_TPG, "Debugfs could not create directory '%s'", dir_name);
944+
return -ENOENT;
945945
}
946+
947+
/* Create debugfs entries */
946948
debugfs_create_file("tpg_xcfa_test", 0644,
947-
dbgfileptr_parent, hw, &tpg_1_4_xcfa_test);
949+
hw->debugfs_root, hw, &tpg_1_4_xcfa_test);
948950
debugfs_create_file("tpg_shdr_overlap_test", 0644,
949-
dbgfileptr_parent, hw, &tpg_1_4_shdr_overlap_test);
951+
hw->debugfs_root, hw, &tpg_1_4_shdr_overlap_test);
950952
debugfs_create_file("tpg_shdr_offset_num_batch", 0644,
951-
dbgfileptr_parent, hw, &tpg_1_4_shdr_offset_num_batch);
953+
hw->debugfs_root, hw, &tpg_1_4_shdr_offset_num_batch);
952954
debugfs_create_file("tpg_shdr_line_offset0", 0644,
953-
dbgfileptr_parent, hw, &tpg_1_4_shdr_line_offset0);
955+
hw->debugfs_root, hw, &tpg_1_4_shdr_line_offset0);
954956
debugfs_create_file("tpg_shdr_line_offset1", 0644,
955-
dbgfileptr_parent, hw, &tpg_1_4_shdr_line_offset1);
957+
hw->debugfs_root, hw, &tpg_1_4_shdr_line_offset1);
958+
956959
CAM_INFO(CAM_TPG, "Layer init called");
960+
957961
return rc;
958962
}

0 commit comments

Comments
 (0)