Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp171759imd; Wed, 31 Oct 2018 16:45:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5fOkjtJjGFNcd3kcJDt6+vnv/94DA7pg3EUdpf7lZvz+6iBs2AymJcvXA8I9RwMhuIuGrwH X-Received: by 2002:a17:902:47:: with SMTP id 65-v6mr5397290pla.112.1541029551504; Wed, 31 Oct 2018 16:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541029551; cv=none; d=google.com; s=arc-20160816; b=rStJRzIue48gtRNBREUctkAP6u5/BiE1ztkMT75V6wx6iamJEGDmlEIYKtC5JbEdnR Xb9JmdmvZPkKfYNxvn9G6JRG6loUdYUlwG7eaE9kTLcng9zTzBDCxEeKPgCHI6R1nwXE moS8QZKpM+u+G/JuLoUlgQd3zEXmJvVTO4w39Y14MEHOMRCoJU3gykhD2dP1U+pleJtj nsTSQGyj8ViyDBqmidNj/usdvJ/UvvIlfXHiWPx1yx59CfKpwYm8GsRJH07uab4lT6+a Os9wrd9GyLtM/CWRFVBGHOX3Lnn3XN2DGnmEL4AOiCdzNIZy+i+QX4/mOIVMi2AC6XS9 Ibvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=tZQNfGMOTEpYOCV7j756gRpWMDMMCGGM9IvNt95GIF4=; b=Te+fknaBZXYGP0Mkv5KZmdiDgVlzVXkT7bjGOsNy5CUjWWn5yHPmR8BHt0VDOHDwRU O/2vZ+fq0AUXjpA5DkXiFHDW4pG46hVX16k34iJgkUEe1ZM75nYhPeXPrplsRXpeLaD4 bCLPehPPy3V801RA3S/rNVkjSmSOjXpf00/+zKmFRYuOca8KuGi91Bw1ALhwBLrz0DRV MU6lmiHsNABQA2wE+IPl9F8MgNqfV8PB9XUfR/1l1QCU0+klyWt64yS/e94NHy6A1aGk xasnApxi3B5nDAc0kI3mJbwQn8HsetKeX93CrokilUrCl0cLIH/elwK1uKfsIgrupq5m Zl/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hNbX+Xlc; 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=pass (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 v141-v6si16383618pfc.193.2018.10.31.16.45.36; Wed, 31 Oct 2018 16:45:51 -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=pass header.i=@kernel.org header.s=default header.b=hNbX+Xlc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729167AbeKAIoz (ORCPT + 99 others); Thu, 1 Nov 2018 04:44:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:55434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728964AbeKAIHd (ORCPT ); Thu, 1 Nov 2018 04:07:33 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 39ABD20821; Wed, 31 Oct 2018 23:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027242; bh=I1EECB/32Iele6bm12Ctioj1LBfdEmVN16THtKuighY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hNbX+Xlcc7QxUTBoxAfLhTII0H30rz/+HeDN0E35Nk4w728UToLDp/dLzQ6Hord6E YFKTnozQYlVIXMolXeul67DjfD7SOnkrX3b46E0Z5HqPTcLnnWbaOKbBh+Og5TUZ9A TTsfN0i9pBMWXOpdgbkgIFQAqH7TM7xAOTvoCHUo= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mika Westerberg , Bjorn Helgaas , Sasha Levin Subject: [PATCH AUTOSEL 4.19 111/146] PCI / ACPI: Enable wake automatically for power managed bridges Date: Wed, 31 Oct 2018 19:05:06 -0400 Message-Id: <20181031230541.28822-111-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/pci/pci-acpi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index c2ab57705043..f8436d1c4d45 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -762,19 +762,33 @@ static void pci_acpi_setup(struct device *dev) 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) -- 2.17.1