Commit f3ecbba1 authored by Mike McGowen's avatar Mike McGowen Committed by Martin K. Petersen
Browse files

scsi: smartpqi: Add timeout value to RAID path requests to physical devices



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.

Reviewed-by: default avatarDavid Strahan <david.strahan@microchip.com>
Reviewed-by: default avatarScott Benesh <scott.benesh@microchip.com>
Reviewed-by: default avatarScott Teel <scott.teel@microchip.com>
Signed-off-by: default avatarMike McGowen <Mike.McGowen@microchip.com>
Signed-off-by: default avatarDon Brace <don.brace@microchip.com>
Link: https://patch.msgid.link/20251106163823.786828-2-don.brace@microchip.com


Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 3a866087
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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;