This is a note to let you know that I've just added the patch titled scsi: ufs: core: Add ufshcd_is_ufs_dev_busy() to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: scsi-ufs-core-add-ufshcd_is_ufs_dev_busy.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit bda613d03e3d3117bd4c6599e86c6a503efd1686 Author: Bean Huo <beanhuo@xxxxxxxxxx> Date: Tue Dec 12 23:08:23 2023 +0100 scsi: ufs: core: Add ufshcd_is_ufs_dev_busy() [ Upstream commit 9fa268875ca4ff5cad0c1b957388a0aef39920c3 ] Add helper inline for retrieving whether UFS device is busy or not. Signed-off-by: Bean Huo <beanhuo@xxxxxxxxxx> Link: https://lore.kernel.org/r/20231212220825.85255-2-beanhuo@xxxxxxxx Reviewed-by: Avri Altman <avri.altman@xxxxxxx> Reviewed-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx> Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx> Stable-dep-of: 4fa382be4304 ("scsi: ufs: core: Fix ufshcd_is_ufs_dev_busy() and ufshcd_eh_timed_out()") Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 0ac0b6aaf9c62..fe1c56bc0a127 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -234,6 +234,12 @@ ufs_get_desired_pm_lvl_for_dev_link_state(enum ufs_dev_pwr_mode dev_state, return UFS_PM_LVL_0; } +static bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba) +{ + return (hba->clk_gating.active_reqs || hba->outstanding_reqs || hba->outstanding_tasks || + hba->active_uic_cmd || hba->uic_async_done); +} + static const struct ufs_dev_quirk ufs_fixups[] = { /* UFS cards deviations table */ { .wmanufacturerid = UFS_VENDOR_MICRON, @@ -1816,10 +1822,7 @@ static void ufshcd_gate_work(struct work_struct *work) goto rel_lock; } - if (hba->clk_gating.active_reqs - || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL - || hba->outstanding_reqs || hba->outstanding_tasks - || hba->active_uic_cmd || hba->uic_async_done) + if (ufshcd_is_ufs_dev_busy(hba) || hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL) goto rel_lock; spin_unlock_irqrestore(hba->host->host_lock, flags);