From 692d184a62181624590b3681de50e3bdc4ec65b7 Mon Sep 17 00:00:00 2001 From: Jigarkumar Zala Date: Mon, 29 Jul 2019 12:04:10 -0700 Subject: [PATCH] msm: camera: icp: lock before updating clock status Clock status can be updated in two ways, either through timer or through the recovery. In case the clock is not available during the recovery then it would try to access registers which are unclocked. To prevent this before updating the clock status spinlock should be acquired. Change-Id: I16aea5e7dafacfe6b520699af195194d5d171c7c Signed-off-by: Tejas Prajapati Signed-off-by: Jigarkumar Zala --- drivers/cam_icp/icp_hw/bps_hw/bps_core.c | 5 +++++ drivers/cam_icp/icp_hw/ipe_hw/ipe_core.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/cam_icp/icp_hw/bps_hw/bps_core.c b/drivers/cam_icp/icp_hw/bps_hw/bps_core.c index 73075a4ec3..7deea1c94d 100644 --- a/drivers/cam_icp/icp_hw/bps_hw/bps_core.c +++ b/drivers/cam_icp/icp_hw/bps_hw/bps_core.c @@ -306,6 +306,7 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type, struct cam_bps_device_core_info *core_info = NULL; struct cam_bps_device_hw_info *hw_info = NULL; int rc = 0; + unsigned long flags; if (!device_priv) { CAM_ERR(CAM_ICP, "Invalid arguments"); @@ -395,12 +396,16 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type, } break; case CAM_ICP_BPS_CMD_DISABLE_CLK: + spin_lock_irqsave(&bps_dev->hw_lock, flags); if (core_info->clk_enable == true) cam_bps_toggle_clk(soc_info, false); core_info->clk_enable = false; + spin_unlock_irqrestore(&bps_dev->hw_lock, flags); break; case CAM_ICP_BPS_CMD_RESET: + spin_lock_irqsave(&bps_dev->hw_lock, flags); rc = cam_bps_cmd_reset(soc_info, core_info); + spin_unlock_irqrestore(&bps_dev->hw_lock, flags); break; default: CAM_ERR(CAM_ICP, "Invalid Cmd Type:%u", cmd_type); diff --git a/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.c b/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.c index 82d0ebe54c..614c748f0d 100644 --- a/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.c +++ b/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.c @@ -305,6 +305,7 @@ int cam_ipe_process_cmd(void *device_priv, uint32_t cmd_type, struct cam_ipe_device_core_info *core_info = NULL; struct cam_ipe_device_hw_info *hw_info = NULL; int rc = 0; + unsigned long flags; if (!device_priv) { CAM_ERR(CAM_ICP, "Invalid arguments"); @@ -389,12 +390,16 @@ int cam_ipe_process_cmd(void *device_priv, uint32_t cmd_type, } break; case CAM_ICP_IPE_CMD_DISABLE_CLK: + spin_lock_irqsave(&ipe_dev->hw_lock, flags); if (core_info->clk_enable == true) cam_ipe_toggle_clk(soc_info, false); core_info->clk_enable = false; + spin_unlock_irqrestore(&ipe_dev->hw_lock, flags); break; case CAM_ICP_IPE_CMD_RESET: + spin_lock_irqsave(&ipe_dev->hw_lock, flags); rc = cam_ipe_cmd_reset(soc_info, core_info); + spin_unlock_irqrestore(&ipe_dev->hw_lock, flags); break; default: CAM_ERR(CAM_ICP, "Invalid Cmd Type:%u", cmd_type);