Skip to contentSkip to conversation

scsi: pm80xx: Remove msleep() loop from pm8001_dev_gone_notify()

PATCH In review TJ Adams 2 participants 3 messages Jul 9, 2024 – Nov 18, 2024

Subsystems (2)
lore
Share & tools
lore

TJ Adams

author
#0 lore raw

PATCH 1/1 scsi: pm80xx: Remove msleep() loop from pm8001_dev_gone_notify()

From: Igor Pylypiv <[email protected]>

It's possible to end up in a state where pm8001_dev->running_req never reaches zero. In that state we will be sleeping forever.

sas_execute_internal_abort_dev() can wait for a response for up to 60 seconds (3 retries x 20 seconds). 60 seconds should be enough for pm8001_dev->running_req to get to zero.

---
 drivers/scsi/pm8001/pm8001_sas.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/pm8001/pm8001_sas.c +5 -2
index a5a31dfa4512..513e9a49838c 100644
@@ -712,8 +712,11 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
 		if (atomic_read(&pm8001_dev->running_req)) {
 			spin_unlock_irqrestore(&pm8001_ha->lock, flags);
 			sas_execute_internal_abort_dev(dev, 0, NULL);
-			while (atomic_read(&pm8001_dev->running_req))
-				msleep(20);
+			if (atomic_read(&pm8001_dev->running_req)) {
+				pm8001_dbg(pm8001_ha, FAIL,
+					   "device_id: %u: Failed to abort %d requests!\n",
+					   device_id, atomic_read(&pm8001_dev->running_req));
+			}
 			spin_lock_irqsave(&pm8001_ha->lock, flags);
 		}
 		PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
Signature · 1 line
2.45.2.803.g4e1b14247a-goog
#1 lore raw
Quoted 4 lines · TJ Adams

From: Igor Pylypiv <[email protected]>

It's possible to end up in a state where pm8001_dev->running_req never reaches zero.

Is that a driver bug then?

Quoted 5 lines

In that state we will be sleeping forever.

sas_execute_internal_abort_dev() can wait for a response for up to 60 seconds (3 retries x 20 seconds). 60 seconds should be enough for pm8001_dev->running_req to get to zero.

May I suggest you drop running_req at some stage, and use other methods to find how many IOs are active?

Quoted 25 lines
---
  drivers/scsi/pm8001/pm8001_sas.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/pm8001/pm8001_sas.c +5 -2
index a5a31dfa4512..513e9a49838c 100644
@@ -712,8 +712,11 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
  		if (atomic_read(&pm8001_dev->running_req)) {
  			spin_unlock_irqrestore(&pm8001_ha->lock, flags);
  			sas_execute_internal_abort_dev(dev, 0, NULL);
-			while (atomic_read(&pm8001_dev->running_req))
-				msleep(20);
+			if (atomic_read(&pm8001_dev->running_req)) {
+				pm8001_dbg(pm8001_ha, FAIL,
+					   "device_id: %u: Failed to abort %d requests!\n",
+					   device_id, atomic_read(&pm8001_dev->running_req));
+			}
  			spin_lock_irqsave(&pm8001_ha->lock, flags);
  		}
  		PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);
author
#2 lore raw

Sorry for the late response.

Quoted 4 lines
Quoted 2 lines

It's possible to end up in a state where pm8001_dev->running_req never reaches zero.

Is that a driver bug then?

I haven't seen this unless artificially creating the situation. This is a preventative change rather than a response to a specific issue seen.

Quoted 8 lines
Quoted 5 lines

In that state we will be sleeping forever.

sas_execute_internal_abort_dev() can wait for a response for up to 60 seconds (3 retries x 20 seconds). 60 seconds should be enough for pm8001_dev->running_req to get to zero.

May I suggest you drop running_req at some stage, and use other methods to find how many IOs are active?

I haven't given much thought about better ways to keep track of active ios, so it will have to come later but definitely noted!

Quoted 44 lines · John Garry
Quoted 4 lines · TJ Adams

From: Igor Pylypiv <[email protected]>

It's possible to end up in a state where pm8001_dev->running_req never reaches zero.

Is that a driver bug then?

Quoted 5 lines

In that state we will be sleeping forever.

sas_execute_internal_abort_dev() can wait for a response for up to 60 seconds (3 retries x 20 seconds). 60 seconds should be enough for pm8001_dev->running_req to get to zero.

May I suggest you drop running_req at some stage, and use other methods to find how many IOs are active?

Quoted 25 lines
---
  drivers/scsi/pm8001/pm8001_sas.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/pm8001/pm8001_sas.c +5 -2
index a5a31dfa4512..513e9a49838c 100644
@@ -712,8 +712,11 @@ static void pm8001_dev_gone_notify(struct domain_device *dev)
              if (atomic_read(&pm8001_dev->running_req)) {
                      spin_unlock_irqrestore(&pm8001_ha->lock, flags);
                      sas_execute_internal_abort_dev(dev, 0, NULL);
-                     while (atomic_read(&pm8001_dev->running_req))
-                             msleep(20);
+                     if (atomic_read(&pm8001_dev->running_req)) {
+                             pm8001_dbg(pm8001_ha, FAIL,
+                                        "device_id: %u: Failed to abort %d requests!\n",
+                                        device_id, atomic_read(&pm8001_dev->running_req));
+                     }
                      spin_lock_irqsave(&pm8001_ha->lock, flags);
              }
              PM8001_CHIP_DISP->dereg_dev_req(pm8001_ha, device_id);