Received: by 10.192.165.148 with SMTP id m20csp43740imm; Thu, 3 May 2018 14:31:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrtUMQt6rkn2ZjQp8RNhKeqCKKuY0XTcxMqHcFyseJQUiM4AI4VD3ODXYTrh/P3P02jmsSV X-Received: by 2002:a63:7351:: with SMTP id d17-v6mr19827689pgn.297.1525383072589; Thu, 03 May 2018 14:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525383072; cv=none; d=google.com; s=arc-20160816; b=Y7fwXExOxLmhQrsJeT6hBmeU8MLrgRpayyGJ+OX2F6dvOfulgtGoHwSHHKpN3BI2Bq JfnxJr0A1JO5wSY58MIOldTxL066u6kXY8YECLI8cdNJECWjNwJYQY2R6MbntbSfe4Mg V3t0F96t2jUQlBW0hHmZS/FPZzxX3VuyzkHnFzeXpddekfBF8gWifFh2AG0zvUXmvpTn qO/b68i/DzR+yuFwrT6pRmbKMVVpAeoPgezSJsmy+q8O1DuMGrwoUrWoWOxUg4yPRc26 5lPcHRtPP+iGcXy/x9cfkNL40fO5xnkhsB7lf6PEVo8blLuOWKHwOQ3xkgKcGyMTITbW LSMw== 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=JpZHX+NoJWqcuJGhXXb+V26TI0RztyiuxiwN2W5vrXc=; b=UU+jKPxnKkcCTLwfF0jKBFaqCGPHllUxLZ1VZ9VKmfWYmgGriSz5ZjId9HTFCXCweA BPsYo5hjOwWEGVuAPiaZlIkf+ZtZFfYHre+5Aj1D8WO5r6+7EaNyg/C92W+d/bnWJS67 /MRzMpVa/0lcZUgSH8L2pXV9FbjoqSMe4+IhHKeHrLkF8itu393hHabqSVHntpSx9tTe uDjq+QJjk5Z2RxMGHnRei0eyJk1yhRqQstD7bBaLo55n0JS8PDRaqa7mSjgJ81j5PyO8 oTqmcyFtbDL9Y6NhC4ggtHgodMOm7U4pBbN1KENrVTTPQSvO0ubivKMIUcTVhXqGflOj CrGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=kxsdmKLE; 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 g12si1747373pfm.258.2018.05.03.14.30.57; Thu, 03 May 2018 14:31:12 -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=kxsdmKLE; 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 S1751236AbeECV3W (ORCPT + 99 others); Thu, 3 May 2018 17:29:22 -0400 Received: from mail-ot0-f180.google.com ([74.125.82.180]:44297 "EHLO mail-ot0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751074AbeECV3U (ORCPT ); Thu, 3 May 2018 17:29:20 -0400 Received: by mail-ot0-f180.google.com with SMTP id g7-v6so22314878otj.11; Thu, 03 May 2018 14:29:19 -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=JpZHX+NoJWqcuJGhXXb+V26TI0RztyiuxiwN2W5vrXc=; b=kxsdmKLEkBmV2SOrwePGU4CwL3X+JaauiLkp04b0Y9Bsj4ooSmkYWmjfaxtXpYWDbd f+ziOrS45wNBKfJtsD2cmugXYTc0wsPv+J00blePleuxztrUeUDVxNgiDV5ahMfPJlXc MxAgOD0snCd+b298PsLijOxcJoahXuVigQklTnEmWHFmOZJricWrbOGBhfrGWNsZbyFl Z+AnjDAAqepdZtaa+aFPpjNWdK18knRxAm+5gVnqtogn2sds4lCD9KtnHB/x8uWGtUqM 90+h/s4PBQmqqN4KRItrWsEdAUzX2vupVgb4/mZkgHR4sXrVS7i0RPRyHFaM1GRpr91L 7gbg== 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=JpZHX+NoJWqcuJGhXXb+V26TI0RztyiuxiwN2W5vrXc=; b=USwIxS3g1mHWN39PKqP5C7sSQx33qcjvNYNx0y20kPnIq7AsAYEMbND7VsfZ4kYFMf dpYNNu6GkxoGsfCQoKbS9Bij4ucHyt3OQObqro0e+9C+yFPrpPOZIQyn0drFmxSac4Op PCaNEjghuAescHPYzkK6+cdVOw2H/ySwLyutgWuh9PdX0twyVE+mWRfdRn5pdIIGrA0a JBof3agMRRFH8LmhbS2SiCQQbX11GLmP2WfHbgSizXYQw8ZUtWuihZcrGsUTm+WrEmqn 15TDV1Wi1Ow1/dqXUlvU7PBgDxulKNZVBvfF4gNdE2tHKI6LqIEXdkie4GQv6KXX6GWj aySg== X-Gm-Message-State: ALQs6tCda/AnF3QYdYPXX0xHmBlw6xmfc54kPIKwCzoYe5RMxzCwmxyY vZHA9EscoT3vNySki8/p3oxBWaT7MDNBOqOFDkU= X-Received: by 2002:a9d:3e07:: with SMTP id a7-v6mr16866244otd.150.1525382959211; Thu, 03 May 2018 14:29:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Thu, 3 May 2018 14:29:18 -0700 (PDT) In-Reply-To: <20180503191126.GA15790@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> <59bc04f8-e819-46c0-651d-a00eef4d34f8@canonical.com> <20180503191126.GA15790@bhelgaas-glaptop.roam.corp.google.com> From: "Rafael J. Wysocki" Date: Thu, 3 May 2018 23:29:18 +0200 X-Google-Sender-Auth: Z4QAqY3lVBw4gcp60SkQdNT82rQ Message-ID: Subject: Re: [Regression] PCI / PM: Simplify device wakeup settings code To: Bjorn Helgaas Cc: Joseph Salisbury , "Rafael J. Wysocki" , "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 Thu, May 3, 2018 at 9:11 PM, Bjorn Helgaas wrote: > On Thu, May 03, 2018 at 02:29:02PM -0400, Joseph Salisbury wrote: >> On 05/02/2018 06:41 AM, Rafael J. Wysocki wrote: >> > 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. >> > I've just look at a bunch of network drivers doing that. >> > >> > It looks like I may need to restore __pci_enable_wake() with an extra >> > "runtime" argument for internal use. >> > >> > Joseph, can you ask the reporter to test the Bjorn's patch, please? >> >> The bug reporter has testing Bjorn's patch. It did in fact resolve the >> bug. Thanks for the quick help, Rafael and Bjorn! > > Just as a word of caution, I think Rafael said my patch was not the > right fix because it would break something else. So I would wait for > a better patch from Rafael before actually resolving this issue. I'll do my best to provide one in the next couple of days.