Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp713238pxv; Thu, 15 Jul 2021 14:12:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwalEYI3IbZcEew+Et/z9+SgJ5flyuV3KI7TQgh7FHvpkwHoFqXUHDVWK02b/e5NZRBNiFK X-Received: by 2002:a17:906:c34e:: with SMTP id ci14mr7818174ejb.199.1626383529150; Thu, 15 Jul 2021 14:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383529; cv=none; d=google.com; s=arc-20160816; b=XqrB2FjZxF4NPf2EkgQbzfkxxRasIR9vF9kEYErmD6otBzdy6e4rf5jnS9Pktoq58f XZ8UJ28B3iO+gI5ZFJSlPjeeOdPRlAr3SKeo9I8onKa9fsn5MjBYRDe9VRhV8MrCf+wd 3x6WdW6sQGXE42oWoIY3fkoyQENFaxiV4gYDIu/CSHi32ogmtxlAFll9OhSQ88FIVmMq yfhy93Uj6KaIM/Fs1RXxqSJ7Mm0o5hHnuVmO11hXIXws8THGUWQyJHdAWAp0C2ebryBt zI/lOYMW9H/3X6VNF8aueYE1Gvy+77FwGP7LrFQ1swasdXntjHt+y9hGu4R1xCkRHAvh IRYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eIevWNFgfFggKEz6hQ42507ch5dZFRqjJKOFN7uSpNc=; b=NORFgxsiEzgBs9Ud4pN69oaGVEgXTIhrAw6VsM4WKLoOeAivoRx3O7CuYr9E92h51A x014axbWoxBw2BSnQFTEg4Jjv9NMxCVkKFk0fylMw84xjKpyqk6pjYwotoQOB668Nhep TFFagx5H0dzkjjFysTvUoOAEqgFA5y4i1bA1gyu/WOtY6aDnc3QwkgzXLdnhhg3J0n4m 4OJeve4R/+R/IcY6zRDxFH71kVbblGm8GM1V89uYPiPwGUZPSzvV+R6xjgxwvym45OgW LslQDl/42Cyo3ukN1QC1NwAbpMoQS8hL4L+IEsZXwVmsjkTXjjg2/6TQApw2koALSRPn odWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zqXS4PeL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id li7si8712423ejb.552.2021.07.15.14.11.45; Thu, 15 Jul 2021 14:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zqXS4PeL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243763AbhGOTWW (ORCPT + 99 others); Thu, 15 Jul 2021 15:22:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:39662 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241771AbhGOTFv (ORCPT ); Thu, 15 Jul 2021 15:05:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDFAB613E5; Thu, 15 Jul 2021 19:02:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375743; bh=6mgecr9hT2o3vUpA0ZgxGUAH2GB6BHXEW9m2waH4tms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zqXS4PeLR4oeR5Awh0jnYwR3XzgRZcHfc1OZAYvwwArT0+e/J21mlykoEKMVZPXcA D312FbNqvpD89hvX3aWNX2DqKUA2w5Sa7UGDR0IgLxQRhaRW1k7D/KW3GbrfmWDK9S arBfxy8ENlWtuC4duGuO8q8b69KUsU71u4JLGVl0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Kharlamov , Bjorn Helgaas , Lukas Wunner Subject: [PATCH 5.12 218/242] PCI: Leave Apple Thunderbolt controllers on for s2idle or standby Date: Thu, 15 Jul 2021 20:39:40 +0200 Message-Id: <20210715182631.461806493@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Konstantin Kharlamov commit 4694ae373dc2114f9a82f6ae15737e65af0c6dea upstream. On Macbook 2013, resuming from suspend-to-idle or standby resulted in the external monitor no longer being detected, a stacktrace, and errors like this in dmesg: pcieport 0000:06:00.0: can't change power state from D3hot to D0 (config space inaccessible) The reason is that we know how to turn power to the Thunderbolt controller *off* via the SXIO/SXFP/SXLF methods, but we don't know how to turn power back on. We have to rely on firmware to turn the power back on. When going to the "suspend-to-idle" or "standby" system sleep states, firmware is not involved either on the suspend side or the resume side, so we can't use SXIO/SXFP/SXLF to turn the power off. Skip SXIO/SXFP/SXLF when firmware isn't involved in suspend, e.g., when we're going to the "suspend-to-idle" or "standby" system sleep states. Fixes: 1df5172c5c25 ("PCI: Suspend/resume quirks for Apple thunderbolt") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=212767 Link: https://lore.kernel.org/r/20210520235501.917397-1-Hi-Angel@yandex.ru Signed-off-by: Konstantin Kharlamov Signed-off-by: Bjorn Helgaas Reviewed-by: Lukas Wunner Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/pci/quirks.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include /* isa_dma_bridge_buggy */ #include "pci.h" @@ -3668,6 +3669,16 @@ static void quirk_apple_poweroff_thunder return; if (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) return; + + /* + * SXIO/SXFP/SXLF turns off power to the Thunderbolt controller. + * We don't know how to turn it back on again, but firmware does, + * so we can only use SXIO/SXFP/SXLF if we're suspending via + * firmware. + */ + if (!pm_suspend_via_firmware()) + return; + bridge = ACPI_HANDLE(&dev->dev); if (!bridge) return;