Message ID | 20221025221054.12377-1-mario.limonciello@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1241684wru; Tue, 25 Oct 2022 15:12:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4r1Klb53o2KRbC4WWcdJi2rq9eGK+YgfTS9Vr2WvItap7xyxQCKMhzn2pp82Yz0BCRfKSS X-Received: by 2002:a17:90b:1651:b0:20d:5255:859 with SMTP id il17-20020a17090b165100b0020d52550859mr482424pjb.185.1666735944567; Tue, 25 Oct 2022 15:12:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666735944; cv=pass; d=google.com; s=arc-20160816; b=eVF1I3PIMMTXsc4jiZ7iTmrZgcNl8n6+YGpj4OKOwCjLupt9SiaISxxbmVje5EuF1t h01T8EIvZiPq5YKxrX04hU6zZey7gDcxD92sCUVHSEUyi0kUNnfyeXJFEAFteOpOFP72 jiI7eG4PaB4qiDz3EEFcFUoUMF8h/vAAJBwDEtVwdtzoFHwk6MZRDzae1IwMaV2a6y8h zQhHYsVSFRaQ49mKEuUNutfPtvEt2OLH6kVhKCsfthV/I0OdhbnewBWD8E9NnicfsWye qyc7hx8OykVJyyCJKWzIf1fpZNclRXG1Rne5qjQdqkEz3UvnMo7FWzLJaNKo84QI9QVg jPPw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3jiRo/hM9NqoJag8d2jT/x/LvS3lQdwskCt8tlystQk=; b=tYnybJh5Zn2a6qe8pCnsYxdrZEkDb6aM8dxZxiB7lzyrIqwuA6aE2qHmMqcOYE3cJV UAOnH3MLa9b8dmx7GZz+S2JNvJrIeMiZUkQzjGsU0rvZB4ioz9PeFvGkdoYVpk09eJiw wLR1lQDu2P5x73/7309o1Yx/LUymm+Y1rQd0SHjcNcmB1E/NDJBf+RErGirTAaPU+o/R GnmT2Cpkp8wVH/u+vTLZj/QY7v7Ji9upyDy8+fuEi+soUOlv0mg8rcSPMYFEZtpuC696 2XqAoAPYBmyuAeBSEz/9s7iV85bvz+rOxYCHjp6EpBflNg86NskKUYaX5etcQNT/rVGt YdZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BSe6kI86; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a17090332c700b001781675f423si5104411plr.556.2022.10.25.15.12.11; Tue, 25 Oct 2022 15:12:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=BSe6kI86; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbiJYWLT (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Tue, 25 Oct 2022 18:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232579AbiJYWKy (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Oct 2022 18:10:54 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2045.outbound.protection.outlook.com [40.107.96.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87072993A9; Tue, 25 Oct 2022 15:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h3eB9VQirvGVfogWUrRayIAGuyekFb7dVsdWFeNtfn1pQeHmUeJneScLeqTEQKdZ+e7vFfalVENpjy+Deyw6zlZZoO64PBOM+0FlnV8tqPjQHpKHfhpW/26m9RRRoiKG/ceoxebBrK9Bib8r5h9RulfayceQlpn3l/0LmqmRNNN0MbfjoAyqGc/mshtXnpspRa2MGRqW7jMgyfeiSzd5qSfQeIR387EHXJXbzDftUPS96ywpCI8mjP0shrrSVPf0+kTegB8XCNuySwAGuVjIhNjOYm2kXPLK6Gj6ENXmizUCpcgvw2u9PTUhstuQs580KljW2rk1X3qH3fnkpqVvhA== 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=3jiRo/hM9NqoJag8d2jT/x/LvS3lQdwskCt8tlystQk=; b=d9kTONXjU7wpaFbXlXg9CbIaxJLMkOtKdrg3WqHWn/RoY9loOXXr5QNSrh/1NWN5fAc1QRGFYCEUZIdPs/0Q98RLb+GzbbR+IbJZdipBRUHSEYpdEmgCYg8pkuY52MD/XxP0/2Mi3/1q0phtYUGJ90rlRevLjvu4x037YDJ10NCWBcWljaa8JwO6IHFm4QEh010i6CrQQNZ4VgTzqvrhMSq0AvOqbGgD/Df5tT6mygIyDKkrKji1OEGUK3E5m+M8B0/ir5IHzpBLTmEGoaQXetOIHlNy1me+PhyiuJQIgvainS25LNI/agT/Nv6pPJXVAl/4Uxqg+0uu2aRWEMoVxQ== 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=3jiRo/hM9NqoJag8d2jT/x/LvS3lQdwskCt8tlystQk=; b=BSe6kI86qw7+9MUGf5kRuBmh9ZFKJoVu/8kBlZSreuXfdSsWh++HSs+MuXG+rF9s7GB5Mun99O1mTHLNrVncBVBzwpicGJ2bPfiG/4XNMGxJVFUsgEJtmPDgWk3L81ug7NPuHOpaO8OXb6ejWb8QqqHLGOJI9SlyzPCsvnDcPz0= Received: from BN9PR03CA0127.namprd03.prod.outlook.com (2603:10b6:408:fe::12) by MN2PR12MB4440.namprd12.prod.outlook.com (2603:10b6:208:26e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Tue, 25 Oct 2022 22:10:48 +0000 Received: from BN8NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::65) by BN9PR03CA0127.outlook.office365.com (2603:10b6:408:fe::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.27 via Frontend Transport; Tue, 25 Oct 2022 22:10:48 +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 BN8NAM11FT010.mail.protection.outlook.com (10.13.177.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5746.16 via Frontend Transport; Tue, 25 Oct 2022 22:10:48 +0000 Received: from AUS-LX-MLIMONCI.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.2375.31; Tue, 25 Oct 2022 17:10:46 -0500 From: Mario Limonciello <mario.limonciello@amd.com> To: <mario.limonciello@amd.com>, "Rafael J. Wysocki" <rafael@kernel.org>, "Len Brown" <lenb@kernel.org>, Bjorn Helgaas <bhelgaas@google.com> CC: Mika Westerberg <mika.westerberg@linux.intel.com>, Mehta Sanju <Sanju.Mehta@amd.com>, Lukas Wunner <lukas@wunner.de>, <linux-acpi@vger.kernel.org>, <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v3] PCI/ACPI: PCI/ACPI: Validate devices with power resources support D3 Date: Tue, 25 Oct 2022 17:10:54 -0500 Message-ID: <20221025221054.12377-1-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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: BN8NAM11FT010:EE_|MN2PR12MB4440:EE_ X-MS-Office365-Filtering-Correlation-Id: ffea848c-b1bd-4547-9d81-08dab6d5c5bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FYdl+qjBpG8BaZ3MzheMnfFwVqk7nnLStwBauDZHD+FgNdem7ZvFYa20XkS5e/BaQSuHW7MM0mCSiBNeFl7gIATqGKrYNRh3CqE/n3feUzGvQu7K0braVdi6eRO4E3gN+siYrJptXFJOQySYQVzqryvkDSoWcN54pJ+PDZlhlD9xfFE1CZKVFje9Kr3mewtZOYwDNN0kNpOaveOP7YitC9D/UbJ4azXzLIsp2qKkNnxEuvsDG6IygGPUN8WsGej52sFhZZAXjvG6RdVO+YzFF4Y1gpspzOZA4Ev0wUo3YrgkFVml2cmp8eFqvS1KL2u0tiO8JqMQvl+DZI5sG48KTIzxlXA4QkKEjbvIruRdNTGCxxS5o3DFV15oN5/IEUEcVmyjTI6cpJx8aDncv6NCtxJSdj7txI/VNY1zk+juZPsmJQPcKHjCRsjA1tfZAYblHd2U27tyNELnsftm659eaL/oa4FaE5HluCwxSZ5aw2Xs71owB1hfGq9tUde4wTz/+23PzFbWAP4xAfhgkKJv1Y0SMhsdTpFk5meVqSCWqlqbLS/Muof6r9BBkbizzJZZO35oQGDTzvW8NgEIIMyDOv9bR3mkZiU9D9hJ2ihzXQHlr+mehsLevCcGbH4KDyPE7lS4zrG/y7hvbxhuNQcR/lPWAyNdaxbRu3/iXCTPv83klDCeOqlu6/f7e+lJvJAZPmTES8NxDNeO6OHwvzUR45nIoZY3J0qAy99h5BJCaAWpp31mWVMHSNACKT387ndCBgLzSnyp09CXvECKfn1hvg175vgMQrZT4L+U5KgGWuQubUqP0VIdsUJtECuz56uE 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:(13230022)(4636009)(346002)(396003)(376002)(39860400002)(136003)(451199015)(46966006)(40470700004)(36840700001)(40480700001)(4326008)(8676002)(2616005)(26005)(16526019)(66574015)(186003)(82310400005)(7696005)(70206006)(36860700001)(41300700001)(40460700003)(47076005)(1076003)(70586007)(5660300002)(426003)(2906002)(8936002)(44832011)(336012)(478600001)(110136005)(19627235002)(316002)(6666004)(54906003)(15650500001)(83380400001)(86362001)(36756003)(356005)(82740400003)(81166007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 22:10:48.7705 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ffea848c-b1bd-4547-9d81-08dab6d5c5bd 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: BN8NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4440 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747699309467836562?= X-GMAIL-MSGID: =?utf-8?q?1747699309467836562?= |
Series |
[v3] PCI/ACPI: PCI/ACPI: Validate devices with power resources support D3
|
|
Commit Message
Mario Limonciello
Oct. 25, 2022, 10:10 p.m. UTC
Firmware typically advertises that PCIe devices can support D3
by a combination of the value returned by _S0W as well as the
HotPlugSupportInD3 _DSD.
`acpi_pci_bridge_d3` looks for this combination but also contains
an assumption that if a device contains power resources it can support
D3. This was introduced from commit c6e331312ebf ("PCI/ACPI: Whitelist
hotplug ports for D3 if power managed by ACPI").
On some firmware configurations for "AMD Pink Sardine" D3 is not
supported for wake in _S0W for the PCIe root port for tunneling.
However the device will still be opted into runtime PM since
`acpi_pci_bridge_d3` returns since the ACPI device contains power
resources.
When the thunderbolt driver is loaded a device link between the USB4
router and the PCIe root port for tunneling is created where the PCIe
root port for tunneling is the consumer and the USB4 router is the
supplier. Here is a demonstration of this topology that occurs:
├─ 0000:00:03.1
| | ACPI Path: \_SB_.PCI0.GP11 (Supports "0" in _S0W)
| | Device Links: supplier:pci:0000:c4:00.5
| └─ D0 (Runtime PM enabled)
├─ 0000:00:04.1
| | ACPI Path: \_SB_.PCI0.GP12 (Supports "0" in _S0W)
| | Device Links: supplier:pci:0000:c4:00.6
| └─ D0 (Runtime PM enabled)
├─ 0000:00:08.3
| | ACPI Path: \_SB_.PCI0.GP19
| ├─ D0 (Runtime PM disabled)
| ├─ 0000:c4:00.3
| | | ACPI Path: \_SB_.PCI0.GP19.XHC3
| | | Device Links: supplier:pci:0000:c4:00.5
| | └─ D3cold (Runtime PM enabled)
| ├─ 0000:c4:00.4
| | | ACPI Path: \_SB_.PCI0.GP19.XHC4
| | | Device Links: supplier:pci:0000:c4:00.6
| | └─ D3cold (Runtime PM enabled)
| ├─ 0000:c4:00.5
| | | ACPI Path: \_SB_.PCI0.GP19.NHI0 (Supports "4" in _S0W)
| | | Device Links: consumer:pci:0000:00:03.1 consumer:pci:0000:c4:00.3
| | └─ D3cold (Runtime PM enabled)
| └─ 0000:c4:00.6
| | ACPI Path: \_SB_.PCI0.GP19.NHI1 (Supports "4" in _S0W)
| | Device Links: consumer:pci:0000:c4:00.4 consumer:pci:0000:00:04.1
| └─ D3cold (Runtime PM enabled)
Allowing the PCIe root port for tunneling to go into runtime PM (even if
it doesn't support D3) allows the USB4 router to also go into runtime PM.
The PCIe root port for tunneling stays in D0 but is in runtime PM. Due to
the device link the USB4 router transitions to D3cold when this happens.
The expectation is the USB4 router should have also remained in D0 since
the PCIe root port for tunneling remained in D0.
Instead of making this assertion from the power resources check
immediately, move the check to later on, which will have validated
that the device supports wake from D3hot or D3cold.
This fix prevents the USB4 router going into D3 when the firmware says that
the PCIe root port for tunneling can't handle it while still allowing
system that don't have the HotplugSupportInD3 _DSD to also enter D3 if they
have power resources that can wake from D3.
Fixes: dff6139015dc6 ("PCI/ACPI: Allow D3 only if Root Port can signal and wake from D3")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v2->v3:
* Reword commit message
v1->v2:
* Just return value of acpi_pci_power_manageable (Rafael)
* Remove extra word in commit message
---
drivers/pci/pci-acpi.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
Comments
On Tue, Oct 25, 2022 at 05:10:54PM -0500, Mario Limonciello wrote: > Firmware typically advertises that PCIe devices can support D3 > by a combination of the value returned by _S0W as well as the > HotPlugSupportInD3 _DSD. > > `acpi_pci_bridge_d3` looks for this combination but also contains > an assumption that if a device contains power resources it can support > D3. This was introduced from commit c6e331312ebf ("PCI/ACPI: Whitelist > hotplug ports for D3 if power managed by ACPI"). > > On some firmware configurations for "AMD Pink Sardine" D3 is not > supported for wake in _S0W for the PCIe root port for tunneling. > However the device will still be opted into runtime PM since > `acpi_pci_bridge_d3` returns since the ACPI device contains power > resources. > > When the thunderbolt driver is loaded a device link between the USB4 > router and the PCIe root port for tunneling is created where the PCIe > root port for tunneling is the consumer and the USB4 router is the > supplier. Here is a demonstration of this topology that occurs: > > ├─ 0000:00:03.1 > | | ACPI Path: \_SB_.PCI0.GP11 (Supports "0" in _S0W) > | | Device Links: supplier:pci:0000:c4:00.5 > | └─ D0 (Runtime PM enabled) > ├─ 0000:00:04.1 > | | ACPI Path: \_SB_.PCI0.GP12 (Supports "0" in _S0W) > | | Device Links: supplier:pci:0000:c4:00.6 > | └─ D0 (Runtime PM enabled) > ├─ 0000:00:08.3 > | | ACPI Path: \_SB_.PCI0.GP19 > | ├─ D0 (Runtime PM disabled) > | ├─ 0000:c4:00.3 > | | | ACPI Path: \_SB_.PCI0.GP19.XHC3 > | | | Device Links: supplier:pci:0000:c4:00.5 > | | └─ D3cold (Runtime PM enabled) > | ├─ 0000:c4:00.4 > | | | ACPI Path: \_SB_.PCI0.GP19.XHC4 > | | | Device Links: supplier:pci:0000:c4:00.6 > | | └─ D3cold (Runtime PM enabled) > | ├─ 0000:c4:00.5 > | | | ACPI Path: \_SB_.PCI0.GP19.NHI0 (Supports "4" in _S0W) > | | | Device Links: consumer:pci:0000:00:03.1 consumer:pci:0000:c4:00.3 > | | └─ D3cold (Runtime PM enabled) > | └─ 0000:c4:00.6 > | | ACPI Path: \_SB_.PCI0.GP19.NHI1 (Supports "4" in _S0W) > | | Device Links: consumer:pci:0000:c4:00.4 consumer:pci:0000:00:04.1 > | └─ D3cold (Runtime PM enabled) > > Allowing the PCIe root port for tunneling to go into runtime PM (even if > it doesn't support D3) allows the USB4 router to also go into runtime PM. > The PCIe root port for tunneling stays in D0 but is in runtime PM. Due to > the device link the USB4 router transitions to D3cold when this happens. > > The expectation is the USB4 router should have also remained in D0 since > the PCIe root port for tunneling remained in D0. > > Instead of making this assertion from the power resources check > immediately, move the check to later on, which will have validated > that the device supports wake from D3hot or D3cold. > > This fix prevents the USB4 router going into D3 when the firmware says that > the PCIe root port for tunneling can't handle it while still allowing > system that don't have the HotplugSupportInD3 _DSD to also enter D3 if they > have power resources that can wake from D3. > > Fixes: dff6139015dc6 ("PCI/ACPI: Allow D3 only if Root Port can signal and wake from D3") > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
On Wed, Oct 26, 2022 at 12:10 AM Mario Limonciello <mario.limonciello@amd.com> wrote: > > Firmware typically advertises that PCIe devices can support D3 > by a combination of the value returned by _S0W as well as the > HotPlugSupportInD3 _DSD. > > `acpi_pci_bridge_d3` looks for this combination but also contains > an assumption that if a device contains power resources it can support > D3. This was introduced from commit c6e331312ebf ("PCI/ACPI: Whitelist > hotplug ports for D3 if power managed by ACPI"). > > On some firmware configurations for "AMD Pink Sardine" D3 is not > supported for wake in _S0W for the PCIe root port for tunneling. > However the device will still be opted into runtime PM since > `acpi_pci_bridge_d3` returns since the ACPI device contains power > resources. > > When the thunderbolt driver is loaded a device link between the USB4 > router and the PCIe root port for tunneling is created where the PCIe > root port for tunneling is the consumer and the USB4 router is the > supplier. Here is a demonstration of this topology that occurs: > > ├─ 0000:00:03.1 > | | ACPI Path: \_SB_.PCI0.GP11 (Supports "0" in _S0W) > | | Device Links: supplier:pci:0000:c4:00.5 > | └─ D0 (Runtime PM enabled) > ├─ 0000:00:04.1 > | | ACPI Path: \_SB_.PCI0.GP12 (Supports "0" in _S0W) > | | Device Links: supplier:pci:0000:c4:00.6 > | └─ D0 (Runtime PM enabled) > ├─ 0000:00:08.3 > | | ACPI Path: \_SB_.PCI0.GP19 > | ├─ D0 (Runtime PM disabled) > | ├─ 0000:c4:00.3 > | | | ACPI Path: \_SB_.PCI0.GP19.XHC3 > | | | Device Links: supplier:pci:0000:c4:00.5 > | | └─ D3cold (Runtime PM enabled) > | ├─ 0000:c4:00.4 > | | | ACPI Path: \_SB_.PCI0.GP19.XHC4 > | | | Device Links: supplier:pci:0000:c4:00.6 > | | └─ D3cold (Runtime PM enabled) > | ├─ 0000:c4:00.5 > | | | ACPI Path: \_SB_.PCI0.GP19.NHI0 (Supports "4" in _S0W) > | | | Device Links: consumer:pci:0000:00:03.1 consumer:pci:0000:c4:00.3 > | | └─ D3cold (Runtime PM enabled) > | └─ 0000:c4:00.6 > | | ACPI Path: \_SB_.PCI0.GP19.NHI1 (Supports "4" in _S0W) > | | Device Links: consumer:pci:0000:c4:00.4 consumer:pci:0000:00:04.1 > | └─ D3cold (Runtime PM enabled) > > Allowing the PCIe root port for tunneling to go into runtime PM (even if > it doesn't support D3) allows the USB4 router to also go into runtime PM. > The PCIe root port for tunneling stays in D0 but is in runtime PM. Due to > the device link the USB4 router transitions to D3cold when this happens. > > The expectation is the USB4 router should have also remained in D0 since > the PCIe root port for tunneling remained in D0. > > Instead of making this assertion from the power resources check > immediately, move the check to later on, which will have validated > that the device supports wake from D3hot or D3cold. > > This fix prevents the USB4 router going into D3 when the firmware says that > the PCIe root port for tunneling can't handle it while still allowing > system that don't have the HotplugSupportInD3 _DSD to also enter D3 if they > have power resources that can wake from D3. > > Fixes: dff6139015dc6 ("PCI/ACPI: Allow D3 only if Root Port can signal and wake from D3") > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> > --- > v2->v3: > * Reword commit message > v1->v2: > * Just return value of acpi_pci_power_manageable (Rafael) > * Remove extra word in commit message > --- > drivers/pci/pci-acpi.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c > index a46fec776ad77..8c6aec50dd471 100644 > --- a/drivers/pci/pci-acpi.c > +++ b/drivers/pci/pci-acpi.c > @@ -984,10 +984,6 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) > if (acpi_pci_disabled || !dev->is_hotplug_bridge) > return false; > > - /* Assume D3 support if the bridge is power-manageable by ACPI. */ > - if (acpi_pci_power_manageable(dev)) > - return true; > - > rpdev = pcie_find_root_port(dev); > if (!rpdev) > return false; > @@ -1023,7 +1019,8 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) > obj->integer.value == 1) > return true; > > - return false; > + /* Assume D3 support if the bridge is power-manageable by ACPI. */ > + return acpi_pci_power_manageable(dev); > } > > int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) > -- > 2.34.1 >
Hi Mario, Thanks for expanding the commit log. I'm sure this patch is the right thing to do; I just want to connect a few more dots to make it less likely that we'll break this in the future. On Tue, Oct 25, 2022 at 05:10:54PM -0500, Mario Limonciello wrote: > Firmware typically advertises that PCIe devices can support D3 > by a combination of the value returned by _S0W as well as the > HotPlugSupportInD3 _DSD. All PCI devices are required to support both D3hot and D3cold (PCIe r6.0, sec 5.3.1.4), so I think what's being advertised here is about what firmware can do (which of course implicitly depends on controls provided by the platform hardware), not what the *device* supports. The OS can put a device in D3hot by itself with the PM Control register, so I assume the important thing here is whether firmware has interfaces to put a device in D3cold and bring it back to D0. I know we only get to acpi_pci_bridge_d3() for PCIe devices, but when the device properties and ACPI interfaces are not PCIe-specific, I don't think we should restrict it by saying "PCIe". > `acpi_pci_bridge_d3` looks for this combination but also contains > an assumption that if a device contains power resources it can support > D3. This was introduced from commit c6e331312ebf ("PCI/ACPI: Whitelist > hotplug ports for D3 if power managed by ACPI"). > > On some firmware configurations for "AMD Pink Sardine" D3 is not > supported for wake in _S0W for the PCIe root port for tunneling. > However the device will still be opted into runtime PM since > `acpi_pci_bridge_d3` returns since the ACPI device contains power > resources. > > When the thunderbolt driver is loaded a device link between the USB4 > router and the PCIe root port for tunneling is created where the PCIe > root port for tunneling is the consumer and the USB4 router is the > supplier. Here is a demonstration of this topology that occurs: > > ├─ 0000:00:03.1 > | | ACPI Path: \_SB_.PCI0.GP11 (Supports "0" in _S0W) > | | Device Links: supplier:pci:0000:c4:00.5 > | └─ D0 (Runtime PM enabled) > ├─ 0000:00:04.1 > | | ACPI Path: \_SB_.PCI0.GP12 (Supports "0" in _S0W) > | | Device Links: supplier:pci:0000:c4:00.6 > | └─ D0 (Runtime PM enabled) > ├─ 0000:00:08.3 > | | ACPI Path: \_SB_.PCI0.GP19 > | ├─ D0 (Runtime PM disabled) > | ├─ 0000:c4:00.3 > | | | ACPI Path: \_SB_.PCI0.GP19.XHC3 > | | | Device Links: supplier:pci:0000:c4:00.5 > | | └─ D3cold (Runtime PM enabled) > | ├─ 0000:c4:00.4 > | | | ACPI Path: \_SB_.PCI0.GP19.XHC4 > | | | Device Links: supplier:pci:0000:c4:00.6 > | | └─ D3cold (Runtime PM enabled) > | ├─ 0000:c4:00.5 > | | | ACPI Path: \_SB_.PCI0.GP19.NHI0 (Supports "4" in _S0W) > | | | Device Links: consumer:pci:0000:00:03.1 consumer:pci:0000:c4:00.3 > | | └─ D3cold (Runtime PM enabled) > | └─ 0000:c4:00.6 > | | ACPI Path: \_SB_.PCI0.GP19.NHI1 (Supports "4" in _S0W) > | | Device Links: consumer:pci:0000:c4:00.4 consumer:pci:0000:00:04.1 > | └─ D3cold (Runtime PM enabled) Can you label the devices above to correspond with the preceding paragraph? I assume one of the XHC devices is the USB4 router, but I don't know which is the Root Port. Are all the devices relevant to the problem? If not, prune the ones that don't matter. It looks like the domain ("0000") could also be pruned out. If you also include the _PR0 and/or _PS0 methods, we'll be able to see why the current code doesn't do what we want and why the new code will. What determines the device links? I assume there's some ACPI information that connects the USB4 router with the Root Port? What are the "D0" and "D3cold" annotations telling me? What does "runtime PM enabled" mean? Is that determined based on some ACPI methods? > Allowing the PCIe root port for tunneling to go into runtime PM (even if > it doesn't support D3) allows the USB4 router to also go into runtime PM. > The PCIe root port for tunneling stays in D0 but is in runtime PM. Due to > the device link the USB4 router transitions to D3cold when this happens. It's probably obvious to PM folks what "going into runtime PM" means, but it would help me out to describe it in terms of the hardware state of the device, e.g., D3hot or whatever. > The expectation is the USB4 router should have also remained in D0 since > the PCIe root port for tunneling remained in D0. > > Instead of making this assertion from the power resources check > immediately, move the check to later on, which will have validated > that the device supports wake from D3hot or D3cold. > > This fix prevents the USB4 router going into D3 when the firmware says that > the PCIe root port for tunneling can't handle it while still allowing > system that don't have the HotplugSupportInD3 _DSD to also enter D3 if they > have power resources that can wake from D3. I guess there's a theme here of looking for concrete terms that I can connect directly to the spec vs abstract things like "going into runtime PM" or "root port can't handle D3" (which I think is actually saying something about what *firmware* can do). > Fixes: dff6139015dc6 ("PCI/ACPI: Allow D3 only if Root Port can signal and wake from D3") > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > --- > v2->v3: > * Reword commit message > v1->v2: > * Just return value of acpi_pci_power_manageable (Rafael) > * Remove extra word in commit message > --- > drivers/pci/pci-acpi.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c > index a46fec776ad77..8c6aec50dd471 100644 > --- a/drivers/pci/pci-acpi.c > +++ b/drivers/pci/pci-acpi.c > @@ -984,10 +984,6 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) > if (acpi_pci_disabled || !dev->is_hotplug_bridge) > return false; > > - /* Assume D3 support if the bridge is power-manageable by ACPI. */ > - if (acpi_pci_power_manageable(dev)) > - return true; > - > rpdev = pcie_find_root_port(dev); > if (!rpdev) > return false; > @@ -1023,7 +1019,8 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) > obj->integer.value == 1) > return true; > > - return false; > + /* Assume D3 support if the bridge is power-manageable by ACPI. */ > + return acpi_pci_power_manageable(dev); > } > > int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) > -- > 2.34.1 >
On 10/26/2022 14:09, Bjorn Helgaas wrote: > Hi Mario, > > Thanks for expanding the commit log. I'm sure this patch is the right > thing to do; I just want to connect a few more dots to make it less > likely that we'll break this in the future. OK. I'll pick up those two tags from Mika and Rafael and try to reword the commit message a bit. > > On Tue, Oct 25, 2022 at 05:10:54PM -0500, Mario Limonciello wrote: >> Firmware typically advertises that PCIe devices can support D3 >> by a combination of the value returned by _S0W as well as the >> HotPlugSupportInD3 _DSD. > > All PCI devices are required to support both D3hot and D3cold (PCIe > r6.0, sec 5.3.1.4), so I think what's being advertised here is about > what firmware can do (which of course implicitly depends on controls > provided by the platform hardware), not what the *device* supports. > > The OS can put a device in D3hot by itself with the PM Control > register, so I assume the important thing here is whether firmware has > interfaces to put a device in D3cold and bring it back to D0. If you completely ignore _S0W, sure you can put the device into D3hot by changing this register but while in the firmware configuration I describe you won't get wake events to pull you out of it. So the PCIe device will stay in this state until the OS does something. > > I know we only get to acpi_pci_bridge_d3() for PCIe devices, but when > the device properties and ACPI interfaces are not PCIe-specific, I > don't think we should restrict it by saying "PCIe". Thanks for clarifying. I'm thinking I'll s/PCIe/ACPI/ in the commit message to convey this. > >> `acpi_pci_bridge_d3` looks for this combination but also contains >> an assumption that if a device contains power resources it can support >> D3. This was introduced from commit c6e331312ebf ("PCI/ACPI: Whitelist >> hotplug ports for D3 if power managed by ACPI"). >> >> On some firmware configurations for "AMD Pink Sardine" D3 is not >> supported for wake in _S0W for the PCIe root port for tunneling. >> However the device will still be opted into runtime PM since >> `acpi_pci_bridge_d3` returns since the ACPI device contains power >> resources. >> >> When the thunderbolt driver is loaded a device link between the USB4 >> router and the PCIe root port for tunneling is created where the PCIe >> root port for tunneling is the consumer and the USB4 router is the >> supplier. Here is a demonstration of this topology that occurs: >> >> ├─ 0000:00:03.1 >> | | ACPI Path: \_SB_.PCI0.GP11 (Supports "0" in _S0W) >> | | Device Links: supplier:pci:0000:c4:00.5 >> | └─ D0 (Runtime PM enabled) >> ├─ 0000:00:04.1 >> | | ACPI Path: \_SB_.PCI0.GP12 (Supports "0" in _S0W) >> | | Device Links: supplier:pci:0000:c4:00.6 >> | └─ D0 (Runtime PM enabled) >> ├─ 0000:00:08.3 >> | | ACPI Path: \_SB_.PCI0.GP19 >> | ├─ D0 (Runtime PM disabled) >> | ├─ 0000:c4:00.3 >> | | | ACPI Path: \_SB_.PCI0.GP19.XHC3 >> | | | Device Links: supplier:pci:0000:c4:00.5 >> | | └─ D3cold (Runtime PM enabled) >> | ├─ 0000:c4:00.4 >> | | | ACPI Path: \_SB_.PCI0.GP19.XHC4 >> | | | Device Links: supplier:pci:0000:c4:00.6 >> | | └─ D3cold (Runtime PM enabled) >> | ├─ 0000:c4:00.5 >> | | | ACPI Path: \_SB_.PCI0.GP19.NHI0 (Supports "4" in _S0W) >> | | | Device Links: consumer:pci:0000:00:03.1 consumer:pci:0000:c4:00.3 >> | | └─ D3cold (Runtime PM enabled) >> | └─ 0000:c4:00.6 >> | | ACPI Path: \_SB_.PCI0.GP19.NHI1 (Supports "4" in _S0W) >> | | Device Links: consumer:pci:0000:c4:00.4 consumer:pci:0000:00:04.1 >> | └─ D3cold (Runtime PM enabled) > > Can you label the devices above to correspond with the preceding > paragraph? I assume one of the XHC devices is the USB4 router, but I > don't know which is the Root Port. In the above example there are 2 USB4 routers, 2 PCIe root ports used for tunneling and 2 XHCI PCIe devices. > > Are all the devices relevant to the problem? If not, prune the ones > that don't matter. It looks like the domain ("0000") could also be > pruned out. They're all relevant because links are made between them. If the XHCI PCIe device was not in runtime PM, it could prevent the router from going into runtime PM as well just the same. I could remove one triplet of devices to keep it simpler (USB4 router, XHCI PCIe device and PCIe root port for tunneling) but all systems I've seen have 2. > > If you also include the _PR0 and/or _PS0 methods, we'll be able to see > why the current code doesn't do what we want and why the new code > will. OK, I'll add a line/assertion which have _PS0/_PR0. > > What determines the device links? I assume there's some ACPI > information that connects the USB4 router with the Root Port? They're created when the firmware node has "usb4-host-interface". I'll add some lines to describe this as well to the commit message. https://github.com/torvalds/linux/blob/v6.1-rc1/drivers/thunderbolt/acpi.c#L29 > > What are the "D0" and "D3cold" annotations telling me? What does > "runtime PM enabled" mean? Is that determined based on some ACPI > methods? D0/D3cold are tell you at rest what power states each ACPI device is in as read from /sys/bus/pci/devices/{bdf}/power_state The USB4 routers are in D3cold, which shouldn't have occurred because the PCIe root ports for tunneling are in D0. This only happened because runtime PM was enabled on the PCIe root port for tunneling, and runtime PM was enabled because acpi_pci_bridge_d3 asserted that it supported it. > >> Allowing the PCIe root port for tunneling to go into runtime PM (even if >> it doesn't support D3) allows the USB4 router to also go into runtime PM. >> The PCIe root port for tunneling stays in D0 but is in runtime PM. Due to >> the device link the USB4 router transitions to D3cold when this happens. > > It's probably obvious to PM folks what "going into runtime PM" means, > but it would help me out to describe it in terms of the hardware state > of the device, e.g., D3hot or whatever. I think a simplified description here is "the device has been put into the deepest sleep state that it can wake itself from at runtime". Suppliers can't go into runtime PM until all consumers of the device have done so. If a consumer doesn't support runtime PM then it will block the supplier from entering runtime PM. > >> The expectation is the USB4 router should have also remained in D0 since >> the PCIe root port for tunneling remained in D0. >> >> Instead of making this assertion from the power resources check >> immediately, move the check to later on, which will have validated >> that the device supports wake from D3hot or D3cold. >> >> This fix prevents the USB4 router going into D3 when the firmware says that >> the PCIe root port for tunneling can't handle it while still allowing >> system that don't have the HotplugSupportInD3 _DSD to also enter D3 if they >> have power resources that can wake from D3. > > I guess there's a theme here of looking for concrete terms that I can > connect directly to the spec vs abstract things like "going into > runtime PM" or "root port can't handle D3" (which I think is actually > saying something about what *firmware* can do). The UBS4 CM spec doesn't describe the ACPI relationships. So I'm afraid the best I can come up with is what Microsoft says: "For the PCIe and USB 3.x software stacks to establish power relations with the USB4 host router, device-specific data (_DSD) for the tunneled PCIe and USB 3.x ports is required. In the absence of this, the USB4 domain may power down without coordinating with the tunneled PCIe and USB 3.x devices." https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/usb4-acpi-requirements#port-mapping-_dsd-for-usb-3x-and-pcie "Runtime PM" is the power relation that is used for Linux. Back when we did dff6139015dc6 earlier this year the Yellow Carp systems didn't have power resources declared in this particularly firmware configuration so the behavior caused by c6e331312ebf didn't negatively affect anything. If they did, I'd like to think I would have done this right the first time =). > >> Fixes: dff6139015dc6 ("PCI/ACPI: Allow D3 only if Root Port can signal and wake from D3") >> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> >> --- >> v2->v3: >> * Reword commit message >> v1->v2: >> * Just return value of acpi_pci_power_manageable (Rafael) >> * Remove extra word in commit message >> --- >> drivers/pci/pci-acpi.c | 7 ++----- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c >> index a46fec776ad77..8c6aec50dd471 100644 >> --- a/drivers/pci/pci-acpi.c >> +++ b/drivers/pci/pci-acpi.c >> @@ -984,10 +984,6 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) >> if (acpi_pci_disabled || !dev->is_hotplug_bridge) >> return false; >> >> - /* Assume D3 support if the bridge is power-manageable by ACPI. */ >> - if (acpi_pci_power_manageable(dev)) >> - return true; >> - >> rpdev = pcie_find_root_port(dev); >> if (!rpdev) >> return false; >> @@ -1023,7 +1019,8 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) >> obj->integer.value == 1) >> return true; >> >> - return false; >> + /* Assume D3 support if the bridge is power-manageable by ACPI. */ >> + return acpi_pci_power_manageable(dev); >> } >> >> int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) >> -- >> 2.34.1 >>
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index a46fec776ad77..8c6aec50dd471 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -984,10 +984,6 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) if (acpi_pci_disabled || !dev->is_hotplug_bridge) return false; - /* Assume D3 support if the bridge is power-manageable by ACPI. */ - if (acpi_pci_power_manageable(dev)) - return true; - rpdev = pcie_find_root_port(dev); if (!rpdev) return false; @@ -1023,7 +1019,8 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev) obj->integer.value == 1) return true; - return false; + /* Assume D3 support if the bridge is power-manageable by ACPI. */ + return acpi_pci_power_manageable(dev); } int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)