Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp660440pxv; Thu, 15 Jul 2021 12:46:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv+WUYJXAvN88PHT8iQUXRRIMyB1k/n0LrM3prJmIsZHKrlhmD5s+kSjpRYztSXk4cL0Hw X-Received: by 2002:a02:818c:: with SMTP id n12mr5504539jag.2.1626378375102; Thu, 15 Jul 2021 12:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378375; cv=none; d=google.com; s=arc-20160816; b=DceQc/7U6cjUNwBN6btneE9SFEDXNmavia1x80LQEmgTTeP13fyRCC9Pqq6al1EKd5 /vhHDsRInn49UJPuZxHjYzva94MDIcnX5vb3Lg03zExZFe1qLUJOUCMYuGLeI/QDbl/q 3Ds3sPP6yIoIWal04nsmDYRyXn5nwA6z9P6CDXBIm6eeJ1sklLJJ2DTTnwg1N6GwPJoO qvkzXc9p8JwXUPBTRQDXRWYafv6R2gET3o+a0yR14NesZCrLRVBZB8TMMNqZB9eZAbYx HN4j4wXujoahH1TZNREycb10hkZSmrFXJ7eqWaHEuoYcE/yB54ayG8zM5TPfC+yij25z PihQ== 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=85fhg0DwlgiIjUprKV9ClhDVrB5D2J9ZGYuptXw5/IM=; b=0vV1bwQr4d2XTb6zVVaz9qNZMQVDXlLVVcKBtRRfY/xEUSFNo/LYX8+JaA+6wAuFOC f+l3HuPYz9+ZI797pclStu7opTdU+CECktbT39nOR/TbzAhGYuO7V/xBSAcRkQGe+NfV YR7tr+m9t2E2p6BI0HOfP01uHAVlJyrj+puWZLrfp6g+NU+t3uiHjoJgWBNpFTcr585j MNMTEIdItXVUSFqMpzLmZuYlnXAqLgD2O0OtNw2kzc+w5sLfgPFpK8WYMj9r99ia1+Oj x7QDjfvMqnUcK7YAPaqV3wb9/dFMJWV9c2BKWmxEl1X/2b6VD9joVtvV6HKrLlgMmd2P kEKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ywmlm0Sr; 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 z16si7033254ilm.29.2021.07.15.12.46.02; Thu, 15 Jul 2021 12:46:15 -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=Ywmlm0Sr; 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 S1344196AbhGOTsU (ORCPT + 99 others); Thu, 15 Jul 2021 15:48:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:58474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240028AbhGOTRc (ORCPT ); Thu, 15 Jul 2021 15:17:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A9D4061407; Thu, 15 Jul 2021 19:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376372; bh=qgnc7KBkHZOHEGIBrbv4WCuYmP/M9+HaiT7B093rFCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ywmlm0SrQWWeRQZ77PCDpx1k/wyxddD6z0a/UbaV088eQ+pxYDR1tswdqt+d58Ypk IkGa3+j2sDclJb2cylatHuL194XPFkGbsQcI1CeBshjiPe9ITAokujA9egBc4KCwnm swfAw2yur8ceyPGmJxZ+4Dys6BMvRUBUA/EI9LXs= 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.13 242/266] PCI: Leave Apple Thunderbolt controllers on for s2idle or standby Date: Thu, 15 Jul 2021 20:39:57 +0200 Message-Id: <20210715182651.215354830@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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" @@ -3656,6 +3657,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;