diff mbox series

[v1] ufs: core: fix another deadlock when rtc update

Message ID 20241023131904.9749-1-peter.wang@mediatek.com (mailing list archive)
State Superseded
Headers show
Series [v1] ufs: core: fix another deadlock when rtc update | expand

Commit Message

Peter Wang (王信友) Oct. 23, 2024, 1:19 p.m. UTC
From: Peter Wang <peter.wang@mediatek.com>

When ufshcd_rtc_work calls ufshcd_rpm_put_sync and the pm's
usage_count is 0, it will enter the runtime suspend callback.
However, the runtime suspend callback will wait to flush
ufshcd_rtc_work, causing a deadlock.
Replacing ufshcd_rpm_put_sync with ufshcd_rpm_put can avoid
the deadlock.

Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
Cc: <stable@vger.kernel.org> 6.11.x

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
 drivers/ufs/core/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bart Van Assche Oct. 23, 2024, 7:34 p.m. UTC | #1
On 10/23/24 6:19 AM, peter.wang@mediatek.com wrote:
> From: Peter Wang <peter.wang@mediatek.com>
> 
> When ufshcd_rtc_work calls ufshcd_rpm_put_sync and the pm's
> usage_count is 0, it will enter the runtime suspend callback.
> However, the runtime suspend callback will wait to flush
> ufshcd_rtc_work, causing a deadlock.
> Replacing ufshcd_rpm_put_sync with ufshcd_rpm_put can avoid
> the deadlock.
> 
> Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
> Cc: <stable@vger.kernel.org> 6.11.x
> 
> Signed-off-by: Peter Wang <peter.wang@mediatek.com>

No blank lines in the tags section please. Additionally, a hash sign
(#) is missing between "<stable@vger.kernel.org>" and "6.11.x".
Otherwise this patch looks good to me. Hence:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Peter Wang (王信友) Oct. 24, 2024, 1:53 a.m. UTC | #2
On Wed, 2024-10-23 at 12:34 -0700, Bart Van Assche wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  
> On 10/23/24 6:19 AM, peter.wang@mediatek.com wrote:
> > From: Peter Wang <peter.wang@mediatek.com>
> > 
> > When ufshcd_rtc_work calls ufshcd_rpm_put_sync and the pm's
> > usage_count is 0, it will enter the runtime suspend callback.
> > However, the runtime suspend callback will wait to flush
> > ufshcd_rtc_work, causing a deadlock.
> > Replacing ufshcd_rpm_put_sync with ufshcd_rpm_put can avoid
> > the deadlock.
> > 
> > Fixes: 6bf999e0eb41 ("scsi: ufs: core: Add UFS RTC support")
> > Cc: <stable@vger.kernel.org> 6.11.x
> > 
> > Signed-off-by: Peter Wang <peter.wang@mediatek.com>
> 
> No blank lines in the tags section please. Additionally, a hash sign
> (#) is missing between "<stable@vger.kernel.org>" and "6.11.x".
> Otherwise this patch looks good to me. Hence:
> 
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>

Hi Bart,

I will update commit message next version.

Thanks
Peter
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index a63dcf48e59d..f5846598d80e 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8219,7 +8219,7 @@  static void ufshcd_update_rtc(struct ufs_hba *hba)
 
 	err = ufshcd_query_attr(hba, UPIU_QUERY_OPCODE_WRITE_ATTR, QUERY_ATTR_IDN_SECONDS_PASSED,
 				0, 0, &val);
-	ufshcd_rpm_put_sync(hba);
+	ufshcd_rpm_put(hba);
 
 	if (err)
 		dev_err(hba->dev, "%s: Failed to update rtc %d\n", __func__, err);