Received: by 10.192.165.148 with SMTP id m20csp361496imm; Wed, 2 May 2018 01:22:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoagMRxjSNR+OhbHuWPh5Ie0vRSyIFEmbv/iHbjVInaV7W3aH+mNvNGEptmdARSIouwXZwq X-Received: by 10.98.33.151 with SMTP id o23mr18613409pfj.202.1525249333256; Wed, 02 May 2018 01:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525249333; cv=none; d=google.com; s=arc-20160816; b=OdYkl0VVYPXYQfGRGv1DvcT2seGDO4wl77T9T4heyKtZ0XwfYskp5nNgrBRfdGEXzb lj6FRSpsFsNQX9Fob/kzPydMNG2oWYx80LCcYblVdsAhnOGRktiSAqK4u2BqBJeCjksx TSbaOpfZsRPX6jD95CLhxNvb9srum4f/7qTsrw0fmj1rJ7USHmqJNx4T9ROTgD31TiN6 eTBb9CChRlyz8DDhrmgq/kshQq7QraP7l6niEn8NWudTzIkonujXQEhx0ikdaXDoCsj8 Wq3pETglvdHrgmEHHoy4hZUDn8Ll2q7mgNtYOAmrwk8WhFZOr2CKklyryddYrWkf6m6A F76w== 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=ewv4PovFJ4z8Al+QYvA3IJWhw3+ZR5m2V/H9OPQN3h0=; b=gMk2dZ7rhUewQCAGiecFR7Q8IPh0TfTjt3cGECARHJCUPGy4yybPJirvMnrBmWk+NF OLn4NTO/9f9d0GrHbE4jC0iyJGertupn9Dw4eeD5zgu6VdwKQu4iLDNg2V9pt6eHzkdT /SZMEsIm5nnDMyVw+KB/f5zqf80L8bxcHMszGa2yEhUQnzA6uwRsCLL8aQdp+0dqoQEv v3CTGNDfgHLGjTMOfNMcKxjlSmpICY7rH6T7o+3ZQ4RkhiB28JJqr6Fq62MkzwSC8eCn 5zBWDou7SXXrz07u8J4Us9qjT8moIhXk01hcmllMThCe8hVx63+VOyQ5gPSXPFZ63znD K7+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=R0/+HKL5; 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=QUARANTINE sp=QUARANTINE 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 v31-v6si11449864plg.157.2018.05.02.01.21.58; Wed, 02 May 2018 01:22:13 -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=R0/+HKL5; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751348AbeEBIVj (ORCPT + 99 others); Wed, 2 May 2018 04:21:39 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:32910 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbeEBIVg (ORCPT ); Wed, 2 May 2018 04:21:36 -0400 Received: by mail-ot0-f193.google.com with SMTP id l22-v6so15649405otj.0; Wed, 02 May 2018 01:21:35 -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=ewv4PovFJ4z8Al+QYvA3IJWhw3+ZR5m2V/H9OPQN3h0=; b=R0/+HKL5WDewy/MVFWXv/kut1seMoUUXCWgaSwJEScRAc7MovGBko3yXIR+KFOVCgh YzsW/tDNCpav48/nugv5tKq7KoYo7eE7zFxdHavMc0zgomKlQu+GsG0umGGfSQhXbXr5 LoVNMpeX+hFYkkzcOYTlIPG3eyTjqbBqIN6ru9glA9GBvJyWtwsEiDthYdSu0XSHx5h+ AUm7UvQuznZ2lHwL295t6GugAy0AOI2M4+86czS2YUHe/1DNzg3IMk6PMetlIQsPx217 kO60uq3P00qVW2MLijHMAHMx/j5+nu1qa/yy3oiYajbbMCI0rpnhtndqqzU5sosAcLyi VFUQ== 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=ewv4PovFJ4z8Al+QYvA3IJWhw3+ZR5m2V/H9OPQN3h0=; b=XzxFLeDcdHfjV3G2DMV0EBIGLXJb0KO5XdpU2n6BJewCufH4V5ePf5fqCHsPN38D8X 73bMc+EbRye1SLZGAbfmpHrDQ3ZSdtDTHEW3chJVDuhuX3AUw74aJhYwP60mZAWLAPu8 HzyCKsffzc0p4LbCOo+zVQY3HoRJyJGWE8/8owYA35dj5dAqMBAa/oL246xE42pYsAbc 8Yu3n5f8ps2kkJRi6L76gbRhzwXTbp2ZZWXb1ITizEFeQoG+kMK7yBpVeJie0BNrMt5W JFLt/uVyVznxhjjQQ2lPyw6Ca80OfBhrio5LmlAaf8PIuBIxS5KHGglo2L+2HyNap5SC nDiA== X-Gm-Message-State: ALQs6tCRaUA6k8TpGyw4Emq8MYZnX7kwJdZSPJP3ioY/a9oUTiQa+jjU 2UrCtAnsb94D84uc3GC1IFrY6C4+0H6OY6b+q/o= X-Received: by 2002:a9d:27a6:: with SMTP id c35-v6mr13735077otb.271.1525249295334; Wed, 02 May 2018 01:21:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Wed, 2 May 2018 01:21:34 -0700 (PDT) In-Reply-To: <20180501195501.GB11698@bhelgaas-glaptop.roam.corp.google.com> References: <56a8953c-d833-837c-57d5-fe758d4db02a@canonical.com> <1f67f00a-8141-f9af-2120-c78f7cfecb1d@canonical.com> <20180501195501.GB11698@bhelgaas-glaptop.roam.corp.google.com> From: "Rafael J. Wysocki" Date: Wed, 2 May 2018 10:21:34 +0200 X-Google-Sender-Auth: d8v4eVu-xjxCwxKmzS90ehcbfaM Message-ID: Subject: Re: [Regression] PCI / PM: Simplify device wakeup settings code To: Bjorn Helgaas Cc: "Rafael J. Wysocki" , Joseph Salisbury , "Rafael J. Wysocki" , Len Brown , Bjorn Helgaas , 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 Tue, May 1, 2018 at 9:55 PM, Bjorn Helgaas wrote: > On Tue, May 01, 2018 at 10:34:29AM +0200, Rafael J. Wysocki wrote: >> On Mon, Apr 30, 2018 at 4:22 PM, Joseph Salisbury >> wrote: >> > On 04/16/2018 11:58 AM, Rafael J. Wysocki wrote: >> >> On Mon, Apr 16, 2018 at 5:31 PM, Joseph Salisbury >> >> wrote: >> >>> On 04/13/2018 05:34 PM, Rafael J. Wysocki wrote: >> >>>> On Fri, Apr 13, 2018 at 7:56 PM, Joseph Salisbury >> >>>> wrote: >> >>>>> Hi Rafael, >> >>>>> >> >>>>> A kernel bug report was opened against Ubuntu [0]. After a kernel >> >>>>> bisect, it was found that reverting the following two commits resolved >> >>>>> this bug: >> >>>>> >> >>>>> 0ce3fcaff929 ("PCI / PM: Restore PME Enable after config space restoration") >> >>>>> 0847684cfc5f("PCI / PM: Simplify device wakeup settings code") >> >>>>> >> >>>>> This is a regression introduced in v4.13-rc1 and still exists in >> >>>>> mainline. The bug causes the battery to drain when the system is >> >>>>> powered down and unplugged, which does not happed prior to these two >> >>>>> commits. >> >>>> What system and what do you mean by "powered down"? How much time >> >>>> does it take for the battery to drain now? >> >>> By powered down, the bug reporter is saying physically powered off and >> >>> unplugged. The system is a HP laptop: >> >>> >> >>> dmi.chassis.vendor: HP >> >>> dmi.product.family: 103C_5335KV HP Notebook >> >>> dmi.product.name: HP Notebook >> >>> vendor_id : GenuineIntel >> >>> cpu family : 6 >> >>> >> >>> >> >>>>> The bisect actually pointed to commit de3ef1e, but reverting >> >>>>> these two commits fixes the issue. >> >>>>> >> >>>>> I was hoping to get your feedback, since you are the patch author. Do >> >>>>> you think gathering any additional data will help diagnose this issue, >> >>>>> or would it be best to submit a revert request? >> >>>> First, reverting these is not an option or you will break systems >> >>>> relying on them now. 4.13 is three releases back at this point. >> >>>> >> >>>> Second, your issue appears to be related to the suspend/shutdown path >> >>>> whereas commit 0ce3fcaff929 is mostly about resume, so presumably the >> >>>> change in pci_enable_wake() causes the problem to happen. Can you try >> >>>> to revert this one alone and see if that helps? >> >>> A test kernel with commits 0ce3fcaff929 and de3ef1eb1cd0 reverted was >> >>> tested. However, the test kernel still exhibited the bug. >> >> So essentially the bisection result cannot be trusted. >> > >> > We performed some more testing and confirmed just a revert of the >> > following commit resolves the bug: >> > >> > 0847684cfc5f0 ("PCI / PM: Simplify device wakeup settings code") >> >> Thanks for confirming this! >> >> > Can you think of any suggestions to help debug further? >> >> The root cause of the regression is likely the change in >> pci_enable_wake() removing the device_may_wakeup() check from it. >> >> Probably, one of the drivers in the platform calls pci_enable_wake() >> directly from its ->shutdown() callback and that causes the device to >> be set up for system wakeup which in turn causes the power draw while >> the system is off to increase. >> >> I would look at the PCI drivers used on that platform to find which of >> them call pci_enable_wake() directly from ->shutdown() and I would >> make these calls conditional on device_may_wakeup(). > > I took a quick look with > > git grep -E "pci_enable_wake\(.*[^0]\);|device_may_wakeup" > > and didn't notice any pci_enable_wake() callers that called > device_may_wakeup() first. > > Probably a dumb question, but would it make sense to restore the > device_may_wakeup() check in pci_enable_wake(), e.g., At least as a matter of test, yes, it would, but not this way: > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index e597655a5643..9fa64c175f92 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -1932,6 +1932,9 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) > { > int ret = 0; > > + if (enable && !device_may_wakeup(&dev->dev)) > + return -EINVAL; > + > /* > * Bridges can only signal wakeup on behalf of subordinate devices, > * but that is set up elsewhere, so skip them. because that would break runtime PM wakeup for devices that aren't allowed to wake up the system from sleep. Anyway, if the patch above makes the problem go away, it will mean we are on the right track.