Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3435529imu; Sun, 11 Nov 2018 15:03:20 -0800 (PST) X-Google-Smtp-Source: AJdET5fh3FPy+D9ahfU+JkmOvpiMsGiDDCMAR1Cb/hmSWZ9/5ftZ1RtKpAZrJQCHxy+3hiPgRCv8 X-Received: by 2002:a17:902:110a:: with SMTP id d10-v6mr17792207pla.85.1541977400068; Sun, 11 Nov 2018 15:03:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977400; cv=none; d=google.com; s=arc-20160816; b=b/1HkkWNEzU6Vq5qblCJ8gVS3niCj3AJz+2toeOlrRhVgOqFyZ2A5BanNincfUwwmY LvYnREVSypQ0S1sjvDJc/hDWWdnwsxlcSbF9DxXDhG8rIaIdxgflAp/JpJiUWX2LC3a+ qz+DO7pvZj6Cc4HCtr4s3zuv6OaPBS/6OsEaGbnKQUCIHY0tu68fSQJXIWl4gVqd6wQX dzLHc8cRPoYaiRKXIiHjWnuB2lts3UL/0FhAGpcKRBO+dQW7XTo3bjVRhL2NdW3GdNZx RulJa9Ii3uAndzWuiawJSxwOOXL0Bx0ctZbmu79vfD0h2ZOb/AiFnKk5iyPYq1V135bJ FUmw== 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=UaZnaEoUbQckPQvs3BiC77rgCMhRgqxA+3PnUtgEtlA=; b=QvMBx5Kqkk9tshzaM2/twN8S1yf5yzxupcyMN0nPe12xWjdRPrmodQrf6F7m2DSWss f9doUe8N95HUq2E5/8ibzDL2V50CCS9FtnodaJIzGsJI9gB1MZkAi9V8OaB5RpxjDtno xletq9z/dNMYkZyi3olhCHTO/lEI7i8UQAYMUHAFZrruONUx6NFMGo2LpB1n93RobM+k /l021yad7H3jsvb3DQXUorAdEdi/K/AmCDH6Mr7wCKqQBmfk67kDiCi99lUR/uVmm2Bp PhUL/Ebvs3sGgZ3IbzhNZVGE0ouXfRvkj2Tg5zkfEj9IXHvr7K5/z9V0dl9YftrhkKgY Zv7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pdVUdp1M; 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 z5-v6si15208670pln.42.2018.11.11.15.03.05; Sun, 11 Nov 2018 15:03:20 -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=pdVUdp1M; 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 S2390672AbeKLIWa (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:52752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390602AbeKLIW1 (ORCPT ); Mon, 12 Nov 2018 03:22:27 -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 058DA216FD; Sun, 11 Nov 2018 22:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975550; bh=2cDvisvv1VGwbE2wLIcWn4H7923H5aFlB9pUeJrViXg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pdVUdp1MLJTv+Y/1t2x+iSepneM9a/C2zTihMHvwjyqI/TgwPJVc9bWJaLjEk/4dc ijbsCGrWke1kNveq3if8trGzFAPSS/ZJD0xNZnvACXWqmYBnS/jV8emaCIJGAo2/2G gFkvT5vCr8JmRO0/6gwxTEKYOTr74rArmdiRS/3o= 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.14 089/222] PCI / ACPI: Enable wake automatically for power managed bridges Date: Sun, 11 Nov 2018 14:23:06 -0800 Message-Id: <20181111221655.948613554@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -738,19 +738,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)