From patchwork Tue Nov 15 20:01:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 20529 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2918233wru; Tue, 15 Nov 2022 12:04:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf7INO93nWsl0UKzH3mM/45q3GXy0zhMG5KHfzurtXj1Oe7+q0v3emdNDrMiJIeOM2XH8X0u X-Received: by 2002:a17:90b:3015:b0:212:da2f:1cb7 with SMTP id hg21-20020a17090b301500b00212da2f1cb7mr81091pjb.10.1668542699601; Tue, 15 Nov 2022 12:04:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668542699; cv=pass; d=google.com; s=arc-20160816; b=HPOuTPjyODJImli77xUeXQb/3TMRhum/9iuIyYHlrtylLAJRHrWax46XktPrAvIgMn kyrhlW0cScf0QNJe95R4byI0KkIUJgx1TNotltkYvClJd6eIvVHlUlkLqtueVWxTPJt8 QPObex+nQWwZBrF9XY5DVA3x71uuVdh4XNz55hapSYS8n/f48NXeG3vpyPdOXOsVW6TM w8aUUAzGzWGspsyjg+JvMxAKmt23NSsiiX8K+V5pGE7xLPMz1LzuEFiprTo33z8Fo3iS x3PhzsgWGB/BD7/cOOHFBxIHFI1Q9CpSE+rqw/YyF4aa3t9sKl/YibJBFaSoy9L5H7TM bMRw== 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=mVMMcO3WWf2cCU/0gNI+bRG3BH7aBwwuOUs+gmWh4R0=; b=bx18CHkLy7QOqRJXAZT+d90G0vPGoR8KE0rIRR4ML4JRJZ29PNA97pgDPPctb3sbmg OH0VJSq13UQFyYqrh/uAVQIAk5YSdT8KwKBfk7IE8/gXsOnsFwpsbl29R3+YuPjdJHz0 zhvb/hPPdbkKRC8t8sIrpIbMpQwbjLWe9tOpysWnqnQ5lZaNIdrTMF2ttVzU0d/S9dCr ZCKbXG/u+kjUaavIf1NEwZyCZhnQQ0m3ij9LwBrmHC+15frYJuRBoKFnICkxpI7ggVIL C3r9re1coraP8jQn9asEs7IBtFs+1D63WRoiYpMOOEeahwYfZ0eiEewJyHxHf6B8GLw5 lyvA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lNzk08AE; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g69-20020a636b48000000b00470759f312csi11288153pgc.864.2022.11.15.12.04.40; Tue, 15 Nov 2022 12:04:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=lNzk08AE; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231833AbiKOUC7 (ORCPT + 99 others); Tue, 15 Nov 2022 15:02:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231673AbiKOUCS (ORCPT ); Tue, 15 Nov 2022 15:02:18 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E24B128E04; Tue, 15 Nov 2022 12:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaMM2a7HMASJsZCKApzI0bsl75wKkxild5Oud/59PHjBdFAI7NokQEVlSRiFD0FAC/fu+R2Vv+UFSxdp+X46MAZpkydCIppE7OAk+Vjay3EaGHS03U7MzZyengl4/R7gl4fSc0JU2Yug48hg1jf4DGVzCGmuMicxN/uq96rp3bOK6yulVNhnPgxwlW1a+00i6l+Cfl6gQl1i6vHe4wKA1MkGiRYwbVzPba5jVtIRN0venwL9into56xrovbyXgAizMLHinPaVIz8sk3QH434158ggT5Lldts9KxVSA3EGenOoMJ/h6Te0L9uOQ1+JPtSIn8K0wBjSl62W7VZ0QZR+g== 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=mVMMcO3WWf2cCU/0gNI+bRG3BH7aBwwuOUs+gmWh4R0=; b=KoNq+hlW4qy1X4U1mbzhBh3eJfIqpldUXvqnNDMxjFyjU1NN7BRrQI/0IZUrTCaO+XKND/ch7wjTIlMONqFWvAioBCZ9WMc0ruRTSSymTTSKoVL2Gcr/VVPBTT+XgmB3OmkRQl0NJ08SG05q3UKlrGQnbcf2EHSIdJvhrHnQMRPmTiWjRDsDppYHiMRb/QT8xzEpDZNRdOgPb+abbO0lsnCBfYhxypaxq+bovBiKkMGjwuhojsNjUqart5B2uElWfuFo+GvZAeFBTUK24Wifkg2cMHVk+xqTohqSIOhxufqhoMFWbBnhO0aUJbGPreJ/K/j2lGL+G7PRUpnLvKADew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mVMMcO3WWf2cCU/0gNI+bRG3BH7aBwwuOUs+gmWh4R0=; b=lNzk08AElPweQFTbWtF4wTgYiM9koQutIeXD6ononNX/YHOC/zzJfyP2vja+BVR3aM1EX+LOfyfoPOFqDhO4GfvrB7unrGuo0qQP16r/nj+wfcIONVxeyVdAzqj8dngIuci9OjTOr7n6NfQUjSv3BIwKa6JvJFbCvll/3QyOS4w= Received: from BN8PR07CA0021.namprd07.prod.outlook.com (2603:10b6:408:ac::34) by PH0PR12MB5403.namprd12.prod.outlook.com (2603:10b6:510:eb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Tue, 15 Nov 2022 20:02:08 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::af) by BN8PR07CA0021.outlook.office365.com (2603:10b6:408:ac::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02: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 BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:07 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:06 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Pavel Machek , "Len Brown" , John Stultz , "Thomas Gleixner" , Stephen Boyd CC: Sven van Ashbrook , Raul Rangel , , , Rajneesh Bhardwaj , S-k Shyam-sundar , Rajat Jain , David E Box , "Hans de Goede" , Subject: [RFC v3 1/4] PM: Add a sysfs file to represent the total sleep duration Date: Tue, 15 Nov 2022 14:01:53 -0600 Message-ID: <20221115200156.12218-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-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: BN8NAM11FT039:EE_|PH0PR12MB5403:EE_ X-MS-Office365-Filtering-Correlation-Id: 12b07378-29a1-453e-9392-08dac7444678 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VQnVWq8m6aQ3IVp0IchLkjzeM/f/SjBANXTeHuMT8ItBEVL54DyoI8t79aUo5RTRTXOJa0axCz56yUihWctoW7MqZDybNJZT7znwKtbgw9Pzwv+PsbKPdg6pNF/zN+iYCRvJLqd6x4krWGfEUUDJFqMQKlf5DPZ3wsvITezr4a2gC1j357t62oJP/7XqQVe22YqytHPQK4RavouF348UCCEmgHf3waEFy3xcMzPc3RY4Ib/xiyljRHOPS/yTvP/u4m0cU+Ak2UD9DUVFHxgNYMb/AM7qkU8qNtEL+Ewk8p6l72r17rJQ3qBR4LInzJfbLYpzqPWEk8sSSqToz7PMcd4bhGVpRjtUj7ko++QkxDPaoBOXxLbqDgjD1rVgLREn5q2CaeumdUYgY4A83NI9ZfTKqrEhONToIWpuD8tjn6RnCK3QSctZYwXsmIcrv67EFoLIY2wDKZLl1qFHCM4MbjzFj3UsNqMAxFdMkkYqfnwPXcjqQO/grcQ94fS2VuTdprcF2biiqwpqFG/da2ZlPMDUmdfa4pzuCM+egccPpMzYHTME4OEZTgleX4EfHB0uT5v7JD2dH9Tjnd5/r4J0MevTYRqo7axKqXd7XAYxT0Oxwfd56Hk8umBbF+ESZyITLSLCQZZWkpGun2jjXD/fZ28vIdeqkDSZiBOnFhG2JnVbHg7N1Y0J6j8AXnlXJIVhglQqKdou3vXeNdPAKh5rRWDRJsEBxhCQWtvQcTW5QtqGhnj9zCpnFVTGqdPkr6Lbhyw2eoI1K+r9uuwY2sXgBgaO8wZEhjegjwcHVu5TBpuQ4uDGeQR4gy+HVoQZPMmw X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(39860400002)(396003)(376002)(346002)(451199015)(46966006)(40470700004)(36840700001)(83380400001)(26005)(478600001)(1076003)(186003)(82310400005)(16526019)(2616005)(6666004)(426003)(336012)(86362001)(40460700003)(82740400003)(7696005)(36860700001)(36756003)(40480700001)(356005)(81166007)(8936002)(47076005)(41300700001)(2906002)(5660300002)(44832011)(7416002)(110136005)(54906003)(8676002)(316002)(70586007)(4326008)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:07.9888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12b07378-29a1-453e-9392-08dac7444678 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: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5403 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749593829706748544?= X-GMAIL-MSGID: =?utf-8?q?1749593829706748544?= For userspace to be able to analyze how much of a suspend cycle was spent in the hardware sleep states userspace software has to use kernel trace points paired with the file `low_power_idle_system_residency_us` on supported systems. To make this information more discoverable, introduce a new sysfs file to represent the duration spent in a sleep state. This file will be present and updated during resume for all suspend types. Signed-off-by: Mario Limonciello --- RFC v2->v3 * Drop one of the sysfs files * Use sysfs_emit instead * Fix symbol name (s/type/time/) * Drop is_visible * Use timespec64 type for suspend stats * Update documentation * Update sysfs file name --- Documentation/ABI/testing/sysfs-power | 8 ++++++++ include/linux/suspend.h | 2 ++ kernel/power/main.c | 15 +++++++++++++++ kernel/power/suspend.c | 2 ++ kernel/time/timekeeping.c | 2 ++ 5 files changed, 29 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index f99d433ff311..3abe20c47e08 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power @@ -413,6 +413,14 @@ Description: The /sys/power/suspend_stats/last_failed_step file contains the last failed step in the suspend/resume path. +What: /sys/power/suspend_stats/last_total +Date: December 2022 +Contact: Mario Limonciello +Description: + The /sys/power/suspend_stats/last_total file contains + the total duration of the sleep cycle. + This is measured in microseconds. + What: /sys/power/sync_on_suspend Date: October 2019 Contact: Jonas Meurer diff --git a/include/linux/suspend.h b/include/linux/suspend.h index cfe19a028918..57f29ab4176c 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -68,6 +68,7 @@ struct suspend_stats { int last_failed_errno; int errno[REC_FAILED_NUM]; int last_failed_step; + struct timespec64 last_total; enum suspend_stat_step failed_steps[REC_FAILED_NUM]; }; @@ -489,6 +490,7 @@ void restore_processor_state(void); extern int register_pm_notifier(struct notifier_block *nb); extern int unregister_pm_notifier(struct notifier_block *nb); extern void ksys_sync_helper(void); +extern void pm_account_suspend_time(const struct timespec64 t); #define pm_notifier(fn, pri) { \ static struct notifier_block fn##_nb = \ diff --git a/kernel/power/main.c b/kernel/power/main.c index 31ec4a9b9d70..f33012860699 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -6,6 +6,7 @@ * Copyright (c) 2003 Open Source Development Lab */ +#include #include #include #include @@ -54,6 +55,11 @@ void unlock_system_sleep(unsigned int flags) } EXPORT_SYMBOL_GPL(unlock_system_sleep); +void pm_account_suspend_time(const struct timespec64 t) +{ + suspend_stats.last_total = timespec64_add(suspend_stats.last_total, t); +} + void ksys_sync_helper(void) { ktime_t start; @@ -377,6 +383,14 @@ static ssize_t last_failed_step_show(struct kobject *kobj, } static struct kobj_attribute last_failed_step = __ATTR_RO(last_failed_step); +static ssize_t last_total_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%llu\n", + timespec64_to_ns(&suspend_stats.last_total) / NSEC_PER_USEC); +} +static struct kobj_attribute last_total = __ATTR_RO(last_total); + static struct attribute *suspend_attrs[] = { &success.attr, &fail.attr, @@ -391,6 +405,7 @@ static struct attribute *suspend_attrs[] = { &last_failed_dev.attr, &last_failed_errno.attr, &last_failed_step.attr, + &last_total.attr, NULL, }; diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index fa3bf161d13f..cb0f72f52528 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -423,6 +423,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) if (suspend_test(TEST_PLATFORM)) goto Platform_wake; + suspend_stats.last_total = (struct timespec64) { 0, 0 }; + if (state == PM_SUSPEND_TO_IDLE) { s2idle_loop(); goto Platform_wake; diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f72b9f1de178..f9c8cfef8fc5 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "tick-internal.h" #include "ntp_internal.h" @@ -1698,6 +1699,7 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *delta)); tk_update_sleep_time(tk, timespec64_to_ktime(*delta)); tk_debug_account_sleep_time(delta); + pm_account_suspend_time(*delta); } #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE) From patchwork Tue Nov 15 20:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 20531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2918364wru; Tue, 15 Nov 2022 12:05:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf5UmUKIn9djy2Cgn9bI/QO4mv/ZDkgXqx4V7olrX9foz4zHlBbK+6Wn6deLm27jKAQ7UpWd X-Received: by 2002:a17:907:765c:b0:7ad:49b8:1687 with SMTP id kj28-20020a170907765c00b007ad49b81687mr15352181ejc.407.1668542713646; Tue, 15 Nov 2022 12:05:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668542713; cv=pass; d=google.com; s=arc-20160816; b=vnJ/OFllkC7C0K+p5/CXlDiiVhYBXqxzI56bCZQ0yW3awz1A2BIY3ov8r4bo3ihhxV ZvDSspOXp046yeImPZS9kGqRY7yUvRnRzZ/GHaXPSgKvhsuYCLEs3knOGIVl1APr8iwX zRoFZDRMgoTke3cmjqz7m53c+MT7NRCtJGpHqPyReP42MCGznBNItRlrL5ANtFTYx3cn nytiuNPFtzHgYgEinDurNrGjECCIf7HHpY+wYi1KrsUdg3CpOICJ8BUP5ABv81njX1h8 kMv6O7ut6rW9yHqmIfeZE/7rPCkEiQ83UoQHjEZwDDKyXW9GJrAW/EkXuz9OdLizoCFB F0zA== 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=BbxBwp6dZXD3CCBU7jCaZkP7td2hc0GmCq8O9URT3qg=; b=bWOwYZ55lKN41bFisaHQWPFcum3vQcbkDG2CjP7xPuvtOJvUG51SE3LXNQHibk0gBP gFaMmU0TLcwPAivqARJqgPmUE+JmOy7Zi6Whi6Vo5Y4dtzor6qkHDuKqfqD3fvAm/QoC 6uf8mscBACl8ikgGs9oreVgZ8sM5aPqUpG1BjvXLLxoVwglrJP1PtxD4dLW1E+yFuMo3 AFa8rXfNKurxA+hnWlC8+hsxNvTtf4Vo3EuJ+KxsnD2EyrrknHTaY4BAXt5CW9YbUcz3 txtT/3CFL4SI1DXU1PfxPQAASQyAaqKh3NmhyYkS3w+nA676gAPiA4ktMtUqq9Y+Z+Tq 958w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0g0ylU6A; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf29-20020a1709077f1d00b0078e27ef9501si13292492ejc.750.2022.11.15.12.04.44; Tue, 15 Nov 2022 12:05:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0g0ylU6A; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231669AbiKOUCi (ORCPT + 99 others); Tue, 15 Nov 2022 15:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbiKOUCM (ORCPT ); Tue, 15 Nov 2022 15:02:12 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C666928E04; Tue, 15 Nov 2022 12:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ac7q4iwTAQvZrTF+M4dUbfVESK27INcQm7dPUS2qkopyEkZNa32ckVQ4D0Byp8DxNdcpD70GKtHEN1xKCqlQpkhnvAKrU/iQIaElfxM2h/bC+tFBfAX4lGPTza8e+lwpuDSjUXaJ61lSxlWEEpqdo2DKzX4svu641NjQBcgqCOk4CXRSxz1dcPElZLQcwP4196jqDA1Z73jRIQVIVfF1cmxGaoiPEGEHy85lxlXuAejzK/XRzOP+1hpvuFwq5fGdqxZw7ER2lp+F3jfXunqfS36q++AgcdzQfLzZ7QL9qURGaTGz5dv8wqYECMRBZ6LMNxfqnHUvVaCXlKxOgjwm7w== 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=BbxBwp6dZXD3CCBU7jCaZkP7td2hc0GmCq8O9URT3qg=; b=XpE1UZMZuj966l/s5T16xmjuAavVV+q2AQ+4NWd6rWYmIfVb11qTUumkHx6k8wef7QtZYOcv1bKYiprreuBVVD8snj2a5bm7u2k1HCyjxDlZ8NeA6OilstbluWoT3FbVZOQHMv1csWri8sfYJXrVT9+pPG0JHtWtD6xRv92XoaLDobHVS+eP+CHyFGFj1YVYOw1IMnryjuPTrDW3gcP9cH0Zf9v5xhl4AugfpsPTHEdMxXcYEdpIAr4BzOc259enyR72lSTqqBKZm6y9Qp9sv1XbYeKcOyVhQsM1tC1Pdn8vDSAGk/UslFt7TdpAZ2LqJsTvIbtJuhnqupk3utVsfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BbxBwp6dZXD3CCBU7jCaZkP7td2hc0GmCq8O9URT3qg=; b=0g0ylU6AK9fRKJnUjO74EWW4gI8bkJza5w1nOGGp91ugyq46Lhfa7qRtoiA8tlQPv2LdByrZW5qEDDefcXNrj+Q4A1H/qsBpTPhqliwyJA8J5VjpoO2WG3VlZ3Dyv+Bl7BfGrFfXNQAXxWWF7b1QwrgAtjgFKLZDxVRJBj66Uhk= Received: from BN8PR07CA0015.namprd07.prod.outlook.com (2603:10b6:408:ac::28) by SJ0PR12MB6710.namprd12.prod.outlook.com (2603:10b6:a03:44c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 20:02:09 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::fd) by BN8PR07CA0015.outlook.office365.com (2603:10b6:408:ac::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02: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 BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:09 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:07 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Rajneesh Bhardwaj , David E Box CC: Sven van Ashbrook , Raul Rangel , , , Pavel Machek , Len Brown , John Stultz , Thomas Gleixner , Stephen Boyd , S-k Shyam-sundar , Rajat Jain , Hans de Goede , Subject: [RFC v3 2/4] platform/x86/intel/pmc: core: Drop check_counters Date: Tue, 15 Nov 2022 14:01:54 -0600 Message-ID: <20221115200156.12218-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-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: BN8NAM11FT039:EE_|SJ0PR12MB6710:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ff52443-d5e3-4744-4f5a-08dac7444718 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cUYSV5DCsWj8Zgc0WYhFwAkGFAbKC85CRpIIMx0/zGFLSdwFLVnaKm4cbBiHVAYL3l5LligkqWp7mteOBIzyc6B64MeseeqgRSXT4Gy4DKmjx3pRQVNT0XT7r2F1V1n8lDQYdCR3PwCPaTWVYx81QExiVptAdQhcam8vwzwEjPNzCNIOZsq94ZpShpglY6XTdJAQKwfhIOfPw73ko51gm3dLYVzDzu5v1QGDLZorWiIFy/LZt0b1dGECufcUAmqRc5798FvsF0GUdK7F1Mer3OYyVHvw4oel3YD2PFhCX2m+s+e7wjmyQgZqp3aST75n5fjJTVzh744fhq4DtXb+vjksuOxff93MjELXe1df/1QtoMqs+UZX+tNxC1DLsGA5mdOYdd3sznclENVSklRQ/BGRm9DyUdc8EreUijEcru2foXsxpE7ft9gzjVi28J/XjpZVLnU80SEgQ2OO1E8w9C/TZ++YfKBjOGi7F6ZUb+TjXrkeqntz8WctevuRACC7d4w0yuLaC/6pPD2o7MoEbBMwAULGXtG5dUrB66S9ML4ieN5k1+BaWxx6qiJ7eMNDvZNO1A2fORmzfpA09TCYfBzo7IE2WhRExReNF61g6aQXvggLgZkriMs3RjCinDI4g92VztMp/HpWIVZSQLt8sgKtl+EoyGaPGToypEYvtqkiTjRFapngR1Qc4SbGGQwyQBFlWerpra4OMfMDpSfyo1Kkf7DShYjptYCQ301Wi0mxRyR+4RZqRJbNRh1ge681sLpQButHW1WBtMkLK+Vbmso9y5dXiafNhIWvsPthVGM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(86362001)(36756003)(2906002)(36860700001)(8936002)(44832011)(7416002)(83380400001)(426003)(186003)(1076003)(356005)(47076005)(2616005)(82740400003)(81166007)(16526019)(336012)(110136005)(5660300002)(316002)(54906003)(478600001)(40480700001)(8676002)(82310400005)(26005)(70586007)(4326008)(70206006)(6666004)(40460700003)(41300700001)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:09.0356 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ff52443-d5e3-4744-4f5a-08dac7444718 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: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6710 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749593844560293173?= X-GMAIL-MSGID: =?utf-8?q?1749593844560293173?= `check_counters` is a stateful variable for indicating whether or not to be checking if counters incremented on resume from s2idle. As the module already has code to gate whether to check the counters that will fail the suspend when this is enabled, use that instead. Signed-off-by: Mario Limonciello --- RFC v2->v3: * New patch --- drivers/platform/x86/intel/pmc/core.c | 7 ++----- drivers/platform/x86/intel/pmc/core.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index 17ec5825d13d..adc2cae4db28 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -2059,8 +2059,6 @@ static __maybe_unused int pmc_core_suspend(struct device *dev) { struct pmc_dev *pmcdev = dev_get_drvdata(dev); - pmcdev->check_counters = false; - /* No warnings on S0ix failures */ if (!warn_on_s0ix_failures) return 0; @@ -2077,7 +2075,6 @@ static __maybe_unused int pmc_core_suspend(struct device *dev) if (pmc_core_dev_state_get(pmcdev, &pmcdev->s0ix_counter)) return -EIO; - pmcdev->check_counters = true; return 0; } @@ -2113,10 +2110,10 @@ static __maybe_unused int pmc_core_resume(struct device *dev) const struct pmc_bit_map **maps = pmcdev->map->lpm_sts; int offset = pmcdev->map->lpm_status_offset; - if (!pmcdev->check_counters) + if (!pmc_core_is_s0ix_failed(pmcdev)) return 0; - if (!pmc_core_is_s0ix_failed(pmcdev)) + if (!warn_on_s0ix_failures) return 0; if (pmc_core_is_pc10_failed(pmcdev)) { diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index 7a059e02c265..5687e91e884c 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -316,7 +316,6 @@ struct pmc_reg_map { * @pmc_xram_read_bit: flag to indicate whether PMC XRAM shadow registers * used to read MPHY PG and PLL status are available * @mutex_lock: mutex to complete one transcation - * @check_counters: On resume, check if counters are getting incremented * @pc10_counter: PC10 residency counter * @s0ix_counter: S0ix residency (step adjusted) * @num_lpm_modes: Count of enabled modes From patchwork Tue Nov 15 20:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 20530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2918297wru; Tue, 15 Nov 2022 12:05:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf75/C+LFUuMoQHxyIJ3Hqn5PsnjVZR0L5I6E/YkP9dqzYQK8X4kobmCQkqqqrfOduvHG+Xd X-Received: by 2002:a17:906:b45:b0:78d:b65a:aabe with SMTP id v5-20020a1709060b4500b0078db65aaabemr15502204ejg.5.1668542704896; Tue, 15 Nov 2022 12:05:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668542704; cv=pass; d=google.com; s=arc-20160816; b=oTKTc515WiB0989mpl0qtcV2AsAP5pzIYORdS11rOS/R4yUDUNSJ/79F6+u8i62RXW Pssf0rv1URtA7hfHszbzp4vAILa9workezq5dBnzfcvHFQFjKYagYY8BD+qk+t3ZqN7C mF0nFkJyjh91dJ081Q3xU4PiL8ajgGrbPNLbG+r4TnP2YGCHHplOXYHviddCxfXcOIv1 zkBV0TkE+l5LyT6X4BGyQfzRQg5a+a3wIUUa3tk5QarH3mxZ2t/rlcMO78qAXzIy+E// ka4duDeiopUz7IzNiRw9LSA+wKCJX3XWwaOO8WFq0oGvASodKnDuXloijbygju/USSp5 K9Kw== 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=jR4HJCIssg6ApayI+7cqqOPLB8XH6rZSsae7Nm9cJ7I=; b=L6po7Hj0tj8ltDjAIgaXE1+6Cv7VcfJtXrSf+ezWKAtZNthAQmbkH8w+GohUPfBTxH e2EhptpZu4BM/xfWYmKr5IquehWvcsxKwl9dskyJxmMhUUVGcK8v608CIbqxYOjZlSgc wTDQ+bxdtGEplR4+IO2tYMosOaDYcAgy5VSHaQnGPVNMlGJSTNQev/BVNnbEB8l/95Dx KGi/XaGbbgyPXOZD6mFWVg578/Q7vepzbHExK93hpUzi/RFkOF8mjL3dFuH1OViHdCt1 +KIvdeL/XhQRyTVxNUL5dFW8040Gk8WxvCsJ7JQGYtWCPPkgB9CcMjAaVv+cZiIeJs8q 1juw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TVUlygJm; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp14-20020a170906c14e00b007ae6f13645dsi13891171ejc.498.2022.11.15.12.04.35; Tue, 15 Nov 2022 12:05:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=TVUlygJm; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231783AbiKOUCu (ORCPT + 99 others); Tue, 15 Nov 2022 15:02:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231645AbiKOUCO (ORCPT ); Tue, 15 Nov 2022 15:02:14 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F00A28E0D; Tue, 15 Nov 2022 12:02:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iSswiwgBwZqeyJvN9ecdAMltKJOUtnSaCZ3Iw35Qd0UqzBFsK8j+g6xfYWkKcO6HR9A9SXuY63tu17iRhyheoiLW+hGciDti/VsdnSBlKSVyfPh9hToIM1ANNHEW2AJ56yF0yvw66QhWNGsN7UNcIDGl1ddN5DjSc9Zz38nMoV2xlUqjPQqCDEkKtF1ntOFwjirVUh4tLZLzyFGLVmNX5HV+XEDUj+9VFxehzBPLe1WAxO9zjWcWkd4w8Qxx3GJglZCkfeuO9g06IKT3zQnFtXDlpPrt9FvKw18e1+/PFZA6jeUE1pmWB4X9Smga0DOuoE4qnXAq/L98BOF/TLO3nA== 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=jR4HJCIssg6ApayI+7cqqOPLB8XH6rZSsae7Nm9cJ7I=; b=Nh6eMXn7tGr207pBeI+1OEifUFGpiB0eB2IVfPwCzDhFcC84aroH/hpWBMHRDsJ8/dhZcelLIhNFQz6QB29kK8Q1jPolxuu6ZD+c/gyMbsxnrGX2in5IL1QmO5exfmb8fgnB4T5bYAAm74MmxUOL39zTHp8qORXCaP3uG96pHt9hNzbjHFAQD+KLYuXTmSIeWeH0mKj4QwB8wK6YUui/Q42QnGKLE1R6A84owA5xoplWi8QTpA1QkKoLLyoeBEUpfe5oDRV8OutmN3wfJ7iAv1XRsxtl+AcifGSCG3X0gWaJO950M+P52tsrFy8B59BU9Z/JIeayDhgWURl0KxLEig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jR4HJCIssg6ApayI+7cqqOPLB8XH6rZSsae7Nm9cJ7I=; b=TVUlygJmdgvBv8+UQPoVEmIRkZ2Lzzq5cBdgU73nlZTaAnw+yYsUWGNEovTTftqZKUhKRCeFaY372MNNNxmN/XyVv/AZ4GWMrCdzQz5/mUCPBzYt2BP2QgT5ho+iA+juMVsHLnLMvTKBXhhLvOLoiY/esyewxebRpbIaxgZpUTs= Received: from BN9PR03CA0247.namprd03.prod.outlook.com (2603:10b6:408:ff::12) by CY5PR12MB6384.namprd12.prod.outlook.com (2603:10b6:930:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Tue, 15 Nov 2022 20:02:10 +0000 Received: from BN8NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::99) by BN9PR03CA0247.outlook.office365.com (2603:10b6:408:ff::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02:10 +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 BN8NAM11FT114.mail.protection.outlook.com (10.13.177.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:10 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:09 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Shyam Sundar S K CC: Sven van Ashbrook , Raul Rangel , , , Pavel Machek , Len Brown , John Stultz , Thomas Gleixner , Stephen Boyd , Rajneesh Bhardwaj , Rajat Jain , David E Box , Hans de Goede , Subject: [RFC v3 3/4] platform/x86/amd: pmc: Report duration of time in deepest hw state Date: Tue, 15 Nov 2022 14:01:55 -0600 Message-ID: <20221115200156.12218-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-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: BN8NAM11FT114:EE_|CY5PR12MB6384:EE_ X-MS-Office365-Filtering-Correlation-Id: b439e362-1d89-41ae-cd0c-08dac74447e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D+NAMeEtuA2U66AkPvlUTce2m9kXAAwn2Wv2OSJNWmQ8nKsBhNcLt0ympTMzWA+bFYBpHFFMWS/YHXu+Xrce/ZvUsEPadPANmZlNgb8Ws4fjdp0Oq/RW8Cu1XfN+SQyPx6HfJfc/X7qR54Ne4Ienx/YSipvqwqGURaajfEfzvBG7Admzx+Zv/rif4DdKr7lu9nnsW2GVhQPTP9zPZi/4eRDLmz8XbC0qDvoEVaEs2yHQL/dDR0gczbob18XpfIAMqVZDDzWQdECDglsqzjTS9OTknx2Zt0bZkLc0IkGVM22+ALfLXZ5au17e+pmJhWc/tbDCsfMVQPyAk3frHXZCyJpl8AfS7zh0tF/eJ52Q4WNZwviLY2iB8SqXWNRUW7emuJBddwtzEzvw14gMf7k51PEZ70RK2l52CBJ430ru1M3QK3yX2BSL292G9n1UT/fanrZREfpljehX1L8f36/X765c049nxgpvTlEpvRUCvJKYZCc/PPEw7augidt4+K1aTJxjidn3ecTlK57/hN3dwpHMnI02Y1C4b4pAS3AtSyPpEaSWdLzRst7SBFPuPHd/yBrQHHWzwaHidIFtmdLXXkqwxlV/r/W1bWS4TxMnVP2bKcpEDhjy4F/9F77aSuQBIHn0Bimgesdd1UR15KQilu+heKpQhWwTErSR9vKyxQDqXNvJXYw3FMer3WIM8EGpmBKI2jiUv+lnqVO+L9p6QSzqZoGd8kKuF3+cN7lDXcubCVCBsf1LW7FVPn4L2XQrG2cHuH0oAR7ElYv88FuMH9D3aefR9fe7xzGNkjPy+clseGxf5vGu0JqdLhQb7dFQ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(41300700001)(186003)(1076003)(40460700003)(2616005)(7416002)(5660300002)(16526019)(336012)(2906002)(8936002)(26005)(316002)(8676002)(36756003)(70206006)(70586007)(4326008)(110136005)(6636002)(7696005)(82310400005)(54906003)(356005)(36860700001)(81166007)(44832011)(82740400003)(83380400001)(47076005)(426003)(40480700001)(86362001)(6666004)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:10.3692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b439e362-1d89-41ae-cd0c-08dac74447e3 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: BN8NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6384 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749593835361963187?= X-GMAIL-MSGID: =?utf-8?q?1749593835361963187?= amd_pmc displays a warning when a suspend didn't get to the deepest state and a dynamic debugging message with the duration if it did. Rather than logging to dynamic debugging the duration spent in the deepest state, report this to a file in sysfs. Signed-off-by: Mario Limonciello --- RFC v2->v3: * Create new sysfs file instead of reporting using kernel symbol --- Documentation/ABI/testing/sysfs-amd-pmc | 6 ++++++ drivers/platform/x86/amd/pmc.c | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-amd-pmc b/Documentation/ABI/testing/sysfs-amd-pmc index c421b72844f1..89354da8e680 100644 --- a/Documentation/ABI/testing/sysfs-amd-pmc +++ b/Documentation/ABI/testing/sysfs-amd-pmc @@ -11,3 +11,9 @@ Contact: Mario Limonciello Description: Reading this file reports the program corresponding to the SMU firmware version. The program field is used to disambiguate two APU/CPU models that can share the same firmware binary. + +What: /sys/bus/platform/drivers/amd_pmc/*/low_power_idle_system_residency_us +Date: December 2022 +Contact: Mario Limonciello +Description: Reading this file reports the duration of the last suspend that + was spent in the deepest hardware sleep state in microseconds. diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c index 96e790e639a2..2550ba6d28f5 100644 --- a/drivers/platform/x86/amd/pmc.c +++ b/drivers/platform/x86/amd/pmc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -363,9 +364,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev) if (!table.s0i3_last_entry_status) dev_warn(pdev->dev, "Last suspend didn't reach deepest state\n"); - else - dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n", - table.timein_s0i3_lastcapture); } #endif @@ -417,12 +415,30 @@ static ssize_t smu_program_show(struct device *d, struct device_attribute *attr, return sysfs_emit(buf, "%u\n", dev->smu_program); } +static ssize_t low_power_idle_system_residency_us_show(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct amd_pmc_dev *dev = &pmc; + struct smu_metrics table; + int ret; + + ret = get_metrics_table(dev, &table); + if (ret) + return ret; + + return sysfs_emit(buf, "%llu\n", table.s0i3_last_entry_status ? + table.timein_s0i3_lastcapture : 0); +} + static DEVICE_ATTR_RO(smu_fw_version); static DEVICE_ATTR_RO(smu_program); +static DEVICE_ATTR_RO(low_power_idle_system_residency_us); static struct attribute *pmc_attrs[] = { &dev_attr_smu_fw_version.attr, &dev_attr_smu_program.attr, + &dev_attr_low_power_idle_system_residency_us.attr, NULL, }; ATTRIBUTE_GROUPS(pmc); From patchwork Tue Nov 15 20:01:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 20533 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2919245wru; Tue, 15 Nov 2022 12:06:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf6OqQf2FUv1QxgX6lGDXluhQ1Hf2NEIi3rc7dUySGQziXXAa+2Al+jr7rWlv163MqTHZy8+ X-Received: by 2002:a17:902:7616:b0:188:b943:2e1c with SMTP id k22-20020a170902761600b00188b9432e1cmr5629860pll.43.1668542813791; Tue, 15 Nov 2022 12:06:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668542813; cv=pass; d=google.com; s=arc-20160816; b=DgstOUGN3qu60pjusDi66HqBNjFQOegutHtO5C0DYs8/SXc46cUdan3Af1Y9MPQtQa nrKlpObDxdO16wz+VHZMESsEjF7acgHdwrWCUBRXNFe1z8g7jYIy8ToXmEbMJTd0o+wb /WW1MFlt4K5/xLA7nrVs3sJM4Y+5BsevcNJN4rLxmYjNNRT9FLyQXXpKoXC1ZtBzswWz W5YvmEdOh5rn5HlA7SM1OSvY/xERK1e/mnKQ6Bb5CEzBKJYpPXvuzY8AzXXOtlHbK2eD rRE8Pq7XaJi7OrtU+B8XXFFHk/NMETAYPt31uq06eVsOMKzwwNgT+qHd5aJjzSrRoxOe A2rw== 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=g/LlIZAzwS1vA6Wr+INKY6X3OCIIC7ZpX7j9iNkdunM=; b=LEjVvIyQvy5eZ3TO/u62OWHMnIQ0kyw83svDt4AlxmvaWyfrNbFFTwZ7sBsdwUyFXt QVEEG5z85/Mk9ho4/rng0dnWhLGuJFYdz3oOKqTVDZ3UUp2mX93BIIKzReWFd76i3rRu RPg71oeVDir3I5zZJOPaW1Lj95PSEGHwU0sQPr2+ap+64Zy90DL6MHmAu+l/+QFUuGoH 2DNPjoYr0nZhsS6fZ5PA9/L481rswxcu19vU/XZ2JF422jRi9mi798qqPqOqyQM7JJBn Dis9e4dk1halg5m2OaSmSzLiyp/yedFBFXf8koBZfVy+Bh36GP+/S+8vsO5woS+ln+DK x55g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Nb4lnqev; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a63e802000000b00430b00f507dsi12998283pgh.430.2022.11.15.12.06.40; Tue, 15 Nov 2022 12:06:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Nb4lnqev; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbiKOUCo (ORCPT + 99 others); Tue, 15 Nov 2022 15:02:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbiKOUCO (ORCPT ); Tue, 15 Nov 2022 15:02:14 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2087.outbound.protection.outlook.com [40.107.237.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0393028E1D; Tue, 15 Nov 2022 12:02:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MnFdqihg1xunfjLgUxznC4rlQINbYOuauyTT/dkp3qI5JjSfnAqcunQEeKM6ndpnWjY2YGLDFQANuK9RpVCcToO5UgQlJBAg/aRzxyBdcjAMDu4bhH3SYo5Oz9pVNk2wQDQZ2LjuPy1W7TFnXfkHsFOOvi/EwBUPEXMbh+n/kldz+U8Dg9ONM9EptGFWKr6ar/3doAaVyUVYM2ZGkA2tOlgXhlRmd54kKMaA0FTiDr4jBkZSzvuDXN95a6x5ppIcdqGPKfDVPmgnJ7BemFkF7svkkA4y+elDg8393oGQsznKS/NCAh7fxah6XRzzvSQzYYJMTz6U6PVfblteALH/uA== 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=g/LlIZAzwS1vA6Wr+INKY6X3OCIIC7ZpX7j9iNkdunM=; b=gJcdIovSRO7MbPK0WWIRRKIpSpaimcGMtkwD0vJvydW0ZWRmyNDF7gNyYi/DC3GTmmuD2EEtTIA8PE8OgJj9fzCRzGvyJWFAcc2kuTNimvl+WmVZCxbirWU0F0Df9ZlZAneEw6qSbmxIk7dk0llm5c+cO8MDRm/BGfkW3NBSLMWXBb/w6Jnge2lo2WXcJTFAgbn//Itn+VyI/R4pyZW3SkDrDIKTB/wJmvehYUbj2fv4s2hbUObCaRiBwC4bWb03jUId3PCUEPUeWExRznUgM0tgSo0Ezn5SAA3hiqLknjbT8ZdPeK84XMVhldCT/MYmJ0ffCGO5JWV+QUOitnabtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g/LlIZAzwS1vA6Wr+INKY6X3OCIIC7ZpX7j9iNkdunM=; b=Nb4lnqevNkS2q+SHndCnMjlUvI1f2X861CQr1GfNW7pcx541PnxY9dFi/fiSip7NLxZHWSzlEQlkHQKDiWWNXIcIAxBN1U8jJmb9D0EifWH2cqDK/cvNrv1yAXc6mAE4SkH5qe1T5oHeFqmgu97h7omoocTTxfYenX/JewbOgBs= Received: from BN9PR03CA0262.namprd03.prod.outlook.com (2603:10b6:408:ff::27) by IA1PR12MB6092.namprd12.prod.outlook.com (2603:10b6:208:3ec::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Tue, 15 Nov 2022 20:02:11 +0000 Received: from BN8NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::8b) by BN9PR03CA0262.outlook.office365.com (2603:10b6:408:ff::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02: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 BN8NAM11FT114.mail.protection.outlook.com (10.13.177.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:11 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:10 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Shyam Sundar S K CC: Sven van Ashbrook , Raul Rangel , , , Pavel Machek , Len Brown , John Stultz , Thomas Gleixner , Stephen Boyd , Rajneesh Bhardwaj , Rajat Jain , David E Box , Hans de Goede , Subject: [RFC v3 4/4] platform/x86/amd: pmc: Populate cpuidle sysfs file with hw sleep data Date: Tue, 15 Nov 2022 14:01:56 -0600 Message-ID: <20221115200156.12218-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-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: BN8NAM11FT114:EE_|IA1PR12MB6092:EE_ X-MS-Office365-Filtering-Correlation-Id: 5336b950-424a-4f88-982a-08dac74448b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lE00Ir5w9+rmw6DMY4EYEVnKk2UcNIdcYXu0E6tyQlNfpIJOXzXC+wROnDcTyuBjqY8OsiqNW79GEN7N71sJTNehfn5Vo444j2v7/SdA6RI5aNdrB7kBFR5vUaQH/oornYk88Ok7KAgHX7tlTSV0ABYpEZGeYZycQh4pXloQvGPjyGtJDhfvXi4BNltiy/sUwOp+S/vzrl0mZAEuUgU2pBFoaXlRDhKJGwtrvYtyVyQbZHZD26QIS3MBUBLnFZqT10pG1iapXNginG7JWocbp3jgXTZaibTiXXZqjL7UhZCohaXejKGrtJWdfbgCBu1D/Xd5w9aB5PuVd2aAz9Vxe7gBuov+Ak7vM9/vJWnVR8vngBDJjDvdkBdRQRzsRYJqOiq0DqPTbfKbwqspnoe3wudDAmpZ9rS+3R0nrffdiLA53WfTfRDa0YmZMmmqFK1Z251VNvWOn3e9bYZo7jB4zaf4Vef8Is9KiQaYPlIxLn+DYTLjxuh0Pdn72UjuiQ5qDAei7uXyPXqwnxx10ZL8da3a3s+Ci1Xzm7ThHbFE75gr6kN5J9zporq9QhCH8P/8NPY3PEYI8Cqu/HFzLOHc6Fo1aPE/j/4l+rleU5OcNlGb3u9vcLnfgk+/izZorzuLeKFq+9mepob55fD+whL+X3crZTTzBx7/PY2FBggRDqE1RVT8nbqbJJ+Cr0+icFsje9cJpt/89zGRonzelvEFks8sr3NQopbgKUdVyR30jvrnZsWrE5xRThiG+yy19Az2ufRimWiGgh3mQllYWywJn27UNbquFBRIL1aBhYu4c73tbj44oVSE3r4Go+QFqY8a X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199015)(36840700001)(40470700004)(46966006)(36756003)(82740400003)(40480700001)(478600001)(82310400005)(83380400001)(86362001)(36860700001)(81166007)(2906002)(40460700003)(2616005)(426003)(47076005)(44832011)(26005)(6666004)(8936002)(16526019)(5660300002)(356005)(7696005)(186003)(7416002)(1076003)(110136005)(54906003)(8676002)(336012)(316002)(6636002)(70586007)(4326008)(41300700001)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:11.7441 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5336b950-424a-4f88-982a-08dac74448b5 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: BN8NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6092 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749593949707017142?= X-GMAIL-MSGID: =?utf-8?q?1749593949707017142?= AMD platforms don't provide an ACPI LPIT table, but the data about duration of time in a hardware sleep state is part of the SMU metrics table. To allow userspace to query this from a standard location, export this information to the standard `/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us`. Signed-off-by: Mario Limonciello --- RFC v2->v3: * New patch --- drivers/platform/x86/amd/pmc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c index 2550ba6d28f5..ef5c23df1a5b 100644 --- a/drivers/platform/x86/amd/pmc.c +++ b/drivers/platform/x86/amd/pmc.c @@ -787,6 +787,11 @@ static void amd_pmc_s2idle_restore(void) /* Notify on failed entry */ amd_pmc_validate_deepest(pdev); + + /* Silently fail, if cpuidle attribute group is not present */ + sysfs_add_file_to_group(&cpu_subsys.dev_root->kobj, + &dev_attr_low_power_idle_system_residency_us.attr, + "cpuidle"); } static struct acpi_s2idle_dev_ops amd_pmc_s2idle_dev_ops = {