From f9f1deb3a39c0d7ee69784ecda03070fdd9417e0 Mon Sep 17 00:00:00 2001 From: Nitin Rawat Date: Fri, 15 Jan 2021 17:59:48 +0530 Subject: [PATCH] scsi: ufs: Hold auto suspend until ufs async scan completes To avoid any suspend during probe, we increment the device usage counter before calling ufshcd_async_scan and decrement before returning from ufshcd_async_scan function. For the scenarios where ufs device initialisation fails or if the ufs device is not present, we are decrementing device usage counter before calling ufshcd_hba_exit. Hence there is a possiblity that after we disable the clocks as part of ufshcd_hba_exit call, runtime suspend may get triggered. As part of runtime suspend, we are accessing the register causing noc error due to unclocked access. To fix this, we are removing pm_runtime_put_sync from ufshcd_add_lus() and adding it in common place at the end of ufshcd_async_scan so that we hold auto suspend until async scan completes in both success and failure case. Call Stack: panic+0x17c panic+0x0 arm64_serror_panic+0x74 do_serror+0x15c el1_error+0xbc el1_irq+0xb0 crypto_qti_resume+0x68 ufshcd_crypto_qti_resume+0x18 ufshcd_crypto_resume+0x3c ufshcd_suspend+0x5b0 ufshcd_runtime_suspend+0x44 ufshcd_pltfrm_runtime_suspend+0x14 pm_generic_runtime_suspend+0x44 __rpm_callback+0x98 rpm_suspend+0x2a4 rpm_idle+0x158 schedule+0x8c schedule_preempt_disabled+0x24 __mutex_lock+0x358 __mutex_lock_slowpath+0x14 mutex_lock+0x34 clk_unprepare+0x58 __ufshcd_setup_clocks+0x140 ufshcd_hba_exit+0x170 ufshcd_async_scan$d36fba0b664edbd124b5d17d005db4c5+0x118 async_run_entry_fn$8847b5d726ee295ba72a029a76bec2f5+0x60 process_one_work+0x2cc worker_thread$f31e2447a3fdcb60f4b193f95acd647c+0x278 kthread$bf1537fa370ac32bde5f056194ddafc6+0x16c ret_from_fork+0x10. Change-Id: I059de2b0eba642bf1a35c27e8e12d31c6f30a836 Signed-off-by: Nitin Rawat --- drivers/scsi/ufs/ufshcd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a4ac543b261c..d365dc3fa9ce 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3,7 +3,7 @@ * * This code is based on drivers/scsi/ufs/ufshcd.c * Copyright (C) 2011-2013 Samsung India Software Operations - * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved. * * Authors: * Santosh Yaraganavi @@ -7772,7 +7772,6 @@ static int ufshcd_add_lus(struct ufs_hba *hba) ufs_bsg_probe(hba); scsi_scan_host(hba->host); - pm_runtime_put_sync(hba->dev); out: return ret; @@ -7933,10 +7932,10 @@ out: * present, turn off the power/clocks etc. */ if (ret) { - pm_runtime_put_sync(hba->dev); ufshcd_exit_clk_scaling(hba); ufshcd_hba_exit(hba); } + pm_runtime_put_sync(hba->dev); } static enum blk_eh_timer_return ufshcd_eh_timed_out(struct scsi_cmnd *scmd)