Skip to contentSkip to conversation

smartpqi updates

PATCH Applied Don Brace 2 participants 7 messages Nov 6, 2025 – Nov 13, 2025

Subsystems (2)
lore
Share & tools
lore

Don Brace

author maintainer
#0 lore raw

cover smartpqi updates

These patches are based on Martin Petersen's 6.19/scsi-queue tree
https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
6.19/scsi-queue

This patch series includes four patches, with two main functional changes:

1. smartpqi-Add-timeout-value-to-RAID-path-requests-to-physical-devices

Sets a timeout value for requests sent to physical devices via the RAID path. This prevents the controller firmware from waiting indefinitely and allows it to time out requests a few seconds before the OS issues Target Management Function (TMF) commands.

The timeout value sent to the firmware is set to 3 seconds less than the OS timeout, which significantly reduces TMF invocations.

2. smartpqi-fix-Device-resources-accessed-after-device-removal Fixes a race condition during device removal by:
* Checking for device removal in the reset handler and canceling any pending reset work if the device is no longer present.
* Canceling outstanding TMF work items in the .sdev_destroy handler.

Together, these changes eliminate races between reset operations and device removal.

The other two patches:
3. smartpqi-add-new-Hurray-Data-pci-device
Adds support for new Hurray Data PCI device.
No functional changes.
4. smartpqi-update-driver-version-to-2.1.36-026
Updates the driver version string.
No functional changes.

---

David Strahan (1):
smartpqi: add support for Hurray Data new controller PCI device

Don Brace (1):
smartpqi: update version to 2.1.36-026

Mike McGowen (2):
smartpqi: Add timeout value to RAID path requests to physical devices
smartpqi: Fix device resources accessed after device removal

 drivers/scsi/smartpqi/smartpqi_init.c | 46 +++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 3 deletions(-)
Signature · 1 line
2.52.0.rc0.28.g4cf919bd7b
author maintainer
#1 lore raw

PATCH 1/4 smartpqi: Add timeout value to RAID path requests to physical devices

From: Mike McGowen <[email protected]>

Add a timeout value to requests sent to physical devices via the RAID path.

A timeout value of zero means wait indefinitely, which may cause the OS to issue Target Management Function (TMF) commands if the device does not respond.

For input timeouts of 8 seconds or greater, the value sent to firmware is reduced by 3 seconds to provide an earlier firmware timeout and allow the OS additional time before timing out.

This change improves timeout handling between the driver, firmware, and OS, helping to better manage device responsiveness and avoid indefinite waits.

---
 drivers/scsi/smartpqi/smartpqi_init.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +17 -0
index b5e71ff26e8e..f5fb262e9c03 100644
@@ -5555,14 +5555,25 @@ static void pqi_raid_io_complete(struct pqi_io_request *io_request,
 	pqi_scsi_done(scmd);
 }
 
+/*
+ * Adjust the timeout value for physical devices sent to the firmware
+ * by subtracting 3 seconds for timeouts greater than or equal to 8 seconds.
+ *
+ * This provides the firmware with additional time to attempt early recovery
+ * before the OS-level timeout occurs.
+ */
+#define ADJUST_SECS_TIMEOUT_VALUE(tv)   (((tv) >= 8) ? ((tv) - 3) : (tv))
+
 static int pqi_raid_submit_io(struct pqi_ctrl_info *ctrl_info,
 	struct pqi_scsi_dev *device, struct scsi_cmnd *scmd,
 	struct pqi_queue_group *queue_group, bool io_high_prio)
 {
 	int rc;
+	u32 timeout;
 	size_t cdb_length;
 	struct pqi_io_request *io_request;
 	struct pqi_raid_path_request *request;
+	struct request *rq;
 
 	io_request = pqi_alloc_io_request(ctrl_info, scmd);
 	if (!io_request)
@@ -5634,6 +5645,12 @@ static int pqi_raid_submit_io(struct pqi_ctrl_info *ctrl_info,
 		return SCSI_MLQUEUE_HOST_BUSY;
 	}
 
+	if (device->is_physical_device) {
+		rq = scsi_cmd_to_rq(scmd);
+		timeout = rq->timeout / HZ;
+		put_unaligned_le32(ADJUST_SECS_TIMEOUT_VALUE(timeout), &request->timeout);
+	}
+
 	pqi_start_io(ctrl_info, queue_group, RAID_PATH, io_request);
 
 	return 0;
Signature · 1 line
2.52.0.rc0.28.g4cf919bd7b
author maintainer
#2 lore raw

PATCH 2/4 smartpqi: Fix device resources accessed after device removal

In reply to Don Brace

From: Mike McGowen <[email protected]>

Correct possible race conditions during device removal.

Previously, a scheduled work item to reset a LUN could still execute after the device was removed, leading to use-after-free and other resource access issues.

This race condition occurs because the abort handler may schedule a LUN reset concurrently with device removal via sdev_destroy(), leading to use-after-free and improper access to freed resources.

This patch:

- Checks in the device reset handler if the device is still present in the controller's SCSI device list before running; if not, the reset is skipped.
- Cancels any pending TMF work that has not started in sdev_destroy().
- Ensures device freeing in sdev_destroy() is done while holding the LUN reset mutex to avoid races with ongoing resets.

Fixes 2d80f4054f7f ("scsi: smartpqi: Update deleting a LUN via sysfs")
---
 drivers/scsi/smartpqi/smartpqi_init.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +19 -0
index f5fb262e9c03..8c4ea4dc5803 100644
@@ -6427,10 +6427,22 @@ static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev
 
 static int pqi_device_reset_handler(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device, u8 lun, struct scsi_cmnd *scmd, u8 scsi_opcode)
 {
+	unsigned long flags;
 	int rc;
 
 	mutex_lock(&ctrl_info->lun_reset_mutex);
 
+	spin_lock_irqsave(&ctrl_info->scsi_device_list_lock, flags);
+	if (pqi_find_scsi_dev(ctrl_info, device->bus, device->target, device->lun) == NULL) {
+		dev_warn(&ctrl_info->pci_dev->dev,
+			"skipping reset of scsi %d:%d:%d:%u, device has been removed\n",
+			ctrl_info->scsi_host->host_no, device->bus, device->target, device->lun);
+		spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+		mutex_unlock(&ctrl_info->lun_reset_mutex);
+		return 0;
+	}
+	spin_unlock_irqrestore(&ctrl_info->scsi_device_list_lock, flags);
+
 	dev_err(&ctrl_info->pci_dev->dev,
 		"resetting scsi %d:%d:%d:%u SCSI cmd at %p due to cmd opcode 0x%02x\n",
 		ctrl_info->scsi_host->host_no, device->bus, device->target, lun, scmd, scsi_opcode);
@@ -6611,7 +6623,9 @@ static void pqi_sdev_destroy(struct scsi_device *sdev)
 {
 	struct pqi_ctrl_info *ctrl_info;
 	struct pqi_scsi_dev *device;
+	struct pqi_tmf_work *tmf_work;
 	int mutex_acquired;
+	unsigned int lun;
 	unsigned long flags;
 
 	ctrl_info = shost_to_hba(sdev->host);
@@ -6638,8 +6652,13 @@ static void pqi_sdev_destroy(struct scsi_device *sdev)
 
 	mutex_unlock(&ctrl_info->scan_mutex);
 
+	for (lun = 0, tmf_work = device->tmf_work; lun < PQI_MAX_LUNS_PER_DEVICE; lun++, tmf_work++)
+		cancel_work_sync(&tmf_work->work_struct);
+
+	mutex_lock(&ctrl_info->lun_reset_mutex);
 	pqi_dev_info(ctrl_info, "removed", device);
 	pqi_free_device(device);
+	mutex_unlock(&ctrl_info->lun_reset_mutex);
 }
 
 static int pqi_getpciinfo_ioctl(struct pqi_ctrl_info *ctrl_info, void __user *arg)
Signature · 1 line
2.52.0.rc0.28.g4cf919bd7b
author maintainer
#3 lore raw

PATCH 3/4 smartpqi: add support for Hurray Data new controller PCI device

In reply to Don Brace

From: David Strahan <[email protected]>

Add support for new Hurray Data controller.

All entries are in HEX.

Add PCI IDs for Hurray Data controllers:

                                         VID  / DID  / SVID / SDID
                                         ----   ----   ----   ----
                                         9005   028f   207d   4840
---
 drivers/scsi/smartpqi/smartpqi_init.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +4 -0
index 8c4ea4dc5803..3886559a5eaa 100644
@@ -10145,6 +10145,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       0x207d, 0x4240)
 	},
+	{
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
+			       0x207d, 0x4840)
+	},
 	{
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
 			       PCI_VENDOR_ID_ADVANTECH, 0x8312)
Signature · 1 line
2.52.0.rc0.28.g4cf919bd7b
author maintainer
#4 lore raw

PATCH 4/4 smartpqi: update version to 2.1.36-026

In reply to Don Brace

Update driver version to 2.1.36-026

---
 drivers/scsi/smartpqi/smartpqi_init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/smartpqi/smartpqi_init.c +3 -3
index 3886559a5eaa..fe549e2b7c94 100644
@@ -34,11 +34,11 @@
 #define BUILD_TIMESTAMP
 #endif
 
-#define DRIVER_VERSION		"2.1.34-035"
+#define DRIVER_VERSION		"2.1.36-026"
 #define DRIVER_MAJOR		2
 #define DRIVER_MINOR		1
-#define DRIVER_RELEASE		34
-#define DRIVER_REVISION		35
+#define DRIVER_RELEASE		36
+#define DRIVER_REVISION		26
 
 #define DRIVER_NAME		"Microchip SmartPQI Driver (v" \
 				DRIVER_VERSION BUILD_TIMESTAMP ")"
Signature · 1 line
2.52.0.rc0.28.g4cf919bd7b
#5 lore raw
In reply to Don Brace

Don,

Quoted 9 lines

David Strahan (1):
smartpqi: add support for Hurray Data new controller PCI device

Don Brace (1):
smartpqi: update version to 2.1.36-026

Mike McGowen (2):
smartpqi: Add timeout value to RAID path requests to physical devices
smartpqi: Fix device resources accessed after device removal

Applied to 6.19/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#6 lore raw
In reply to Don Brace
Quoted 9 lines · Don Brace

These patches are based on Martin Petersen's 6.19/scsi-queue tree
https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
6.19/scsi-queue

This patch series includes four patches, with two main functional changes:

1. smartpqi-Add-timeout-value-to-RAID-path-requests-to-physical-devices

[...]

Applied to 6.19/scsi-queue, thanks!

[1/4] smartpqi: Add timeout value to RAID path requests to physical devices

      https://git.kernel.org/mkp/scsi/c/f3ecbba1aa71
[2/4] smartpqi: Fix device resources accessed after device removal
      https://git.kernel.org/mkp/scsi/c/b518e86d1a70
[3/4] smartpqi: add support for Hurray Data new controller PCI device
      https://git.kernel.org/mkp/scsi/c/48e6b7e70802
[4/4] smartpqi: update version to 2.1.36-026
      https://git.kernel.org/mkp/scsi/c/4cec99e83d92
Signature · 1 line
Martin K. Petersen