Skip to contentSkip to conversation

Call scsi_host_busy() after the SCSI host has been added

PATCH Applied Bart Van Assche 4 participants 7 messages Jan 9 – Jan 17

Subsystems (2)
lore
Share & tools
lore

Bart Van Assche

author reviewer
#0 lore raw

v2 cover Call scsi_host_busy() after the SCSI host has been added

Hi Martin,

The UFS driver is the only SCSI driver I know of that may call scsi_host_busy() before the SCSI host has been added. This patch series modifies the UFS driver such that scsi_host_busy() is only called after the SCSI host has been added. Additionally, commit a0b7780602b1 ("scsi: core:
Fix a regression triggered by scsi_host_busy()") is reverted because all scsi_host_busy() calls now happen after the corresponding SCSI host has been added.

Please consider this patch series for the next merge window.

Thanks,

Bart.

Changes compared to v1:
- Removed the WARN_ON_ONCE(!shost->tag_set.ops); statement from patch 2/2.

Bart Van Assche (2):
ufs: core: Only call scsi_host_busy() after the SCSI host has been
added
scsi: core: Revert "Fix a regression triggered by scsi_host_busy()"

 drivers/scsi/hosts.c      | 5 ++---
 drivers/ufs/core/ufshcd.c | 6 ++++--
 2 files changed, 6 insertions(+), 5 deletions(-)
author reviewer
#1 lore raw

PATCH v2 1/2 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 a0b7780602b1 ("scsi: core: Fix a regression triggered by scsi_host_busy()").

---
 drivers/ufs/core/ufshcd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +4 -2
index 562d8cffc6f6..69630677b23f 100644
@@ -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",
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] ufs: core: Only call scsi_host_busy() after the SCSI host has been added

Quoted 38 lines · Bart Van Assche

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()").

---
 drivers/ufs/core/ufshcd.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ufs/core/ufshcd.c +2 -1
index 562d8cffc6f6..69630677b23f 100644
@@ -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[] = {

drivers/ufs/core/ufshcd.c +2 -1
@@ -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);
Quoted 2 lines

        dev_err(hba->dev, "Device power mode=%d, UIC link state=%d\n",

author reviewer
#3 lore raw

PATCH v2 2/2 scsi: core: Revert "Fix a regression triggered by scsi_host_busy()"

In reply to Bart Van Assche

Revert commit a0b7780602b1 ("scsi: core: Fix a regression triggered by scsi_host_busy()") because all scsi_host_busy() calls now happen after the corresponding SCSI host has been added.

---
 drivers/scsi/hosts.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/hosts.c +2 -3
index 196479cbfe6e..4d17f242d191 100644
@@ -626,9 +626,8 @@ int scsi_host_busy(struct Scsi_Host *shost)
 {
 	int cnt = 0;
 
-	if (shost->tag_set.ops)
-		blk_mq_tagset_busy_iter(&shost->tag_set,
-					scsi_host_check_in_flight, &cnt);
+	blk_mq_tagset_busy_iter(&shost->tag_set,
+				scsi_host_check_in_flight, &cnt);
 	return cnt;
 }
 EXPORT_SYMBOL(scsi_host_busy);
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] scsi: core: Revert "Fix a regression triggered by scsi_host_busy()"

Quoted 5 lines · Bart Van Assche

Revert commit a0b7780602b1 ("scsi: core: Fix a regression triggered by scsi_host_busy()") because all scsi_host_busy() calls now happen after the corresponding SCSI host has been added.

thanks

Quoted 21 lines
---
  drivers/scsi/hosts.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/hosts.c +2 -3
index 196479cbfe6e..4d17f242d191 100644
@@ -626,9 +626,8 @@ int scsi_host_busy(struct Scsi_Host *shost)
  {
  	int cnt = 0;
 
-	if (shost->tag_set.ops)
-		blk_mq_tagset_busy_iter(&shost->tag_set,
-					scsi_host_check_in_flight, &cnt);
+	blk_mq_tagset_busy_iter(&shost->tag_set,
+				scsi_host_check_in_flight, &cnt);
  	return cnt;
  }
  EXPORT_SYMBOL(scsi_host_busy);
#5 lore raw
In reply to Bart Van Assche

Bart,

Quoted 7 lines

The UFS driver is the only SCSI driver I know of that may call scsi_host_busy() before the SCSI host has been added. This patch series modifies the UFS driver such that scsi_host_busy() is only called after the SCSI host has been added. Additionally, commit a0b7780602b1 ("scsi: core: Fix a regression triggered by scsi_host_busy()") is reverted because all scsi_host_busy() calls now happen after the corresponding SCSI host has been added.

Applied to 6.20/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#6 lore raw
In reply to Bart Van Assche
Quoted 9 lines · Bart Van Assche

The UFS driver is the only SCSI driver I know of that may call scsi_host_busy() before the SCSI host has been added. This patch series modifies the UFS driver such that scsi_host_busy() is only called after the SCSI host has been added. Additionally, commit a0b7780602b1 ("scsi: core:
Fix a regression triggered by scsi_host_busy()") is reverted because all scsi_host_busy() calls now happen after the corresponding SCSI host has been added.

[...]

Applied to 6.20/scsi-queue, thanks!

[1/2] ufs: core: Only call scsi_host_busy() after the SCSI host has been added

      https://git.kernel.org/mkp/scsi/c/202d5dadd3a0
[2/2] scsi: core: Revert "Fix a regression triggered by scsi_host_busy()"
      https://git.kernel.org/mkp/scsi/c/e60b57972099
Signature · 1 line
Martin K. Petersen