Browse Source

msm: camera: cre: add degug fs entry to update clock rate

This change adds a debug fs entry to run cre on specified
clock.

CRs-Fixed: 3056442
Change-Id: I85bcdfa90ceae6dac5e23b87e1338cd3f3092fa6
Signed-off-by: Vikram Sharma <[email protected]>
Vikram Sharma 3 years ago
parent
commit
5ea2e174a8

+ 46 - 0
drivers/cam_cre/cam_cre_hw_mgr/cam_cre_hw_mgr.c

@@ -33,6 +33,24 @@
 
 static struct cam_cre_hw_mgr *cre_hw_mgr;
 
+static bool cam_cre_debug_clk_update(struct cam_cre_clk_info *hw_mgr_clk_info)
+{
+	if (cre_hw_mgr.cre_debug_clk &&
+		cre_hw_mgr.cre_debug_clk != hw_mgr_clk_info->curr_clk) {
+		hw_mgr_clk_info->base_clk = cre_hw_mgr.cre_debug_clk;
+		hw_mgr_clk_info->curr_clk = cre_hw_mgr.cre_debug_clk;
+		hw_mgr_clk_info->uncompressed_bw = cre_hw_mgr.cre_debug_clk;
+		hw_mgr_clk_info->compressed_bw = cre_hw_mgr.cre_debug_clk;
+		CAM_DBG(CAM_PERF, "bc = %d cc = %d ub %d cb %d",
+			hw_mgr_clk_info->base_clk, hw_mgr_clk_info->curr_clk,
+			hw_mgr_clk_info->uncompressed_bw,
+			hw_mgr_clk_info->compressed_bw);
+		return true;
+	}
+
+	return false;
+}
+
 static struct cam_cre_io_buf_info *cam_cre_mgr_get_rsc(
 	struct cam_cre_ctx *ctx_data,
 	struct cam_buf_io_cfg *in_io_buf)
@@ -1200,6 +1218,9 @@ static bool cam_cre_check_clk_update(struct cam_cre_hw_mgr *hw_mgr,
 		clk_info->frame_cycles, clk_info->budget_ns);
 	ctx_data->clk_info.rt_flag = clk_info->rt_flag;
 
+	if (cre_hw_mgr.cre_debug_clk)
+		return cam_cre_debug_clk_update(hw_mgr_clk_info);
+
 	if (busy)
 		rc = cam_cre_update_clk_busy(hw_mgr, ctx_data,
 			hw_mgr_clk_info, clk_info, base_clk);
@@ -2869,6 +2890,15 @@ static int cam_cre_create_debug_fs(void)
 		goto err;
 	}
 
+	dbgfileptr = debugfs_create_file("cre_debug_clk", 0644,
+		cre_hw_mgr.dentry, NULL, &cam_cre_debug_default_clk);
+
+	if (IS_ERR(dbgfileptr)) {
+		if (PTR_ERR(dbgfileptr) == -ENODEV)
+			CAM_WARN(CAM_CRE, "DebugFS not enabled in kernel!");
+		else
+			rc = PTR_ERR(dbgfileptr);
+	}
 	return 0;
 err:
 	debugfs_remove_recursive(cre_hw_mgr->dentry);
@@ -2999,3 +3029,19 @@ cre_ctx_bitmap_failed:
 
 	return rc;
 }
+
+static int cam_cre_set_dbg_default_clk(void *data, u64 val)
+{
+	cre_hw_mgr.cre_debug_clk = val;
+	return 0;
+}
+
+static int cam_cre_get_dbg_default_clk(void *data, u64 *val)
+{
+	*val = cre_hw_mgr.cre_debug_clk;
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(cam_cre_debug_default_clk,
+	cam_cre_get_dbg_default_clk,
+	cam_cre_set_dbg_default_clk, "%16llu");

+ 1 - 0
drivers/cam_cre/cam_cre_hw_mgr/cam_cre_hw_mgr.h

@@ -370,6 +370,7 @@ struct cam_cre_hw_mgr {
 	int32_t       iommu_hdl;
 	int32_t       iommu_sec_hdl;
 	uint32_t      num_cre;
+	uint64_t      cre_debug_clk;
 	bool          secure_mode;
 	void    *ctx_bitmap;
 	size_t   ctx_bitmap_size;