Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp638403pxv; Thu, 15 Jul 2021 12:09:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhgRgZ+wnlGPy4Gxfd5DOSsOxTP2PqWqdnFdEaauCgi9/vy72aDqrCFRkeCZnZGfaF9k46 X-Received: by 2002:a50:ed89:: with SMTP id h9mr9134180edr.106.1626376182685; Thu, 15 Jul 2021 12:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376182; cv=none; d=google.com; s=arc-20160816; b=pgDcsxjOQGraFS4UkkEMvkjleIXXW+TwdwPF1ea3sLgOx91HnC3g9eA/4n4iEGO8e6 vg78S02o8y//f6T7eTb3eVE/P0WffjyKPLFBxLTaoHuax18sdYmUjkKMSS+76w3qdgkr a75mwxIB3ODzcd8C0wvQEwi0E/ngjbM+SYiuc2pyMZ8Eobv0MSY62LPg724YUy+6U/h8 WZVmt9LbSKEp6EMg58Icu5/qsxEJUZcEFCvo1Tbj5fbfMe8HJk7omNCA9HPWVqNhV7I2 YvT+n7z+g3cKvdylwEaBv4ng1LHE76ydc1Bzv4SRibLnRBcaoLm5S2fFrRawGXLAYwOo PHIA== 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=DO23zq/wkcxD4c9NW/Dk3WdvDQNldF3j97FiIjLh5Dg=; b=ozKbV68+p/i+3POXPZJFuIHYH+Fz3FYL8XnObekt+2dE8lao8Ncu/7dXUuM3rD0uVh yGXqPjAHxyCV9zwi0hSArdWRYvM0YVkWTIZneH8wDFCQzS0i9DiEYTEczeNnYFTObMCy 2MLvjQv/5CP7qVusgrXGvJdrUY3iXq5ru5+CQIms4Ll3PzOKNrriHcOjQpH2xX98UkCa +7YhDBKV8/evQK9p64dsNcdTbE1iR7S73fn8bm+3m++LO882Hibb7iy+7XvYow2J4y4y vXeTNeu6sPAKHGzI2bSTZBcgMZYd30X5nrbFSrXyrlH6FXoL+ALBbWmBjvRMh8f2sbkE vT7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XdeiihRt; 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 18si8383995ejj.476.2021.07.15.12.09.18; Thu, 15 Jul 2021 12:09:42 -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=XdeiihRt; 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 S235738AbhGOTHP (ORCPT + 99 others); Thu, 15 Jul 2021 15:07:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242216AbhGOS44 (ORCPT ); Thu, 15 Jul 2021 14:56:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EF151613CF; Thu, 15 Jul 2021 18:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375242; bh=UG+xe0gmkJyUMV6rYwQSTi0E/RhmITZ7uSIMV8LI6cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XdeiihRtKMHLEt0QVxhPZzYqvrHQsb1nQAzyG2qIWCHPDloBkMwh9Ka5+nX6ISNyE GQ7oPSwKuFngGPDFl0rOmbcE2qMHcIGu7wD5Rb7ZBZI/3U6Y2TspZxNFvIPcbcTFsP a+G9AWA3d4PyrSvsd/V12t9kxBCxuTitO99QlsPQ= 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.10 198/215] PCI: Leave Apple Thunderbolt controllers on for s2idle or standby Date: Thu, 15 Jul 2021 20:39:30 +0200 Message-Id: <20210715182634.175714720@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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" @@ -3667,6 +3668,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;