> > static inline bool ufshcd_ready_for_uic_cmd(struct ufs_hba *hba) > > { > > - return ufshcd_readl(hba, REG_CONTROLLER_STATUS) & UIC_COMMAND_READY; > > + ktime_t timeout = ktime_add_ms(ktime_get(), UIC_CMD_TIMEOUT); > > + u32 val = 0; > > + > > + do { > > + val = ufshcd_readl(hba, REG_CONTROLLER_STATUS) & > > + UIC_COMMAND_READY; > > + if (val) > > + break; > > + udelay(500); > > + } while (ktime_before(ktime_get(), timeout)); > > + > > + return val ? true : false; > > } > > Sleeping during up to 500 ms while holding a spin lock is not acceptable. > Has it been considered to modify the UFS core such that the host_lock is > not held around calls of the above function, e.g. via the (untested) patch > below? > > Thanks, > > Bart. Let me consider it. > > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index > 9736b2b4120e..394283b04d7c 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -2416,7 +2416,6 @@ __ufshcd_send_uic_cmd(struct ufs_hba *hba, struct > uic_command *uic_cmd, > bool completion) > { > lockdep_assert_held(&hba->uic_cmd_mutex); > - lockdep_assert_held(hba->host->host_lock); > > if (!ufshcd_ready_for_uic_cmd(hba)) { > dev_err(hba->dev, > @@ -2452,9 +2451,7 @@ int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct > uic_command *uic_cmd) > mutex_lock(&hba->uic_cmd_mutex); > ufshcd_add_delay_before_dme_cmd(hba); > > - spin_lock_irqsave(hba->host->host_lock, flags); > ret = __ufshcd_send_uic_cmd(hba, uic_cmd, true); > - spin_unlock_irqrestore(hba->host->host_lock, flags); > if (!ret) > ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd); > > @@ -4122,8 +4119,8 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, > struct uic_command *cmd) > wmb(); > reenable_intr = true; > } > - ret = __ufshcd_send_uic_cmd(hba, cmd, false); > spin_unlock_irqrestore(hba->host->host_lock, flags); > + ret = __ufshcd_send_uic_cmd(hba, cmd, false); > if (ret) { > dev_err(hba->dev, > "pwr ctrl cmd 0x%x with mode 0x%x uic error %d\n",