From patchwork Tue Dec 6 03:11:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UGV0ZXIgV2FuZyAo546L5L+h5Y+LKQ==?= X-Patchwork-Id: 13065360 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28E49C4708C for ; Tue, 6 Dec 2022 03:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=osJu2nr6Ff383ljmn0q5/VMY+0bOUYBJtn6LYgyr0OE=; b=oPc6TxVucFNkG+jQ9kXAPbL2yI BiSdZDM+eH+1Th/6Vj2YNu5w42WNjbyhDAdFmDWNx8Ng9moHtpMgstkxhKe49aW+bheQqMNvBHO+4 5L+kpUFuHqpBc7eEF18atD4dwDnDglrFmxoMrUBK8TAzltIjBGEPct87VA/MJsQYdMQjrVUtP54nl AThIUti7FT0VLxKDvrwjOivgyQogFICk+EObkeaT7Nb6ftN1UNH+Np1IAHlX/Vee9mo5qWd5ug/MC ldPhJ5qDMYUPtt9z4ujrcgOsLboVY0MuxLZxXCHbQoi7TdvhVYs/QjrjW4oyYE+fgIrd3+8AqFckR utNdNG+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2OWn-00GSxe-QH; Tue, 06 Dec 2022 03:21:53 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p2OWl-00GSwX-7f for linux-mediatek@lists.infradead.org; Tue, 06 Dec 2022 03:21:52 +0000 X-UUID: 14e578e6052049148d1ffeedd1d00012-20221205 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=osJu2nr6Ff383ljmn0q5/VMY+0bOUYBJtn6LYgyr0OE=; b=mXrpeMLbPPH0DAkm2hq5+sFQX6weRJ1cIiIKkZQvoZzEPUc7j0P1gwXGVLDkdnmfBWedDd7y+H/Q8Sbd4LNpYuusxZxL5PVQCso0IWG3hJWB3ouQzjT4Fb/AB/TGbzP8gyQOLiS8IvtKxPheYftiGawRxiDGtPj911rgtB6+UlA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:ecd78621-eb0e-43ba-a562-69d3c09425a8,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:dcaaed0,CLOUDID:8d516924-4387-4253-a41d-4f6f2296b154,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: 14e578e6052049148d1ffeedd1d00012-20221205 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 555015220; Mon, 05 Dec 2022 20:21:48 -0700 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Tue, 6 Dec 2022 11:11:11 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 6 Dec 2022 11:11:11 +0800 From: To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v4] ufs: core: wlun suspend SSU/enter hibern8 fail recovery Date: Tue, 6 Dec 2022 11:11:09 +0800 Message-ID: <20221206031109.10609-1-peter.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221205_192151_318324_7943ED7D X-CRM114-Status: UNSURE ( 7.40 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org From: Peter Wang When SSU/enter hibern8 fail in wlun suspend flow, trigger error handler and return busy to break the suspend. If not, wlun runtime pm status become error and the consumer will stuck in runtime suspend status. Signed-off-by: Peter Wang Reviewed-by: Stanley Chu Reviewed-by: Bart Van Assche Reviewed-by: Adrian Hunter --- drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index b1f59a5fe632..98f105f32877 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -9049,6 +9049,19 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) if (!hba->dev_info.b_rpm_dev_flush_capable) { ret = ufshcd_set_dev_pwr_mode(hba, req_dev_pwr_mode); + if (ret && pm_op != UFS_SHUTDOWN_PM) { + /* + * If return err in suspend flow, IO will hang. + * Trigger error handler and break suspend for + * error recovery. + */ + spin_lock_irq(hba->host->host_lock); + hba->force_reset = true; + ufshcd_schedule_eh_work(hba); + spin_unlock_irq(hba->host->host_lock); + + ret = -EBUSY; + } if (ret) goto enable_scaling; } @@ -9060,6 +9073,19 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) */ check_for_bkops = !ufshcd_is_ufs_dev_deepsleep(hba); ret = ufshcd_link_state_transition(hba, req_link_state, check_for_bkops); + if (ret && pm_op != UFS_SHUTDOWN_PM) { + /* + * If return err in suspend flow, IO will hang. + * Trigger error handler and break suspend for + * error recovery. + */ + spin_lock_irq(hba->host->host_lock); + hba->force_reset = true; + ufshcd_schedule_eh_work(hba); + spin_unlock_irq(hba->host->host_lock); + + ret = -EBUSY; + } if (ret) goto set_dev_active;