From patchwork Wed Sep 6 18:43:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 720754 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 C3B33EE14D8 for ; Wed, 6 Sep 2023 19:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244141AbjIFTQl (ORCPT ); Wed, 6 Sep 2023 15:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243932AbjIFTQj (ORCPT ); Wed, 6 Sep 2023 15:16:39 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::620]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E32185; Wed, 6 Sep 2023 12:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X0yYyAXPGWPCgdWkhLCISbcj5kRYedweEss2iI/TwqGr/oAwQ2+XY3fzGg6UokOJcrngTgcWt3SSLcv/9/yVUeoHq3JbnOlYzMwDaXl+EOna+3NfKWWnjO4gdbhhsZD1YoV/dJuIpyoALCl6RY/tldo8qOUxnlO3kxTuZyUdZtd1Ci8ObOtlARSzfs/DabkdC9TevN+RpNJ9N+oELIt5mn31kGtgUFVUc1gbJ2aI6pE/QTYoH0sys8XqIaxrSmq0XR8h/OgoAqP2aDaFtpbkG23TSFplWCL9/IaZhHW5Dyw+0Gf6PWg4EHdmiJuWfMYiquUTaHdfBYxASyLUD8xXVA== 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=bhgdq7tuoTrEq5dIpJ1dvdmdDEcRiop06oGFEE7Xd/s=; b=CBXoJL8O7yhRxrsda0mTjAMCzIOvlKbJQA6Pm5C4qTgRmq6/FGomw4V9CsSD+TDBFzAkTGLoCtmNoq+p9DfmTgNTyOkipnZGQ4YX7A3dDnxGrI1Kr5DjrU0BQEfk1roVr4wmWgBij0r+zOOo+pi96+AdyR1PsRg57Mh6gs1shU9YnTEf6UOxs6KH3drgIPxo0yTgBgacmdssQylAJdqt4OP2LbY27bqYatZ9Cl+Rdqrz+iccp4kw0NgXpVmEjAS2r7Ltq9hM5Ynsz6XjuCvCWVxcA8YT7TzOwONoDDYHsR/vZzLmVv0+Hetm8cQ8WhxZjnHnbJ+R9R7NdXL3wVVRQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=bhgdq7tuoTrEq5dIpJ1dvdmdDEcRiop06oGFEE7Xd/s=; b=TKwSDBO1HXiwbEdlTgjhgmP/JWIUe0JFrtYkVO6r6pxRMqk6ffnPx8xWZ6+RwpqAa/MtOSEKajf8RIjxz636NFOJlGWiOvW4PLjUb85s2jdAO73lHtbQogXV5zoGy19pG7QmdEOWfzPKsT2ajLGJs2qbm/kvvVJ05rHSwSRCJA4= Received: from BL1P223CA0003.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::8) by DS7PR12MB5912.namprd12.prod.outlook.com (2603:10b6:8:7d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Wed, 6 Sep 2023 19:16:32 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:2c4:cafe::88) by BL1P223CA0003.outlook.office365.com (2603:10b6:208:2c4::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36 via Frontend Transport; Wed, 6 Sep 2023 19:16:32 +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 BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 19:16:32 +0000 Received: from AUS-P9-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.2507.27; Wed, 6 Sep 2023 14:16:29 -0500 From: Mario Limonciello To: Hans de Goede , Bjorn Helgaas , "Rafael J . Wysocki" CC: Shyam Sundar S K , "open list:X86 PLATFORM DRIVERS" , "open list:PCI SUBSYSTEM" , , Mario Limonciello , "Rafael J . Wysocki" Subject: [PATCH v17 1/4] ACPI: x86: s2idle: Export symbol for fetching constraints for module use Date: Wed, 6 Sep 2023 13:43:51 -0500 Message-ID: <20230906184354.45846-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230906184354.45846-1-mario.limonciello@amd.com> References: <20230906184354.45846-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: BL6PEPF0001AB59:EE_|DS7PR12MB5912:EE_ X-MS-Office365-Filtering-Correlation-Id: b91e16b1-3107-403f-7a21-08dbaf0dc7bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M3mU4xb6k2MBsiBQkF6X7DKCvxejopNikMULMvT1uq4GBSumpdp3N7O++jyaHfIJ0W/w3EzbNe9hSkof6+0UaTc58Gv9M7xHAZZl+1pVUg3ahOzhOfJMU0DNisaPcyHEfDpZxF0XkPB2NvzIL3uhRBYxIDgHML7Cf+WOQcDnYId9oDb81IFK6LntF8spLFyDIFiHnC5ZyT98fxQ0RSlMKPXCbz+HABS11rRCraShrL0cl+ZAobFvy9n4HV73r1qGuBtpXp2Kjmg5WraZf/xhZq3OEVBYEQjwEBgEOSJy50VV70bkwDOGF38PwDk9UNY9J5MltjwvJIu9FGhTo6pOHDRkzyjkqm+YOcCc9Q2ZMeSAeJXtzXXc3u3hJH3L96ml/d2d6a2y6hQvGm5hQHufe+s/BfgohURv2062nqoHFHvwcyY7FiP3l+bBLs/Op+ohfeCa7+GROlzki3eTnYuFBV3nRWNs4YAOHdE4giwIW6loAcjZJ/j73lUE4ZEo9izuHja5YZB5P6+8vmdFfN9nYtWIDcqwhLeNuxucDMa0jo+NVeu9bJWxRx3iskNNl9C2oClF0nA/dXok6XHAa1iT3bNWvyDDOkC/Z9dV/z1OglzqfrROWIkIUzMT6P2Rw/xGvvSjLkPdxXxcHuVjQPJK0AcTRqas8a0UFnn5ifqYsisX6AMLumO0inZE7RCE0vN01cNM4YT3efGzsbzi2cvx6Nqgau/JtwiiRKfXv0mZ52/sOPBnBR3fsZj6sUadUdGhVtNlECd7UYk6Bbdhlm12ZQ== 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:(13230031)(4636009)(346002)(136003)(376002)(39860400002)(396003)(1800799009)(186009)(82310400011)(451199024)(36840700001)(46966006)(40470700004)(81166007)(6666004)(7696005)(356005)(82740400003)(40460700003)(36756003)(36860700001)(47076005)(86362001)(40480700001)(1076003)(2616005)(4744005)(2906002)(426003)(16526019)(336012)(26005)(478600001)(83380400001)(110136005)(70206006)(70586007)(41300700001)(4326008)(8936002)(8676002)(5660300002)(316002)(44832011)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 19:16:32.3238 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b91e16b1-3107-403f-7a21-08dbaf0dc7bf 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: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5912 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The amd-pmc driver will be fetching constraints to make decisions at suspend time. This driver can be compiled as a module, so export the symbol for when it is a module. Acked-by: Rafael J. Wysocki Signed-off-by: Mario Limonciello --- drivers/acpi/x86/s2idle.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c index 08f7c6708206..de9c313c21fa 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -322,6 +322,7 @@ int acpi_get_lps0_constraint(struct acpi_device *adev) return ACPI_STATE_UNKNOWN; } +EXPORT_SYMBOL_GPL(acpi_get_lps0_constraint); static void lpi_check_constraints(void) { From patchwork Wed Sep 6 18:43:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 720753 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 8103EEE14D0 for ; Wed, 6 Sep 2023 19:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244156AbjIFTQs (ORCPT ); Wed, 6 Sep 2023 15:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232004AbjIFTQn (ORCPT ); Wed, 6 Sep 2023 15:16:43 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::60e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6341E41; Wed, 6 Sep 2023 12:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LmblRZeuLSIFcGHThRIWJ0Q6OxfLIDr1h/iwL0Ts8qAPmmxEzcDrHQorz8qCRFjgEs1AInkCOIAR61cNr8ZhLEUyuzAGVsK8B8kIA+vW3rTAxpFK0kI/Z/X6FvJ7MAD9vHsGa4fLtnOllGl1bNaclM/VDy4YUqBN7frBEVsHEwsuRcTg/0rKe4s7fL0SzUH96ZbnfMC9Za8As1WBwvjAGXx6hYGo6eQKhl6xQQW6RgCXtKAmxl4MbRKt1JJxlb9rhZzQzaFUdZV4W4PvD4+0Y93i8Dz99qX+S54RwfTUw4WiylnxV21wHi4EX8lTfMnCSKDiWOHBv6Q6RQ1w8/EbQg== 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=x5xxYKRtpI0GejmHbFRAM5xdMKLsVnMzvB9IwcTCtRE=; b=awT6czXzzyAGuON+2cf0oAMDfDzilyneRVDge/RKlDGtB0FG7Aks97NhvMuLPvqG+TVeSMU2eE+Y+PrLCJhaciGqCX2cK2spdW7gNYobulGdilFsMPZtX39VdD3MQgV2aq0bDFBS//P+/ln22zDhCB53gVL6i8G1+sYdLlZOpGvfAHO4swNVa3+K65aEbbMtMrr33lB4flrh33UaFB6UYbCHzg+pUKRNOHep/0W7THGs2aZB+m5PzIfLKw3Zpynd4UBUSgMWiMoIFvbBwz/EWfxQ2QRVBbSYkeHvASIBDlDJGL3HQoYYwh2BLK84QpQGYmjFBD+67i7VEehmSek+Lw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=x5xxYKRtpI0GejmHbFRAM5xdMKLsVnMzvB9IwcTCtRE=; b=Bp/8lSU0sL+8WSWpk3VtDXyybXNbkXi/jvcj24OryLEBLBZtBSjEIwpJvyy+06k10hMAf17k3vqcTD+yhwpvnPPhMh9NPigoypkMZo/80Tv7K+d4nW6Hc8EcPEm3+pu9OrJkUdXL3vcavKbKbpJMIHVliL7jLs1685tuTULRWrc= Received: from BL1P223CA0024.NAMP223.PROD.OUTLOOK.COM (2603:10b6:208:2c4::29) by BL1PR12MB5142.namprd12.prod.outlook.com (2603:10b6:208:312::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Wed, 6 Sep 2023 19:16:32 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:2c4:cafe::da) by BL1P223CA0024.outlook.office365.com (2603:10b6:208:2c4::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34 via Frontend Transport; Wed, 6 Sep 2023 19:16:32 +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 BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 19:16:32 +0000 Received: from AUS-P9-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.2507.27; Wed, 6 Sep 2023 14:16:30 -0500 From: Mario Limonciello To: Hans de Goede , Bjorn Helgaas , "Rafael J . Wysocki" CC: Shyam Sundar S K , "open list:X86 PLATFORM DRIVERS" , "open list:PCI SUBSYSTEM" , , Mario Limonciello Subject: [PATCH v17 2/4] PCI: Add support for drivers to register optin or veto of D3 Date: Wed, 6 Sep 2023 13:43:52 -0500 Message-ID: <20230906184354.45846-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230906184354.45846-1-mario.limonciello@amd.com> References: <20230906184354.45846-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: BL6PEPF0001AB59:EE_|BL1PR12MB5142:EE_ X-MS-Office365-Filtering-Correlation-Id: b6f500ed-edd4-4019-6332-08dbaf0dc809 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bvmObIpYMnYlBT0WpRwfPzkRn4e4EZyWEU9spVxO5eg4SWSvfmrsefb/IDWUL+0BZzvyw289kbeWbxpdSRzdtPDqgKhQMNzAQHsoCF4MBPpExmwAFl5jPOXZ0Niyz4ZbFXqR17L2G1+6aVQjpmh5ad3PG2BlehDr7oagAWzXYbjRzXeUXrKIs5PpERwfm69poIjZeVJ/R9S5Ks0SjDyB0RZ25fhA2XWP7xAAM9BDETGCPAh0ybExsEokH648Qgax/4GTZ0KRQcg/XhAoU50w6kThA1dC3jlu3HrnvM66kyf6xEvGTtRdSmoENKc55bxLeuskGg7kCeN1dg3r+3a1JOUHew2sO1PNp7qyHZbTHl1uyg3BdlXPHnOaooyPYIqZuOkYB4Qyw9Gm8u7G+QVRHd4E8F/y7a+mIG9qsODxBXAxgWKQV3AZOUGxX5VEArEBJFrvVHvIehSz6TfzMwPmL/BIzmHw3ldaXMZW4t4vyL5Rzyk46uWTAHo+VdCAFlzpNlQAha5Sj2C4NSKegzmv0bkaEnIaskLElxQXEycPHUx6FBoYMwnBkm7NIyyVNlSWE/0aQ/qEJWFzxEc9LlgKVOTeOxY6ShyebNVgQD1+dl6znpfDSxOmT/B4kbq38ELJkzNftGP2TF1g6yHW7+8/paGAT6nqc/kTmauyvsFKnwSUsw0GtVo2NjxdBbrwAOebqmzgQrtlAGuzD9imtHEtvuSObuHpa13/Bn7O1yYh+eE4okw7plsM1EYTnAeJaqigxxdQEjytUbRdS2Si5By7IQ== 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:(13230031)(4636009)(39860400002)(346002)(396003)(376002)(136003)(82310400011)(186009)(1800799009)(451199024)(40470700004)(36840700001)(46966006)(82740400003)(2616005)(40460700003)(26005)(81166007)(16526019)(356005)(1076003)(7696005)(47076005)(36756003)(36860700001)(426003)(336012)(83380400001)(40480700001)(4326008)(478600001)(8676002)(8936002)(70586007)(44832011)(110136005)(70206006)(5660300002)(316002)(86362001)(54906003)(6666004)(2906002)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 19:16:32.8082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6f500ed-edd4-4019-6332-08dbaf0dc809 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: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5142 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend") changed pci_bridge_d3_possible() so that any vendor's PCIe ports from modern machines (>=2015) are allowed to be put into D3. This policy change has worked for most machines, but the behavior is improved with `pcie_port_pm=off` on some others. Add support for drivers to register both 'optin' and 'veto' callbacks and a priority which can be used for deciding whether a device should use D3. When drivers register the callbacks, the list is sorted by priority. Suggested-by: Hans de Goede Signed-off-by: Mario Limonciello --- drivers/pci/pci.c | 143 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 9 +++ 2 files changed, 152 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 59c01d68c6d5..06ab73f58adf 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,8 @@ unsigned int pci_pm_d3hot_delay; static void pci_pme_list_scan(struct work_struct *work); static LIST_HEAD(pci_pme_list); +static LIST_HEAD(d3_possible_list); +static DEFINE_MUTEX(d3_possible_list_mutex); static DEFINE_MUTEX(pci_pme_list_mutex); static DECLARE_DELAYED_WORK(pci_pme_work, pci_pme_list_scan); @@ -161,6 +164,14 @@ static bool pcie_ats_disabled; /* If set, the PCI config space of each device is printed during boot. */ bool pci_early_dump; +/* Preferences set by a driver for D3 optin/veto */ +enum driver_d3_pref { + D3_PREF_UNSET, /* Not configured by driver */ + D3_PREF_NONE, /* Driver does not care */ + D3_PREF_OPTIN, /* Driver prefers D3 */ + D3_PREF_VETO, /* Driver vetoes D3 */ +}; + bool pci_ats_disabled(void) { return pcie_ats_disabled; @@ -3031,6 +3042,10 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) if (pci_bridge_d3_force) return true; + /* check for any driver optin of D3 for the bridge */ + if (bridge->driver_d3 == D3_PREF_OPTIN) + return true; + /* Even the oldest 2010 Thunderbolt controller supports D3. */ if (bridge->is_thunderbolt) return true; @@ -3050,6 +3065,10 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) if (dmi_check_system(bridge_d3_blacklist)) return false; + /* check for any driver veto for D3 for the bridge */ + if (bridge->driver_d3 == D3_PREF_VETO) + return false; + /* * It should be safe to put PCIe ports from 2015 or newer * to D3. @@ -3168,6 +3187,130 @@ void pci_d3cold_disable(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_d3cold_disable); +static struct pci_dev *pci_get_upstream_port(struct pci_dev *pci_dev) +{ + struct pci_dev *bridge; + + bridge = pci_upstream_bridge(pci_dev); + if (!bridge) + return NULL; + + if (!pci_is_pcie(bridge)) + return NULL; + + switch (pci_pcie_type(bridge)) { + case PCI_EXP_TYPE_ROOT_PORT: + case PCI_EXP_TYPE_UPSTREAM: + case PCI_EXP_TYPE_DOWNSTREAM: + return bridge; + default: + break; + }; + + return NULL; +} + +static void pci_refresh_d3_possible(void) +{ + struct pci_d3_driver_ops *driver; + struct pci_dev *pci_dev = NULL; + struct pci_dev *bridge; + + /* 1st pass: unset any preferences set a previous invocation */ + while ((pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev))) { + bridge = pci_get_upstream_port(pci_dev); + if (!bridge) + continue; + + if (bridge->driver_d3 != D3_PREF_UNSET) + bridge->driver_d3 = D3_PREF_UNSET; + } + + pci_dev = NULL; + + /* 2nd pass: update the preference and refresh bridge_d3 */ + while ((pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev))) { + bridge = pci_get_upstream_port(pci_dev); + if (!bridge) + continue; + + /* don't make multiple passes on the same device */ + if (bridge->driver_d3 != D3_PREF_UNSET) + continue; + + /* the list is pre-sorted by highest priority */ + mutex_lock(&d3_possible_list_mutex); + list_for_each_entry(driver, &d3_possible_list, list_node) { + /* another higher priority driver already set preference */ + if (bridge->driver_d3 != D3_PREF_UNSET) + break; + /* check for opt in to D3 */ + if (driver->optin && driver->optin(bridge)) + bridge->driver_d3 = D3_PREF_OPTIN; + /* check for opt out of D3 */ + else if (driver->veto && driver->veto(bridge)) + bridge->driver_d3 = D3_PREF_VETO; + } + mutex_unlock(&d3_possible_list_mutex); + + /* no driver set a preference */ + if (bridge->driver_d3 == D3_PREF_UNSET) + bridge->driver_d3 = D3_PREF_NONE; + + /* update bridge_d3 */ + pci_bridge_d3_update(pci_dev); + } +} + +static int pci_d3_driver_cmp(void *priv, const struct list_head *_a, + const struct list_head *_b) +{ + struct pci_d3_driver_ops *a = container_of(_a, typeof(*a), list_node); + struct pci_d3_driver_ops *b = container_of(_b, typeof(*b), list_node); + + if (a->priority < b->priority) + return -1; + else if (a->priority > b->priority) + return 1; + return 0; +} + +/** + * pci_register_d3_possible_cb - Register a driver callback for checking d3 veto + * @arg: driver provided structure with function pointer and priority + * + * This function can be used by drivers to register a callback that can be + * used to veto a device going into D3. + * Returns 0 on success, error code on failure. + */ +int pci_register_d3_possible_cb(struct pci_d3_driver_ops *arg) +{ + mutex_lock(&d3_possible_list_mutex); + list_add(&arg->list_node, &d3_possible_list); + list_sort(NULL, &d3_possible_list, pci_d3_driver_cmp); + mutex_unlock(&d3_possible_list_mutex); + pci_refresh_d3_possible(); + return 0; +} +EXPORT_SYMBOL_GPL(pci_register_d3_possible_cb); + +/** + * pci_unregister_d3_possible_cb - Unregister a driver callback for checking d3 veto + * @arg: driver provided structure with function pointer and priority + * + * This function can be used by drivers to unregister a callback that can be + * used to veto a device going into D3. + */ +void pci_unregister_d3_possible_cb(struct pci_d3_driver_ops *arg) +{ + mutex_lock(&d3_possible_list_mutex); + list_del(&arg->list_node); + list_sort(NULL, &d3_possible_list, pci_d3_driver_cmp); + mutex_unlock(&d3_possible_list_mutex); + pci_refresh_d3_possible(); +} +EXPORT_SYMBOL_GPL(pci_unregister_d3_possible_cb); + /** * pci_pm_init - Initialize PM functions of given PCI device * @dev: PCI device to handle. diff --git a/include/linux/pci.h b/include/linux/pci.h index 8c7c2c3c6c65..863399e78869 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -389,6 +389,7 @@ struct pci_dev { bit manually */ unsigned int d3hot_delay; /* D3hot->D0 transition time in ms */ unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */ + unsigned int driver_d3; /* Driver D3 request preference */ #ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state; /* ASPM link state */ @@ -1404,6 +1405,14 @@ void pci_d3cold_disable(struct pci_dev *dev); bool pcie_relaxed_ordering_enabled(struct pci_dev *dev); void pci_resume_bus(struct pci_bus *bus); void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state); +struct pci_d3_driver_ops { + struct list_head list_node; + int priority; + bool (*optin)(struct pci_dev *pdev); + bool (*veto)(struct pci_dev *pdev); +}; +int pci_register_d3_possible_cb(struct pci_d3_driver_ops *arg); +void pci_unregister_d3_possible_cb(struct pci_d3_driver_ops *arg); /* For use by arch with custom probe code */ void set_pcie_port_type(struct pci_dev *pdev); From patchwork Wed Sep 6 18:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 720564 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 2FC6AEE14D8 for ; Wed, 6 Sep 2023 19:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244157AbjIFTQt (ORCPT ); Wed, 6 Sep 2023 15:16:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243932AbjIFTQn (ORCPT ); Wed, 6 Sep 2023 15:16:43 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2083.outbound.protection.outlook.com [40.107.220.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CF251724; Wed, 6 Sep 2023 12:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i2SWKWz1luwaFqrKZdRqlA8y1cC+CF3FdP7DeCyAUn8FwpISEzrjAyF52whqZX2SiTCY4z5j2F84qlAS3yq2Uo7u68e3JEbdJiSYXMWRPmdUZjMYgtdydwfRMeXP/N6fxH5JlIilctyIxu/+FRYOoIMGhybCsRVYtjYFMxxIPBnf5tnl/NPekG+vXkePT7w0UCCEcCB0iDADyl/M8xJZ0GgB/dT9vAI/btqEKBDaDy+FmEvGmRiNwAZf7LhA5RO4/bH6YZPopN864z2GPs4XT5MLgi+ZEnOq0LR9Dbb/Ay0Av8EVgMmiJ3cQnnQkvHQ8cS6lhdWn+phzrJEQwZXsHw== 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=jMINZpGe4Tmcf7sznCpjthcF3tkn9xAgC24SFAdpxHc=; b=Y/0KOS5e3JG27DWkQpb3+ejosjdc9CvrjjyyaUdvFcZB1+Rqo90ZwyTNcy9k94qkDCtpQbMuIeeoLOw+Lpm4mMs6JYINuouzVdnLMPc6aH5HQOkPaHD5Wf+Ey5+4hJCfoqqQkzgLaglo1vN8yO+cRG2DUv5qd3XVTpSRK9jTb6zUaBCVZmLV+Ob0Om9wH4Xk05rqnuI1w15p2eu8bwLfCGpYktPbqFeUdKxkOZYuDk5oavpYwfJkkaZ2D8olVvdEOPz0UVb7x6/J4Jvurj9gGBdE2lyKevaL+4VY2oX7frtfl3v0+uA0RvoLO0ykrZDmjdytV8rDcBEyhsQJa+5j/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=jMINZpGe4Tmcf7sznCpjthcF3tkn9xAgC24SFAdpxHc=; b=neLGc+00M6Q2CbV2srI5k8mk0FZcsGzwYdLKoGqMAltLpyfX8aOULE7AWy0lvZjK/koPEyCofeoNx74jdSPsn/cMd682FIgnItiiVtZ/s8DDw2nC0N+UgoQIoSV0fn79vhbDx2J+NLh1RDa/vzwXj2Flvmk4UPzwkzhlnacn7Vc= Received: from BL0PR1501CA0014.namprd15.prod.outlook.com (2603:10b6:207:17::27) by PH7PR12MB7161.namprd12.prod.outlook.com (2603:10b6:510:200::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Wed, 6 Sep 2023 19:16:37 +0000 Received: from BL6PEPF0001AB54.namprd02.prod.outlook.com (2603:10b6:207:17:cafe::9b) by BL0PR1501CA0014.outlook.office365.com (2603:10b6:207:17::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34 via Frontend Transport; Wed, 6 Sep 2023 19:16:37 +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 BL6PEPF0001AB54.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 19:16:37 +0000 Received: from AUS-P9-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.2507.27; Wed, 6 Sep 2023 14:16:31 -0500 From: Mario Limonciello To: Hans de Goede , Bjorn Helgaas , "Rafael J . Wysocki" CC: Shyam Sundar S K , "open list:X86 PLATFORM DRIVERS" , "open list:PCI SUBSYSTEM" , , Mario Limonciello Subject: [PATCH v17 3/4] PCI: Check for changes in pci_bridge_d3_possible() when updating D3 Date: Wed, 6 Sep 2023 13:43:53 -0500 Message-ID: <20230906184354.45846-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230906184354.45846-1-mario.limonciello@amd.com> References: <20230906184354.45846-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: BL6PEPF0001AB54:EE_|PH7PR12MB7161:EE_ X-MS-Office365-Filtering-Correlation-Id: 86805025-a223-4a3e-6c0d-08dbaf0dcac4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A73mtvIsIPO3oMVwtiC/75u9DEM70BtoY/BcCb+MPwlRnHoje5O6GEYG8cVJ5Z/0pfnWM73orVEzB9MgtPVmXp6vKcYEKDH6aU5COKzu7Udr6OMs8gXGoepF2Oz7Fyb9v6ifmD6GtV67O/M/PLTwy4YG8m/r4iQQlCRWR7HwhT3GmPrfon+W1xeLCvbtoI6IGsb1/dRtJ/cgVjkW/2pw1WY+f7zGloe8tf9cjJ4xGDibxU/R6I/ngyj9T0ghPUvf0o8p0Ympn4e+3Sy2wh8qNseTTqPlshyw1KUr4Mrp7yGfjEfmGHvE4b4GrQmlvTwEHUEsokyeOWrt+gGEXiO0a5sNt2/X3nrujFBW5YmSVvuu7cQ5+Wt0cRtPOphM+VMQSK73Khv6iK0xdRELxCkcTrHIp5xOoYR+i4TBS5ENX5Thlr5XYf+MYQFNqel4xvcpNtOUPHkHZdoWqexWzWz1TTzreIQ0zmhZE12t7J9Q608Us/AbGmO9JRcIx1bY2nJ90J04Ti3Ae/abJRAp7hnkz7zJu4NqsgPfTp7tqwkc8gt9UISfHJoH98REC/IAQTibi7vUH2v1trEOQBn8g0eoZCZuIG8/8j6+XuUO5O+H+RmduGNzlKEEQkciYVLXJAMibYp42F6t3W+A8sB3lmVYZjpHraxakmJw1hajfp2LSpbGR7i1xFayImwXLcbpqVpq96472SQT5cdwUXKhomvq1Fq/GSGzqinFjVdL6mBzHSoMAjimSQRM4s5EljXfhBABGou7TVXO78ft97G8APj8pA== 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:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199024)(1800799009)(82310400011)(186009)(46966006)(36840700001)(40470700004)(2616005)(316002)(54906003)(1076003)(478600001)(4326008)(8936002)(8676002)(356005)(81166007)(82740400003)(7696005)(110136005)(70586007)(70206006)(40480700001)(41300700001)(5660300002)(44832011)(83380400001)(16526019)(26005)(6666004)(336012)(426003)(2906002)(47076005)(36860700001)(40460700003)(86362001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 19:16:37.3894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86805025-a223-4a3e-6c0d-08dbaf0dcac4 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: BL6PEPF0001AB54.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7161 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org As drivers can report an optin or veto for a given PCI device it's possible that pci_bridge_d3_possible() reports different values while calling pci_bridge_d3_update(). Take these values into account while updating the ability for a bridge to go into D3. Signed-off-by: Mario Limonciello --- drivers/pci/pci.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 06ab73f58adf..9004d8ea460a 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3100,6 +3100,14 @@ static int pci_dev_check_d3cold(struct pci_dev *dev, void *data) return !*d3cold_ok; } +static void pci_bridge_d3_propagate(struct pci_dev *bridge, bool d3_ok) +{ + if (bridge->bridge_d3 != d3_ok) { + bridge->bridge_d3 = d3_ok; + pci_bridge_d3_propagate(bridge, d3_ok); + } +} + /* * pci_bridge_d3_update - Update bridge D3 capabilities * @dev: PCI device which is changed @@ -3112,12 +3120,16 @@ void pci_bridge_d3_update(struct pci_dev *dev) { bool remove = !device_is_registered(&dev->dev); struct pci_dev *bridge; - bool d3cold_ok = true; + bool d3_ok = true; bridge = pci_upstream_bridge(dev); - if (!bridge || !pci_bridge_d3_possible(bridge)) + if (!bridge) return; + /* Propagate change to upstream bridges */ + d3_ok = pci_bridge_d3_possible(bridge); + pci_bridge_d3_propagate(bridge, d3_ok); + /* * If D3 is currently allowed for the bridge, removing one of its * children won't change that. @@ -3134,7 +3146,7 @@ void pci_bridge_d3_update(struct pci_dev *dev) * first may allow us to skip checking its siblings. */ if (!remove) - pci_dev_check_d3cold(dev, &d3cold_ok); + pci_dev_check_d3cold(dev, &d3_ok); /* * If D3 is currently not allowed for the bridge, this may be caused @@ -3142,15 +3154,12 @@ void pci_bridge_d3_update(struct pci_dev *dev) * so we need to go through all children to find out if one of them * continues to block D3. */ - if (d3cold_ok && !bridge->bridge_d3) + if (d3_ok && !bridge->bridge_d3) pci_walk_bus(bridge->subordinate, pci_dev_check_d3cold, - &d3cold_ok); + &d3_ok); - if (bridge->bridge_d3 != d3cold_ok) { - bridge->bridge_d3 = d3cold_ok; - /* Propagate change to upstream bridges */ - pci_bridge_d3_update(bridge); - } + /* Propagate change to upstream bridges */ + pci_bridge_d3_propagate(bridge, d3_ok); } /** From patchwork Wed Sep 6 18:43:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 720752 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 C6F75EE14DB for ; Wed, 6 Sep 2023 19:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241772AbjIFTQu (ORCPT ); Wed, 6 Sep 2023 15:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244167AbjIFTQr (ORCPT ); Wed, 6 Sep 2023 15:16:47 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2073.outbound.protection.outlook.com [40.107.94.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8845199B; Wed, 6 Sep 2023 12:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HkRpO5SWfMGY8sAMKAZbYvEFBhq+JYnP7lG9DLNf62zTRiHE0gLU/+E3IWfhKhA4kMx8I5F8XK5jm8CezE0HmII7zK8ANukG9TJ5wQ7GfGfylLbfSNjSuLr8BhHdsZei9Iwi1TSPXuFNcddC+LmQy77ArZlb3H/msWQflYbeESVPwIRXQ/8YqMp4FKbTiCDBfNOND0ZRyTL85o6WHqh+PonBG53kV/NhOI8FXuB3ez0qpWMwLr9tpZKJ8+fcZOP2XHhQ0Z3vmm3rCeFZwR7OOa7wCpqa8UuaMlAsJIHi/Fjtzp77HW8dslN24KNwlSLLUUmxli4750f5c1sOGIB0HA== 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=6hsrSL5Gg1qBLVBtbtx/99Vig8rSi+bhsVPhCskMjbc=; b=SczAoLmMuBPTKuyTq1Ep2jcIi6M7nV1B+QaYkOt8Pl+6EkoLIynVA8X+nATdf4iBNaR/beE6AXkUsPPKsKlenHvoeNld9dCXTP4FD0fmKpf3RhI6iWS+0Zz+qEa4lYJWaGnnXJzz2ZBRPASkcampMTIfgUDJADfxiLAfbpRR0MKd0f/1PjROIV0N5yKHVX6F3V9TUULeITjO3NSnJMeBAocCfffnrhC8D/szwZKjXDYXwFkV1VwDQK7l/xZALfFlLRTRO6Zl8I4uobEPLenkwR5NirUxAmp49XvMNYialr4gRrdj4ASvdwhBPG2xrDQqGxK3K16q7XIySXCFgpK2CQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=6hsrSL5Gg1qBLVBtbtx/99Vig8rSi+bhsVPhCskMjbc=; b=bi4dOJMml1hMNws/5OKaWpRCDBTpVC2cdhAudxAZ8qD/AKnxOkRxkVtst6Fn/e4znOe5TvTUovrCG3HJtLaAnKPsf717us0sZuGQaXIQwIyM5jewKYZ6rnkz1zb3nGzr8MvRBnkBD8/cJIigyzCbvUztKkEq3RvGLfIQAhF3xMY= Received: from BL0PR1501CA0026.namprd15.prod.outlook.com (2603:10b6:207:17::39) by PH7PR12MB6905.namprd12.prod.outlook.com (2603:10b6:510:1b7::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Wed, 6 Sep 2023 19:16:38 +0000 Received: from BL6PEPF0001AB54.namprd02.prod.outlook.com (2603:10b6:207:17:cafe::8b) by BL0PR1501CA0026.outlook.office365.com (2603:10b6:207:17::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.29 via Frontend Transport; Wed, 6 Sep 2023 19:16:37 +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 BL6PEPF0001AB54.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 19:16:37 +0000 Received: from AUS-P9-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.2507.27; Wed, 6 Sep 2023 14:16:32 -0500 From: Mario Limonciello To: Hans de Goede , Bjorn Helgaas , "Rafael J . Wysocki" CC: Shyam Sundar S K , "open list:X86 PLATFORM DRIVERS" , "open list:PCI SUBSYSTEM" , , Mario Limonciello , Iain Lane Subject: [PATCH v17 4/4] platform/x86/amd: pmc: Report device constraints Date: Wed, 6 Sep 2023 13:43:54 -0500 Message-ID: <20230906184354.45846-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230906184354.45846-1-mario.limonciello@amd.com> References: <20230906184354.45846-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: BL6PEPF0001AB54:EE_|PH7PR12MB6905:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f54e7e0-7f72-41f1-19c9-08dbaf0dcb13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kJ7hktQiTRi9McI5UrF+ML5T0vHAkYRkOP1DPvdIWPUH9v6jHDNZfPGKRAJZHvwC0IvK3i1Y6tSoRm2U7WxTlKboeActK+TTCzOz8agEKFpkf7EAimWxb4i5CyvEQm71sIEnhARwoWll5l1tWpD80nnDamb0bn8kMKXaSOuJAfY+UjTBBYS+1UwepCIZyqwp8YIfapoQCSjJYoJuq+F2QHql/R8kcDh9ZCofVOha3wjyLz1L+lyTQfyeH+xprfH5K0G7odt+DIBxd3Sk4hAf8AsCF4l02QJjw+wO2diPXaOT0jBBovHWEkr05ASrmDb0CkQ6l51XEh7MVYOIOu2m830M6mj/sTmBxfnqN9axXv1gWnfL+5Z2bB2i6vOONrq0sHjkVAfsDAjpvhMuWdJQBCb0IzYOl5tuEjpm5VO0Sqm/hml7dWs1xTbNWUntKHxH4GOdSCZLEVE4KIKGCKzwW7oqvbl1NJuW659sXE8G48cT3j1caTYUaNn6z115t+qopxCfOyauKnPvLfG3tUYu69Pw69tbP10J/A33PzX2JaI6Y8YtEb4Rol7d4ZKsZUPB8TokUCUeq8KeECajAaq0+58TA0HUPAnXMzyK1IudRHh2n8xsHJL8y9gFpvDwntwN8xWtjj5y8bVtFfe/Zizw0r/ygO645P4R5KL44PmOXQlpOISu45Hhud4MsYCCwPw5l7HmX5dt+I7y66l9+jg2s7zN12ltuq/4ugXgwtqse3uLzrMyMhIJ7R+RzNDzrXwddeaUMRm8q7WNDkbSYj1g+g== 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:(13230031)(4636009)(396003)(376002)(136003)(39860400002)(346002)(186009)(82310400011)(1800799009)(451199024)(36840700001)(46966006)(40470700004)(40480700001)(40460700003)(44832011)(336012)(8676002)(8936002)(426003)(4326008)(2616005)(41300700001)(26005)(16526019)(5660300002)(36860700001)(47076005)(1076003)(2906002)(83380400001)(110136005)(6666004)(478600001)(966005)(316002)(70586007)(54906003)(70206006)(7696005)(36756003)(86362001)(356005)(82740400003)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 19:16:37.9050 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6f54e7e0-7f72-41f1-19c9-08dbaf0dcb13 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: BL6PEPF0001AB54.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6905 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Iain reports that USB devices can't be used to wake a Lenovo Z13 from suspend. This is because the PCIe root port has been put into D3hot and AMD's platform can't handle USB devices waking from a hardware sleep state in this case. This problem only occurs on Linux, and only when the AMD PMC driver is utilized to put the device into a hardware sleep state. When the AMD PMC driver is enabled it will notify the hardware that the OS is ready for it to try to enter a hardware sleep state. Comparing the behavior on Windows and Linux, Windows doesn't put the root ports into D3. This is because the Windows uPEP driver takes into account constraints that are advertised by the platform in an ACPI device. The constraints are available for individual devices via `acpi_get_lps0_constraint`. Add support for the amd-pmc driver to fetch constraints for devices and report them as either an 'optin' or a 'veto' to the PCI core when it evaluates whether a device should support 'D3'. This interface intentionally doesn't specify D3hot or D3cold, it's collectively 'D3'. Any enabled constraints set to ACPI_STATE_S3 or greater will be reported to the 'optin' callback to ensure that they policy is set to select 'D3'. Any disabled constraints, missing constraints, or constraints set to less than ACPI_STATE_S3 will be reported to the 'veto' callback to ensure the policy matches the Windows behavior of disabling 'D3'. This behavior is necessary due to the policy enacted by commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend"). 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 Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmc/pmc.c | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/platform/x86/amd/pmc/pmc.c b/drivers/platform/x86/amd/pmc/pmc.c index c1e788b67a74..ed5d2a0c6a55 100644 --- a/drivers/platform/x86/amd/pmc/pmc.c +++ b/drivers/platform/x86/amd/pmc/pmc.c @@ -741,6 +741,49 @@ static int amd_pmc_czn_wa_irq1(struct amd_pmc_dev *pdev) return 0; } +/* + * Constraints are specified in the ACPI LPS0 device and specify what the + * platform intended for the device. + * + * If a constraint is present and >= to ACPI_STATE_S3, then enable D3 for the + * device with the 'optin' callback. + * If a constraint is not present or < ACPI_STATE_S3, then disable D3 for the + * device with the 'veto' callback. + */ +static int amd_pmc_get_constraint(struct pci_dev *pci_dev) +{ + struct acpi_device *adev = ACPI_COMPANION(&pci_dev->dev); + + if (!adev) + return ACPI_STATE_UNKNOWN; + + return acpi_get_lps0_constraint(adev); +} + +static bool amd_pmc_d3_optin_check(struct pci_dev *pci_dev) +{ + int constraint = amd_pmc_get_constraint(pci_dev); + + if (constraint == ACPI_STATE_UNKNOWN || + constraint < ACPI_STATE_S3) + return false; + + dev_dbg(&pci_dev->dev, "Opting in to D3 due to constraint %d\n", constraint); + return true; +} + +static bool amd_pmc_d3_veto_check(struct pci_dev *pci_dev) +{ + int constraint = amd_pmc_get_constraint(pci_dev); + + if (constraint != ACPI_STATE_UNKNOWN && + constraint >= ACPI_STATE_S3) + return false; + + dev_dbg(&pci_dev->dev, "Vetoing D3 due to constraint %d\n", constraint); + return true; +} + static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg) { struct rtc_device *rtc_device; @@ -881,6 +924,12 @@ static struct acpi_s2idle_dev_ops amd_pmc_s2idle_dev_ops = { .restore = amd_pmc_s2idle_restore, }; +static struct pci_d3_driver_ops amd_pmc_d3_veto_ops = { + .optin = amd_pmc_d3_optin_check, + .veto = amd_pmc_d3_veto_check, + .priority = 50, +}; + static int amd_pmc_suspend_handler(struct device *dev) { struct amd_pmc_dev *pdev = dev_get_drvdata(dev); @@ -1074,10 +1123,17 @@ static int amd_pmc_probe(struct platform_device *pdev) amd_pmc_quirks_init(dev); } + err = pci_register_d3_possible_cb(&amd_pmc_d3_veto_ops); + if (err) + goto err_register_lps0; + amd_pmc_dbgfs_register(dev); pm_report_max_hw_sleep(U64_MAX); return 0; +err_register_lps0: + if (IS_ENABLED(CONFIG_SUSPEND)) + acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops); err_pci_dev_put: pci_dev_put(rdev); return err; @@ -1089,6 +1145,7 @@ static void amd_pmc_remove(struct platform_device *pdev) if (IS_ENABLED(CONFIG_SUSPEND)) acpi_unregister_lps0_dev(&amd_pmc_s2idle_dev_ops); + pci_unregister_d3_possible_cb(&amd_pmc_d3_veto_ops); amd_pmc_dbgfs_unregister(dev); pci_dev_put(dev->rdev); mutex_destroy(&dev->lock);