From patchwork Fri Nov 10 18:55:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13452718 X-Patchwork-Delegate: bhelgaas@google.com 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 81F57C4332F for ; Fri, 10 Nov 2023 19:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236202AbjKJTov (ORCPT ); Fri, 10 Nov 2023 14:44:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236191AbjKJTog (ORCPT ); Fri, 10 Nov 2023 14:44:36 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2041.outbound.protection.outlook.com [40.107.237.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BB2D5FD0; Fri, 10 Nov 2023 10:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cGPtBp7ZMM9iB3jQApmOp0EVGqf5ejzWunQPgZ7M2xHXNmzVdBnehrX2JhUgpEK7xw+kgTqXuDiAZoFZ+JtJYbdHbfrxWXKYHAwCfY10e/LeF+qJwYZLukL38PAv0+2MDQ+ZbdWlrZTs74h0NIW8E2ITmfDfcFaGDodCn3K8+caiB12iQwgaxY46jBcto5u0nXpw5DnImAu+kDktGFHkCf2sFPwpwDV+EIhOtS3zjZrQgYPnqc5cY2vZ0HFbuhj6FIF9TlRPlGgIuU53hmBHoN6VXbfYsWMOwsrGTpduQOmYIFkATiwx8xnZT+IzUQUVhnCuk3iwo+bNED4F+GoE7g== 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=Evpbeo1dZAqXLwCv66bXfYPNXxJZjiCaBhoTDXXLTik=; b=lr+fk9ZfayBsrDfo7LTZv0PGT9J0tT/COxwjuDkk5frhzmIyNzCicWCArdvMR0wrSeYtoAoV6ytGMS5USZx/9VZo30meYuX2VJJxhMEruZS+V2NGYnokf5ExupTUeXaa0XLWGMvceiF9rHNHYyou+am2Qs7lwrsJ2rCV6WX6LcwkhG1dwQS9oNMfTPqYRNCKEV4DkfIshThGXKWvGyq3AAINTCMHBjnW2E5Jl9Qd+/YBDZv/XS4RVqoUZBsGBxzqOHZ0z7rtyYTNiyhpU17+EWd35QhoqYNcjne6E8dQiHfAmU8iM6dWVMKsl/gcDYM+aA48HbWKXFh30D9KJDa+0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.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 (0) 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=Evpbeo1dZAqXLwCv66bXfYPNXxJZjiCaBhoTDXXLTik=; b=RFI9087FQs0vTBF/7k+RkxqdXxAn1syGtpccyjW6Iip+RdG569IbWYpRuQwLp6zTcsqKTLoiFbgJ1mCSn9MeR5cfTB03jj5/6lMI71i0g1pheBAXYolVjZMLv9P4tpMOX+N7QJF+COwTghjI+Z3D7NqK8iXxvOkAHtYWzWSg0WU= Received: from MN2PR01CA0030.prod.exchangelabs.com (2603:10b6:208:10c::43) by IA0PR12MB7627.namprd12.prod.outlook.com (2603:10b6:208:437::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Fri, 10 Nov 2023 18:55:29 +0000 Received: from BL6PEPF0001AB4F.namprd04.prod.outlook.com (2603:10b6:208:10c:cafe::b0) by MN2PR01CA0030.outlook.office365.com (2603:10b6:208:10c::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19 via Frontend Transport; Fri, 10 Nov 2023 18:55:29 +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 BL6PEPF0001AB4F.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6977.16 via Frontend Transport; Fri, 10 Nov 2023 18:55:28 +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.32; Fri, 10 Nov 2023 12:55:26 -0600 From: Mario Limonciello To: Bjorn Helgaas , "Rafael J . Wysocki" CC: "open list:PCI SUBSYSTEM" , , , "Mario Limonciello" Subject: [PATCH 1/3] PCI: Call PCI ACPI _DSM with consistent revision argument Date: Fri, 10 Nov 2023 12:55:01 -0600 Message-ID: <20231110185503.46117-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231110185503.46117-1-mario.limonciello@amd.com> References: <20231110185503.46117-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: BL6PEPF0001AB4F:EE_|IA0PR12MB7627:EE_ X-MS-Office365-Filtering-Correlation-Id: c64b0b10-ea75-4634-c2db-08dbe21e9b99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sq/wCSpVqcJc7ZNxqUL0ZLuHIT1SW+tnItcTtGSIIAjud9cT4hYQ1ruPtN7goTwthqjl2hJU3tscJOm3Ko5mRL7NwqRme5EDZLLL/ogRYC4Wk/ehnecrlj7xXknKp1DJeuuK9Gbv+og5bIsW1lacowBk6N2y4fMyPOKEgR5vEVPMzETAUVyDeDPtcnyn5TmxlcUIA6bOw5vOOVRC6c4kRv+G0zqTYo7NsyCcSN1dV+6Dy4hJaDwGld1VvyoMw3UCnTMOH+ZgqrCMi1I/7FNQQOiKOWvwmdzaGMfcvj4debYJ5XHVyNyZHXW6xHL6oxzpmrQ19OlsSwiE9CsmYVCC/hQR9uKfuEeRz9ptHV/rb8D/sYxxoMwgHo1L81xTNl+j9j167WC6PjwGdzLGXBwLItNQVkK9jxTpxH3heWlroha3ssSy/5LRvb3CnvepzGDoqUhapm0ZJEdvd1DFOG2krVih0tpMdeaSmshQpUESybhgIbOkKAP6FogdUWkITExkXHipv+EUEKbl3MMgnEJC3yw4TEYlIwyFVQ7KfuaAfcsD0gfRriZHuy0m5o/1skugaK/JuiQvnpvr8n+tmXxANiHIEEKz13Zs6xLtGaQbQk9f95qHhT1NnWM1ATQk1/IlaXytb+InAxwazel3A6G+hwvBKiFxFvGC4JFpHf0pZpeXKm2sRpq7xUk7rnxQw74gLuZ8KMl7prRyEmbrlCAlHznLZX/NgBY09QS/uaSI9jS3EPNDzVLb6nLGlF8nSPCKf2Hbifak2yAaJJrqskGQHA== 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)(396003)(39860400002)(136003)(376002)(230922051799003)(82310400011)(64100799003)(186009)(1800799009)(451199024)(36840700001)(40470700004)(46966006)(40460700003)(478600001)(336012)(83380400001)(81166007)(426003)(6666004)(7696005)(2616005)(1076003)(16526019)(26005)(82740400003)(40480700001)(966005)(356005)(47076005)(36860700001)(70586007)(70206006)(54906003)(316002)(44832011)(110136005)(4326008)(86362001)(2906002)(5660300002)(8936002)(41300700001)(8676002)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2023 18:55:28.8623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c64b0b10-ea75-4634-c2db-08dbe21e9b99 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: BL6PEPF0001AB4F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7627 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The PCI ACPI _DSM is called across multiple places in the PCI core with different arguments for the revision. The PCI firmware specification specifies that this is an incorrect behavior. "OSPM must invoke all Functions other than Function 0 with the same Revision ID value" Link: https://members.pcisig.com/wg/PCI-SIG/document/15350 PCI Firmware specification 3.3, section 4.6 Signed-off-by: Mario Limonciello Acked-by: Rafael J. Wysocki --- drivers/acpi/pci_root.c | 3 ++- drivers/pci/pci-acpi.c | 6 ++++-- drivers/pci/pci-label.c | 4 ++-- drivers/pci/pcie/edr.c | 13 +++++++------ include/linux/pci-acpi.h | 1 + 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 58b89b8d950e..bca2270a93d4 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -1055,7 +1055,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, * exists and returns 0, we must preserve any PCI resource * assignments made by firmware for this host bridge. */ - obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 1, + obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), + &pci_acpi_dsm_guid, pci_acpi_dsm_rev, DSM_PCI_PRESERVE_BOOT_CONFIG, NULL, ACPI_TYPE_INTEGER); if (obj && obj->integer.value == 0) host_bridge->preserve_config = 1; diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 004575091596..bea72e807817 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -28,6 +28,7 @@ const guid_t pci_acpi_dsm_guid = GUID_INIT(0xe5c937d0, 0x3553, 0x4d7a, 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d); +const int pci_acpi_dsm_rev = 5; #if defined(CONFIG_PCI_QUIRKS) && defined(CONFIG_ARM64) static int acpi_get_rc_addr(struct acpi_device *adev, struct resource *res) @@ -1215,7 +1216,8 @@ void acpi_pci_add_bus(struct pci_bus *bus) if (!pci_is_root_bus(bus)) return; - obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 3, + obj = acpi_evaluate_dsm_typed(ACPI_HANDLE(bus->bridge), + &pci_acpi_dsm_guid, pci_acpi_dsm_rev, DSM_PCI_POWER_ON_RESET_DELAY, NULL, ACPI_TYPE_INTEGER); if (!obj) return; @@ -1376,7 +1378,7 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev, if (bridge->ignore_reset_delay) pdev->d3cold_delay = 0; - obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 3, + obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, pci_acpi_dsm_rev, DSM_PCI_DEVICE_READINESS_DURATIONS, NULL, ACPI_TYPE_PACKAGE); if (!obj) diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index 0c6446519640..91bdd04029f0 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c @@ -41,7 +41,7 @@ static bool device_has_acpi_name(struct device *dev) if (!handle) return false; - return acpi_check_dsm(handle, &pci_acpi_dsm_guid, 0x2, + return acpi_check_dsm(handle, &pci_acpi_dsm_guid, pci_acpi_dsm_rev, 1 << DSM_PCI_DEVICE_NAME); #else return false; @@ -162,7 +162,7 @@ static int dsm_get_label(struct device *dev, char *buf, if (!handle) return -1; - obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 0x2, + obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, pci_acpi_dsm_rev, DSM_PCI_DEVICE_NAME, NULL); if (!obj) return -1; diff --git a/drivers/pci/pcie/edr.c b/drivers/pci/pcie/edr.c index 5f4914d313a1..ab6a50201124 100644 --- a/drivers/pci/pcie/edr.c +++ b/drivers/pci/pcie/edr.c @@ -35,7 +35,7 @@ static int acpi_enable_dpc(struct pci_dev *pdev) * Behavior when calling unsupported _DSM functions is undefined, * so check whether EDR_PORT_DPC_ENABLE_DSM is supported. */ - if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5, + if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, pci_acpi_dsm_rev, 1ULL << EDR_PORT_DPC_ENABLE_DSM)) return 0; @@ -51,8 +51,9 @@ static int acpi_enable_dpc(struct pci_dev *pdev) * Firmware Specification r3.2, sec 4.6.12, EDR_PORT_DPC_ENABLE_DSM is * optional. Return success if it's not implemented. */ - obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, 5, - EDR_PORT_DPC_ENABLE_DSM, &argv4); + obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, + pci_acpi_dsm_rev, EDR_PORT_DPC_ENABLE_DSM, + &argv4); if (!obj) return 0; @@ -88,12 +89,12 @@ static struct pci_dev *acpi_dpc_port_get(struct pci_dev *pdev) * Behavior when calling unsupported _DSM functions is undefined, * so check whether EDR_PORT_DPC_ENABLE_DSM is supported. */ - if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, 5, + if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, pci_acpi_dsm_rev, 1ULL << EDR_PORT_LOCATE_DSM)) return pci_dev_get(pdev); - obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, 5, - EDR_PORT_LOCATE_DSM, NULL); + obj = acpi_evaluate_dsm(adev->handle, &pci_acpi_dsm_guid, + pci_acpi_dsm_rev, EDR_PORT_LOCATE_DSM, NULL); if (!obj) return pci_dev_get(pdev); diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 078225b514d4..7966ef8f14b3 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -115,6 +115,7 @@ static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { } #endif extern const guid_t pci_acpi_dsm_guid; +extern const int pci_acpi_dsm_rev; /* _DSM Definitions for PCI */ #define DSM_PCI_PRESERVE_BOOT_CONFIG 0x05 From patchwork Fri Nov 10 18:55:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13452785 X-Patchwork-Delegate: bhelgaas@google.com 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 A35F9C4332F for ; Fri, 10 Nov 2023 20:42:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346575AbjKJUmc (ORCPT ); Fri, 10 Nov 2023 15:42:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346585AbjKJUl5 (ORCPT ); Fri, 10 Nov 2023 15:41:57 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2089.outbound.protection.outlook.com [40.107.223.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04206C83; Fri, 10 Nov 2023 10:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oRfAh82m7CMXurMg7iSnOZ9/G5HfmlS44vBNjfRFlPL7LFHX2NdSdNYk1n1bVKFsicYCKe4ILHin0LRElcb0cdIfEzXaX7fV9lC7x1frutCjg9b5uxOVpd+rM+LU4+cQgOzScEzn3TVqQRePuq548Zm9MtLKb0g1G+8zokEJRpMKXaKRE1rQbrLvWR5dmRz5JeEGiezfuqI58Qb/rXJqj+wm4ED/LAGWE8h5hszQFiqM3qKEPt1iQXWDML/sG0/lID7/EjkbxoM1DQBHQLE50tbij6BYwZGi/h7RhonSh8tGecmpnjPR2d1v6HfGeutAt5aUepNOg8JuAO2wrezFHg== 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=ML7lbkbZ+5pEQd7nFxbuj28Rl2dq0DBNE+aUqfsFCNY=; b=Djplrvth2q5X350xexhISDAMaOz3OgwGnTDxd3NuWSTWI/gGr12PVrChmKiN8JAczShIf7PFiGRHA5I8YPw6Bx69JjHrBGRXHI7j1gVKvCH9Em+ns0Pq0+GCYuNf2h61I+5SBxK2OUr4p+TkvFx6IP+xn9AzBG2cABgB5EN4WAT2Ff0ZoupP6v4eIprZNWnyewx57WHYfyy06C9o2YAd0+Ln9fDxmtfzuYwcfB0InjY+xI9CR6bL2s8kQW5UBxmyjBvhhRmxPEJ13bflH8kVIUNAyutK29s5rYXxbYDdLKQxZ4P8w6R6AEDgKD0YM6ueI2LGaRWP/5gMo/KxtSEwEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.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 (0) 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=ML7lbkbZ+5pEQd7nFxbuj28Rl2dq0DBNE+aUqfsFCNY=; b=TdKY1nuLUW6nMnJqoXLUQbFIyHdOqrgd0Qi6c1fcpkHPAuX4G81ZUAWRP+mIXT2mIsGDcWIwdHe8ME6sCY7wnF4tT6Hvo4Szpx4irrfM/cMLDHkBfBmn13KRPPOpCHcV1nr9IjcZ8uiZkNyxKWI9rb2AtRXiQtEYRKW7glIp5Es= Received: from MN2PR01CA0018.prod.exchangelabs.com (2603:10b6:208:10c::31) by BN9PR12MB5097.namprd12.prod.outlook.com (2603:10b6:408:136::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19; Fri, 10 Nov 2023 18:55:29 +0000 Received: from BL6PEPF0001AB4F.namprd04.prod.outlook.com (2603:10b6:208:10c:cafe::46) by MN2PR01CA0018.outlook.office365.com (2603:10b6:208:10c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19 via Frontend Transport; Fri, 10 Nov 2023 18:55:29 +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 BL6PEPF0001AB4F.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6977.16 via Frontend Transport; Fri, 10 Nov 2023 18:55:29 +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.32; Fri, 10 Nov 2023 12:55:27 -0600 From: Mario Limonciello To: Bjorn Helgaas , "Rafael J . Wysocki" CC: "open list:PCI SUBSYSTEM" , , , "Mario Limonciello" Subject: [PATCH 2/3] PCI/ACPI: Add API for specifying aux power in D3cold Date: Fri, 10 Nov 2023 12:55:02 -0600 Message-ID: <20231110185503.46117-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231110185503.46117-1-mario.limonciello@amd.com> References: <20231110185503.46117-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: BL6PEPF0001AB4F:EE_|BN9PR12MB5097:EE_ X-MS-Office365-Filtering-Correlation-Id: 60c531db-3c74-41ed-20e3-08dbe21e9bf9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mCl6vqb7Kqio28JcK1sgcChicTopOtiiDyFH/B8gN5IUDMam+GIj4C/7+br41eM87rZl0zIkLMSuXCdDh/PffoA2U/NwhhGJQSYPWC0ZzgSWFCFbLSEQVXvot0NlJR3kCRh62al0xnnP5dzOp7aTwKHLxh/26JBsEsZ1PH0dpdg0NAKtlRT9i2YNR9V4dLai4hNbU3dVPGOkrGpG0WwqndNceYd+ktFUcFPsnt39ASEVIQkeQcYpkyV24vN9+SdALjYZ5QUDbFE5LRbBV0II8HxzNt95jTTbyIH0cCYt3ZNq44Ypp2bFOC5VTtuzaz4Q4PZfUw9hFtc8gwznlgaoLOjS8fxmOP43K2+WSduxeksevpNLjZaPTublQQ+SaIJsfb2Xv3l5/k8AJV9UmWR6UV7mirkwv2xU+L1LHTDWjE2S2Uf+ZMwsXrLSWzWCKXe+mmOcmRZhHRsikeVmzWah74Z8sNwWUAAJtwGND7RP4G6aenovr4Jaj/rwSzbmDYWMIMzITweEhyw37uFIEbWhTZh6IyqAAk/JWD0EXd2+VgPClVmZOWqAdf9L8G+K9vE0vIu0wVBPso3hWDh0oXlFOPDzX9BeKJya5+H0mqHvSgB0b746G5iadR8wUSpS8+bkHlMSMwqc0y4pSR134bCzNDtMzouIspdTuohFdn0QhOekhZNbK0HTaC6ajryiukfHb3SmpzsM0kAX2HgNrNgimMfGGHiT/5UgjhXu6AUgmIl1FsZDqi8vPiwSGkPLsEaAWSJ679bcYPRC8RO8a+c63Q== 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)(396003)(376002)(39860400002)(136003)(230922051799003)(186009)(1800799009)(451199024)(64100799003)(82310400011)(46966006)(40470700004)(36840700001)(70586007)(70206006)(316002)(110136005)(1076003)(2616005)(54906003)(40460700003)(86362001)(36860700001)(6666004)(36756003)(478600001)(966005)(7696005)(47076005)(41300700001)(5660300002)(426003)(336012)(81166007)(356005)(44832011)(82740400003)(8936002)(8676002)(4326008)(2906002)(16526019)(83380400001)(26005)(40480700001)(32563001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2023 18:55:29.4405 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 60c531db-3c74-41ed-20e3-08dbe21e9bf9 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: BL6PEPF0001AB4F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5097 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The PCI firmware specification includes support for a _DSM function to negotiate aux power to be provided to the device while it is in D3cold. "The Request D3cold Aux Power Limit function describes how a device driver conveys its auxiliary power requirements to the host platform when the device is in D3cold. The system firmware responds with a value indicating whether the request can be supported. The power request is specific to the Auxiliary power supply; main power may be removed while in D3cold. A device must not draw any more power than what has been negotiated via this mechanism after entering D3cold" Add API for callers to utilize this _DSM. Link: https://members.pcisig.com/wg/PCI-SIG/document/15350 PCI Firmware specification 3.3, section 4.6.10 Signed-off-by: Mario Limonciello --- drivers/pci/pci-acpi.c | 54 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 7 ++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index bea72e807817..257858a6719e 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1348,6 +1348,60 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev) return adev; } +/** + * pci_acpi_request_aux_power_for_d3cold - Request auxiliary power for D3cold + * @pdev: PCI device to request power for + * @arg: mW requested + * + * This function requests auxiliary power for a PCI device in D3cold state + * when main power is removed above the value guaranteed by PCI specification. + * + * Return: + * 0 on success + * -ENODEV when the device does not support the _DSM + * -EIO on ACPI call failure + * -EACCESS when the request was denied + * Positive value corresponding to platform requested retry interval in seconds + */ +int pci_acpi_request_aux_power_for_d3cold(struct pci_dev *pdev, int arg) +{ + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); + union acpi_object *obj; + union acpi_object argv4 = { + .integer.type = ACPI_TYPE_INTEGER, + .integer.value = arg, + }; + int val; + + if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, + pci_acpi_dsm_rev, + 1 << DSM_PCI_REQUEST_D3COLD_AUX_POWER)) + return -ENODEV; + + obj = acpi_evaluate_dsm_typed(adev->handle, &pci_acpi_dsm_guid, + pci_acpi_dsm_rev, + DSM_PCI_REQUEST_D3COLD_AUX_POWER, + &argv4, ACPI_TYPE_INTEGER); + if (!obj) + return -EIO; + + val = obj->integer.value; + ACPI_FREE(obj); + + switch (val) { + case PCI_D3COLD_AUX_DENIED: + return -EACCES; + case PCI_D3COLD_AUX_GRANTED: + case PCI_D3COLD_AUX_NO_MAIN_POWER_REMOVAL: + return 0; + default: + break; + } + + return val; +} +EXPORT_SYMBOL_GPL(pci_acpi_request_aux_power_for_d3cold); + /** * pci_acpi_optimize_delay - optimize PCI D3 and D3cold delay from ACPI * @pdev: the PCI device whose delay is to be updated diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 7966ef8f14b3..bc6372bcb7d6 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -122,6 +122,13 @@ extern const int pci_acpi_dsm_rev; #define DSM_PCI_DEVICE_NAME 0x07 #define DSM_PCI_POWER_ON_RESET_DELAY 0x08 #define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09 +#define DSM_PCI_REQUEST_D3COLD_AUX_POWER 0x0A + +#define PCI_D3COLD_AUX_DENIED 0 +#define PCI_D3COLD_AUX_GRANTED 1 +#define PCI_D3COLD_AUX_NO_MAIN_POWER_REMOVAL 2 + +int pci_acpi_request_aux_power_for_d3cold(struct pci_dev *pdev, int arg); #ifdef CONFIG_PCIE_EDR void pci_acpi_add_edr_notifier(struct pci_dev *pdev); From patchwork Fri Nov 10 18:55:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13452703 X-Patchwork-Delegate: bhelgaas@google.com 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 6E972C4167B for ; Fri, 10 Nov 2023 19:17:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346119AbjKJTRC (ORCPT ); Fri, 10 Nov 2023 14:17:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345759AbjKJTQs (ORCPT ); Fri, 10 Nov 2023 14:16:48 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2047.outbound.protection.outlook.com [40.107.244.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE8CD6C90; Fri, 10 Nov 2023 10:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhRmmCM6XXHI2ZTrvZDvHIJrwrmlloS6ysksNSpKFZ/jGHSsjdNwbQqwsw5Sn399qv1U84r29x7zBh8TkETngEUelXYu6hd75Yw4HCn/+OAF7z4p1V3+vOburW4CpnVDEdGx47ChOCidOXmiSXVuRwvLEMX3UQ9LR68N77h17eahPccHO5+1OiZvdj/7eD0r+G4h7JgsW9a5Nb1sqV37DuzVPana8wTJZAJWsl51Fa9LNkH7HBgfz1Z4FQXofHBbsy7/CSm2wI2NdidOB93tnlGaJzQsRX4+vmFJCVxgRula+iISlQEHoD6A4unl2Dv7gv2M19d4HcKAH5XXrz7Qqg== 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=COYn6LvPddBHTWly4J+FD6qXdpwcv2oBpv77/QbspEw=; b=QNrohEiRb5pCSD/OKdA3nulPL9+feHLXkjEbZiO54Pngf/z31Mm0sOMCwwWmfIsN9dfiwxxxZAXfL8b4STjAY1VAejj/D3F/7dWN9QROOkL5pqSs6IKMXQMkvappgLKLfbJsQpL7XF04g0+osnmEe75f+kpBM8HQuvBTBFcta41CC4lWhPU3YXNBmPxp/k7+6V+mWYhiobzSol3v56QUbV6ZZjmOharReajj5CQ/bw77egBBSGHXP/PQEixL9wzZaKeALvE15+NyRGlk3zUq8CWNSedQhVDB8QShGV4REnBYEQZIdKsezlolGUB9SRtm0JxHOWPlb3ujuci1fKEiRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.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 (0) 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=COYn6LvPddBHTWly4J+FD6qXdpwcv2oBpv77/QbspEw=; b=0nTyx2VhyRhoraw6MTQ1nUiyoJ5naO697W6A+4m8XZJ7bnG+k9Jprud8thu5VUe7eervs4rVSk0hvRA9kO8NL5oaJct1FnGLy34MCsm0jGGhcS33XsqqkMEHPDiUr6EINfh+Gs++Sw9oNq80bvZuaDYsKCNUeGVXKZSq1Bn0Foc= Received: from MN2PR01CA0005.prod.exchangelabs.com (2603:10b6:208:10c::18) by SN7PR12MB6930.namprd12.prod.outlook.com (2603:10b6:806:262::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19; Fri, 10 Nov 2023 18:55:30 +0000 Received: from BL6PEPF0001AB4F.namprd04.prod.outlook.com (2603:10b6:208:10c:cafe::76) by MN2PR01CA0005.outlook.office365.com (2603:10b6:208:10c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.19 via Frontend Transport; Fri, 10 Nov 2023 18:55:30 +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 BL6PEPF0001AB4F.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6977.16 via Frontend Transport; Fri, 10 Nov 2023 18:55:29 +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.32; Fri, 10 Nov 2023 12:55:28 -0600 From: Mario Limonciello To: Bjorn Helgaas , "Rafael J . Wysocki" CC: "open list:PCI SUBSYSTEM" , , , "Mario Limonciello" Subject: [PATCH 3/3] PCI/ACPI: Add API for specifying a PERST# assertion delay Date: Fri, 10 Nov 2023 12:55:03 -0600 Message-ID: <20231110185503.46117-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231110185503.46117-1-mario.limonciello@amd.com> References: <20231110185503.46117-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: BL6PEPF0001AB4F:EE_|SN7PR12MB6930:EE_ X-MS-Office365-Filtering-Correlation-Id: 3953cfdf-cb02-4105-0a13-08dbe21e9c43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a35lPOCYviJ1NbEDH5THP9qPdPr9slElG/0h/fCwxs7175OI1f6zp7yWkFkHgKp5A+X0ryt0dRzPJgT6Qa0lVMoLjx+lpxvvCVmHwyEUIQc415o1nVhAYSfBLyYsRtVcSmF5iAWu+2khf+aHP9uGjFUfaD6BHubHZtKh+U+XGdQWbW2HINz+qKf7KVs7uc+RHUnr5ScTbLhNSk9PCCi4//S8+mrpX7n9jN+E+pZj3D9SpR2BYKtMfkMPSEu3MIPPw7zo86/JXVjhKAF7rG7ComaCjSfUWuh7QX50ITW5n7Q1i49RL17YCjxNZX1om8VdWa2xoud8x1179tfJeQtyQtdnDycS6Z4B9UNlEtxBReHXZlyCAWLMDAsXoRuYGgnrgGhq1W6/lMrBduQh5HfKr01Z3ytI92AB7Nh8Swx66W7s53lFz1p2pDRVABe9IEbstW0l6/gizrTm5Hsi0bC4wQZ47lV9wvrqMTUgdsIJawUSf53l8rjxdURc+wvJh8MVd1/a6nIDaDM/oDKq7q4389GjznafB9wbSb3Hlveh04JzkUOCEwQLi8KLH/ZIxDhzt5ydlqjsHAxZXG5finnRMysbWvFE1xcj91dgl0T9FyPacAA5lC7pQ0B4vFeGnECc6zpR/h6PJUfFZLxatFndbiYABxIe8iaFw/DBynDJO1DUHYQ2z1rGyatljPt4lncLNYhl0GTV2fhp9SKLO3JVfkyvv/Edl4XjfB2mQjMj+a1SfDSz9NOnHPLFXmfRNjBTi5JsiWewgmjOuQa0QhtkGg== 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)(376002)(346002)(396003)(136003)(230922051799003)(82310400011)(64100799003)(1800799009)(451199024)(186009)(36840700001)(40470700004)(46966006)(7696005)(83380400001)(4326008)(8676002)(8936002)(2616005)(966005)(426003)(6666004)(26005)(70586007)(16526019)(44832011)(110136005)(478600001)(316002)(336012)(54906003)(70206006)(1076003)(47076005)(40480700001)(5660300002)(36860700001)(40460700003)(41300700001)(81166007)(356005)(82740400003)(36756003)(2906002)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2023 18:55:29.9717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3953cfdf-cb02-4105-0a13-08dbe21e9c43 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: BL6PEPF0001AB4F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6930 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The PCI firmware specification includes support for a _DSM function to specify a PERST# assertion delay. "The Add PERST# Assertion Delay function is used to convey the requirement for a fixed delay in timing between the time the PME_TO_Ack message is received at the PCI Express Downstream Port that originated the PME_Turn_Off message, and the time the platform asserts PERST# to the slot during the corresponding Endpoint’s or PCI Express Upstream Port’s transition to D3cold while the system is in an ACPI operational state." Add API for callers to utilize this _DSM. Link: https://members.pcisig.com/wg/PCI-SIG/document/15350 PCI Firmware specification 3.3, section 4.6.11 Signed-off-by: Mario Limonciello --- drivers/pci/pci-acpi.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 257858a6719e..82e04808040d 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1402,6 +1402,46 @@ int pci_acpi_request_aux_power_for_d3cold(struct pci_dev *pdev, int arg) } EXPORT_SYMBOL_GPL(pci_acpi_request_aux_power_for_d3cold); +/** + * pci_acpi_set_perst_delay - Set the assertion delay for the PERST# signal + * @pdev: PCI device to set the delay for + * @arg: Delay value in microseconds + * + * This function sets the delay for the PERST# signal of the given PCI device. + * The delay value is specified in microseconds through the @arg parameter. + * The maximum delay value is 10000 microseconds. + * + * Return: 0 on success, negative error code on failure + */ +int pci_acpi_set_perst_delay(struct pci_dev *pdev, int arg) +{ + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); + union acpi_object *obj; + union acpi_object argv4 = { + .integer.type = ACPI_TYPE_INTEGER, + .integer.value = arg, + }; + int val; + + if (!acpi_check_dsm(adev->handle, &pci_acpi_dsm_guid, + pci_acpi_dsm_rev, 1 << DSM_PCI_ADD_PERST_DELAY)) + return -ENODEV; + + if (arg > 10000) + return -EINVAL; + + obj = acpi_evaluate_dsm_typed(adev->handle, &pci_acpi_dsm_guid, + pci_acpi_dsm_rev, DSM_PCI_ADD_PERST_DELAY, + &argv4, ACPI_TYPE_INTEGER); + if (!obj) + return -EIO; + + val = obj->integer.value; + ACPI_FREE(obj); + return (val == arg) ? 0 : -EINVAL; +} +EXPORT_SYMBOL_GPL(pci_acpi_set_perst_delay); + /** * pci_acpi_optimize_delay - optimize PCI D3 and D3cold delay from ACPI * @pdev: the PCI device whose delay is to be updated diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index bc6372bcb7d6..bdce83c3afbf 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -123,12 +123,14 @@ extern const int pci_acpi_dsm_rev; #define DSM_PCI_POWER_ON_RESET_DELAY 0x08 #define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09 #define DSM_PCI_REQUEST_D3COLD_AUX_POWER 0x0A +#define DSM_PCI_ADD_PERST_DELAY 0x0B #define PCI_D3COLD_AUX_DENIED 0 #define PCI_D3COLD_AUX_GRANTED 1 #define PCI_D3COLD_AUX_NO_MAIN_POWER_REMOVAL 2 int pci_acpi_request_aux_power_for_d3cold(struct pci_dev *pdev, int arg); +int pci_acpi_set_perst_delay(struct pci_dev *pdev, int arg); #ifdef CONFIG_PCIE_EDR void pci_acpi_add_edr_notifier(struct pci_dev *pdev);