[PATCH][SRU][F-hwe-5.11 19/30] scsi: smartpqi: Update device scan operations

Krzysztof Kozlowski krzysztof.kozlowski at canonical.com
Thu Jul 1 06:51:30 UTC 2021


From: Kevin Barnett <kevin.barnett at microchip.com>

BugLink: https://bugs.launchpad.net/bugs/1933518

Change return type from EINPROGRESS to EBUSY to signal applications to
retry a REGNEWD if the driver cannot process the REGNEWD. Events such as
OFA, suspend, and shutdown return EINPROGRESS if a scan is currently
running. This prevents applications from immediately retrying REGNEWD.

Schedule a new REGNEWD if system low on memory.

Link: https://lore.kernel.org/r/161549382157.25025.16054784597622125373.stgit@brunhilda
Reviewed-by: Scott Benesh <scott.benesh at microchip.com>
Reviewed-by: Mike McGowen <mike.mcgowen at microchip.com>
Reviewed-by: Scott Teel <scott.teel at microchip.com>
Signed-off-by: Kevin Barnett <kevin.barnett at microchip.com>
Signed-off-by: Don Brace <don.brace at microchip.com>
Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>
(cherry picked from commit 66f1c2b40270b759eb070990ebd5c8f94244360f)
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski at canonical.com>
---
 drivers/scsi/smartpqi/smartpqi_init.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index d9418cd01d9f..8fc4626816d2 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -2312,21 +2312,27 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 
 static int pqi_scan_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 {
-	int rc = 0;
+	int rc;
+	int mutex_acquired;
 
 	if (pqi_ctrl_offline(ctrl_info))
 		return -ENXIO;
 
-	if (!mutex_trylock(&ctrl_info->scan_mutex)) {
+	mutex_acquired = mutex_trylock(&ctrl_info->scan_mutex);
+
+	if (!mutex_acquired) {
+		if (pqi_ctrl_scan_blocked(ctrl_info))
+			return -EBUSY;
 		pqi_schedule_rescan_worker_delayed(ctrl_info);
-		rc = -EINPROGRESS;
-	} else {
-		rc = pqi_update_scsi_devices(ctrl_info);
-		if (rc)
-			pqi_schedule_rescan_worker_delayed(ctrl_info);
-		mutex_unlock(&ctrl_info->scan_mutex);
+		return -EINPROGRESS;
 	}
 
+	rc = pqi_update_scsi_devices(ctrl_info);
+	if (rc && !pqi_ctrl_scan_blocked(ctrl_info))
+		pqi_schedule_rescan_worker_delayed(ctrl_info);
+
+	mutex_unlock(&ctrl_info->scan_mutex);
+
 	return rc;
 }
 
-- 
2.27.0




More information about the kernel-team mailing list