From patchwork Wed Oct 25 02:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13435398 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 CF768C25B6E for ; Wed, 25 Oct 2023 02:06:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbjJYCGR (ORCPT ); Tue, 24 Oct 2023 22:06:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231537AbjJYCGP (ORCPT ); Tue, 24 Oct 2023 22:06:15 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2041.outbound.protection.outlook.com [40.107.94.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18EA10E4; Tue, 24 Oct 2023 19:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2x9YqB2NlHJ1wANb6a+5ws0YdBX3vsjkt2/PRvDZ6WVqRq+uCJr1h8waxQKENkrEzICJNxTJXx2Zl+1ed8VTjUKnPYuVK64ZntHNWxSH08W82WQue1h2mjojOs+E2Ln30DnTESHiNK70bC3v/XE99xCZrwgwKGyW/UwYXd792ztOAWGF6BEbhiQOjETyoaS9L3z87ikMhh8JGXzbrZOL7WLztVuIlRWMG/kf8gjvdErcq4tJOrLpwHvVW0lh6T0cB7u5ZOysGMXgGcXKjc7YUdibJY3vZLqMDCTej0zSzE9Z3Tsl7wG5nXxboNCEkbENn6Dnxnz/qnrWvzVxW73lA== 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=lFiX9EXXuC5AphQlOCTSzBjRFt7sYTmuPaVEd26TXvc=; b=HNpMUBzMMVG1YPEkOu7uhJ7ni34EYHeY7lf5NEOVX8oAElXdzANT2QEwQIeswYBOJ6VKOZd8b2suvylsi0h+wKVcX1S+KmpBiCFkbVQuvUtLUWxpABDN047Kx4FffDtt9BaTpbwjddI7LIsTn3y0e0e29jBuWPaeq0G6TDf413F2dqj3PYNKn8JySvZUDC/+Z9VP7Qm6/lzdqlN5gfAm2g7w9+LEKnChrU9A3PTN/xIm5sai0vhOA5dSEa7KWyE/s2FdxxGy2K7LyPqKQ1sVe+zmw1qzbLTayOKuhCOsg1W8jVcMePnkN3mjW+36LpQwxCa9g1m3WJguz7AhjipIDw== 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 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=lFiX9EXXuC5AphQlOCTSzBjRFt7sYTmuPaVEd26TXvc=; b=gpKGP4L8NWADkgnTH5HuCytkDb6jK2OGWl90iV0vo6BEVvbd0nq90DC/ZzndUnYwyWqWAXcpVWE5iU3lJWDjkT/HHX/uJzzfmDWgtBQbvAfp3yNSVsmv+UERIOrXvqL18VNrqPrPebNEUcu4ZcwgCLms75WcQByihvxkvFcTrXk= Received: from MW4PR03CA0279.namprd03.prod.outlook.com (2603:10b6:303:b5::14) by PH7PR12MB6978.namprd12.prod.outlook.com (2603:10b6:510:1b8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33; Wed, 25 Oct 2023 02:06:08 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:303:b5:cafe::fe) by MW4PR03CA0279.outlook.office365.com (2603:10b6:303:b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33 via Frontend Transport; Wed, 25 Oct 2023 02:06:08 +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 CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Wed, 25 Oct 2023 02:06:08 +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; Tue, 24 Oct 2023 21:06:06 -0500 From: Mario Limonciello To: Bjorn Helgaas , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Shyam Sundar S K , "open list:PCI SUBSYSTEM" , "open list:X86 PLATFORM DRIVERS" , Lukas Wunner , Kai-Heng Feng , Mario Limonciello Subject: [PATCH 1/4] PCI: Make d3cold_allowed sysfs attribute read only Date: Tue, 24 Oct 2023 21:05:43 -0500 Message-ID: <20231025020546.504-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025020546.504-1-mario.limonciello@amd.com> References: <20231025020546.504-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: CO1PEPF000044F3:EE_|PH7PR12MB6978:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a33660a-69c7-45ee-bb21-08dbd4fef400 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 025Luz6E2ySYlzM8KZccO3dhJc3ioCEIYXjiq2ZPsGa6tFobxIQ/OItRoyD6gLXYJk+W7uTkrphnoDD5VZnLdUzbeQ3s4ZUW3saTyiOZ5BoxzmbI9hrUlb2pVtlcYAX9PxNd6iaidMDAbDnUD/rQVQZy75sMpS5OdLTa1Mr2o3HmspFK84Rw9mSMUfjcPJOSnHsX+GgGSWLrzbHs27f/LGeAOxn9LqByo2wxH0mlArb1PofvTXb1skJ4VUKop+L+xfNeDC/SDDDkbXsBwfyOkqSaKLAUotTFZXEzE4C9gwb5v4LjyzfqYf6liGQ7Hxs7gS5YadCbKF0Z7+9oGPZS0LfT063bTZJGVgZaezwvANLk/A1QW18t67lFFKExo2hOn+X9bskuGbpwLE/R0DQjsqB/25J9kwu0y4ohXNE56mbb5umjRV9iB/+m9pb4TJOl2YvAqq8GD6rhFWVaDw9fy2lr0fxFi9sHdiH0UZ/NZK08yrqc3l7bY3rnxN+szTBXIktx1i3tDB7AJ+uU2SPpe3P/8WKUKZ/8NYmY5jGxNb0FzXx/UzAAyJa9C5UovcGdcUI0VAgbjmz0c3PkXPyhQyYwkBYmluXa4c+xVZiuMGmACe2opnykOaKwdiiZdwDxkc/z07olAAHib+l1d1R5LFxjZWyY/B2YyADNn9GIQAXJnuLCZey2NNpVxJsgiUzYG2iBt5n+KeHTfja4xZhql+SATDd8kR363+biXK/a7XY4jhTeuFX/c1JEFU+XYiumvHIiP1PKqEJGWhNedor1AAGSFjY1F41FLaV+tevU4d4= 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)(396003)(346002)(136003)(230922051799003)(64100799003)(186009)(451199024)(82310400011)(1800799009)(46966006)(36840700001)(40470700004)(26005)(86362001)(41300700001)(2906002)(36860700001)(40460700003)(44832011)(5660300002)(2616005)(36756003)(8676002)(4326008)(8936002)(7696005)(16526019)(478600001)(6666004)(110136005)(81166007)(1076003)(82740400003)(356005)(70206006)(70586007)(54906003)(316002)(966005)(83380400001)(336012)(47076005)(40480700001)(426003)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 02:06:08.1964 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a33660a-69c7-45ee-bb21-08dbd4fef400 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: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6978 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Before kernel 3.6 D3cold was considered "opt-in" for PCIe devices. Userspace was able to opt PCIe devices into d3cold support by using the `d3cold_allowed` sysfs attribute. The policy changed to default to enabled with commit 4f9c1397e2e8 ("PCI/PM: Enable D3/D3cold by default for most devices"). The sysfs file remains however and can potentially allow userspace to prevent the SoC from getting into the deepest sleep state on modern systems. For debugging purposes `pcie_port_pm=` can be used to control whether a PCI port will go into D3cold and runtime PM can be turned off by `/sys/bus/pci/devices/*/power/control` on PCI end points. Change the sysfs attribute to a noop that ignores the input when written and shows a warning. Simplify the internal kernel logic to drop `d3cold_allowed`. Link: https://lore.kernel.org/linux-pci/20230918132424.GA11357@wunner.de/ Signed-off-by: Mario Limonciello Acked-by: Rafael J. Wysocki --- Changes from previous submission: * Update commit message * Roll into series for D3 related handling --- Documentation/ABI/testing/sysfs-bus-pci | 4 ++-- drivers/pci/pci-acpi.c | 2 +- drivers/pci/pci-sysfs.c | 14 ++------------ drivers/pci/pci.c | 3 +-- include/linux/pci.h | 1 - 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci index ecf47559f495..b5db141dfee6 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci @@ -283,8 +283,8 @@ Description: device will never be put into D3Cold state. If it is set, the device may be put into D3Cold state if other requirements are satisfied too. Reading this attribute will show the current - value of d3cold_allowed bit. Writing this attribute will set - the value of d3cold_allowed bit. + value of no_d3cold bit. + Writing to this attribute is deprecated and will do nothing. What: /sys/bus/pci/devices/.../sriov_totalvfs Date: November 2012 diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 05b7357bd258..a05350a4e49c 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -911,7 +911,7 @@ pci_power_t acpi_pci_choose_state(struct pci_dev *pdev) { int acpi_state, d_max; - if (pdev->no_d3cold || !pdev->d3cold_allowed) + if (pdev->no_d3cold) d_max = ACPI_STATE_D3_HOT; else d_max = ACPI_STATE_D3_COLD; diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 5e741a05cf2c..52ed5a55a371 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -523,17 +523,7 @@ static ssize_t d3cold_allowed_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct pci_dev *pdev = to_pci_dev(dev); - unsigned long val; - - if (kstrtoul(buf, 0, &val) < 0) - return -EINVAL; - - pdev->d3cold_allowed = !!val; - pci_bridge_d3_update(pdev); - - pm_runtime_resume(dev); - + dev_warn_once(dev, "pci: writing to d3cold_allowed is deprecated\n"); return count; } @@ -541,7 +531,7 @@ static ssize_t d3cold_allowed_show(struct device *dev, struct device_attribute *attr, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); - return sysfs_emit(buf, "%u\n", pdev->d3cold_allowed); + return sysfs_emit(buf, "%u\n", !pdev->no_d3cold); } static DEVICE_ATTR_RW(d3cold_allowed); #endif diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 59c01d68c6d5..8c5a6f68f63d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3067,7 +3067,7 @@ static int pci_dev_check_d3cold(struct pci_dev *dev, void *data) bool *d3cold_ok = data; if (/* The device needs to be allowed to go D3cold ... */ - dev->no_d3cold || !dev->d3cold_allowed || + dev->no_d3cold || /* ... and if it is wakeup capable to do so from D3cold. */ (device_may_wakeup(&dev->dev) && @@ -3204,7 +3204,6 @@ void pci_pm_init(struct pci_dev *dev) dev->d3hot_delay = PCI_PM_D3HOT_WAIT; dev->d3cold_delay = PCI_PM_D3COLD_WAIT; dev->bridge_d3 = pci_bridge_d3_possible(dev); - dev->d3cold_allowed = true; dev->d1_support = false; dev->d2_support = false; diff --git a/include/linux/pci.h b/include/linux/pci.h index 8c7c2c3c6c65..5f4ed71d31f5 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -376,7 +376,6 @@ struct pci_dev { unsigned int no_d1d2:1; /* D1 and D2 are forbidden */ unsigned int no_d3cold:1; /* D3cold is forbidden */ unsigned int bridge_d3:1; /* Allow D3 for bridge */ - unsigned int d3cold_allowed:1; /* D3cold is allowed by user */ unsigned int mmio_always_on:1; /* Disallow turning off io/mem decoding during BAR sizing */ unsigned int wakeup_prepared:1; From patchwork Wed Oct 25 02:05:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13435397 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 651E7C25B48 for ; Wed, 25 Oct 2023 02:06:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231539AbjJYCGQ (ORCPT ); Tue, 24 Oct 2023 22:06:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjJYCGP (ORCPT ); Tue, 24 Oct 2023 22:06:15 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2046.outbound.protection.outlook.com [40.107.243.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E979710DD; Tue, 24 Oct 2023 19:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elQJocCXdGaTywAAcAKUNDhAcExsY3i46sL5Ja0oYJWpPTmx/BDFxZ1+u28GkpdE488Zo6eeA7bxbqCCBGMLXgLJ3yOBBMMGH8eUpMh+7GUXpWw4NLvxp+TRo4ZreBAhqMzqcdAAZFfAkViGnM4O1OTL5MvGAEHqOqITqdNq7VeNyh2IxMCwxeecDLAQXCK+YRzQsFMRdracN6rGY+2uzPk5FeCDCxKDr08l2MOLvSaKMR261SqQN1gUBzGQL45OMpxKEEPLXVI0PngxXwazQlYfkSiJnTK5KP6lvE9R5nGTX3L11H33kmHj3+WVYN5myYbuw9fBvIu6PSxQHkg41A== 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=kB/htuh/LmLMsy+Xjs9vdnldu2LPswk2sXkenxKpz/g=; b=YXSeREgZq4niALfLwb9Hzz1pCmD3l6a4WRR0SUA2mk+EF+YV8x/9bRmEZjxs4UBTir1eL5wpGNvqOyZHIjz6FCuQJ5+gPQ2L9czUSjwytMZViq88pWCyIR8wpE5Db5pVbZQDaAIKjfuidOJDqGdaR1u2aFOsSjW6FWi7g0F9BUcAjeJOaixUU0plt1WMZKWDEx/tzbeTtHo1mNqv+PaoQiHjCZb3Zhqt6bjnCggCbfSCchdesK+rSYJLrj0Ml087yMqbJBrjweSeziPPeAnMcOaA1hgcLtyAe6spmEAAZRAetcZouecNFAYbBp7irHCmcstTV77aYgySLV2j/Xx49w== 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 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=kB/htuh/LmLMsy+Xjs9vdnldu2LPswk2sXkenxKpz/g=; b=rH0GQyVMdlb3m2wjmYtxbgCPqPHCmvIvKS6zD1ZtVPPxeqkAVYjBluavtvNAK8pAl46jMlsV2gnN7uXHLpTmgBdABkNg2Szow74XgPriklXWrHH8TrYemw9Xcuw8R1E9C0pAAhVYkxKSw1yy8tCtG59ZPYC1Mw9TPnS/YMq7S0g= Received: from MW4PR03CA0295.namprd03.prod.outlook.com (2603:10b6:303:b5::30) by IA1PR12MB6354.namprd12.prod.outlook.com (2603:10b6:208:3e2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Wed, 25 Oct 2023 02:06:09 +0000 Received: from CO1PEPF000044F3.namprd05.prod.outlook.com (2603:10b6:303:b5:cafe::19) by MW4PR03CA0295.outlook.office365.com (2603:10b6:303:b5::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33 via Frontend Transport; Wed, 25 Oct 2023 02:06:09 +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 CO1PEPF000044F3.mail.protection.outlook.com (10.167.241.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Wed, 25 Oct 2023 02:06:09 +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; Tue, 24 Oct 2023 21:06:07 -0500 From: Mario Limonciello To: Bjorn Helgaas , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Shyam Sundar S K , "open list:PCI SUBSYSTEM" , "open list:X86 PLATFORM DRIVERS" , Lukas Wunner , Kai-Heng Feng , Mario Limonciello Subject: [PATCH 2/4] PCI: Refresh root ports in pci_bridge_d3_update() Date: Tue, 24 Oct 2023 21:05:44 -0500 Message-ID: <20231025020546.504-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025020546.504-1-mario.limonciello@amd.com> References: <20231025020546.504-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: CO1PEPF000044F3:EE_|IA1PR12MB6354:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a863d84-b704-4aa1-51ca-08dbd4fef499 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VgXl1TGbz/oRBmPT99MVuVApCIFyYBg7ur+Z/5uK3bvcjr5ELoGXLaHPvcruu2kimw0ArwNuGXo7BIA7NnBuZ9dJsL13xN3KqoXGlBiuRJYuLbqwEpVTVwBhP7eYRl72Czn/4W4CAnUw46e+eEe4Z7ytlpIMK7fua574vrCyrgoyNlFduyRYsp7DxmlfYOQi2XjBB/D4ACOIx/j67tC1tA+D4wXUn3Tim1qz9hEnya2xKSB1qUbLt0H1AFRLkPSwFCsmr1aqW51sx+vBBo0lE56JxOCX6zEtjUTF/Xe6NDS2zYL4NUpShj4O2AXqoZpnu2O3PFImobg5OmmOalgUx3dNcCwaMMuJaDx9N7/VSZnG/dd2hko7A85RLqF+vsPIOucQPfmgl1nMDiubDY5q562ZJ3kd7BUi7l6H31wh2nls/+HpR+8mq7eMFWj8KKoaHK47ZLpHmdFdaTsochPoDST8/UQAgOJdDj1p43OBoix2RJIl7WQ7ft64AG0QObZ1TuAPPJROTiIoYl8LNdetOqd9DJ19UpTUKNZKsZ3eY6SWgnv3Uy6+hyjas6BKoiAR0EgJIIGtS2EVNbqbiGhUl3SCiCothQcTjYnIlSwQwn34dpoHz/H4CesrYAE4LxEKCl7onyLoyMPlGvwWxzXOh9Z7sMi2+s4aHOVoBdFO5I5sIDvTYPFasYYQiP35A1YLP/kZPm3ynZHiPd8ysZoh0mLU7MCU7QHmzRaws6E60Zw1I2oeSoICFwZtBjfdre1OvduFGKybAVdldl/tk9nYAw== 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)(396003)(376002)(136003)(346002)(230922051799003)(82310400011)(451199024)(1800799009)(64100799003)(186009)(36840700001)(46966006)(40470700004)(336012)(4326008)(8936002)(40480700001)(44832011)(40460700003)(41300700001)(36756003)(81166007)(2616005)(1076003)(86362001)(316002)(2906002)(5660300002)(8676002)(478600001)(110136005)(6666004)(70206006)(70586007)(54906003)(83380400001)(7696005)(426003)(356005)(82740400003)(26005)(16526019)(47076005)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 02:06:09.2121 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a863d84-b704-4aa1-51ca-08dbd4fef499 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: CO1PEPF000044F3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6354 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If pci_d3cold_enable() or pci_d3cold_disable() is called on a root port it is ignored because there is no upstream bridge. If called on a root port, use `no_d3cold` variable to decide policy and also immediately refresh whether D3 is possible. Signed-off-by: Mario Limonciello --- Changes from RFC v1: * New patch --- drivers/pci/pci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8c5a6f68f63d..28f70e8ea478 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3021,6 +3021,9 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge) if (pci_bridge_d3_disable) return false; + if (bridge->no_d3cold) + return false; + /* * Hotplug ports handled by firmware in System Management Mode * may not be put into D3 by the OS (Thunderbolt on non-Macs). @@ -3096,7 +3099,11 @@ void pci_bridge_d3_update(struct pci_dev *dev) bool d3cold_ok = true; bridge = pci_upstream_bridge(dev); - if (!bridge || !pci_bridge_d3_possible(bridge)) + if (!bridge) { + dev->bridge_d3 = pci_bridge_d3_possible(dev); + return; + } + if (!pci_bridge_d3_possible(bridge)) return; /* From patchwork Wed Oct 25 02:05:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13435399 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 86E5AC25B6F for ; Wed, 25 Oct 2023 02:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230469AbjJYCGT (ORCPT ); Tue, 24 Oct 2023 22:06:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbjJYCGR (ORCPT ); Tue, 24 Oct 2023 22:06:17 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2066.outbound.protection.outlook.com [40.107.101.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28E3C10D4; Tue, 24 Oct 2023 19:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nNuNnuYVB++XFLuelNVqlqi6NXhhjc7o3hVUhtlFVpok5TUu/SVpvAj8p9xK4YUE7eqouzOEfqDMdtfLTyg/ryYDbYx2sHo8ynbzl9BPy63j8lOenHnB57lGw8y/dQbAFkbXEYdbo9zCtkAymL5Q6PYNyqmeUBJE2zRuin7QLjj+27K9yco04tkZHGhdrm02Lflqeo/SxU0Zex34JkdbWLLSvTkVTgvMegbDLU92Jew16ffnieukpVTNEfZgm6CnlNZSum9OCgqzreco+orkZY/4kFRr3pIUfA2Y2HfIz6PGTlUMWOmnF02nMeWJzU2/K4NtyFFqT2AbgTM5uWUynw== 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=TeMEEDA0o/xz+YB5OAwmFUl9k7FxdNparpTFBxGlRcE=; b=jDp0bSMRNIYskS7eXXWwVsx1cBIhgnfGjexCwgXvgfJwR+keSHJkAMBRkh/EC3WhogLnwOP5X5CBgIWHxTIZn2GqNwajxkd57fkBgcUtW7WJtEdzCj7+L3EMR0q8OlPBOqEvHxZsVwuRhxXBQcvkYaKcH2caISa2UiaI83rNtE/67cS1VcZEB3hD8QQGZsx5mBYOdTQ4GHElpfuNUEHxeveL0egcg9XVh8k6nT/WnXf50SnmIqmbDW8vSSxH2MDVtoh6dYNJy0dVIvZsgVhk7EK2t04UHb7wWIBeE7YGICAlkF1d/4sDjBrE9wqtygXl/nFcY3cWLEYN3L/8eyb2FA== 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 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=TeMEEDA0o/xz+YB5OAwmFUl9k7FxdNparpTFBxGlRcE=; b=H4zmO76hEKeEdGHk/bAWcEeA4yLSSF4oY/a1yK+Fo/Wkglerw7s9jgSVVLkylNF9UVkmYYCMO7+6ScOOJp2rXS/XRstBYN6xZnzPslfeDwC602QHzV7CLJTdCO8vkVqPUpOwHdxXooP6QDdAOM/d/VgMRlXQaYmJa8QSkF2jQZE= Received: from MW4P220CA0008.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::13) by DM4PR12MB5088.namprd12.prod.outlook.com (2603:10b6:5:38b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Wed, 25 Oct 2023 02:06:11 +0000 Received: from CO1PEPF000044F0.namprd05.prod.outlook.com (2603:10b6:303:115:cafe::3c) by MW4P220CA0008.outlook.office365.com (2603:10b6:303:115::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.33 via Frontend Transport; Wed, 25 Oct 2023 02:06:11 +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 CO1PEPF000044F0.mail.protection.outlook.com (10.167.241.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Wed, 25 Oct 2023 02:06:10 +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; Tue, 24 Oct 2023 21:06:09 -0500 From: Mario Limonciello To: Bjorn Helgaas , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Shyam Sundar S K , "open list:PCI SUBSYSTEM" , "open list:X86 PLATFORM DRIVERS" , Lukas Wunner , Kai-Heng Feng , Mario Limonciello , "Rafael J. Wysocki" Subject: [PATCH 3/4] ACPI: x86: s2idle: Export symbol for fetching constraints for module use Date: Tue, 24 Oct 2023 21:05:45 -0500 Message-ID: <20231025020546.504-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025020546.504-1-mario.limonciello@amd.com> References: <20231025020546.504-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: CO1PEPF000044F0:EE_|DM4PR12MB5088:EE_ X-MS-Office365-Filtering-Correlation-Id: c4e85683-1086-4a60-c3cb-08dbd4fef59a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WAoexHCSxfGf8GuVoEK1YR1+PAudWXLucExOK8PAuHSe4N7Vtr6l5MN0ZtMDokSgriSKkTav8UxJMEGqpHiU6tebjg1kljOUjipEd8ke3r9xyfnVjUCQg4x+40LHnMTRHlqguCNf7J48lcPoE4rY3TxwUABnM0AFbP7EsoGm92zVB3XUvCOkBAQWusxgKk2IYaPK8gwUTt3ObfywfO705ZsIyCqLB4vfSM5xa00VrahR5vDMmy4sWiW9OYXcURjkiDnCtGxVJQchJpc/LPPjqL9O9kfqB/ZjoG5yJucdWG4wJD5IYAC1jP0Kz5CFXTr9oJhN6MOY+3jMPn2T5zjfypgC/qGp8X2yZcCXrkGkxNLSFa1+cg3yo+49YEL8z1/NsYilOkIVJA1a3WhjOpkEApO0NWjvpEKYrVcyOxhHtkzNWjzNJqZKyf0qG5Wp0fJTIEbgxQ7w/O/j3ZOzNf/FapO/IewZPYrUz+EAwVBksyYG0iX2WbYIvQakAj2fzMsFqTCZAGy6IdWJlASfXrNAyshNuG1KLJp/uK24FnwE3Rk3HFIpy4nJ3eC9t1EP5Q8z7+e5noqNKbrTfJEFlDnLWVTx60eS+n0ezfVppHqTWktmdnPofk+rj7JSMEELLDlt1f3KaAIoXdCbyol1mNvfsJ3bhzAg51CcDG6q8acrBRuU+hhahx1ydAA/4jP/KJY1DSjC+8zMP4vUZEKTOlvHYNfpMCn/NNDzQQZcq+nblf0N+5MfQTLB+32khuEAtI0bYbLoVs0SAZZjt+XpuGNDww== 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)(136003)(396003)(376002)(346002)(230922051799003)(1800799009)(451199024)(64100799003)(82310400011)(186009)(46966006)(40470700004)(36840700001)(86362001)(478600001)(40460700003)(47076005)(5660300002)(316002)(2906002)(6666004)(70206006)(110136005)(54906003)(8936002)(70586007)(4326008)(36860700001)(426003)(41300700001)(44832011)(36756003)(4744005)(1076003)(2616005)(81166007)(7696005)(8676002)(82740400003)(16526019)(83380400001)(356005)(26005)(336012)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 02:06:10.8993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4e85683-1086-4a60-c3cb-08dbd4fef59a 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: CO1PEPF000044F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5088 Precedence: bulk List-ID: X-Mailing-List: linux-pci@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 Oct 25 02:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13435400 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 398E7C07545 for ; Wed, 25 Oct 2023 02:06:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbjJYCGW (ORCPT ); Tue, 24 Oct 2023 22:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjJYCGU (ORCPT ); Tue, 24 Oct 2023 22:06:20 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2064.outbound.protection.outlook.com [40.107.92.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3932110E3; Tue, 24 Oct 2023 19:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AETvowjEV1G3G+W0+S+7bdlX2BK3EhbRwer9hDRYPC1At+ujcRzMW0llAeWWfvel0Xx5d+PI/P5gdRV3Ph2Q35unvGTQsSeXnzieC7b74AhsK6g+jaq2uSb8kYwAygMNDLg0XHWwU0BClEmc/J9+0HIZLYREi4nLbph2Q1GUe1Nhvsnlx5/OPJU1wHu9vH00BLt+Ak9AH6paeaXpvUJ20BJhJINgysHL9mmE9UZBhjPCn9iznLzsPQipo28D8xEd9tAMPXXsAZdcVC0LHxlgwO3RcTi9tca9vy5KlIXRwXPbv661tTyq5LD2lwWLC5Uxl9aF5j4Hc1gTnNftiOYxpg== 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=+F3uO+5IWBcf7q6yTe2ZhI9rXKBglfqAeJ41mJytnzo=; b=DeSj4FrdRvoRlhcWG+GqX0xedrooCWALk+sN7GxcZkC3xir26j9iX4GbXznx8htzfXLP5fJJV9JJ8aZc7dB5Sj4olhuQJMsLQ4Kuw/kqIfoemuflmOO3uN9iCXVCBfmL7bqHsyOhbHbqQWj9WxyoR/rNihwQPzp0ZmGUaj5I2s6XH3yqKxUoX9TWEOsmllwtG8vMnaP8R+rQaHYjNoS6zPF088WGeDPqQb1SkGnBt7MUYmIB8dV1TwdMcon54Jx7AyWP45MY3J1cnTeH7bvDoFLF19jA9JOzxV8gMhMNr7ufsfSEDMJwQKACKnC2yIY05Rvohi/vHZ7owRDlchw7Eg== 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 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=+F3uO+5IWBcf7q6yTe2ZhI9rXKBglfqAeJ41mJytnzo=; b=Re41GFkRETwo0vzHdyHGBzWRaOafIBR6pIxj9vCP2pX9TePkW9hrtFrRivCSY5s36VaeFsuAd1OIlR/1j1UpWJexyIiHKFH47CZzvIGcwqntVHJojoG1fsrovDccUVOBR0NH1rRflTetkABbxzXi2vbye+JyBpECQMbEd8CZrJI= Received: from MW4P220CA0022.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::27) by SJ2PR12MB9115.namprd12.prod.outlook.com (2603:10b6:a03:55c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Wed, 25 Oct 2023 02:06:12 +0000 Received: from CO1PEPF000044F0.namprd05.prod.outlook.com (2603:10b6:303:115:cafe::63) by MW4P220CA0022.outlook.office365.com (2603:10b6:303:115::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.32 via Frontend Transport; Wed, 25 Oct 2023 02:06:12 +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 CO1PEPF000044F0.mail.protection.outlook.com (10.167.241.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6933.15 via Frontend Transport; Wed, 25 Oct 2023 02:06:12 +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; Tue, 24 Oct 2023 21:06:10 -0500 From: Mario Limonciello To: Bjorn Helgaas , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Shyam Sundar S K , "open list:PCI SUBSYSTEM" , "open list:X86 PLATFORM DRIVERS" , Lukas Wunner , Kai-Heng Feng , Mario Limonciello Subject: [PATCH 4/4] platform/x86/amd: pmc: Add support for using constraints to decide D3 policy Date: Tue, 24 Oct 2023 21:05:46 -0500 Message-ID: <20231025020546.504-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025020546.504-1-mario.limonciello@amd.com> References: <20231025020546.504-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: CO1PEPF000044F0:EE_|SJ2PR12MB9115:EE_ X-MS-Office365-Filtering-Correlation-Id: b6264cc3-ca17-4cc5-df3c-08dbd4fef699 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rXlWUXDIr+ZsYF1yu3p975niA66x/MacU4CpMv1+UulsuZHIz5hvw6McKuEywU9b7gxq6kFxEP0ocSRBV2s8aIlYwmHpbXfD6bqpjSa1ix1OJdAaSpqyxZCs4n4q5HOppJyr2NrvJEvBqPe9ex3J/u2nlAUl2BmtIjipJwIm1wgQcPr4K8jw/05vTCWfOUO/KGdwftCDVG4h3YeMGHsFutLXl8lJOy2UyvUn4/3sHevjQURMvxXbFzMz6E1AoD42s7eDp2Q6jliVJkAxkqWXU1mxFby5tv/vr22G7+BlY/Jva1Q8qAw3wPg7DlOkacB43JZoCeIillF7Wq2Uia1bVOOM9e4ryumm6jXFCS1BFXfEk0ff74oqbq6YwiqkS8x7BAYE8mM65olB4KbOoG75YOXPUpnN0hSIh3W+bJRmEYQ92zOeR3HLqoR/mzxELFFQNBuqLxl6XkrUXD4g2ISFhlQeLvq9BjJX5D+u9F6XQ+co5pTAFmXJWSWoGLHW0LQlvhV/7HwDQsJt/BKx7ZfCjGQ991p3aCucWSFrm337kP3a59/ebxtZXljzBAW/v3joWmQMTVObF0b14n26xaywS9cqhmKw1rD+VcuVTSbwzDL4Pmmovxj+mSAWVbr0EupioaqtrxKbayHdossEvznvt2mS7g5EsUuc2Jz4rjOOwxi5nyWP69ItoG2LTJqds1gN9ytZ6VbRnFPJ+deXOD5dcjJJ+W8yFrOLuk1GyuUmz2/tSffALwuYk5hOvls39ADJ 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)(396003)(376002)(346002)(136003)(230922051799003)(451199024)(186009)(82310400011)(1800799009)(64100799003)(40470700004)(46966006)(36840700001)(2906002)(40460700003)(5660300002)(316002)(8936002)(8676002)(36756003)(4326008)(40480700001)(44832011)(478600001)(110136005)(70586007)(54906003)(82740400003)(6666004)(86362001)(70206006)(356005)(7696005)(426003)(41300700001)(2616005)(26005)(1076003)(83380400001)(81166007)(336012)(966005)(36860700001)(47076005)(16526019)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2023 02:06:12.5711 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6264cc3-ca17-4cc5-df3c-08dbd4fef699 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: CO1PEPF000044F0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9115 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The default kernel policy will allow modern machines to effectively put all PCIe bridges into PCI D3. This policy doesn't match what Windows uses. In Windows the driver stack includes a "Power Engine Plugin" (uPEP driver) to decide the policy for integrated devices using PEP device constraints. Device constraints are expressed as a number in the _DSM of the PNP0D80 device and exported by the kernel in acpi_get_lps0_constraint(). Add support for SoCs to use constraints on Linux as well for deciding target state for integrated PCI bridges. Disable existing production SoCs by default with this change. Link: https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/platform-design-for-modern-standby#low-power-core-silicon-cpu-soc-dram Signed-off-by: Mario Limonciello --- Changes from RFC v1: * Use pci_d3cold_*able() instead --- 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..346564517667 100644 --- a/drivers/platform/x86/amd/pmc/pmc.c +++ b/drivers/platform/x86/amd/pmc/pmc.c @@ -741,6 +741,61 @@ static int amd_pmc_czn_wa_irq1(struct amd_pmc_dev *pdev) return 0; } +static inline void amd_pmc_apply_constraint(struct pci_dev *pci_dev, bool apply) +{ + if (apply) + pci_d3cold_disable(pci_dev); + else + pci_d3cold_enable(pci_dev); +} + +/* + * Constraints are specified in the ACPI LPS0 device and specify what the + * platform intended for devices that are internal to the SoC. + * + * If a constraint is present and >= to ACPI_STATE_D3, then enable D3. + * If a constraint is not present or < ACPI_STATE_D3, then disable D3. + */ +static void amd_pmc_check_constraints(struct amd_pmc_dev *pdev, bool apply) +{ + struct pci_dev *pci_dev = NULL; + struct acpi_device *adev; + int constraint; + + switch (pdev->cpu_id) { + case AMD_CPU_ID_RV: + case AMD_CPU_ID_RN: + case AMD_CPU_ID_YC: + case AMD_CPU_ID_CB: + case AMD_CPU_ID_PS: + case AMD_CPU_ID_SP: + return; + default: + break; + } + + while ((pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev))) { + adev = ACPI_COMPANION(&pci_dev->dev); + if (!adev) + continue; + constraint = acpi_get_lps0_constraint(adev); + dev_dbg(&pci_dev->dev, "constraint is %d\n", constraint); + + switch (constraint) { + case ACPI_STATE_UNKNOWN: + case ACPI_STATE_D0: + case ACPI_STATE_D1: + case ACPI_STATE_D2: + amd_pmc_apply_constraint(pci_dev, apply); + continue; + /* use the logic pci_bridge_d3_possible() to decide */ + case ACPI_STATE_D3: + default: + continue; + } + } +} + static int amd_pmc_verify_czn_rtc(struct amd_pmc_dev *pdev, u32 *arg) { struct rtc_device *rtc_device; @@ -1074,6 +1129,7 @@ static int amd_pmc_probe(struct platform_device *pdev) amd_pmc_quirks_init(dev); } + amd_pmc_check_constraints(dev, TRUE); amd_pmc_dbgfs_register(dev); pm_report_max_hw_sleep(U64_MAX); return 0; @@ -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); + amd_pmc_check_constraints(dev, FALSE); amd_pmc_dbgfs_unregister(dev); pci_dev_put(dev->rdev); mutex_destroy(&dev->lock);