From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A868918C011 for ; Fri, 26 Sep 2025 01:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=60.244.123.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758850192; cv=none; b=iwk51Tn53JPM6TBtdlew3Vv6EfgE7dD8do/5Z8cKjYew8WsYOEofMxbxCIjt7hrBnaw9AhYrwvZSiTCBIEBrNWzsdR/1FME7Lw+dv1trXkgj1+vU3iXNksb8x1WOw++Rw7QL+Q0WvSxhs5CBnZDyZc/4sXJgqHmOP5ELkCH1sN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758850192; c=relaxed/simple; bh=n3HUOU58L4HrnUe/kLVELMgQ9ELK2Qn2qs2a1J+HZQw=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=ub1SA7D4mUOJsH3aDT6n52m/zDR0JUhNRpYSfC9yO0zWb3ggDeix0sAh0MZvnwoaPcHxsFirBx0pH3FDutGAMboAV8MB49HZJjyi0dw3+TmboH4Wof5yEizIeGP4/5btLcW0Kfz41ux29qU1o3x6cduhkS92UnxcqtjMRw43Ib4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b=BTPLJtA5; arc=none smtp.client-ip=60.244.123.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="BTPLJtA5" X-UUID: 478b6a189a7811f08d9e1119e76e3a28-20250926 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=xwpcnj/gLNO00jCiyZdggOPX41apJPSkaDAZWSmuLN4=; b=BTPLJtA55ublbPtq7ECAwr8PKjpV6DfLPERe4G3cE0Ln5LAQKnpkY3gKKXOqhCIjJ/oB9bsnGWJgCsrvAkgkZQ0pOoRMBGR//kApo9GlDrp2kZiAHOS+zZL335MHxcookr6VadCr3KZrsXfirFM29W2WbV0mR+Bq19yUCGAeGEY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.6,REQID:2df58769-8202-494b-8bc8-1d17ba919970,IP:0,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION:r elease,TS:0 X-CID-META: VersionHash:a9d874c,CLOUDID:e64ab3f8-ebfe-43c9-88c9-80cb93f22ca4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102|836|888|898,TC:-5,Content:0|15|5 0,EDM:-3,IP:nil,URL:0,File:130,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 478b6a189a7811f08d9e1119e76e3a28-20250926 Received: from mtkmbs14n2.mediatek.inc [(172.21.101.76)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 604144747; Fri, 26 Sep 2025 09:29:43 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Fri, 26 Sep 2025 09:29:41 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Fri, 26 Sep 2025 09:29:41 +0800 From: To: , , , , CC: , , , , , , , , , , , , , , , Subject: [PATCH v3] ufs: core: Fix runtime suspend error deadlock Date: Fri, 26 Sep 2025 09:29:26 +0800 Message-ID: <20250926012940.3933367-1-peter.wang@mediatek.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N From: Peter Wang Resolve the deadlock issue during runtime suspend when an error triggers the error handler. Prevent the deadlock by checking pm_op_in_progress and performing a quick recovery. This approach ensures that the error handler does not wait indefinitely for runtime PM to resume, allowing runtime suspend to proceed smoothly. Signed-off-by: Peter Wang Suggested-by: Bart Van Assche Reviewed-by: Bart Van Assche --- drivers/ufs/core/ufshcd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 88a0e9289ca6..8185a7791923 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -6681,6 +6681,14 @@ static void ufshcd_err_handler(struct work_struct *work) } spin_unlock_irqrestore(hba->host->host_lock, flags); + ufshcd_rpm_get_noresume(hba); + if (hba->pm_op_in_progress) { + ufshcd_link_recovery(hba); + ufshcd_rpm_put(hba); + return; + } + ufshcd_rpm_put(hba); + ufshcd_err_handling_prepare(hba); spin_lock_irqsave(hba->host->host_lock, flags); -- 2.45.2