Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4763465pxu; Mon, 21 Dec 2020 23:30:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzIJrAPDf5Hx7Hwv+upr/xutvNp8j9DtEBf5B1z/gC1gNMyFSp9azQ++t5/qeY2swgtuEG X-Received: by 2002:aa7:db59:: with SMTP id n25mr18557147edt.203.1608622246337; Mon, 21 Dec 2020 23:30:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608622246; cv=none; d=google.com; s=arc-20160816; b=pZ4qCcU90d7PTWnKxb4qhSrHnVKmH6lC8lW2tmPTLbOkKfi+YAqyPGEBejax42lqbf 9IYCUOQJT5AChT9c/qUHY6gMH7T7jG305e++dz0d4WPJYD1nZuhshVx6p4F2Kd4MHApm MrnvEoyZUDh+tOFTOgzeHPGhs3Ne0zeHqM5gHm+wPOdIRDevS5HnSIgEuqNMjveutCKH KDuhEi42V/qHFl3GL4+wTi4c0bLlesCb9AwpacmJQ4ngyQYeGJdiRQ0rKRGipKrf+rba LVyQlLGVZOTU0N1c/NSbzU+Sgny+vw32BJo89I9GSj9vdltdv+yVFJZyDCbBBvovZi0X zvRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ayPdDuvatBO9tkfYrkY/pI4NDAmWLQFPZUM1u2Ciy6o=; b=t2M0o6QyBfkmOg/233YGPv6+NCbsHTHvmmrwPnCWbJ7VuYKoL3XmtvRCOdP2YnJujb JbeJAF9UaMT9T2tJEry8UBhmqQxxoOtnM7lXWIFi6zPj3RbzLfQdPW0tdHLLIkaZ4R7h IwC6/eu1xdyCrYipzglhjwWWAJXoqL+umfLOs5TKN2stI+Itn3BCdZOBY9yAzxaGgLud EXuinYqnA1bQ/Ss45vM0Pw/tY/pS6J9I5HkFw4auD4KN2cEkE/oGEAK2jzmmDGONxW+r ERkOgM+B9SmG01U3XMRavnFvJVnDifT/7B13TuDS0eADXqLx3H2A3552n155g4kvkdCz UyJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf25si10471711ejb.303.2020.12.21.23.30.22; Mon, 21 Dec 2020 23:30:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725852AbgLVH3y (ORCPT + 99 others); Tue, 22 Dec 2020 02:29:54 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:36462 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725300AbgLVH3y (ORCPT ); Tue, 22 Dec 2020 02:29:54 -0500 X-UUID: acd3b05d6aad462ca40b7be72477fd16-20201222 X-UUID: acd3b05d6aad462ca40b7be72477fd16-20201222 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2124740852; Tue, 22 Dec 2020 15:29:09 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 22 Dec 2020 15:29:06 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 22 Dec 2020 15:29:05 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , , , , , , Stanley Chu Subject: [PATCH v2 1/2] scsi: ufs: Fix possible power drain during system suspend Date: Tue, 22 Dec 2020 15:29:04 +0800 Message-ID: <20201222072905.32221-2-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201222072905.32221-1-stanley.chu@mediatek.com> References: <20201222072905.32221-1-stanley.chu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: F0EAABB76E452A13F2540CD0F980F108AA7D99BB3014DC64699FA1307E8A9B912000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently if device needs to do flush or BKOP operations, the device VCC power is kept during runtime-suspend period. However, if system suspend is happening while device is runtime-suspended, such power may not be disabled successfully. The reasons may be, 1. If current PM level is the same as SPM level, device will keep runtime-suspended by ufshcd_system_suspend(). 2. Flush recheck work may not be scheduled successfully during system suspend period. If it can wake up the system, this is also not the intention of the recheck work. To fix this issue, simply runtime-resume the device if the flush is allowed during runtime suspend period. Flush capability will be disabled while leaving runtime suspend, and also not be allowed in system suspend period. Fixes: 51dd905bd2f6 ("scsi: ufs: Fix WriteBooster flush during runtime suspend") Reviewed-by: Chaotian Jing Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e221add25a7e..9d61dc3eb842 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8903,7 +8903,8 @@ int ufshcd_system_suspend(struct ufs_hba *hba) if ((ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl) == hba->curr_dev_pwr_mode) && (ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl) == - hba->uic_link_state)) + hba->uic_link_state) && + !hba->dev_info.b_rpm_dev_flush_capable) goto out; if (pm_runtime_suspended(hba->dev)) { -- 2.18.0