From: Bart Van Assche <bvanassche@acm.org>
To: peter.wang@mediatek.com, linux-scsi@vger.kernel.org,
martin.petersen@oracle.com
Cc: wsd_upstream@mediatek.com, linux-mediatek@lists.infradead.org,
chun-hung.wu@mediatek.com, alice.chao@mediatek.com,
cc.chou@mediatek.com, chaotian.jing@mediatek.com,
jiajie.hao@mediatek.com, yi-fan.peng@mediatek.com,
qilin.tan@mediatek.com, lin.gui@mediatek.com,
tun-yu.yu@mediatek.com, eddie.huang@mediatek.com,
naomi.chu@mediatek.com, ed.tsai@mediatek.com
Subject: Re: [PATCH v1 01/10] ufs: host: mediatek: Fix runtime suspend error deadlock
Date: Thu, 18 Sep 2025 11:27:49 -0700 [thread overview]
Message-ID: <80a31144-852f-4df5-802e-a8c5d04a298a@acm.org> (raw)
In-Reply-To: <20250918104000.208856-2-peter.wang@mediatek.com>
On 9/18/25 3:36 AM, peter.wang@mediatek.com wrote:
> Fix the deadlock issue during runtime suspend by checking
> the error handler's progress. If the error handler is active,
> break the runtime suspend process by returning -EAGAIN.
> This approach prevents potential deadlocks when acquiring
> runtime PM and enhances system stability.
"enhances system stability" sounds like marketing language to me. Please
provide a root-cause analysis and also explain why this change is only
required for the MediaTek driver and not for any other UFS host drivers.
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
> index 758a393a9de1..b1797386668c 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -1746,9 +1746,15 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
> struct arm_smccc_res res;
>
> if (status == PRE_CHANGE) {
> - if (ufshcd_is_auto_hibern8_supported(hba))
> - return ufs_mtk_auto_hibern8_disable(hba);
> - return 0;
> + if (!ufshcd_is_auto_hibern8_supported(hba))
> + return 0;
> + err = ufs_mtk_auto_hibern8_disable(hba);
> +
> + /* May trigger EH work without exiting hibern8 error */
> + if (ufshcd_eh_in_progress(hba))
> + return -EAGAIN;
> + else
> + return err;
> }
>
> if (ufshcd_is_link_hibern8(hba)) {
How can ufs_mtk_suspend() be called while the error handler is in
progress? ufshcd_err_handler() disables RPM before it sets the
UFSHCD_EH_IN_PROGRESS flag.
> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
> index ea0021f067c9..45e2ca65de90 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -97,6 +97,11 @@ enum uic_link_state {
> UIC_LINK_BROKEN_STATE = 3, /* Link is in broken state */
> };
>
> +/* UFSHCD error handling flags */
> +enum {
> + UFSHCD_EH_IN_PROGRESS = (1 << 0),
> +};
> +
> #define ufshcd_is_link_off(hba) ((hba)->uic_link_state == UIC_LINK_OFF_STATE)
> #define ufshcd_is_link_active(hba) ((hba)->uic_link_state == \
> UIC_LINK_ACTIVE_STATE)
> @@ -129,6 +134,13 @@ enum uic_link_state {
> #define ufshcd_is_ufs_dev_deepsleep(h) \
> ((h)->curr_dev_pwr_mode == UFS_DEEPSLEEP_PWR_MODE)
>
> +#define ufshcd_set_eh_in_progress(h) \
> + ((h)->eh_flags |= UFSHCD_EH_IN_PROGRESS)
> +#define ufshcd_eh_in_progress(h) \
> + ((h)->eh_flags & UFSHCD_EH_IN_PROGRESS)
> +#define ufshcd_clear_eh_in_progress(h) \
> + ((h)->eh_flags &= ~UFSHCD_EH_IN_PROGRESS)
The UFSHCD_EH_IN_PROGRESS definition and also the
ufshcd_set_eh_in_progress() and ufshcd_clear_eh_in_progress()
definitions must remain in the UFS core private code. Please do not move
these definitions into the include/ufs/ufshcd.h header file.
Thanks,
Bart.
next prev parent reply other threads:[~2025-09-18 18:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 10:36 [PATCH v1 00/10] Enhance UFS Mediatek Driver peter.wang
2025-09-18 10:36 ` [PATCH v1 01/10] ufs: host: mediatek: Fix runtime suspend error deadlock peter.wang
2025-09-18 18:27 ` Bart Van Assche [this message]
2025-09-19 8:11 ` Peter Wang (王信友)
2025-09-19 20:57 ` Bart Van Assche
2025-09-22 8:37 ` Peter Wang (王信友)
2025-09-22 18:27 ` Bart Van Assche
2025-09-23 5:56 ` Peter Wang (王信友)
2025-09-18 10:36 ` [PATCH v1 02/10] ufs: host: mediatek: Correct clock scaling with PM QoS flow peter.wang
2025-09-18 18:30 ` Bart Van Assche
2025-09-19 8:11 ` Peter Wang (王信友)
2025-09-19 21:02 ` Bart Van Assche
2025-09-22 8:39 ` Peter Wang (王信友)
2025-09-22 19:21 ` Bart Van Assche
2025-09-23 5:58 ` Peter Wang (王信友)
2025-09-18 10:36 ` [PATCH v1 03/10] ufs: host: mediatek: Adjust clock scaling for PM flow peter.wang
2025-09-18 10:36 ` [PATCH v1 04/10] ufs: host: mediatek: Handle clock scaling for high gear in " peter.wang
2025-09-18 10:36 ` [PATCH v1 05/10] ufs: host: mediatek: Adjust sync length for FASTAUTO mode peter.wang
2025-09-18 19:28 ` Bart Van Assche
2025-09-19 8:12 ` Peter Wang (王信友)
2025-09-18 10:36 ` [PATCH v1 06/10] ufs: host: mediatek: Enable interrupts for MCQ mode peter.wang
2025-09-18 18:34 ` Bart Van Assche
2025-09-19 8:14 ` Peter Wang (王信友)
2025-09-19 21:09 ` Bart Van Assche
2025-09-22 8:41 ` Peter Wang (王信友)
2025-09-22 19:26 ` Bart Van Assche
2025-09-23 5:59 ` Peter Wang (王信友)
2025-09-18 10:36 ` [PATCH v1 07/10] ufs: host: mediatek: Fix shutdown/suspend race condition peter.wang
2025-09-18 18:39 ` Bart Van Assche
2025-09-19 8:15 ` Peter Wang (王信友)
2025-09-19 21:10 ` Bart Van Assche
2025-09-18 10:36 ` [PATCH v1 08/10] ufs: host: mediatek: Remove duplicate function peter.wang
2025-09-18 19:29 ` Bart Van Assche
2025-09-18 10:36 ` [PATCH v1 09/10] ufs: host: mediatek: Add support for new platform with MMIO_OTSD_CTR peter.wang
2025-09-18 10:36 ` [PATCH v1 10/10] ufs: host: mediatek: Support new feature for MT6991 peter.wang
2025-09-18 19:32 ` Bart Van Assche
2025-09-19 8:17 ` Peter Wang (王信友)
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=80a31144-852f-4df5-802e-a8c5d04a298a@acm.org \
--to=bvanassche@acm.org \
--cc=alice.chao@mediatek.com \
--cc=cc.chou@mediatek.com \
--cc=chaotian.jing@mediatek.com \
--cc=chun-hung.wu@mediatek.com \
--cc=ed.tsai@mediatek.com \
--cc=eddie.huang@mediatek.com \
--cc=jiajie.hao@mediatek.com \
--cc=lin.gui@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=naomi.chu@mediatek.com \
--cc=peter.wang@mediatek.com \
--cc=qilin.tan@mediatek.com \
--cc=tun-yu.yu@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