Message ID | 20211130233324.1402448-16-bvanassche@acm.org |
---|---|
State | Superseded |
Headers | show |
Series | UFS patches for kernel v5.17 | expand |
On 01/12/2021 01:33, Bart Van Assche wrote: > 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. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> > --- > drivers/scsi/ufs/ufshcd.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 074ea9ae54e0..c4cf5c4b4893 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -2684,6 +2684,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) > if (!down_read_trylock(&hba->clk_scaling_lock)) > return SCSI_MLQUEUE_HOST_BUSY; > > + /* > + * Allows the UFS error handler to wait for prior ufshcd_queuecommand() > + * calls. > + */ > + rcu_read_lock(); > + > switch (hba->ufshcd_state) { > case UFSHCD_STATE_OPERATIONAL: > break; > @@ -2762,7 +2768,10 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) > } > > ufshcd_send_command(hba, tag); > + > out: > + rcu_read_unlock(); > + > up_read(&hba->clk_scaling_lock); > > if (ufs_trigger_eh()) { > @@ -5951,8 +5960,7 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) > } > ufshcd_scsi_block_requests(hba); > /* Drain ufshcd_queuecommand() */ > - down_write(&hba->clk_scaling_lock); > - up_write(&hba->clk_scaling_lock); > + synchronize_rcu(); > cancel_work_sync(&hba->eeh_work); > } > >
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 074ea9ae54e0..c4cf5c4b4893 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2684,6 +2684,12 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) if (!down_read_trylock(&hba->clk_scaling_lock)) return SCSI_MLQUEUE_HOST_BUSY; + /* + * Allows the UFS error handler to wait for prior ufshcd_queuecommand() + * calls. + */ + rcu_read_lock(); + switch (hba->ufshcd_state) { case UFSHCD_STATE_OPERATIONAL: break; @@ -2762,7 +2768,10 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) } ufshcd_send_command(hba, tag); + out: + rcu_read_unlock(); + up_read(&hba->clk_scaling_lock); if (ufs_trigger_eh()) { @@ -5951,8 +5960,7 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba) } ufshcd_scsi_block_requests(hba); /* Drain ufshcd_queuecommand() */ - down_write(&hba->clk_scaling_lock); - up_write(&hba->clk_scaling_lock); + synchronize_rcu(); cancel_work_sync(&hba->eeh_work); }
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. Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/ufs/ufshcd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)