From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53C99C4CED0 for ; Wed, 18 Sep 2019 21:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 286C521907 for ; Wed, 18 Sep 2019 21:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387888AbfIRVbX (ORCPT ); Wed, 18 Sep 2019 17:31:23 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:42258 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732113AbfIRVbV (ORCPT ); Wed, 18 Sep 2019 17:31:21 -0400 Received: from 79.184.255.25.ipv4.supernova.orange.pl (79.184.255.25) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.292) id ff4cb8bbef048af8; Wed, 18 Sep 2019 23:31:19 +0200 From: "Rafael J. Wysocki" To: Mario Limonciello Cc: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, LKML , Ryan Hong , Crag Wang , sjg@google.com, Jared Dominguez , Linux PCI , Linux PM Subject: Re: [PATCH] nvme-pci: Save PCI state before putting drive into deepest state Date: Wed, 18 Sep 2019 23:31:19 +0200 Message-ID: <4858057.cjDlXVALXj@kreacher> In-Reply-To: <1568245353-13787-1-git-send-email-mario.limonciello@dell.com> References: <1568245353-13787-1-git-send-email-mario.limonciello@dell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, September 12, 2019 1:42:33 AM CEST Mario Limonciello wrote: > The action of saving the PCI state will cause numerous PCI configuration > space reads which depending upon the vendor implementation may cause > the drive to exit the deepest NVMe state. > > In these cases ASPM will typically resolve the PCIe link state and APST > may resolve the NVMe power state. However it has also been observed > that this register access after quiesced will cause PC10 failure > on some device combinations. > > To resolve this, move the PCI state saving to before SetFeatures has been > called. This has been proven to resolve the issue across a 5000 sample > test on previously failing disk/system combinations. This sounds reasonable to me, but it would be nice to CC that to linux-pm and/or linux-pci too. > Signed-off-by: Mario Limonciello > --- > drivers/nvme/host/pci.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c > index 732d5b6..9b3fed4 100644 > --- a/drivers/nvme/host/pci.c > +++ b/drivers/nvme/host/pci.c > @@ -2894,6 +2894,13 @@ static int nvme_suspend(struct device *dev) > if (ret < 0) > goto unfreeze; > > + /* > + * A saved state prevents pci pm from generically controlling the > + * device's power. If we're using protocol specific settings, we don't > + * want pci interfering. > + */ > + pci_save_state(pdev); > + > ret = nvme_set_power_state(ctrl, ctrl->npss); > if (ret < 0) > goto unfreeze; > @@ -2908,12 +2915,6 @@ static int nvme_suspend(struct device *dev) This is the case in which the PCI layer is expected to put the device into D3, so you need pdev->state_saved = 0; at this point, because you have saved the config space already. > ret = 0; > goto unfreeze; And here you don't need to jump to "unfreeze" any more. > } > - /* > - * A saved state prevents pci pm from generically controlling the > - * device's power. If we're using protocol specific settings, we don't > - * want pci interfering. > - */ > - pci_save_state(pdev); > unfreeze: > nvme_unfreeze(ctrl); > return ret; >