From patchwork Wed Dec 28 06:01:57 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: 13082709 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 CD775C4167B for ; Wed, 28 Dec 2022 06:03:29 +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=wiYFVfxNlNI/ohkpHnj9j4/4wiWx5D1lBRjT+uCIufQ=; b=FSKVjbJgsFiicZxvVsYe/N09cg e8OyqeRpMDTQkfr0Rc3S+yDFEzZ+GCFypQ0RMLOqtI4YxRE9gUuCs3UQ52sYpYtQUnKLl8OHtlB6o E19QWXljucP4jOg48TL3rSzF3QIuBugIYVw2VypXGHQ8VFy8X+UlWlzIl851Qj9pRRHiJ1pYKzo5f d4EkvKhlI5azUBDpzJnlTL3x70QgwK+hNZdEYY/uERnSSEB2G14WYgrx2K31YqY1bVSsWhLlj11xY 0V8KtlL53bEJ0ipT7TVGlLCISymcUiSJtm2+7iwpjz6uNn1scvn4ZeJLVeAXci4I6SMdGHWqhlYb0 uroL3gNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAPWy-002Bg8-HR; Wed, 28 Dec 2022 06:03:12 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAPWr-002Bef-DR for linux-mediatek@bombadil.infradead.org; Wed, 28 Dec 2022 06:03:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=wiYFVfxNlNI/ohkpHnj9j4/4wiWx5D1lBRjT+uCIufQ=; b=g1QK1CmBGpYopHjrozOQLKmw4J kF9KZ60Gvvg4Sts9BdzNvPfiR7JZMB5cYG1q6cEl/3qymhamTDu1x20RJXjwH14LXvaMMxlmpvbqp /Z/Ld+VTmyxmFKFwJNDoerRLF3Vf4WDU7civdFU2PenoIT9AmOHl8AOVzcq/1NfXysl3ggQ5Y9MX1 x+Cqsy+MPhIAgNJtNqqMEnp5IK1wg6JSOEijSh26me9SiSLnvmV3APcEMU8B62xiEkmS+VhkPOYYy 6zx+SZTRJtZ9ANy2E55eUyia5H7Dr3K4wHqVbRrvb7BtnhfgdJ1qS7aG/FuA6fCZWKU7NNE1mlX6m xUOD0ODQ==; Received: from mailgw01.mediatek.com ([216.200.240.184]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pAPWg-00Fu9J-1n for linux-mediatek@lists.infradead.org; Wed, 28 Dec 2022 06:02:59 +0000 X-UUID: ef1751c84e324e35b51af4075a9b8a8e-20221227 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=wiYFVfxNlNI/ohkpHnj9j4/4wiWx5D1lBRjT+uCIufQ=; b=V3MU+Cp/7WOg2Bm2eE0KzpLNIOCglwQdV1lXpJVEdakxe3d/3aozNgIrBZcA04XNJP2k9sbu/kFsqYh3dgqY6Fkc8y0nuwamrjRrCiaPvgBh8YW92dDS2MzCXDsrj0NhNKSKgCj6ti2lohlkMDcSPxLOnOBX8CVB41AZl8rcvEo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.14,REQID:de2ae0ea-b724-4068-9f53-d9468cf1d1f1,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:95 X-CID-INFO: VERSION:1.1.14,REQID:de2ae0ea-b724-4068-9f53-d9468cf1d1f1,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTION :quarantine,TS:95 X-CID-META: VersionHash:dcaaed0,CLOUDID:c7a79a8a-8530-4eff-9f77-222cf6e2895b,B ulkID:221228140213F34ZXJJX,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: ef1751c84e324e35b51af4075a9b8a8e-20221227 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 439881535; Tue, 27 Dec 2022 23:02:11 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 28 Dec 2022 14:01:59 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 28 Dec 2022 14:01:59 +0800 From: To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v3] ufs: core: wlun resume SSU(Acitve) fail recovery Date: Wed, 28 Dec 2022 14:01:57 +0800 Message-ID: <20221228060157.24852-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-20221228_060257_502944_8A7FAFF4 X-CRM114-Status: UNSURE ( 8.19 ) 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 wlun resume SSU(Active) timeout, scsi try eh_host_reset_handler. But ufshcd_eh_host_reset_handler hang at wait flush_work(&hba->eh_work). And ufshcd_err_handler hang at wait rpm resume. Do link recovery only in this case. Below is IO hang stack dump. schedule+0x110/0x204 schedule_timeout+0x98/0x138 wait_for_common_io+0x130/0x2d0 blk_execute_rq+0x10c/0x16c __scsi_execute+0xfc/0x278 ufshcd_set_dev_pwr_mode+0x1c8/0x40c __ufshcd_wl_resume+0xf0/0x5cc ufshcd_wl_runtime_resume+0x40/0x18c scsi_runtime_resume+0x88/0x104 __rpm_callback+0x1a0/0xaec rpm_resume+0x7e0/0xcd0 __rpm_callback+0x430/0xaec rpm_resume+0x800/0xcd0 pm_runtime_work+0x148/0x198 schedule+0x110/0x204 schedule_timeout+0x48/0x138 wait_for_common+0x144/0x2dc __flush_work+0x3d0/0x508 ufshcd_eh_host_reset_handler+0x134/0x3a8 scsi_try_host_reset+0x54/0x204 scsi_eh_ready_devs+0xb30/0xd48 scsi_error_handler+0x260/0x874 schedule+0x110/0x204 rpm_resume+0x120/0xcd0 __pm_runtime_resume+0xa0/0x17c ufshcd_err_handling_prepare+0x40/0x430 ufshcd_err_handler+0x1c4/0xd4c Signed-off-by: Peter Wang --- drivers/ufs/core/ufshcd.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index e18c9f4463ec..0dfb9a35bf66 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -7366,6 +7366,23 @@ static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd) hba = shost_priv(cmd->device->host); + /* + * If pm op resume fail and wait err recovery, do link recovery only. + * Because schedule eh work will get dead lock in ufshcd_rpm_get_sync + * and wait wlun resume, but wlun resume error wait eh work finish. + */ + if (hba->pm_op_in_progress && + hba->curr_dev_pwr_mode != UFS_ACTIVE_PWR_MODE) { + err = ufshcd_link_recovery(hba); + if (err) { + dev_err(hba->dev, "%s: power state %d pm_progress %d", + __func__, + hba->curr_dev_pwr_mode, + hba->pm_op_in_progress); + } + return err; + } + spin_lock_irqsave(hba->host->host_lock, flags); hba->force_reset = true; ufshcd_schedule_eh_work(hba);