From 6c27e9b705fabba1fa2c228b70cd1b9c8338b97e Mon Sep 17 00:00:00 2001 From: Pradeep P V K Date: Fri, 8 Sep 2023 11:55:47 +0530 Subject: [PATCH] mtd: msm_qpic_nand: Add mutex lock in system suspend/resume functions Some race condition is happening where as part of mtd_write_oob post msm_nand_get_devices function msm_nand_suspend function is getting invoked and since we don't have any locks there so it ends up turning off the qpic clocks leading to NOC error. Add mutex lock in system suspend/resume functions for synchronization. Change-Id: Iaa3e3ee0041c425e2edddc5a023074009010e393 Signed-off-by: Sarthak Garg Signed-off-by: Pradeep P V K --- drivers/mtd/devices/msm_qpic_nand.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/mtd/devices/msm_qpic_nand.c b/drivers/mtd/devices/msm_qpic_nand.c index 41fadf756ac3..329e7ebbd191 100644 --- a/drivers/mtd/devices/msm_qpic_nand.c +++ b/drivers/mtd/devices/msm_qpic_nand.c @@ -231,20 +231,27 @@ static void msm_nand_print_rpm_info(struct device *dev) static int msm_nand_suspend(struct device *dev) { int ret = 0; + struct msm_nand_info *info = dev_get_drvdata(dev); + + mutex_lock(&info->lock); if (!pm_runtime_suspended(dev)) ret = msm_nand_runtime_suspend(dev); + mutex_unlock(&info->lock); return ret; } static int msm_nand_resume(struct device *dev) { int ret = 0; + struct msm_nand_info *info = dev_get_drvdata(dev); + mutex_lock(&info->lock); if (!pm_runtime_suspended(dev)) ret = msm_nand_runtime_resume(dev); + mutex_unlock(&info->lock); return ret; } #else