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

Commit 15330ab9 authored by Veerabhadrarao Badiganti's avatar Veerabhadrarao Badiganti Committed by Gerrit - the friendly Code Review server
Browse files

scsi: ufs: Increase fDeviceInit flag poll time to 5sec



Few UFS devices are taking a long time to finish its internal
initialization. UFS driver polls fDeviceInit flag which indicates
device initialization completion.

Increase this flag poll time to 5sec to cover support for those UFS
devices as well.

Change-Id: I99e1ed54d57c9fd75bbe1b22ea30553b1ce0fb83
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
parent dedc7a56
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -5686,9 +5686,10 @@ EXPORT_SYMBOL_GPL(ufshcd_config_pwr_mode);
 */
static int ufshcd_complete_dev_init(struct ufs_hba *hba)
{
	int i;
	int i = 0;
	int err;
	bool flag_res = 1;
	ktime_t timeout;

	err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
		QUERY_FLAG_IDN_FDEVICEINIT, NULL);
@@ -5699,10 +5700,30 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba)
		goto out;
	}

	/* poll for max. 1000 iterations for fDeviceInit flag to clear */
	for (i = 0; i < 1000 && !err && flag_res; i++)
	/*
	 * Some vendor devices are taking longer time to complete its internal
	 * initialization, so set fDeviceInit flag poll time to 5 secs
	 */
	timeout = ktime_add_ms(ktime_get(), 5000);

	/* poll for max. 5sec for fDeviceInit flag to clear */
	while (1) {
		bool timedout = ktime_after(ktime_get(), timeout);
		err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG,
					QUERY_FLAG_IDN_FDEVICEINIT, &flag_res);
		if (err || !flag_res || timedout)
			break;

		/*
		 * Poll for this flag in a tight loop for first 1000 iterations.
		 * This is same as old logic which is working for most of the
		 * devices, so continue using the same.
		 */
		if (i == 1000)
			msleep(20);
		else
			i++;
	}

	if (err)
		dev_err(hba->dev,