Message ID | 20231213182656.6165-2-mario.limonciello@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7981815dys; Wed, 13 Dec 2023 10:27:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEi8TPw+ba/IINhr1G5mR/33pgt+c5xoC+i63hoUEKphyo07N4mbcIVTLI61UaHPIZ2/E8x X-Received: by 2002:a05:6a00:1783:b0:6ce:2732:277 with SMTP id s3-20020a056a00178300b006ce27320277mr5209833pfg.38.1702492053651; Wed, 13 Dec 2023 10:27:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702492053; cv=pass; d=google.com; s=arc-20160816; b=w4PXBNYLbsVrt3wSRJ0pi+J32CQkBxwp0Sn2pG7Bag0SUV8sf1j5vO79f59999Dxaa bD+nkoKfznHDXvZo8mfz0mmZ1fGohBcETwdxwHVaMJ3gpUTCCiuj6VmUb/jUikeqz5fc 3u5hG5GvtY49o1JRrJfy+AdyF9pgAD376PpU5U/E+SnmNkVti0y+o1N8SZheeRSmT+9c nkqxAWKdc9GwNvL8MK9kuXkabTof6po/sQkdcvub8IJ7uY7XXETBI85bePMmwbHTb7Yx kuMs8gvjq40Y4tc7RMj4g479OXbcPw7PjAq/oZ6sN8A5+7iqhQuv9qO4cPWRFz4jU8n3 EYiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=edUbeuuX5BsjxuAwGF3ufN/ANXoiMaNzF9x8579BmJw=; fh=Rx9/fAnZzsj/hB/+nzcyRMJzmx0rQCrVMUHIwDTjudE=; b=ovK1AzcFgbOAJE6n1/QPMGS28+ffw8XxioIzFCrvXJ9qpBpG9r43HpnbquJI9jz+J4 QFNg/jL6I8Je7ZLttZxAhgPQ9OufLWtLTuySdTygnMGAvwgyVQP8dCGT31o7V7Gxgg01 vpaj/n1+a/1OzEkfpcDsBwyZEpTUZsdyMN+8x//69WSpbFUSy/vmE0emLYkPJm5v1V8J qswLd7vVB3gvt/xcSBkP14ERqAKajEGlpTuxLlUr7fgGm2F8Ydaiml6at0g5GdbmgBfU IO2wmFE48qfk6A5hHDP+r7CeyDth8xaphyaWgZIG6xo0C3g0HQzvVfb271jX55Zn+rfu 5AIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=L7Tgag+V; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o16-20020a056a00215000b006ce4207c516si9786297pfk.388.2023.12.13.10.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:27:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=L7Tgag+V; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 18739803F94C; Wed, 13 Dec 2023 10:27:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442359AbjLMS1R (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 13:27:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442319AbjLMS1O (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 13:27:14 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2073.outbound.protection.outlook.com [40.107.96.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42A74A7; Wed, 13 Dec 2023 10:27:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ShD3zbI9PpZyLKMeUzfzVD+ZwwfoW9HsgK2AklxtypCNNqYCrslJq2JHp8nhOv7iUWnVQ9cXfjRmG4DgDGpC+eBqywWuBOCrVFQMm+ATaDl+F0xsmYQpGYYu+5bbApbRUpm6g+q1H/tKojr39Bm/xWH07gopPbyJS9nfRsO6aZ0sHXVfMz5ZhJ2JvaSvvnfkzvr5G0lecQ8SMecLUxHLoX/IGW9vBqp1hBxp4KzNMLl/5BQGXUJ8OwPcH1R7noKfRxm2buJvIOS8ePRj+fs5XWpkDFageSuz6eK/kfLC+QME4jUbPesyVOr7WJTXvfWH4ZqKJlZ53V5obGaxF+VK0w== 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=edUbeuuX5BsjxuAwGF3ufN/ANXoiMaNzF9x8579BmJw=; b=ZxT+i5tp1diUylp0Dg/YKZXs0F1z7mk6pp9sU5+dJ0IPid16ThfF8pQjkCtEU/Hs0eo4mhmRPh9681yHldcDdKrKAdpzpdBQHLwE58S0ag4ee8+ftSi3ytVhF98nUUdyB38CBOgkAY5Yzc9UNaRfhfJszaHTR3B1eFacpnsTQ+6J3qq5qFnmtPxZWvjCPNR7XadR1Eyn7QzAAVRyKWrQpHZZwJh86Q1X9oEjfdpMgsYiQqRT0ISeXh8/sXqAeHDLL0L+INdAHjEAsmZ9MUPWmsvpoTWiodvqrFQ6qos7Lf3sSzaCeqNpMiJITkhj2ZP925GsXwFsRtZqKTY6GNAt0Q== 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=edUbeuuX5BsjxuAwGF3ufN/ANXoiMaNzF9x8579BmJw=; b=L7Tgag+VfzgEm5g+ku9X0YKaVOQOBLEVuwwdO13Hsy5zfEBvSNApHwYgYGS47cwxtWih+UssbqgnGnCgayBIYUCeDOuY+eJM6kteoKXxED9mjaqPA26+qgQdr4ZPCraFlfF2tgB4U7yPGhUTqh7xqa/D7CiKmssrfcPRyjDq3UM= Received: from BYAPR01CA0011.prod.exchangelabs.com (2603:10b6:a02:80::24) by SN7PR12MB7936.namprd12.prod.outlook.com (2603:10b6:806:347::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.33; Wed, 13 Dec 2023 18:27:17 +0000 Received: from CO1PEPF000044EF.namprd05.prod.outlook.com (2603:10b6:a02:80:cafe::a) by BYAPR01CA0011.outlook.office365.com (2603:10b6:a02:80::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26 via Frontend Transport; Wed, 13 Dec 2023 18:27:17 +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 CO1PEPF000044EF.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.26 via Frontend Transport; Wed, 13 Dec 2023 18:27:17 +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.34; Wed, 13 Dec 2023 12:27:15 -0600 From: Mario Limonciello <mario.limonciello@amd.com> To: Bjorn Helgaas <bhelgaas@google.com>, "Rafael J . Wysocki" <rjw@rjwysocki.net> CC: <linux-pci@vger.kernel.org>, <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Mario Limonciello <mario.limonciello@amd.com>, <mpearson-lenovo@squebb.ca> Subject: [PATCH 1/2] PCI: Avoid runtime resuming devices if system is shutting down Date: Wed, 13 Dec 2023 12:26:55 -0600 Message-ID: <20231213182656.6165-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213182656.6165-1-mario.limonciello@amd.com> References: <20231213182656.6165-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: CO1PEPF000044EF:EE_|SN7PR12MB7936:EE_ X-MS-Office365-Filtering-Correlation-Id: cf4fa19b-9f3e-4fc2-38de-08dbfc0922dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 267UzojrTvQd+L4B8HuF6zUmxDEBK5QwYa/TqdrNZvCvMUJt/FVQ1wsU5b9JoOVStyiFAtcjn1duUAOmK2MQwdgtvBVEXfMVSitZUdUJs0AY0enpn2NS2lVP77ZF127Bj1TRpyjeCAFd7qOPaR2abI/tuTh0kdesNgnXh3mowF6r7MW48c1632AgK0Y3lPvDS97tzG7PdlLg4n6Y2WWmYg/0VnOGyGiblP8vlSOKFPrcjIPA2u/kFJkttQB4VTdj/RN2VXQAggWnAb6oRh+fzyWyEGuafig3jfefep2yOgt/Wt+0SO1Say8JGwI83yHIcuRpdZfWazcRws9F+EGpz4Zd1/WUYy2ZyCvGwWbp3F4Vg8ZVKmXpVZuEFQ9mXaim1vhUEQB/twC2DS3Qm51/DkJjIq3gjOBbN86Mod3893QBtIHBDNQJR5v/CvBlI/LR56NMK3WBWUDHBoyXXfL8G16jB+rIvFlSZHINRfqwKTbdXkJV4wU+ytGrKx5+devirLESfiFhQcDBUohnOI9HSA0u+fNCiRZwmUt6FrrT3mLdD9NXj9Fgy1SH4fHjpG08ioHehTZZnKtYrBQK0zTDILnN5qGT3kZnApvtpHhqJ27G1kENFAoDF73UYtbI6VbDVZlbF8CjGXwbG/qig8zwZOTN+256Sd28xY73DVKCTvZ37qdsWSBx+upxvC83Rl8in6LEiozoTiuEqYsSU+XuOMreCzpLBuXQ6tC9uzQ9LYgfZYFVIctts3lx4cOcXpthHEzlnwjG8+DniyGl7zWMOA== 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)(136003)(396003)(346002)(39860400002)(230922051799003)(1800799012)(186009)(451199024)(82310400011)(64100799003)(40470700004)(46966006)(36840700001)(83380400001)(2906002)(7696005)(81166007)(41300700001)(356005)(86362001)(478600001)(4744005)(54906003)(426003)(40480700001)(70206006)(82740400003)(70586007)(110136005)(316002)(6666004)(8676002)(8936002)(4326008)(40460700003)(44832011)(36756003)(1076003)(5660300002)(47076005)(36860700001)(16526019)(336012)(2616005)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2023 18:27:17.1323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf4fa19b-9f3e-4fc2-38de-08dbfc0922dd 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: CO1PEPF000044EF.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7936 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:27:30 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785192307683312780 X-GMAIL-MSGID: 1785192307683312780 |
Series |
Improvements to system power consumption at S5
|
|
Commit Message
Mario Limonciello
Dec. 13, 2023, 6:26 p.m. UTC
When the system is going to S5 resuming devices is unnecessary at
best and may cause problems for power consumption at S5 at worst.
Check the target `system_state` in the pci driver shutdown() callback
and skip the runtime resume step if the system is being powered off.
Cc: mpearson-lenovo@squebb.ca
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pci/pci-driver.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Wed, Dec 13, 2023 at 7:27 PM Mario Limonciello <mario.limonciello@amd.com> wrote: > > When the system is going to S5 resuming devices is unnecessary at > best and may cause problems for power consumption at S5 at worst. > > Check the target `system_state` in the pci driver shutdown() callback > and skip the runtime resume step if the system is being powered off. > > Cc: mpearson-lenovo@squebb.ca > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > --- > drivers/pci/pci-driver.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > index 51ec9e7e784f..5a6f7a786952 100644 > --- a/drivers/pci/pci-driver.c > +++ b/drivers/pci/pci-driver.c > @@ -507,7 +507,9 @@ static void pci_device_shutdown(struct device *dev) > struct pci_dev *pci_dev = to_pci_dev(dev); > struct pci_driver *drv = pci_dev->driver; > > - pm_runtime_resume(dev); > + /* If system will go to S5, don't wake up PCI devices for shutdown */ > + if (system_state != SYSTEM_POWER_OFF) > + pm_runtime_resume(dev); What's the guarantee that the driver's shutdown callback will not access MMIO regions of a runtime-suspended device? > if (drv && drv->shutdown) > drv->shutdown(pci_dev); > --
On 12/13/2023 12:31, Rafael J. Wysocki wrote: > On Wed, Dec 13, 2023 at 7:27 PM Mario Limonciello > <mario.limonciello@amd.com> wrote: >> >> When the system is going to S5 resuming devices is unnecessary at >> best and may cause problems for power consumption at S5 at worst. >> >> Check the target `system_state` in the pci driver shutdown() callback >> and skip the runtime resume step if the system is being powered off. >> >> Cc: mpearson-lenovo@squebb.ca >> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> >> --- >> drivers/pci/pci-driver.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c >> index 51ec9e7e784f..5a6f7a786952 100644 >> --- a/drivers/pci/pci-driver.c >> +++ b/drivers/pci/pci-driver.c >> @@ -507,7 +507,9 @@ static void pci_device_shutdown(struct device *dev) >> struct pci_dev *pci_dev = to_pci_dev(dev); >> struct pci_driver *drv = pci_dev->driver; >> >> - pm_runtime_resume(dev); >> + /* If system will go to S5, don't wake up PCI devices for shutdown */ >> + if (system_state != SYSTEM_POWER_OFF) >> + pm_runtime_resume(dev); > > What's the guarantee that the driver's shutdown callback will not > access MMIO regions of a runtime-suspended device? This is something that may need to be audited. I have an expectation that drivers will runtime resume a device before they try to access it. > >> if (drv && drv->shutdown) >> drv->shutdown(pci_dev); >> --
On Wed, Dec 13, 2023 at 7:33 PM Mario Limonciello <mario.limonciello@amd.com> wrote: > > On 12/13/2023 12:31, Rafael J. Wysocki wrote: > > On Wed, Dec 13, 2023 at 7:27 PM Mario Limonciello > > <mario.limonciello@amd.com> wrote: > >> > >> When the system is going to S5 resuming devices is unnecessary at > >> best and may cause problems for power consumption at S5 at worst. > >> > >> Check the target `system_state` in the pci driver shutdown() callback > >> and skip the runtime resume step if the system is being powered off. > >> > >> Cc: mpearson-lenovo@squebb.ca > >> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > >> --- > >> drivers/pci/pci-driver.c | 4 +++- > >> 1 file changed, 3 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c > >> index 51ec9e7e784f..5a6f7a786952 100644 > >> --- a/drivers/pci/pci-driver.c > >> +++ b/drivers/pci/pci-driver.c > >> @@ -507,7 +507,9 @@ static void pci_device_shutdown(struct device *dev) > >> struct pci_dev *pci_dev = to_pci_dev(dev); > >> struct pci_driver *drv = pci_dev->driver; > >> > >> - pm_runtime_resume(dev); > >> + /* If system will go to S5, don't wake up PCI devices for shutdown */ > >> + if (system_state != SYSTEM_POWER_OFF) > >> + pm_runtime_resume(dev); > > > > What's the guarantee that the driver's shutdown callback will not > > access MMIO regions of a runtime-suspended device? > > This is something that may need to be audited. > > I have an expectation that drivers will runtime resume a device before > they try to access it. But they don't need to do it, because the core does it right now, which is my point.
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 51ec9e7e784f..5a6f7a786952 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -507,7 +507,9 @@ static void pci_device_shutdown(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_driver *drv = pci_dev->driver; - pm_runtime_resume(dev); + /* If system will go to S5, don't wake up PCI devices for shutdown */ + if (system_state != SYSTEM_POWER_OFF) + pm_runtime_resume(dev); if (drv && drv->shutdown) drv->shutdown(pci_dev);