Received: by 10.192.165.148 with SMTP id m20csp433289imm; Wed, 9 May 2018 15:36:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqngFZBggy4lWSwzsIHCPQAmhe9P0bf0rWlWmtAKZRurz2AvEjG4C42B1L0lqaYl7PYXa6a X-Received: by 10.98.10.72 with SMTP id s69mr45478366pfi.134.1525905371078; Wed, 09 May 2018 15:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525905371; cv=none; d=google.com; s=arc-20160816; b=jENQSstngxfXkHcfv7/oh7fb05w7hMNAprauN3cjLwbMHQj/Y15PhrVksDJOXGfWJn L46pF1EGf1vNEE6rc3OqwvMh7LM+jQkwtH97HI1R2aSYleqYIR3vnp13p1SjWzYb/ZP6 0WxbMrIRmdzeFA82DHTeSyPcT8grrB9UuJ+JcvzvfeJTTyoumTaa49oWT5csHJXzjfV9 bmIzGxNuKmQ0S+t4tGEUS4ApH2HNueaWLoLE8htTIUKBml+9H2+/kgmVwvlQHFrpGOf2 HvqfkX1jtJlGuarlIVvq/LJ3aANt5+fLQz2M6khnuMVGHAzLobvJRVmF/l26EMpIyI1h DWiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=E/51bi0RyXYO6SmGqXiwKfqPL2ZHAw7JBYa6Z+FmZjg=; b=W/8AMwvrCvd75g8qqiPpAaPGf6cT/PgpdOWUMANFPCtb75Ae/bQou2lL3eTjukmPkx j4gHjUulGTgkSFWeE6DkZnKcQOGt7/wXuMvHbRJFK+zqJmRW597+LAawG/0m0njLz9+D bYY+U2+6LF1kKzsVjtMritbwIFwNQp+hxyx8AKVNbiA5Gvv/ox5XOIG7T6yu8DH6pdF+ biK2yXEu9Zlm4tPr7tE9tc0nBm3Av5OdkIkvAhiKWJh8YLh5VU2kjgDW68o0se/KAsFH kSpcfwnY6McQegQsgpxF73KBKOckA6IDBjYhJjdmi8oA4pwIc8oHJL8mVmiBzNHOxYEz vLGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=a9BwGtQh; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si18691686pfd.357.2018.05.09.15.35.54; Wed, 09 May 2018 15:36:11 -0700 (PDT) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=a9BwGtQh; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965904AbeEIWeu (ORCPT + 99 others); Wed, 9 May 2018 18:34:50 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:38290 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965118AbeEIWer (ORCPT ); Wed, 9 May 2018 18:34:47 -0400 Received: by mail-ot0-f193.google.com with SMTP id n3-v6so166765ota.5; Wed, 09 May 2018 15:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=E/51bi0RyXYO6SmGqXiwKfqPL2ZHAw7JBYa6Z+FmZjg=; b=a9BwGtQhUQtBwsNq8O9HFrf3gCIaAlq6mdD8TiBmzHLoMbt5IJRS7B15d+fAmZIcAd 0SqZVv850vSXVAG2LsfUU4iD/3HLcaq7hP2AhzvH+Nd5yKfOV3tpEkt6XBWkGB7I82V6 Mu61csC4S4i2a4hvqUe9FlymkLIYhlBjU8PSPVRdQ78f0HpObqaZ9JX4IaQCl8bUvGLN oDqVFjqRuxvuuqB2WkmKPaqQLZndNR3Rs0Ko8kHy7PK2ge5X4YbqRFyMIu8JpbgKDNfL 7NJdmbrBGizzAVtQVBZY3b5C8Glexn29wW82rnOFp36lZucFt43Kv8T61BTfdJSMCcF2 Czxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=E/51bi0RyXYO6SmGqXiwKfqPL2ZHAw7JBYa6Z+FmZjg=; b=J1PPZ8prhFh9ffbxk7KKb7F9/ZmGDf06GIpbu1Y3fvSXCzGWit0yxfaYbILJVkJ11Z eK/GgHc7/n9VhVFVd2Dg8w6l9w6YEof83YD7gV+f1TXppjvJUr9iM2VuVZpe6v6CINHU rwElmvuU8+czQBRzRAqFlgs1f4StIXh/afqCqNiJwO4f6F4Kel5M/qZpov9JxkvDk9Ut bIS3BEZVMQuOAp5GzI5pHK/uFGMjm7Op0COPd/uGn7bMgruegC/4W3tftsRswuH0g8J/ cTgjWQJsgIESCHpIib3gS1hk2f4ng8uifVwMz6jQXBQid/K4/xEVlFJ/1OuzbwGf/TV7 8KIg== X-Gm-Message-State: ALKqPwffZAj3haF+MljXiiGDUC21BBBkFJrcurbE/1iq6FxpWMAX3xkd CUrPGxN1jaBBO4uGzf45Vwina8UG91Bgv8jOShY= X-Received: by 2002:a9d:9d6:: with SMTP id 22-v6mr3035730otz.291.1525905287058; Wed, 09 May 2018 15:34:47 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Wed, 9 May 2018 15:34:46 -0700 (PDT) In-Reply-To: <1823373.ea0yBGqyI6@aspire.rjw.lan> References: <56a8953c-d833-837c-57d5-fe758d4db02a@canonical.com> <1823373.ea0yBGqyI6@aspire.rjw.lan> From: "Rafael J. Wysocki" Date: Thu, 10 May 2018 00:34:46 +0200 X-Google-Sender-Auth: whcDD10rlBxZwCePTHZsCqWZaHo Message-ID: Subject: Re: [PATCH] PCI / PM: Check device_may_wakeup() in pci_enable_wake() To: Bjorn Helgaas Cc: Joseph Salisbury , ACPI Devel Maling List , Linux PCI , "linux-kernel@vger.kernel.org" , 1745646@bugs.launchpad.net, Mika Westerberg Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 9, 2018 at 12:18 AM, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Commit 0847684cfc5f0 (PCI / PM: Simplify device wakeup settings code) > went too far and dropped the device_may_wakeup() check from > pci_enable_wake() which causes wakeup to be enabled during system > suspend, hibernation or shutdown for some PCI devices that are not > allowed by user space to wake up the system from sleep (or power off). > > As a result of this excessive power is drawn by some of the affected > systems while in sleep states or off. > > Restore the device_may_wakeup() check in pci_enable_wake(), but make > sure that the PCI bus type's runtime suspend callback will not call > device_may_wakeup() which is about system wakeup from sleep and not > about device wakeup from runtime suspend. > > Fixes: 0847684cfc5f0 (PCI / PM: Simplify device wakeup settings code) > Reported-by: Joseph Salisbury > Signed-off-by: Rafael J. Wysocki Bjorn, any concerns here? > --- > drivers/pci/pci.c | 29 +++++++++++++++++++++++------ > 1 file changed, 23 insertions(+), 6 deletions(-) > > Index: linux-pm/drivers/pci/pci.c > =================================================================== > --- linux-pm.orig/drivers/pci/pci.c > +++ linux-pm/drivers/pci/pci.c > @@ -1910,7 +1910,7 @@ void pci_pme_active(struct pci_dev *dev, > EXPORT_SYMBOL(pci_pme_active); > > /** > - * pci_enable_wake - enable PCI device as wakeup event source > + * __pci_enable_wake - enable PCI device as wakeup event source > * @dev: PCI device affected > * @state: PCI state from which device will issue wakeup events > * @enable: True to enable event generation; false to disable > @@ -1928,7 +1928,7 @@ EXPORT_SYMBOL(pci_pme_active); > * Error code depending on the platform is returned if both the platform and > * the native mechanism fail to enable the generation of wake-up events > */ > -int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) > +static int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) > { > int ret = 0; > > @@ -1969,6 +1969,23 @@ int pci_enable_wake(struct pci_dev *dev, > > return ret; > } > + > +/** > + * pci_enable_wake - change wakeup settings for a PCI device > + * @pci_dev: Target device > + * @state: PCI state from which device will issue wakeup events > + * @enable: Whether or not to enable event generation > + * > + * If @enable is set, check device_may_wakeup() for the device before calling > + * __pci_enable_wake() for it. > + */ > +int pci_enable_wake(struct pci_dev *pci_dev, pci_power_t state, bool enable) > +{ > + if (enable && !device_may_wakeup(&pci_dev->dev)) > + return -EINVAL; > + > + return __pci_enable_wake(pci_dev, state, enable); > +} > EXPORT_SYMBOL(pci_enable_wake); > > /** > @@ -1981,9 +1998,9 @@ EXPORT_SYMBOL(pci_enable_wake); > * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI > * ordering constraints. > * > - * This function only returns error code if the device is not capable of > - * generating PME# from both D3_hot and D3_cold, and the platform is unable to > - * enable wake-up power for it. > + * This function only returns error code if the device is not allowed to wake > + * up the system from sleep or it is not capable of generating PME# from both > + * D3_hot and D3_cold and the platform is unable to enable wake-up power for it. > */ > int pci_wake_from_d3(struct pci_dev *dev, bool enable) > { > @@ -2114,7 +2131,7 @@ int pci_finish_runtime_suspend(struct pc > > dev->runtime_d3cold = target_state == PCI_D3cold; > > - pci_enable_wake(dev, target_state, pci_dev_run_wake(dev)); > + __pci_enable_wake(dev, target_state, pci_dev_run_wake(dev)); > > error = pci_set_power_state(dev, target_state); > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html