Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ea586f6 authored by Subhash Jadavani's avatar Subhash Jadavani Committed by Kyle Yan
Browse files

scsi: ufs: add option to override the command timeout



Some platforms might be very slow and command completion may take
much longer than default scsi command timeouts.
SCSI Read/Write command timeout can be changed by blk_queue_rq_timeout()
but there is no option to override timeout for rest of the scsi commands.

This change adds device tree parameter "scsi-cmd-timeout" to allow
overriding the default scsi command timeout for all scsi commands.

Change-Id: Ib77d39ebb7787f8d8fa66c6e21a98df8b43103fd
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
parent 70e75889
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ Optional properties:
- limit-tx-pwm-gear	: Specify the max. limit on the TX PWM gear
			  Valid range: 1-4. 1 => PWM-G1, 2 => PWM-G2, 3 => PWM-G3, 4 => PWM-G4
- limit-rx-pwm-gear	: Specify the max. limit on the RX PWM gear. Refer "limit-tx-pwm-gear" for expected values.
- scsi-cmd-timeout	: Specify the command timeout (in seconds) for scsi commands

Note: If above properties are not defined it can be assumed that the supply
regulators or clocks are always on.
+16 −0
Original line number Diff line number Diff line
@@ -264,6 +264,21 @@ static void ufshcd_parse_gear_limits(struct ufs_hba *hba)
		hba->limit_rx_pwm_gear = -1;
}

static void ufshcd_parse_cmd_timeout(struct ufs_hba *hba)
{
	struct device *dev = hba->dev;
	struct device_node *np = dev->of_node;
	int ret;

	if (!np)
		return;

	ret = of_property_read_u32(np, "scsi-cmd-timeout",
		&hba->scsi_cmd_timeout);
	if (ret)
		hba->scsi_cmd_timeout = 0;
}

#ifdef CONFIG_SMP
/**
 * ufshcd_pltfrm_suspend - suspend power management function
@@ -370,6 +385,7 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,

	ufshcd_parse_pm_levels(hba);
	ufshcd_parse_gear_limits(hba);
	ufshcd_parse_cmd_timeout(hba);

	if (!dev->dma_mask)
		dev->dma_mask = &dev->coherent_dma_mask;
+6 −0
Original line number Diff line number Diff line
@@ -4794,10 +4794,16 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth)
static int ufshcd_slave_configure(struct scsi_device *sdev)
{
	struct request_queue *q = sdev->request_queue;
	struct ufs_hba *hba = shost_priv(sdev->host);

	blk_queue_update_dma_pad(q, PRDT_DATA_BYTE_COUNT_PAD - 1);
	blk_queue_max_segment_size(q, PRDT_DATA_BYTE_COUNT_MAX);

	if (hba->scsi_cmd_timeout) {
		blk_queue_rq_timeout(q, hba->scsi_cmd_timeout * HZ);
		scsi_set_cmd_timeout_override(sdev, hba->scsi_cmd_timeout * HZ);
	}

	sdev->autosuspend_delay = UFSHCD_AUTO_SUSPEND_DELAY_MS;
	sdev->use_rpm_auto = 1;

+2 −0
Original line number Diff line number Diff line
@@ -846,6 +846,8 @@ struct ufs_hba {
	u32 limit_tx_pwm_gear;
	u32 limit_rx_pwm_gear;

	u32 scsi_cmd_timeout;

	/* Bitmask for enabling debug prints */
	u32 ufshcd_dbg_print;