scsi: ufs: core: Only call scsi_host_busy() after the SCSI host has been added

scsi_host_busy() iterates over the host tag set. The host tag set is
initialized by scsi_mq_setup_tags(). The latter function is called by
scsi_add_host(). Hence only call scsi_host_busy() after the SCSI host
has been added. This patch prepares for reverting commit a0b7780602
("scsi: core: Fix a regression triggered by scsi_host_busy()").

Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260109205104.496478-2-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Bart Van Assche 2026-01-09 12:51:01 -08:00 committed by Martin K. Petersen
parent 8f0b4cce44
commit 202d5dadd3

View File

@ -283,7 +283,8 @@ static bool ufshcd_has_pending_tasks(struct ufs_hba *hba)
static bool ufshcd_is_ufs_dev_busy(struct ufs_hba *hba)
{
return scsi_host_busy(hba->host) || ufshcd_has_pending_tasks(hba);
return (hba->scsi_host_added && scsi_host_busy(hba->host)) ||
ufshcd_has_pending_tasks(hba);
}
static const struct ufs_dev_quirk ufs_fixups[] = {
@ -678,7 +679,8 @@ static void ufshcd_print_host_state(struct ufs_hba *hba)
dev_err(hba->dev, "UFS Host state=%d\n", hba->ufshcd_state);
dev_err(hba->dev, "%d outstanding reqs, tasks=0x%lx\n",
scsi_host_busy(hba->host), hba->outstanding_tasks);
hba->scsi_host_added ? scsi_host_busy(hba->host) : 0,
hba->outstanding_tasks);
dev_err(hba->dev, "saved_err=0x%x, saved_uic_err=0x%x\n",
hba->saved_err, hba->saved_uic_err);
dev_err(hba->dev, "Device power mode=%d, UIC link state=%d\n",