[PATCH v1 01/10] ufs: host: mediatek: Fix runtime suspend error deadlock

Peter Wang (王信友) peter.wang at mediatek.com
Fri Sep 19 01:11:05 PDT 2025


On Thu, 2025-09-18 at 11:27 -0700, Bart Van Assche wrote:
> On 9/18/25 3:36 AM, peter.wang at 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.
> 

Hi Bart,

Apologies, I’m not sure how to express this in a way that
doesn’t sound like marketing language. But this patch is 
indeed meant to enhance system stability, and the reason 
is quite trivial.

An error occurred during the suspend process, causing IO to hang.
This is because the error handler (eh) work is waiting for
resume, while the suspend work is waiting for the error handler 
to finish before sending SSU.


> > 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.
> 

This error is triggered by ufs_mtk_auto_hibern8_disable,
As the comment description
/* May trigger EH work without exiting hibern8 error */
so it could happen during the suspend period.


> 
> 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.


Do you think we should check ufshcd_eh_in_progress in 
__ufshcd_wl_suspend? I'm not sure, because we don't see this 
error on all UFS hosts — the vendor suspend operations 
(ufshcd_vops_suspend) could be different.

Thanks.
Peter




More information about the Linux-mediatek mailing list