Jelajahi Sumber

msm: camera: icp: Fix HFI error logging

This fix addresses the current problem of ICP communicating through HFI
prior to HFI being set up.

CRs-Fixed: 3130279
Change-Id: I306b6dd85eb08b7c5c6f49f9f2aad05a42b394bc
Signed-off-by: Li Sha Lim <[email protected]>
Li Sha Lim 3 tahun lalu
induk
melakukan
477dbfc187

+ 11 - 0
drivers/cam_icp/icp_hw/a5_hw/a5_core.c

@@ -222,6 +222,7 @@ int cam_a5_init_hw(void *device_priv,
 	struct cam_icp_cpas_vote cpas_vote;
 	unsigned long flags;
 	int rc = 0;
+	bool send_freq_info = (init_hw_args == NULL) ? false : *((bool *)init_hw_args);
 
 	if (!device_priv) {
 		CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
@@ -285,6 +286,12 @@ int cam_a5_init_hw(void *device_priv,
 			cam_io_w_mb(a5_soc_info->a5_qos_val,
 				soc_info->reg_map[A5_SIERRA_BASE].mem_base +
 				ICP_SIERRA_A5_CSR_ACCESS);
+		if (send_freq_info) {
+			int32_t clk_rate = 0;
+
+			clk_rate = clk_get_rate(soc_info->clk[soc_info->src_clk_idx]);
+			hfi_send_freq_info(clk_rate);
+		}
 	}
 
 	spin_lock_irqsave(&a5_dev->hw_lock, flags);
@@ -303,6 +310,7 @@ int cam_a5_deinit_hw(void *device_priv,
 	struct cam_a5_device_core_info *core_info = NULL;
 	unsigned long flags;
 	int rc = 0;
+	bool send_freq_info = (init_hw_args == NULL) ? false : *((bool *)init_hw_args);
 
 	if (!device_priv) {
 		CAM_ERR(CAM_ICP, "Invalid cam_dev_info");
@@ -324,6 +332,9 @@ int cam_a5_deinit_hw(void *device_priv,
 	}
 	spin_unlock_irqrestore(&a5_dev->hw_lock, flags);
 
+	if (send_freq_info)
+		hfi_send_freq_info(0);
+
 	rc = cam_a5_disable_soc_resources(soc_info);
 	if (rc)
 		CAM_ERR(CAM_ICP, "soc disable is failed: %d", rc);

+ 1 - 8
drivers/cam_icp/icp_hw/a5_hw/a5_soc.c

@@ -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.
  */
 
 #include <linux/io.h>
@@ -193,12 +194,6 @@ int cam_a5_enable_soc_resources(struct cam_hw_soc_info *soc_info)
 		CAM_SVS_VOTE, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "enable platform failed");
-	else {
-		int32_t clk_rate = 0;
-
-		clk_rate = clk_get_rate(soc_info->clk[soc_info->src_clk_idx]);
-		hfi_send_freq_info(clk_rate);
-	}
 
 	return rc;
 }
@@ -210,8 +205,6 @@ int cam_a5_disable_soc_resources(struct cam_hw_soc_info *soc_info)
 	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "disable platform failed");
-	else
-		hfi_send_freq_info(0);
 
 	return rc;
 }

+ 6 - 2
drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c

@@ -3547,6 +3547,7 @@ static int cam_icp_mgr_icp_power_collapse(struct cam_icp_hw_mgr *hw_mgr)
 {
 	struct cam_hw_intf *icp_dev_intf = hw_mgr->icp_dev_intf;
 	int rc;
+	bool send_freq_info = true;
 
 	CAM_DBG(CAM_PERF, "ENTER");
 
@@ -3557,7 +3558,8 @@ static int cam_icp_mgr_icp_power_collapse(struct cam_icp_hw_mgr *hw_mgr)
 
 	rc = __power_collapse(hw_mgr);
 
-	if (icp_dev_intf->hw_ops.deinit(icp_dev_intf->hw_priv, NULL, 0))
+	if (icp_dev_intf->hw_ops.deinit(icp_dev_intf->hw_priv, (void *)&send_freq_info,
+		sizeof(send_freq_info)))
 		CAM_ERR(CAM_ICP, "Failed in icp deinit");
 
 	CAM_DBG(CAM_PERF, "EXIT");
@@ -4351,6 +4353,7 @@ static int cam_icp_mgr_icp_resume(struct cam_icp_hw_mgr *hw_mgr)
 	int rc = 0;
 	struct cam_hw_intf *icp_dev_intf = hw_mgr->icp_dev_intf;
 	bool downloadFromResume = true;
+	bool send_freq_info = true;
 
 	CAM_DBG(CAM_ICP, "Enter");
 
@@ -4364,7 +4367,8 @@ static int cam_icp_mgr_icp_resume(struct cam_icp_hw_mgr *hw_mgr)
 		return cam_icp_mgr_hw_open_k(hw_mgr, &downloadFromResume);
 	}
 
-	rc = icp_dev_intf->hw_ops.init(icp_dev_intf->hw_priv, NULL, 0);
+	rc = icp_dev_intf->hw_ops.init(icp_dev_intf->hw_priv, &send_freq_info,
+		sizeof(send_freq_info));
 	if (rc)
 		return -EINVAL;
 

+ 12 - 0
drivers/cam_icp/icp_hw/lx7_hw/lx7_core.c

@@ -229,6 +229,7 @@ int cam_lx7_hw_init(void *priv, void *args, uint32_t arg_size)
 	struct cam_hw_info *lx7 = priv;
 	unsigned long flags;
 	int rc;
+	bool send_freq_info = (args == NULL) ? false : *((bool *)args);
 
 	if (!lx7) {
 		CAM_ERR(CAM_ICP, "LX7 device info cannot be NULL");
@@ -250,6 +251,13 @@ int cam_lx7_hw_init(void *priv, void *args, uint32_t arg_size)
 	if (rc) {
 		CAM_ERR(CAM_ICP, "failed to enable soc resources rc=%d", rc);
 		goto soc_fail;
+	} else {
+		if (send_freq_info) {
+			int32_t clk_rate = 0;
+
+			clk_rate = clk_get_rate(lx7->soc_info.clk[lx7->soc_info.src_clk_idx]);
+			hfi_send_freq_info(clk_rate);
+		}
 	}
 
 	spin_lock_irqsave(&lx7->hw_lock, flags);
@@ -268,6 +276,7 @@ int cam_lx7_hw_deinit(void *priv, void *args, uint32_t arg_size)
 	struct cam_hw_info *lx7_info = priv;
 	unsigned long flags;
 	int rc;
+	bool send_freq_info = (args == NULL) ? false : *((bool *)args);
 
 	if (!lx7_info) {
 		CAM_ERR(CAM_ICP, "LX7 device info cannot be NULL");
@@ -281,6 +290,9 @@ int cam_lx7_hw_deinit(void *priv, void *args, uint32_t arg_size)
 	}
 	spin_unlock_irqrestore(&lx7_info->hw_lock, flags);
 
+	if (send_freq_info)
+		hfi_send_freq_info(0);
+
 	rc = cam_lx7_soc_resources_disable(&lx7_info->soc_info);
 	if (rc)
 		CAM_WARN(CAM_ICP,

+ 1 - 8
drivers/cam_icp/icp_hw/lx7_hw/lx7_soc.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/interrupt.h>
@@ -142,12 +143,6 @@ int cam_lx7_soc_resources_enable(struct cam_hw_soc_info *soc_info)
 						CAM_SVS_VOTE, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "failed to enable soc resources rc=%d", rc);
-	else {
-		int32_t clk_rate = 0;
-
-		clk_rate = clk_get_rate(soc_info->clk[soc_info->src_clk_idx]);
-		hfi_send_freq_info(clk_rate);
-	}
 
 	return rc;
 }
@@ -159,8 +154,6 @@ int cam_lx7_soc_resources_disable(struct cam_hw_soc_info *soc_info)
 	rc = cam_soc_util_disable_platform_resource(soc_info, true, true);
 	if (rc)
 		CAM_ERR(CAM_ICP, "failed to disable soc resources rc=%d", rc);
-	else
-		hfi_send_freq_info(0);
 
 	return rc;
 }