From: <naomi.chu@mediatek.com>
To: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Avri Altman <avri.altman@wdc.com>,
Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: <wsd_upstream@mediatek.com>, <naomi.chu@mediatek.com>,
<peter.wang@mediatek.com>, <alice.chao@mediatek.com>,
<chun-hung.wu@mediatek.com>, <cc.chou@mediatek.com>,
<yi-fan.peng@mediatek.com>
Subject: [PATCH 1/1] ufs: core: add fatal errors check for LINERESET
Date: Fri, 23 May 2025 18:10:34 +0800 [thread overview]
Message-ID: <20250523101041.3615819-1-naomi.chu@mediatek.com> (raw)
From: Naomi Chu <naomi.chu@mediatek.com>
The current error handling flow directly checks the power mode after a
LINERESET occurs. However, if a PA_INIT_ERR occurs after the LINERESET,
checking the power mode may require waiting for three DME_GET timeouts,
which wastes 1.5 seconds.
To improve efficiency, when a LINERESET occurs, wait for PA_INIT to
complete and check for any other errors. After a LINERESET, PA_INIT
takes up to 75.4ms to complete. Therefore, a 100ms delay is added.
Signed-off-by: Naomi Chu <naomi.chu@mediatek.com>
---
drivers/ufs/core/ufshcd.c | 45 +++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 7735421e3991..c7cc62429fc9 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -6359,6 +6359,46 @@ static inline bool ufshcd_is_saved_err_fatal(struct ufs_hba *hba)
(hba->saved_err & (INT_FATAL_ERRORS | UFSHCD_UIC_HIBERN8_MASK));
}
+static bool ufshcd_is_linereset_fatal(struct ufs_hba *hba)
+{
+ bool needs_reset = true;
+ unsigned long flags;
+ int err;
+
+ spin_lock_irqsave(hba->host->host_lock, flags);
+
+ if (ufshcd_is_saved_err_fatal(hba)) {
+ spin_unlock_irqrestore(hba->host->host_lock, flags);
+ goto out;
+ }
+
+ /*
+ * Wait for 100ms to ensure the PA_INIT flow is complete,
+ * and check for PA_INIT_ERR or other fatal errors.
+ */
+ spin_unlock_irqrestore(hba->host->host_lock, flags);
+ msleep(100);
+ spin_lock_irqsave(hba->host->host_lock, flags);
+
+ if (ufshcd_is_saved_err_fatal(hba)) {
+ spin_unlock_irqrestore(hba->host->host_lock, flags);
+ goto out;
+ }
+
+ /*
+ * PA_INIT_ERR on the device side will not trigger UIC
+ * error interrupt.
+ * Send NOP to check if the link is alive.
+ */
+ spin_unlock_irqrestore(hba->host->host_lock, flags);
+ err = ufshcd_verify_dev_init(hba);
+ if (!err)
+ needs_reset = false;
+
+out:
+ return needs_reset;
+}
+
void ufshcd_schedule_eh_work(struct ufs_hba *hba)
{
lockdep_assert_held(hba->host->host_lock);
@@ -6655,6 +6695,11 @@ static void ufshcd_err_handler(struct work_struct *work)
if (!hba->saved_uic_err)
hba->saved_err &= ~UIC_ERROR;
spin_unlock_irqrestore(hba->host->host_lock, flags);
+ if (ufshcd_is_linereset_fatal(hba)) {
+ needs_reset = true;
+ spin_lock_irqsave(hba->host->host_lock, flags);
+ goto do_reset;
+ }
if (ufshcd_is_pwr_mode_restore_needed(hba))
needs_restore = true;
spin_lock_irqsave(hba->host->host_lock, flags);
--
2.45.2
next reply other threads:[~2025-05-23 10:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 10:10 naomi.chu [this message]
2025-05-23 16:14 ` Bart Van Assche
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=20250523101041.3615819-1-naomi.chu@mediatek.com \
--to=naomi.chu@mediatek.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alice.chao@mediatek.com \
--cc=alim.akhtar@samsung.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=avri.altman@wdc.com \
--cc=bvanassche@acm.org \
--cc=cc.chou@mediatek.com \
--cc=chun-hung.wu@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=peter.wang@mediatek.com \
--cc=wsd_upstream@mediatek.com \
--cc=yi-fan.peng@mediatek.com \
/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
all inboxes | Powered by JetHome®