Received: by 10.223.185.111 with SMTP id b44csp653743wrg; Fri, 9 Mar 2018 11:04:23 -0800 (PST) X-Google-Smtp-Source: AG47ELsyqFCs9IlCz4nDuSHTuk+j0VYqTDtC+ktC+njtCeQHRQkbk6aOSWhxSatmOH+f/S47bDKb X-Received: by 10.101.81.132 with SMTP id h4mr25397476pgq.332.1520622263665; Fri, 09 Mar 2018 11:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520622263; cv=none; d=google.com; s=arc-20160816; b=Ci8mDJRR5CxthXV5ZeyTDiZYxzn7EwfYRiZVVqWgvhsHDnHdTOxyfRqzE293IhK4O4 8RBE5VoVuSLIUgBA4TvDHJMFeBslEY+ghLxcegccRSecGKutXb4Sva6CnibKNQDMhBWA qii6Bnc0HtCbXceGVxet+wcA9AzPE2mERD6Y0P20BPLVce7oK5Xv9rsSvV0HcRgAt7U3 GjMpItXkgCPj4I1UDeJCvV02gyP7K0BN2srX8Rv1GuPIlPLSGIOjmaBKwzCCFQWvNp1O h/kGrjn3xfZLnmeCr2egcQOcKww8tijXxxaDYk6ICSKcpl+2/OeTcMOM+9tcgABhPgSp ep8w== 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=Wc5V6r0y0wIRU6r4mdA6PCvZaJJiSx+RDXVFswI2CLM=; b=o1KqNt5Bvphsnc9c+xsTGqTO6WGVPUZHCu3nUocYaaO3WuLSHQY8lzPB7NGX0Ju4VI itU7/VS+mat+ZvsIa17LHv4/26kMBkP+vjy1aT8nWu0JnlhzBzz4rSMSGdpgTQeHIOKI uusfCQYZ9EHwuASNPp26485frVLit9UljUZnuvWDIUBwzJoafBfNfHY1bfSF11/2awtf dLgYIH3BOLWSHE/eheHOa3ak5z/lDOVcyvtWgTvLUPG5ptCdyxlS4AbJKaLLVZnZY4+Y jWAb1Da5iBGRW7Dy5BpUy9UPocVJFynlSMl45suD0bqmW9/tMgAWFP3LUqyY51+DQXT9 aYVg== 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 q18si1306629pfd.194.2018.03.09.11.04.08; Fri, 09 Mar 2018 11:04:23 -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 S932656AbeCITAK (ORCPT + 99 others); Fri, 9 Mar 2018 14:00:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:40712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932468AbeCITAG (ORCPT ); Fri, 9 Mar 2018 14:00:06 -0500 Received: from localhost (unknown [104.132.51.71]) (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 BDA532178C; Fri, 9 Mar 2018 19:00:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDA532178C 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 v2 03/13] 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 , Frederick Lawler Date: Fri, 09 Mar 2018 13:00:05 -0600 Message-ID: <152062200554.77693.6916522408891197006.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <152062141493.77693.9630397416694091342.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <152062141493.77693.9630397416694091342.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..e561fa0f456c 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_pme_root_status_cleanup(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. + * 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_pme_root_status_cleanup(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 d6f10a97d400..ec9e936c2a5b 100644 --- a/drivers/pci/pcie/portdrv_pci.c +++ b/drivers/pci/pcie/portdrv_pci.c @@ -61,20 +61,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; @@ -102,7 +88,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,