From: Dolev Raviv <draviv@codeaurora.org>
To: James.Bottomley@HansenPartnership.com
Cc: linux-scsi@vger.kernel.org, linux-scsi-owner@vger.kernel.org,
sthumma@codeaurora.org, linux-arm-msm@vger.kernel.org,
santoshsy@gmail.com, Dolev Raviv <draviv@codeaurora.org>
Subject: [PATCH 3/3] scsi: ufs: retry if the link-startup fails
Date: Tue, 1 Jul 2014 12:22:39 +0300 [thread overview]
Message-ID: <1404206559-21445-4-git-send-email-draviv@codeaurora.org> (raw)
In-Reply-To: <1404206559-21445-1-git-send-email-draviv@codeaurora.org>
From: Sujit Reddy Thumma <sthumma@codeaurora.org>
In some cases, due to hardware timing issues the Uni-Pro link-startup
might fail. The UFS HCI recovery procedure contradicts the Uni-Pro
sequence. The UFS HCI specifies to resend DME_LINKSTARTUP command
after IS.ULLS (link-lost interrupt) is received. The Uni-Pro specifies
that if link-startup fails the link is in "down" state. The link-lost is
indicated to the DME user only when the link is up. Hence, the UFS HCI
recovery procedure of waiting for IS.ULLS and retrying link-startup may
not work properly.
In order to resolve the ambiguity, reset the host controller to make
sure the link is in down state and retry the link-startup.
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
---
drivers/scsi/ufs/ufshcd.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index f189e8a..3776f5d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -58,6 +58,9 @@
/* Task management command timeout */
#define TM_CMD_TIMEOUT 100 /* msecs */
+/* maximum number of link-startup retries */
+#define DME_LINKSTARTUP_RETRIES 3
+
/* Expose the flag value from utp_upiu_query.value */
#define MASK_QUERY_UPIU_FLAG_LOC 0xFF
@@ -1923,12 +1926,32 @@ static int ufshcd_hba_enable(struct ufs_hba *hba)
static int ufshcd_link_startup(struct ufs_hba *hba)
{
int ret;
+ int retries = DME_LINKSTARTUP_RETRIES;
/* enable UIC related interrupts */
ufshcd_enable_intr(hba, UIC_COMMAND_COMPL);
- ret = ufshcd_dme_link_startup(hba);
+ do {
+ ret = ufshcd_dme_link_startup(hba);
+
+ /* check if device is detected by inter-connect layer */
+ if (!ret && !ufshcd_is_device_present(hba)) {
+ dev_err(hba->dev, "%s: Device not present\n", __func__);
+ ret = -ENXIO;
+ goto out;
+ }
+
+ /*
+ * DME link lost indication is only received when link is up,
+ * but we can't be sure if the link is up until link startup
+ * succeeds. So reset the local Uni-Pro and try again.
+ */
+ if (ret && ufshcd_hba_enable(hba))
+ goto out;
+ } while (ret && retries--);
+
if (ret)
+ /* failed to get the link up... retire */
goto out;
ret = ufshcd_make_hba_operational(hba);
--
1.8.5.2
--
QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
next prev parent reply other threads:[~2014-07-01 9:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-01 9:22 [PATCH 0/3] ufs driver fixes and updates Dolev Raviv
2014-07-01 9:22 ` [PATCH 1/3] scsi: ufs: read door bell register after clearing interrupt aggregation Dolev Raviv
2014-07-01 9:22 ` [PATCH 2/3] scsi: ufs: Fix sending unsupported SCSI command Dolev Raviv
2014-07-01 9:22 ` Dolev Raviv [this message]
2014-07-07 10:37 ` [PATCH 3/3] scsi: ufs: retry if the link-startup fails Christoph Hellwig
2014-07-08 10:18 ` Dolev Raviv
2014-07-08 10:35 ` 'Christoph Hellwig'
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404206559-21445-4-git-send-email-draviv@codeaurora.org \
--to=draviv@codeaurora.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-scsi-owner@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=santoshsy@gmail.com \
--cc=sthumma@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox