From patchwork Tue Jul 11 00:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 702319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC600EB64DA for ; Tue, 11 Jul 2023 01:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230318AbjGKBi1 (ORCPT ); Mon, 10 Jul 2023 21:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230120AbjGKBi0 (ORCPT ); Mon, 10 Jul 2023 21:38:26 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2076.outbound.protection.outlook.com [40.107.244.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5764CEA; Mon, 10 Jul 2023 18:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IuC8aQeqKDfHhlGlqjwzkJru41k2xmT1s2/xP+Toe6IJ43kV13RAcmCJC8rt4ioH0K6mVs8yhYndaJKlVB5jJU0ehtRnyWXjKJ6GnrfhSYsYv7E8kIEJjXv9BQf5rt7g3Ghwgr8PuX0dehbuVBcIWz1h7OE3vDKyNJmSDChEX0+KAKDJ7fyvAOxWdQGOaXtCYX/JhZelpu0wIrhQdDiyaphrlpQgWXFIjmdSy3ejhAQabz06R7w7t2Y/PrnRj+tJo2f8aMUdIN/tiKHQtTTj1Zm0nH6RzveC6Fdax4f1uNMCVDBz4Vd9TnpRtjXEq4wjMcVEgKmhNlSQgy8cXvyhvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1anTshY9C9Ufkx6GGkQZ1hmb/VgNZ5K1T57bpVYOmpM=; b=KcWtcBT4I1VzE8PxLKeaJKct0fiKZmjFJBAuVq7ZRGLtBptN8/PwimJ8kgr21M/pswcFWQ/LI7TOCW7G9UOcySgKsOqHYDyBT2f9BT8kYsWv+/YYDGbdTq9wragCZyL20qDq52ASDqt7+LYRALxe/ul7r1fwZ2WyCAUV0VxebfSpjifGz07S7zHUe9brGvkq57nbyfVWYKUfn7dnBDeP8lCvD6Mg3uPk3ttJD4wKymAkzqCVOKDknBDUEmk7PMXWGnk/iVN5ZCn9Enqe8xLFpYfne4bnxRtfdqFGllxc0EsKaf2+yMUCrGt53bjHouGcW0qtmvFj4QP4lrj0QgilSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1anTshY9C9Ufkx6GGkQZ1hmb/VgNZ5K1T57bpVYOmpM=; b=2BMtQeMwNayeeM+T+0uQAMKy1TZH2PRwDuEwt1oB21cSNb/Lg6CPnvfqFp3rRWLpevJoC9x5hR/f2xFQbpiK5IALW8Tllsv0aynVUFsRLa852JyhGmm9NuheOZm+KdCd+4d0fa/zjPcNDS3Dl2ABsnfn9PKcKzlhGHHjhU6Eb/U= Received: from MW4PR03CA0047.namprd03.prod.outlook.com (2603:10b6:303:8e::22) by PH7PR12MB9065.namprd12.prod.outlook.com (2603:10b6:510:1f7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Tue, 11 Jul 2023 01:38:22 +0000 Received: from CO1NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::ca) by MW4PR03CA0047.outlook.office365.com (2603:10b6:303:8e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 01:38:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT091.mail.protection.outlook.com (10.13.175.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Tue, 11 Jul 2023 01:38:21 +0000 Received: from SITE-L-T34-2.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 20:38:20 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Bjorn Helgaas CC: , , Len Brown , , Mario Limonciello , Mika Westerberg Subject: [PATCH v7 1/2] PCI: Refactor pci_bridge_d3_possible() Date: Mon, 10 Jul 2023 19:53:24 -0500 Message-ID: <20230711005325.1499-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711005325.1499-1-mario.limonciello@amd.com> References: <20230711005325.1499-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT091:EE_|PH7PR12MB9065:EE_ X-MS-Office365-Filtering-Correlation-Id: 2806e301-b4b2-4407-b758-08db81af8301 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nLJlllrtw+PoIBVOvL9gtXpSwYwqAt3yS0CZpBnDotDU5UJRTnX5Xr0SJO172f5mzZWH7qQ/x4swdaalzEmmlC/EMlhxeLji4t3v9V3sgXZgm+iKMQ7ObChJvxq01jf76JkhdfReUO2VVMqd3Ij3zv9iWo4zTSGzZlpEFT9lIpwpTm3TwZk4gL/7096YP72w0n7qc/NHQojqcMYAVI3M9fww++b09zfnhYDWM0rh9q7K0HJZx69vyHX3NSyKnckPmVIAzJAJATmU/R8NdLvo1BKbVIvjF/Kf1OIMjw0aMGqNT29G++IMFdNS6wdXAxD0x5n1g909dyhgDA7LA4cB+FMtxeXH1u6pI2d3iHFXBujcXNacA1Avm5IWBvzyi3CDIEAMbQaCu3zz7WM9IdAEGqLkEViRZ/WhvbxAd7EIQjMJ5FULPgXfUd2zM2db2D1RqL0La8eGkDfjoO90QuaGYyUfKzrJazeFZbWX/2pZUfW5k2ksNKJ2tarde9MhSI7p9TljiVvlbhtQp+Ym6ZMBUjRy+DZksiEJsrQ6QFhDKeezJTfn8k5TGGvXj782yRd4ukIfbGLSpAo/NvEy9OsIA2AflaDSxrbTOrsx03jjeb3nJ9y1zkqf8P8V2Uo0+imYCOsuOcmJeIvOEyX/FCpclx8El19yyQSDJbKiAg1hgGTP/5LzADyQHW7Vwq2Nx9oNx3kW/T3V//Eo9tnPi66DBfK5lnYMWAHcB4ML90BWLbdkwv230y3sjOA4nYOdpGyAgtJeUEH27Erk2bVSZBj18Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(86362001)(82740400003)(40460700003)(40480700001)(36756003)(7696005)(110136005)(54906003)(70586007)(70206006)(81166007)(356005)(478600001)(36860700001)(26005)(1076003)(186003)(2616005)(16526019)(44832011)(316002)(2906002)(5660300002)(8936002)(8676002)(426003)(336012)(83380400001)(4326008)(41300700001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 01:38:21.8526 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2806e301-b4b2-4407-b758-08db81af8301 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9065 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org All of the cases handled by pci_bridge_d3_possible() are specific to these branches: ``` case PCI_EXP_TYPE_ROOT_PORT: case PCI_EXP_TYPE_UPSTREAM: case PCI_EXP_TYPE_DOWNSTREAM: ``` Drop a level of indentation by returning false in the default case instead. No intended functional changes. Acked-by: Rafael J. Wysocki Reviewed-by: Mika Westerberg Signed-off-by: Mario Limonciello --- drivers/pci/pci.c | 68 +++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 60230da957e0c..f916fd76eba79 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3004,48 +3004,48 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) case PCI_EXP_TYPE_ROOT_PORT: case PCI_EXP_TYPE_UPSTREAM: case PCI_EXP_TYPE_DOWNSTREAM: - if (pci_bridge_d3_disable) - return false; + break; + default: + return false; + } - /* - * Hotplug ports handled by firmware in System Management Mode - * may not be put into D3 by the OS (Thunderbolt on non-Macs). - */ - if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge)) - return false; + if (pci_bridge_d3_disable) + return false; - if (pci_bridge_d3_force) - return true; + /* + * Hotplug ports handled by firmware in System Management Mode + * may not be put into D3 by the OS (Thunderbolt on non-Macs). + */ + if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge)) + return false; - /* Even the oldest 2010 Thunderbolt controller supports D3. */ - if (bridge->is_thunderbolt) - return true; + if (pci_bridge_d3_force) + return true; - /* Platform might know better if the bridge supports D3 */ - if (platform_pci_bridge_d3(bridge)) - return true; + /* Even the oldest 2010 Thunderbolt controller supports D3. */ + if (bridge->is_thunderbolt) + return true; - /* - * Hotplug ports handled natively by the OS were not validated - * by vendors for runtime D3 at least until 2018 because there - * was no OS support. - */ - if (bridge->is_hotplug_bridge) - return false; + /* Platform might know better if the bridge supports D3 */ + if (platform_pci_bridge_d3(bridge)) + return true; - if (dmi_check_system(bridge_d3_blacklist)) - return false; + /* + * Hotplug ports handled natively by the OS were not validated + * by vendors for runtime D3 at least until 2018 because there + * was no OS support. + */ + if (bridge->is_hotplug_bridge) + return false; - /* - * It should be safe to put PCIe ports from 2015 or newer - * to D3. - */ - if (dmi_get_bios_year() >= 2015) - return true; - break; - } + if (dmi_check_system(bridge_d3_blacklist)) + return false; - return false; + /* + * It should be safe to put PCIe ports from 2015 or newer + * to D3. + */ + return dmi_get_bios_year() >= 2015; } static int pci_dev_check_d3cold(struct pci_dev *dev, void *data) From patchwork Tue Jul 11 00:53:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 701530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B884C001E0 for ; Tue, 11 Jul 2023 01:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbjGKBi2 (ORCPT ); Mon, 10 Jul 2023 21:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230311AbjGKBi0 (ORCPT ); Mon, 10 Jul 2023 21:38:26 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20609.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::609]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E69F2127; Mon, 10 Jul 2023 18:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LFS8o9pFEV0dUIgVUcMRBquji1fKNklvXJUe9TPxRIPbH0ayfsuARzocOICBZcwLvR4HJqyUKOfQAp9t0j9nM2elNSsKbTLfUK4Nh13cyRswEKBeH4kDnznuzq7t5Ex6noYcOXf645Xx8qAfvYQcK/+V7G/PVT8FvFfaFuGqX8KIdk3WsQDHc+DcHXugqtIzTPvKPi8RUPrb+Kx8PPGnMj3tTmX/FPXmM9LLjqqKyJpAPBTGXahqhWuDbrUn2HI3ipwMUX206oF1UgF/rx8GZNj4M1lARx2n27HZEaHrVMIGJ1ld8WujtmdHVOZpk13M0fJra1ArSDp3ATc7JqR9zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xjqRBZV/BRWYoL1Op7sNBPP8iaAjNShEAKeUMswYBQM=; b=g7zLOLTfUhYL6y7wi8xI9IISSE++190BhRUxnTBgV+WwTx8RuoFsDYO6T0dnY2FIZYEC6tRC9UGYn8Yr4hjsspj3gWZckt0xafFoBlUt0jCte3ijzpYaw+4XxIXcse7dzsCZOcvPhIWJKI7V208kKwEzwDIqaDW7B30+IAZ9o8t24FGKpcLTnNZ0Bk8CeneveyXjn6xY1BPJOwz4E3nF8a8CoBewb56hBYKfGJym7mlKWSUrItx94y5kqSg3jmZFXRt68qTxysRlIS3lDY69afGYMvlEspHLt4itjXfgUZ3RHEnP0FKO+eQMBGMEowtTbGPzLFMQCv4arj6l+kz+Sw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xjqRBZV/BRWYoL1Op7sNBPP8iaAjNShEAKeUMswYBQM=; b=Z7DiiqgT2KQNQBKnRJrO7ZTTGiI3xx2Fu3OkGkjvRLUDQIQxLdz8hTwZ/SeqhZCnsGDSlZDAg4bfJTw8iqtDll1aU+f2pM/wHh5PaVh9hGdbUOXxSEPg0x8fbXlmKImXHPObRn3aJjuEn2gf2VUShYrmo8ZqbnaGL+MSerm2sxo= Received: from MW4PR03CA0047.namprd03.prod.outlook.com (2603:10b6:303:8e::22) by CY5PR12MB6035.namprd12.prod.outlook.com (2603:10b6:930:2d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Tue, 11 Jul 2023 01:38:23 +0000 Received: from CO1NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::ca) by MW4PR03CA0047.outlook.office365.com (2603:10b6:303:8e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Tue, 11 Jul 2023 01:38:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT091.mail.protection.outlook.com (10.13.175.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6588.19 via Frontend Transport; Tue, 11 Jul 2023 01:38:22 +0000 Received: from SITE-L-T34-2.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 10 Jul 2023 20:38:21 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" , Bjorn Helgaas CC: , , Len Brown , , Mario Limonciello , Iain Lane , "Kuppuswamy Sathyanarayanan" , Mika Westerberg Subject: [PATCH v7 2/2] PCI: Don't put non-power manageable PCIe root ports into D3 Date: Mon, 10 Jul 2023 19:53:25 -0500 Message-ID: <20230711005325.1499-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711005325.1499-1-mario.limonciello@amd.com> References: <20230711005325.1499-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT091:EE_|CY5PR12MB6035:EE_ X-MS-Office365-Filtering-Correlation-Id: 5aa9c40c-0637-49db-111b-08db81af8380 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mCdjBFgUZLGYswVaPHe2ZHQZbl3MRpYU2rKZmm48nggnmAZnGQdQ+CKaWKp6k4bSdJsEyClI4j79SJMdwQPf7IADkmyrwPCiEVuqnAMc16eTMqO1RwGiUFwuGMjwQAJEJUogoZe2yPoDVCG6IbX2IItc7yxGXjGylDKF3+zMCFsxgQG5JNoFupRFEGOp8qk/NI1sFalN8KIAtKl+IiZUFJAuX+7aQpB8U07sJUgepJEwOmHzGzS1AL2gktVP82DAssvKc0+kNVQO6ozZa5Uq7oUO+6xGS5IqTLMRYu/lND02a+XQB+RKBGnCpC2i99WpqgIibCfn2jxCwOK1bb2TRr9j0/gO1pA+YavXBxny+LVAKf1UP9XDfVH74IMiJsU0Vcq3vSl1YSIHRVKXaFUZmlSoyO7kWfEGw4+rGnOzE5OtSZVPNZAoNFdZNVMyuDdxUy39TZoWcRaJnvjYzS3ZYjk2zrM3cjtMZXLy5NeKrKtrAjh2LU511Tuee0+CkeF1LUG3MB1tx06WhDZSEUuaZmfVNSJuzd/dpPm3Am6g4+qfHskA+fdYk2HqS5+9EHo8CnibGXo27tmFsp+ZyB7hmqQjC0XavtPhqkmrdANnkL6jpkoE5xbMfGtotdJoiBs2XQdfUKEENXof5Gp0wEm12xrPtfsOUfipvYvmgCSd/4h0j88S2jkGWJCXGK/03dH28I5osVVlqj1t/DwqUQWJawmVWohMDrYv8USK9vD3LPquqqjdSp1RblDEwsIQsOC+aITOE167YlVRe7JtFvs0xvNsZXScrsMnT1G6Um3a51w= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(346002)(136003)(396003)(376002)(451199021)(36840700001)(40470700004)(46966006)(336012)(426003)(2616005)(41300700001)(26005)(1076003)(83380400001)(16526019)(186003)(36860700001)(966005)(47076005)(478600001)(81166007)(82740400003)(356005)(110136005)(54906003)(7696005)(40460700003)(4326008)(44832011)(70206006)(70586007)(40480700001)(316002)(86362001)(8936002)(82310400005)(5660300002)(8676002)(2906002)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2023 01:38:22.6806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5aa9c40c-0637-49db-111b-08db81af8380 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6035 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Since commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend") PCIe ports from modern machines (>2015) are allowed to be put into D3 by storing a flag in the `struct pci_dev` structure. pci_power_manageable() uses this flag to indicate a PCIe port can enter D3. pci_pm_suspend_noirq() uses the return from pci_power_manageable() to decide whether to try to put a device into its target state for a sleep cycle via pci_prepare_to_sleep(). For devices that support D3, the target state is selected by this policy: 1. If platform_pci_power_manageable(): Use platform_pci_choose_state() 2. If the device is armed for wakeup: Select the deepest D-state that supports a PME. 3. Else: Use D3hot. Devices are considered power manageable by the platform when they have one or more objects described in the table in section 7.3 of the ACPI 6.4 specification. At suspend Linux puts PCIe root ports that are not power manageable by the platform into D3hot. Windows only puts PCIe root ports into D3 when they are power manageable by the platform. The policy selected for Linux to put non-power manageable PCIe root ports into D3hot at system suspend doesn't match anything in the PCIe or ACPI specs. Linux shouldn't assume PCIe root ports support D3 just because they're on a machine newer than 2015, the ports should also be considered power manageable by the platform. Add an extra check for PCIe root ports to ensure D3 isn't selected for them if they are not power-manageable through platform firmware. This will avoid pci_pm_suspend_noirq() changing the power state via pci_prepare_to_sleep(). The check is focused on PCIe root ports because they are part of the platform. Other PCIe bridges may be connected externally and thus cannot impose platform specific limitations. Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/07_Power_and_Performance_Mgmt/device-power-management-objects.html [1] Fixes: 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend") Reported-by: Iain Lane Closes: https://forums.lenovo.com/t5/Ubuntu/Z13-can-t-resume-from-suspend-with-external-USB-keyboard/m-p/5217121 Acked-by: Rafael J. Wysocki Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Mika Westerberg Signed-off-by: Mario Limonciello --- v6->v7: * revert back to v5 code, rewrite commit message to specific examples and be more generic --- drivers/pci/pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index f916fd76eba79..4be8c6f8f4ebe 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3041,6 +3041,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) if (dmi_check_system(bridge_d3_blacklist)) return false; + /* + * It's not safe to put root ports that aren't power manageable + * by the platform into D3. + */ + if (pci_pcie_type(bridge) == PCI_EXP_TYPE_ROOT_PORT && + !platform_pci_power_manageable(bridge)) + return false; + /* * It should be safe to put PCIe ports from 2015 or newer * to D3.