]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: ufs: core: Only call scsi_host_busy() after the SCSI host has been added
authorBart Van Assche <bvanassche@acm.org>
Fri, 9 Jan 2026 20:51:01 +0000 (12:51 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 12 Jan 2026 03:07:36 +0000 (22:07 -0500)
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 a0b7780602b1
("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>
drivers/ufs/core/ufshcd.c

index 80c0b49f30b01284d1a392dbea76ed8d4a68ab5b..5f694f95fd863e4275e27a956efce45ef3c8ea0a 100644 (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",