From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Bean Huo <beanhuo@micron.com>, Can Guo <cang@codeaurora.org>,
Stanley Chu <stanley.chu@mediatek.com>,
Avri Altman <avri.altman@wdc.com>,
Asutosh Das <asutoshd@codeaurora.org>
Subject: [PATCH 09/11] scsi: ufs: Fix a kernel crash during shutdown
Date: Tue, 9 Nov 2021 16:44:38 -0800 [thread overview]
Message-ID: <20211110004440.3389311-10-bvanassche@acm.org> (raw)
In-Reply-To: <20211110004440.3389311-1-bvanassche@acm.org>
Fix the following kernel crash:
Unable to handle kernel paging request at virtual address ffffffc91e735000
Call trace:
__queue_work+0x26c/0x624
queue_work_on+0x6c/0xf0
ufshcd_hold+0x12c/0x210
__ufshcd_wl_suspend+0xc0/0x400
ufshcd_wl_shutdown+0xb8/0xcc
device_shutdown+0x184/0x224
kernel_restart+0x4c/0x124
__arm64_sys_reboot+0x194/0x264
el0_svc_common+0xc8/0x1d4
do_el0_svc+0x30/0x8c
el0_svc+0x20/0x30
el0_sync_handler+0x84/0xe4
el0_sync+0x1bc/0x1c0
Fix this crash by ungating the clock before destroying the work queue
on which clock gating work is queued.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/ufs/ufshcd.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 1e15ed1f639f..13848e93cda8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -1666,7 +1666,8 @@ int ufshcd_hold(struct ufs_hba *hba, bool async)
bool flush_result;
unsigned long flags;
- if (!ufshcd_is_clkgating_allowed(hba))
+ if (!ufshcd_is_clkgating_allowed(hba) ||
+ !hba->clk_gating.is_initialized)
goto out;
spin_lock_irqsave(hba->host->host_lock, flags);
hba->clk_gating.active_reqs++;
@@ -1826,7 +1827,7 @@ static void __ufshcd_release(struct ufs_hba *hba)
if (hba->clk_gating.active_reqs || hba->clk_gating.is_suspended ||
hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL ||
- hba->outstanding_tasks ||
+ hba->outstanding_tasks || !hba->clk_gating.is_initialized ||
hba->active_uic_cmd || hba->uic_async_done ||
hba->clk_gating.state == CLKS_OFF)
return;
@@ -1961,11 +1962,15 @@ static void ufshcd_exit_clk_gating(struct ufs_hba *hba)
{
if (!hba->clk_gating.is_initialized)
return;
+
ufshcd_remove_clk_gating_sysfs(hba);
- cancel_work_sync(&hba->clk_gating.ungate_work);
- cancel_delayed_work_sync(&hba->clk_gating.gate_work);
- destroy_workqueue(hba->clk_gating.clk_gating_workq);
+
+ /* Ungate the clock if necessary. */
+ ufshcd_hold(hba, false);
hba->clk_gating.is_initialized = false;
+ ufshcd_release(hba);
+
+ destroy_workqueue(hba->clk_gating.clk_gating_workq);
}
/* Must be called with host lock acquired */
next prev parent reply other threads:[~2021-11-10 0:45 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 0:44 [PATCH 00/11] UFS patches for kernel v5.17 Bart Van Assche
2021-11-10 0:44 ` [PATCH 01/11] scsi: ufs: Rename a function argument Bart Van Assche
2021-11-10 1:28 ` Chanho Park
2021-11-10 9:48 ` Keoseong Park
2021-11-11 16:59 ` Alim Akhtar
2021-11-10 0:44 ` [PATCH 02/11] scsi: ufs: Remove is_rpmb_wlun() Bart Van Assche
2021-11-10 17:47 ` Asutosh Das (asd)
2021-11-11 16:52 ` Alim Akhtar
2021-11-10 0:44 ` [PATCH 03/11] scsi: ufs: Remove the sdev_rpmb member Bart Van Assche
2021-11-10 17:50 ` Asutosh Das (asd)
2021-11-11 16:47 ` Alim Akhtar
2021-11-10 0:44 ` [PATCH 04/11] scsi: ufs: Remove dead code Bart Van Assche
2021-11-11 7:06 ` Avri Altman
2021-11-15 15:58 ` Bean Huo
2021-11-15 16:01 ` Bean Huo
2021-11-10 0:44 ` [PATCH 05/11] scsi: core: Add support for reserved tags Bart Van Assche
2021-11-10 0:44 ` [PATCH 06/11] scsi: ufs: Rework ufshcd_change_queue_depth() Bart Van Assche
2021-11-11 7:22 ` Avri Altman
2021-11-15 18:27 ` Bart Van Assche
2021-11-10 0:44 ` [PATCH 07/11] scsi: ufs: Fix a deadlock in the error handler Bart Van Assche
2021-11-10 6:42 ` Christoph Hellwig
2021-11-15 18:28 ` Bart Van Assche
2021-11-11 7:33 ` Avri Altman
2021-11-15 18:29 ` Bart Van Assche
2021-11-10 0:44 ` [PATCH 08/11] scsi: ufs: Improve SCSI abort handling further Bart Van Assche
2021-11-10 8:57 ` Adrian Hunter
2021-11-10 18:56 ` Bart Van Assche
2021-11-12 10:56 ` Adrian Hunter
2021-11-15 23:09 ` Bart Van Assche
2021-11-16 9:03 ` Adrian Hunter
2021-11-16 16:07 ` Bart Van Assche
2021-11-11 9:17 ` Peter Wang
2021-11-16 9:07 ` Peter Wang
2021-11-16 16:08 ` Bart Van Assche
2021-11-16 20:16 ` Adrian Hunter
2021-11-16 21:53 ` Bart Van Assche
2021-11-17 7:37 ` Adrian Hunter
2021-11-10 0:44 ` Bart Van Assche [this message]
2021-11-11 7:48 ` [PATCH 09/11] scsi: ufs: Fix a kernel crash during shutdown Avri Altman
2021-11-15 18:45 ` Bart Van Assche
2021-11-10 0:44 ` [PATCH 10/11] scsi: ufs: Optimize the command queueing code Bart Van Assche
2021-11-10 8:04 ` Adrian Hunter
2021-11-10 18:57 ` Bart Van Assche
2021-11-11 7:51 ` Avri Altman
2021-11-12 23:40 ` Asutosh Das (asd)
2021-11-10 0:44 ` [PATCH 11/11] scsi: ufs: Implement polling support Bart Van Assche
2021-11-10 1:36 ` Douglas Gilbert
2021-11-19 19:39 ` Bart Van Assche
2021-11-11 8:11 ` Avri Altman
2021-11-19 19:01 ` Bart Van Assche
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211110004440.3389311-10-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=adrian.hunter@intel.com \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=cang@codeaurora.org \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stanley.chu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox