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

Commit 27475f8c authored by Subhash Jadavani's avatar Subhash Jadavani
Browse files

scsi: ufs: add retries for hibern8 enter



If hibern8 enter command fails then UFS link state may be unknown which
may result into timeout of all the commands issued after failure.

This change does 2 things (for pre-defined number of retry counts) after
hibern8 enter failure:
1. Recovers the UFS link to active state
2. If link is recovered to active state, tries to put the UFS link in
   hibern8 enter again until retry count expires.

Change-Id: I6ae6d1371126b3b71ba2154182d6b9920e8996f5
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
parent 792eb6a3
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -140,6 +140,9 @@
/* maximum number of link-startup retries */
#define DME_LINKSTARTUP_RETRIES 3

/* Maximum retries for Hibern8 enter */
#define UIC_HIBERN8_ENTER_RETRIES 3

/* maximum number of reset retries before giving up */
#define MAX_HOST_RESET_RETRIES 5

@@ -3643,7 +3646,7 @@ static int ufshcd_link_recovery(struct ufs_hba *hba)
	return ret;
}

static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
static int __ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
{
	int ret;
	struct uic_command uic_cmd = {0};
@@ -3658,6 +3661,12 @@ static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
		UFSHCD_UPDATE_ERROR_STATS(hba, UFS_ERR_HIBERN8_ENTER);
		dev_err(hba->dev, "%s: hibern8 enter failed. ret = %d",
			__func__, ret);
		/*
		 * If link recovery fails then return error so that caller
		 * don't retry the hibern8 enter again.
		 */
		if (ufshcd_link_recovery(hba))
			ret = -ENOLINK;
	} else {
		dev_dbg(hba->dev, "%s: Hibern8 Enter at %lld us", __func__,
			ktime_to_us(ktime_get()));
@@ -3666,6 +3675,19 @@ static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
	return ret;
}

static int ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
{
	int ret = 0, retries;

	for (retries = UIC_HIBERN8_ENTER_RETRIES; retries > 0; retries--) {
		ret = __ufshcd_uic_hibern8_enter(hba);
		if (!ret || ret == -ENOLINK)
			goto out;
	}
out:
	return ret;
}

static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
{
	struct uic_command uic_cmd = {0};