Эх сурвалжийг харах

msm: camera: icp: Add support for multiple ICP hw mgr

To enable multiple HW MGRs, static icp hw mgr is an array
and no longer a singleton object. The hw managers share the
same function routines; thus, routines that assume singleton
hw mgr are changed to support input parameter hw mgr. Different
hw mgr has separate sets of hw ctx, clk/bw info, workq, iommu hdl
, hw intf, WD, debugfs, locks, etc. So, They can run simultaneously
and independently of one another.

Before hw mgr initit/deinit, map corresponding icp subdevice to
hw mgr based on cell index in DT.

Each hw mgr has its own debugfs that can be interacted by users
independently of others.

CRs-Fixed: 3336534
Change-Id: I1ac5e244c5219c2e8f0c46f44e9a8ba6da16cf99
Signed-off-by: Sokchetra Eung <[email protected]>
Sokchetra Eung 2 жил өмнө
parent
commit
e9524ed007

+ 3 - 3
drivers/cam_icp/cam_icp_subdev.c

@@ -332,7 +332,7 @@ static int cam_icp_component_bind(struct device *dev,
 	mutex_init(&icp_dev->icp_lock);
 
 	rc = cam_icp_hw_mgr_init(pdev->dev.of_node, (uint64_t *)(&hw_mgr_intf),
-		&iommu_hdl, cam_icp_dev_mini_dump_cb);
+		&iommu_hdl, cam_icp_dev_mini_dump_cb, device_idx);
 	if (rc) {
 		CAM_ERR(CAM_ICP, "device[%s] HW manager init failed: %d", subdev_name, rc);
 		goto hw_init_fail;
@@ -371,7 +371,7 @@ static int cam_icp_component_bind(struct device *dev,
 ctx_fail:
 	for (--i; i >= 0; i--)
 		cam_icp_context_deinit(&icp_dev->ctx_icp[i]);
-	cam_icp_hw_mgr_deinit();
+	cam_icp_hw_mgr_deinit(device_idx);
 hw_init_fail:
 	cam_subdev_remove(&icp_dev->sd);
 probe_fail:
@@ -415,7 +415,7 @@ static void cam_icp_component_unbind(struct device *dev,
 	for (i = 0; i < CAM_ICP_CTX_MAX; i++)
 		cam_icp_context_deinit(&icp_dev->ctx_icp[i]);
 
-	cam_icp_hw_mgr_deinit();
+	cam_icp_hw_mgr_deinit(device_idx);
 	cam_node_deinit(icp_dev->node);
 	cam_subdev_remove(&icp_dev->sd);
 	mutex_destroy(&icp_dev->icp_lock);

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 206 - 173
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c


+ 11 - 1
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.h

@@ -71,6 +71,8 @@
 /* Current appliacble vote paths, based on number of UAPI definitions */
 #define CAM_ICP_MAX_PER_PATH_VOTES 6
 
+#define CAM_ICP_HW_MGR_NAME_SIZE  32
+
 struct hfi_mini_dump_info;
 
 /**
@@ -266,6 +268,7 @@ struct cam_ctx_clk_info {
 /**
  * struct cam_icp_hw_ctx_data
  * @context_priv: Context private data
+ * @hw_mgr_priv: HW MGR of the context
  * @ctx_mutex: Mutex for context
  * @fw_handle: Firmware handle
  * @scratch_mem_size: Scratch memory size
@@ -293,6 +296,7 @@ struct cam_ctx_clk_info {
  */
 struct cam_icp_hw_ctx_data {
 	void *context_priv;
+	void *hw_mgr_priv;
 	struct mutex ctx_mutex;
 	uint32_t fw_handle;
 	uint32_t scratch_mem_size;
@@ -345,6 +349,7 @@ struct icp_cmd_generic_blob {
  * @hw_type: IPE/BPS device type
  * @watch_dog: watchdog timer handle
  * @watch_dog_reset_counter: Counter for watch dog reset
+ * @timeout_cb_data: private cb data to be used when device timeouts
  */
 struct cam_icp_clk_info {
 	uint32_t base_clk;
@@ -359,6 +364,7 @@ struct cam_icp_clk_info {
 	uint32_t hw_type;
 	struct cam_req_mgr_timer *watch_dog;
 	uint32_t watch_dog_reset_counter;
+	void *timeout_cb_data;
 };
 
 /**
@@ -369,6 +375,8 @@ struct cam_icp_clk_info {
  * @ctx_data: Context data
  * @icp_caps: ICP capabilities
  * @mini_dump_cb: Mini dump cb
+ * @hw_mgr_name: name of the hw mgr
+ * @hw_mgr_id: ID of the hw mgr, equivalent to hw mgr index
  * @icp_booted: Processor is booted i.e. firmware loaded
  * @icp_resumed: Processor is powered on
  * @iommu_hdl: Non secure IOMMU handle
@@ -426,6 +434,8 @@ struct cam_icp_hw_mgr {
 	struct cam_icp_hw_ctx_data ctx_data[CAM_ICP_CTX_MAX];
 	struct cam_icp_query_cap_cmd icp_caps;
 	cam_icp_mini_dump_cb mini_dump_cb;
+	char hw_mgr_name[CAM_ICP_HW_MGR_NAME_SIZE];
+	uint32_t hw_mgr_id;
 
 	bool icp_booted;
 	bool icp_resumed;
@@ -451,7 +461,7 @@ struct cam_icp_hw_mgr {
 	uint64_t icp_debug_clk;
 	uint64_t icp_default_clk;
 	struct cam_icp_clk_info clk_info[ICP_CLK_HW_MAX];
-	bool secure_mode;
+	uint32_t secure_mode;
 	bool icp_jtag_debug;
 	u64 icp_debug_type;
 	u64 icp_dbg_lvl;

+ 6 - 6
drivers/cam_icp/icp_hw/include/cam_icp_hw_mgr_intf.h

@@ -57,12 +57,6 @@ enum cam_icp_hw_error_type {
 typedef void(*cam_icp_mini_dump_cb)(void *priv,
 	void *args);
 
-int cam_icp_hw_mgr_init(struct device_node *of_node,
-	uint64_t *hw_mgr_hdl, int *iommu_hdl,
-	cam_icp_mini_dump_cb mini_dump_cb);
-
-void cam_icp_hw_mgr_deinit(void);
-
 /**
  * struct cam_icp_cpas_vote
  * @ahb_vote: AHB vote info
@@ -121,4 +115,10 @@ struct cam_icp_hw_error_evt_data {
 	enum cam_icp_hw_error_type     err_type;
 };
 
+int cam_icp_hw_mgr_init(struct device_node *of_node,
+	uint64_t *hw_mgr_hdl, int *iommu_hdl,
+	cam_icp_mini_dump_cb mini_dump_cb, int device_idx);
+
+void cam_icp_hw_mgr_deinit(int device_idx);
+
 #endif /* CAM_ICP_HW_MGR_INTF_H */

+ 7 - 4
drivers/cam_utils/cam_trace.h

@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #if !defined(_CAM_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
@@ -110,19 +111,21 @@ TRACE_EVENT(cam_log_debug,
 
 
 TRACE_EVENT(cam_icp_fw_dbg,
-	TP_PROTO(char *dbg_message, uint64_t timestamp),
-	TP_ARGS(dbg_message, timestamp),
+	TP_PROTO(char *dbg_message, uint64_t timestamp, char *dev_name),
+	TP_ARGS(dbg_message, timestamp, dev_name),
 	TP_STRUCT__entry(
 		__string(dbg_message, dbg_message)
 		__field(uint64_t, timestamp)
+		__string(dev_name, dev_name)
 	),
 	TP_fast_assign(
 		__assign_str(dbg_message, dbg_message);
 		__entry->timestamp = timestamp;
+		__assign_str(dev_name, dev_name);
 	),
 	TP_printk(
-		"%llu %s: ",
-		 __entry->timestamp, __get_str(dbg_message)
+		"[%s] %llu %s: ",
+		__get_str(dev_name), __entry->timestamp, __get_str(dbg_message)
 	)
 );
 

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно