Received: by 10.223.185.116 with SMTP id b49csp4685948wrg; Tue, 6 Mar 2018 22:14:59 -0800 (PST) X-Google-Smtp-Source: AG47ELsvPDHEsmVzCvyFktP1AwngD2pQBi+Xbdr8SQHcO0iY3cu7aa8GJ56cpEsRUVHpc5iakG+p X-Received: by 10.98.153.86 with SMTP id d83mr21304131pfe.46.1520403299567; Tue, 06 Mar 2018 22:14:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520403299; cv=none; d=google.com; s=arc-20160816; b=jg2S5sZtiXW+PrPMCCbYjfjJ1HQAYaDk02258CwgECgxGqcIupMUTAukN845zSgfum s79l6YB6q0MjcEGv3L5OqXaWumbToEJkotuUqZJxWpTcpujDYsTEcNZ16DbwrcQFyW9l dqRMnsaEuvAciTlnUzxY6CAh09n9hgLxm6zbt5awOBRT3UUCShXhQCqUSERLfxOeSymd 4hVgP+HCdC9qmijw25ntY1jG322O/HAF5N0yeByCKpakbrBajlbQveHXY5PIRkj/twqM Rgx2Me47IbYcaaT8izUk0e2VSBeGgcKFbzHiSkPNZG4tzjoEWc5edy7kbTz73dvsAn39 ZaTw== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dmarc-filter:arc-authentication-results; bh=Vjdz6YzixeTHbGGt9WrgB0SozUqKTYpZpD63wo1hHuI=; b=xet1a4QGNnOa1S+q6TYlks4ZuMddm/sjdws1cxwOV6ut/zX1YInpBwxUn58D7mkwkl rir9pYhpN3+UAAgB10aRcyUvJZvM48YmBJSXv2XHi0WoNAT8xlU5GkuZBgsz2qTFgNLV M/9V+iswK8ZrLGLbJ3TbCHseKPjZMluni1Z9JSHfYoZ0dTniCmMt4VQ3Sw/2klZhoAZM qC7Og5NOZ/xs5/qBgN86eYpkQNELtkm+cmSOBsz3iHAFWwcffU00JUhs7vLNrGMbPvxm IWjKyUaJIyyQHM4HRVCIwnzZGBlEINTFTMIOetodIlBV9m0MqZqrzYLkPEwe1HBSqFFZ oLAw== 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 l24si10959961pgo.580.2018.03.06.22.14.45; Tue, 06 Mar 2018 22:14:59 -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 S1751159AbeCGGNk (ORCPT + 99 others); Wed, 7 Mar 2018 01:13:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:42442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750803AbeCGGNf (ORCPT ); Wed, 7 Mar 2018 01:13:35 -0500 Received: from localhost (unknown [50.35.13.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C7472177C; Wed, 7 Mar 2018 06:13:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C7472177C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Subject: [PATCH v1 2/9] PCI/PM: Clear PCIe PME Status bit in core, not PCIe port driver From: Bjorn Helgaas To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Keith Busch , Sinan Kaya , Lukas Wunner Date: Wed, 07 Mar 2018 00:13:34 -0600 Message-ID: <152040321483.240786.16597888035806933750.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <152040297576.240786.1532465558381209070.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <152040297576.240786.1532465558381209070.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + if (drv && drv->pm && drv->pm->resume_noirq) error = drv->pm->resume_noirq(dev); diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c index 4413dd85e923..f91afd09e356 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -62,20 +62,6 @@ static int pcie_portdrv_restore_config(struct pci_dev *dev) } #ifdef CONFIG_PM -static int pcie_port_resume_noirq(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(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_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) - pcie_clear_root_pme_status(pdev); - return 0; -} - static int pcie_port_runtime_suspend(struct device *dev) { return to_pci_dev(dev)->bridge_d3 ? 0 : -EBUSY; @@ -103,7 +89,6 @@ static const struct dev_pm_ops pcie_portdrv_pm_ops = { .thaw = pcie_port_device_resume, .poweroff = pcie_port_device_suspend, .restore = pcie_port_device_resume, - .resume_noirq = pcie_port_resume_noirq, .runtime_suspend = pcie_port_runtime_suspend, .runtime_resume = pcie_port_runtime_resume, .runtime_idle = pcie_port_runtime_idle,