Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2274688pxb; Mon, 11 Jan 2021 05:48:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXhHoQZvtpcm/SpywjTLlN5qLYOCaPoOCg9UWnjxiqOP28NmiuR063X+5yDWStDyRmRXYN X-Received: by 2002:a17:906:154d:: with SMTP id c13mr11041439ejd.471.1610372897048; Mon, 11 Jan 2021 05:48:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372897; cv=none; d=google.com; s=arc-20160816; b=mmxwa6+ZCh3PgaIMsVowJ6x0XvJ7AWnf3p7O8EG5K7Iq2rZcr11Rwy1h9WsMXq4aGa agO1OZziKm8iwsk1HMxM3tgVFQHKtBvVsEMNPFc4/Ooac+N04MfYyqJbGMYSu+3LJXry GNFvuCu9t0J463TCuCcXZaojdMebY/1X4UjS16XcCk74fevHRZXypah7c14dd8oz7sMF ro7SYl68eC3zsO5R9hG6SEiLioPY0tQ3X+QBE3cNmISveLoApThIyMZgqBii9dx2AZo5 6S+5PoItmPvmHpfHARTOAssGbl7UBSR1VIjojKuErIhrxcwp/lPeKUusBqoedoO499PA pSRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JbLwKQGO2+eSY+XAaE3oOi5nQgmM+U3iRYZZTiifLRE=; b=1CT2n24kGU1V6zF1g7Bu6J2ZUPzqU+qObFi9Zh87J3BYkAygi4oSbo21Ax5GJQnMzt Z2pOG3zpAlzt0+FwSH/hgNpnKq6erWw8W8kynpHQrUgZkVX0hXBeYoRmPY8QpAcC2438 8F+YGxWFpCAph7+pVedklitt5EhQLmy+xHZtx2XXO0I0cjCo670p/LDflgl3TsMde1My Q/IHoxXq9Ff8/ZqnqXzRWiNbqZ4Ov34fFb3wyAfMWmPbhERVavpDCcMcVjnk8Wi0aR+y YB1Zvw+sglTiGh9Ze09KRM+nf3CQdJKSRqbGB0Say4cVU0Si4c9/VCk3Vb/UxX62noLu /Q8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WRSobjXq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si6840166ejd.409.2021.01.11.05.47.53; Mon, 11 Jan 2021 05:48:17 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WRSobjXq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731390AbhAKNL1 (ORCPT + 99 others); Mon, 11 Jan 2021 08:11:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:57080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731236AbhAKNKk (ORCPT ); Mon, 11 Jan 2021 08:10:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25847227C3; Mon, 11 Jan 2021 13:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370624; bh=BQSipWm4K8jrZ6XWz6uhxK9p+QWwX1+/3UZ0O6jNdkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WRSobjXqWIzYURRcWNiy5kfO0Un2p1rGmlQnl80mrfTrWSou0DKrFQdqvbam6qGVZ JvgWnC7sj71k/Ovu2TZhOMAg8uDNE3FrnXJYn55lhVCXwJWPpESuBzi/q506Z7431f 9Z113A8pnOXFDNc6S8P+pI4+6ehK4m77/wlDfhbc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 03/92] scsi: ufs-pci: Ensure UFS device is in PowerDown mode for suspend-to-disk ->poweroff() Date: Mon, 11 Jan 2021 14:01:07 +0100 Message-Id: <20210111130039.323817472@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter [ Upstream commit af423534d2de86cd0db729a5ac41f056ca8717de ] The expectation for suspend-to-disk is that devices will be powered-off, so the UFS device should be put in PowerDown mode. If spm_lvl is not 5, then that will not happen. Change the pm callbacks to force spm_lvl 5 for suspend-to-disk poweroff. Link: https://lore.kernel.org/r/20201207083120.26732-3-adrian.hunter@intel.com Signed-off-by: Adrian Hunter Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd-pci.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c index 3b19de3ae9a30..e4ba2445ff56f 100644 --- a/drivers/scsi/ufs/ufshcd-pci.c +++ b/drivers/scsi/ufs/ufshcd-pci.c @@ -96,6 +96,30 @@ static int ufshcd_pci_resume(struct device *dev) { return ufshcd_system_resume(dev_get_drvdata(dev)); } + +/** + * ufshcd_pci_poweroff - suspend-to-disk poweroff function + * @dev: pointer to PCI device handle + * + * Returns 0 if successful + * Returns non-zero otherwise + */ +static int ufshcd_pci_poweroff(struct device *dev) +{ + struct ufs_hba *hba = dev_get_drvdata(dev); + int spm_lvl = hba->spm_lvl; + int ret; + + /* + * For poweroff we need to set the UFS device to PowerDown mode. + * Force spm_lvl to ensure that. + */ + hba->spm_lvl = 5; + ret = ufshcd_system_suspend(hba); + hba->spm_lvl = spm_lvl; + return ret; +} + #endif /* !CONFIG_PM_SLEEP */ #ifdef CONFIG_PM @@ -190,8 +214,14 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) } static const struct dev_pm_ops ufshcd_pci_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(ufshcd_pci_suspend, - ufshcd_pci_resume) +#ifdef CONFIG_PM_SLEEP + .suspend = ufshcd_pci_suspend, + .resume = ufshcd_pci_resume, + .freeze = ufshcd_pci_suspend, + .thaw = ufshcd_pci_resume, + .poweroff = ufshcd_pci_poweroff, + .restore = ufshcd_pci_resume, +#endif SET_RUNTIME_PM_OPS(ufshcd_pci_runtime_suspend, ufshcd_pci_runtime_resume, ufshcd_pci_runtime_idle) -- 2.27.0