Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3482788imu; Sun, 11 Nov 2018 16:07:11 -0800 (PST) X-Google-Smtp-Source: AJdET5eF4+Xlvoa6/3mixYQN/84oezqqXSVcMkwLb1JUgsgr8TMajEg7wlmJOUrJ+K5M6RvU+KGI X-Received: by 2002:a62:4e88:: with SMTP id c130-v6mr1119243pfb.141.1541981231401; Sun, 11 Nov 2018 16:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981231; cv=none; d=google.com; s=arc-20160816; b=W08jGojGwzbHT7RFmZ78i0/Cjxrd5hOu7+qonvFOILRKyKpPxYJc7n7CZB8CLbEeAW Befra6rNMGQWQEL0K3CDon1VcwMjeWpC9WEk7RMYJ6Pefkv0dSWwTRciNuW7GMsaptqc DyMCwPjfpBx/d+59rFzWX1LcwtYyCjeqaPWKA5UMTXrQdkZ4Q760SN0w71Q/xtMANogw DVDno6MZ3tJe8QTbINbXaoTT7BqQLTMfGY/I+TmnBog5V/45yaxr3HnIH/B6OtLxxAvi rXU2j6acMrJw+XMFRzvN6VOJIYrBe8cJxqTzMybJZtSv+vom5tW0Ssk71YSQhPGwyoxg 0Pag== 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:subject:cc:to :from:dkim-signature; bh=m573ipDwY7fHJd5LwKosz8qlKXy9QdTJ7ZM2DYAqt0E=; b=L4jQywoxE90ypCumDaGxgW1yDaBYkXv4I6NN5WZlLnDWjxF0nXHtsJEbzwosCLkMjT hztrh/TmO831SBvc/H+vK4FdW6zAYW6C8QL8zRHAZDzm0pC5UKEfb4j3J0e4XlhEulLt Y6AYGAradwKhZ2pd5ihcEEqK/Y6kGzbVBZet9NIZ1sNHu9nWUc/3GA4cXXskYKNroJEJ ZEq1NEC6/pksnw3kzc7ohAAC7gfHBerwSPBeLlJmyUOKajI6KXWZPrHPEFiVfnf+6Xbz w0v9gJiibv9duJpCsM1gn/8bJH3NRGaFRlWIq41E/3PTNtuqYJvxDnSBQIAi9kTpQwut NWnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UETqvei/"; 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 o12-v6si17066083pfh.9.2018.11.11.16.06.56; Sun, 11 Nov 2018 16:07:11 -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; dkim=pass header.i=@kernel.org header.s=default header.b="UETqvei/"; 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 S1731876AbeKLIRl (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:34122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731856AbeKLIRk (ORCPT ); Mon, 12 Nov 2018 03:17:40 -0500 Received: from localhost (unknown [206.108.79.134]) (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 B949D21731; Sun, 11 Nov 2018 22:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975264; bh=ioUZbtrZcHVcTIWotmmlH8/j9mqS9gOXubVSJC3xjwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UETqvei/YmKtT55I4A+UnKVjW47Mm35QoIAbWUEtuH5YkwqUpXHhFNGFFrV2PsCFm 0bhPlIvjFvy5HkW9e6nBxG4NSvGa2TyJwdj5JAJ8GMgcBUDwcOYKCe/wCZB0YvQOp8 Nb17qv7Q4hGjfFg24N+S/p43HD28B6O/WDGfrDzg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mika Westerberg , Bjorn Helgaas , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.19 155/361] PCI / ACPI: Enable wake automatically for power managed bridges Date: Sun, 11 Nov 2018 14:18:22 -0800 Message-Id: <20181111221642.219621814@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg [ Upstream commit 6299cf9ec3985cac70bede8a855b5087b81a6640 ] We enable power management automatically for bridges where pci_bridge_d3_possible() returns true. However, these bridges may have ACPI methods such as _DSW that need to be called before D3 entry. For example in Lenovo Thinkpad X1 Carbon 6th _DSW method is used to prepare D3cold for the PCIe root port hosting Thunderbolt chain. Because wake is not enabled _DSW method is never called and the port does not enter D3cold properly consuming more power than necessary. Users can work this around by writing "enabled" to "wakeup" sysfs file under the device in question but that is not something an ordinary user is expected to do. Since we already automatically enable power management for PCIe ports with ->bridge_d3 set extend that to enable wake for them as well, assuming the port has any ACPI wakeup related objects implemented in the namespace (adev->wakeup.flags.valid is true). This ensures the necessary ACPI methods get called at appropriate times and allows the root port in Thinkpad X1 Carbon 6th to go into D3cold. Signed-off-by: Mika Westerberg Signed-off-by: Bjorn Helgaas Reviewed-by: Rafael J. Wysocki Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/pci-acpi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -762,19 +762,33 @@ static void pci_acpi_setup(struct device return; device_set_wakeup_capable(dev, true); + /* + * For bridges that can do D3 we enable wake automatically (as + * we do for the power management itself in that case). The + * reason is that the bridge may have additional methods such as + * _DSW that need to be called. + */ + if (pci_dev->bridge_d3) + device_wakeup_enable(dev); + acpi_pci_wakeup(pci_dev, false); } static void pci_acpi_cleanup(struct device *dev) { struct acpi_device *adev = ACPI_COMPANION(dev); + struct pci_dev *pci_dev = to_pci_dev(dev); if (!adev) return; pci_acpi_remove_pm_notifier(adev); - if (adev->wakeup.flags.valid) + if (adev->wakeup.flags.valid) { + if (pci_dev->bridge_d3) + device_wakeup_disable(dev); + device_set_wakeup_capable(dev, false); + } } static bool pci_acpi_bus_match(struct device *dev)