Commit 5675c381 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: ufs: Stop using the clock scaling lock in the error handler

Instead of locking and unlocking the clock scaling lock, surround the
command queueing code with an RCU reader lock and call synchronize_rcu().
This patch prepares for removal of the clock scaling lock.

Link: https://lore.kernel.org/r/20211203231950.193369-16-bvanassche@acm.orgTested-by: default avatarBean Huo <beanhuo@micron.com>
Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 3489c34b
...@@ -2684,6 +2684,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ...@@ -2684,6 +2684,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
if (!down_read_trylock(&hba->clk_scaling_lock)) if (!down_read_trylock(&hba->clk_scaling_lock))
return SCSI_MLQUEUE_HOST_BUSY; return SCSI_MLQUEUE_HOST_BUSY;
/*
* Allows the UFS error handler to wait for prior ufshcd_queuecommand()
* calls.
*/
rcu_read_lock();
switch (hba->ufshcd_state) { switch (hba->ufshcd_state) {
case UFSHCD_STATE_OPERATIONAL: case UFSHCD_STATE_OPERATIONAL:
break; break;
...@@ -2762,7 +2768,10 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) ...@@ -2762,7 +2768,10 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
} }
ufshcd_send_command(hba, tag); ufshcd_send_command(hba, tag);
out: out:
rcu_read_unlock();
up_read(&hba->clk_scaling_lock); up_read(&hba->clk_scaling_lock);
if (ufs_trigger_eh()) { if (ufs_trigger_eh()) {
...@@ -5951,8 +5960,7 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) ...@@ -5951,8 +5960,7 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
} }
ufshcd_scsi_block_requests(hba); ufshcd_scsi_block_requests(hba);
/* Drain ufshcd_queuecommand() */ /* Drain ufshcd_queuecommand() */
down_write(&hba->clk_scaling_lock); synchronize_rcu();
up_write(&hba->clk_scaling_lock);
cancel_work_sync(&hba->eeh_work); cancel_work_sync(&hba->eeh_work);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment