Received: by 10.223.185.116 with SMTP id b49csp6080627wrg; Thu, 8 Mar 2018 01:14:34 -0800 (PST) X-Google-Smtp-Source: AG47ELtwk/Os83zN+wLeuqmTBYSdwOFU2dhcJHVrI289xDq59vDKgIdVOqJLFo9bgaZ5fCLMojXS X-Received: by 2002:a17:902:ab88:: with SMTP id f8-v6mr23760269plr.325.1520500474189; Thu, 08 Mar 2018 01:14:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520500474; cv=none; d=google.com; s=arc-20160816; b=zs8YxHzxHJV/oOeyVCQ3/gzdXdumPkXs+OtcfN0CEdQAD38aMyFVB/1fvzSwMciPgx ollrOsswp3P9FRW2QoeQwVcsfdCK4Z9rtu0gDDCiPkXpoRg1jEU9gWa4ep+4KwvxYyZB afGpdIIISglB8Uhyv0+C7LhgVIE1SzZBLcF/cviQeqayJGO8YzEQaD0xToZP6BszVEZd iNUo1Z4utP73znCR6Kyrzec3IfYAVeSSLFhzQpE6JDDz7A+ZQbUqGQISAaiuE9EXYCes HGBoQwJsUkVXLSR2B+hMU7rj1g3iOVM3H1nDeyLA/++F/UfO8e5LlCSq09MoETzdhZLT gukw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=w98LulcWkqjNczZvWjkTRQOUKdky34ZLJ7l9GqF6bng=; b=jDc7dkl1LBLAGUsWnRqQJvzKfOn7jwAm3tVOOHhBKSoA2U0iUdYc9kG7rglbDktotz F9JwL36o2wZXtHwt62Jldoj5ZkbqPDXyugTC9r0QcxDJDE+7OW22nOXqDyjoThIUjZVD cWcVd70x8gXgHVh9DwpX+ghxA90U+tgBy1lsNm5/bO/cFgR1+VTS1xFRUNRFo8Jf5PB/ KxAaYbs4tU4E4abtLyjsjUpE25yuupAzB4fuW+Q7mzsIOnuqxM119dwfmQHhaFzKM/6B 8h0brj0D+dacgEStYoCKWL6KoXYm0MsxDrJKSCc0eVFHBUpgt0cARqjUfINZsqz3efrf P5JQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3si12679918pgn.642.2018.03.08.01.14.19; Thu, 08 Mar 2018 01:14:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935635AbeCHJNE (ORCPT + 99 others); Thu, 8 Mar 2018 04:13:04 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:46198 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935359AbeCHJM7 (ORCPT ); Thu, 8 Mar 2018 04:12:59 -0500 Received: from 79.184.254.228.ipv4.supernova.orange.pl (79.184.254.228) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id 91132b46c2d05ffb; Thu, 8 Mar 2018 10:12:57 +0100 From: "Rafael J. Wysocki" To: Lukas Wunner Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Keith Busch , Sinan Kaya Subject: Re: [PATCH v1 2/9] PCI/PM: Clear PCIe PME Status bit in core, not PCIe port driver Date: Thu, 08 Mar 2018 10:13:39 +0100 Message-ID: <8601339.xFspzpXtrk@aspire.rjw.lan> In-Reply-To: <20180308080331.GA5671@wunner.de> References: <152040297576.240786.1532465558381209070.stgit@bhelgaas-glaptop.roam.corp.google.com> <152040321483.240786.16597888035806933750.stgit@bhelgaas-glaptop.roam.corp.google.com> <20180308080331.GA5671@wunner.de> 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, March 8, 2018 9:03:31 AM CET Lukas Wunner wrote: > On Wed, Mar 07, 2018 at 12:13:34AM -0600, Bjorn Helgaas wrote: > > From: Bjorn Helgaas > > > > fe31e69740ed ("PCI/PCIe: Clear Root PME Status bits early during system > > resume") added a .resume_noirq() callback to the PCIe port driver to clear > > the PME Status bit during resume to work around a BIOS issue. > > > > The BIOS evidently enabled PME interrupts for ACPI-based runtime wakeups > > but did not clear the PME Status bit during resume, which meant PMEs after > > resume did not trigger interrupts because PME Status did not transition > > from cleared to set. > > > > The fix was in the PCIe port driver, so it worked when CONFIG_PCIEPORTBUS > > was set. But I think we *always* want the fix because the platform may use > > PME interrupts even if Linux is built without the PCIe port driver. > > > > Move the fix from the port driver to the PCI core so we can work around > > this "PME doesn't work after waking from a sleep state" issue regardless of > > CONFIG_PCIEPORTBUS. > > > > Signed-off-by: Bjorn Helgaas > > --- > > drivers/pci/pci-driver.c | 14 ++++++++++++++ > > drivers/pci/pcie/portdrv_pci.c | 15 --------------- > > 2 files changed, 14 insertions(+), 15 deletions(-) > > > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > > index 3bed6beda051..bf0704b75f79 100644 > > --- a/drivers/pci/pci-driver.c > > +++ b/drivers/pci/pci-driver.c > > @@ -525,6 +525,18 @@ static void pci_pm_default_resume_early(struct pci_dev *pci_dev) > > pci_fixup_device(pci_fixup_resume_early, pci_dev); > > } > > > > +static void pcie_resume_early(struct pci_dev *pci_dev) > > +{ > > + /* > > + * Some BIOSes forget to clear Root PME Status bits after system wakeup > > + * which breaks ACPI-based runtime wakeup on PCI Express, so clear those > > + * bits now just in case (shouldn't hurt). > > + */ > > + if (pci_is_pcie(pci_dev) && > > + pci_pcie_type(pci_dev) == PCI_EXP_TYPE_ROOT_PORT) > > + pcie_clear_root_pme_status(pci_dev); > > +} > > + > > /* > > * Default "suspend" method for devices that have no driver provided suspend, > > * or not even a driver at all (second part). > > @@ -873,6 +885,8 @@ static int pci_pm_resume_noirq(struct device *dev) > > if (pci_has_legacy_pm_support(pci_dev)) > > return pci_legacy_resume_early(dev); > > > > + pcie_resume_early(pci_dev); > > I'm wondering if it would be better to implement this as a PCI quirk: > > DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(PCI_ANY_ID, PCI_ANY_ID, > PCI_CLASS_BRIDGE_PCI, 8, ...) > > Then it would also be executed for the ->restore_noirq phase, not only > ->resume_noirq. And it could be constrained to only the affected PCI > or DMI IDs. > > However it would then also be executed on ->runtime_resume, I'm not > sure if that's a problem or not. While that may not be a problem strictly speaking (the root port resume only takes place when the port itself has been suspended, so this should not interfere with PME handling for the devices under it), but it also is not necessary in that case, because the platform firmware doesn't mess up with the root port's PM registers then. Or if it does, the whole PCIe PM is managed by AML/SMM and we should not even touch this register at all.