From nobody Wed Feb 11 22:55:50 2026 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 8213EC77B72 for ; Wed, 12 Apr 2023 19:50:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230209AbjDLTuQ (ORCPT ); Wed, 12 Apr 2023 15:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbjDLTtr (ORCPT ); Wed, 12 Apr 2023 15:49:47 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8132F72A9; Wed, 12 Apr 2023 12:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fg1h/Z5iTSTYA8XIeYs6RUYIRzHAVb1J1xDj95ZVy0eT7MBGshJY7aoDYWijkALoUxwgYmqw2y8pcIQTgPMRHAAPCAFhYg1RgArj1IpuEZxxvDOsqefRl8L8OrkaX+Y9EHUDwnaO+E6ccuBZKhNnFHQdP3nJpgrXWM23Z5prACxsiNM0qJL7c4Or1A/42AlNDjFPILE8svv0UJGqS2AqjKppycRBFHKWBmllTVdNx6I/PUQRsCQ5wzNO5JIl/V+q68Q7ZEXnvLQhocg4hCp6+V0Khg+Q+kPylGxI/BXcR9mjqyyeHS5+0RxMfSYTJMLXs/qzu8yBTGcl9z3hKZqPMg== 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=ShWWw2wVhhkH4z6IvzIsoi7Ih8udnCG50Wc55BRZPCw=; b=jmcvcJpwz09HCx5YKtjAP9W8gCND55bVv/4VOkYQ+r1N6x9m06kOgxHXIqIz1hzhAjDU79OdAUwGo7Qmcmeh3hyTp6EtupVo+wTd1MY9D42Ip+bPCWpuVOrKq8chqDERYw7GmqHpnLH0bYtgPhGEZlbIUsiCnEdvX6VFpxKo0IqYScz221UJGe7Du0ksS8igSmT0GYlKzLYBv4S4McgBQqchrVkmZsQ25J0vPErSHkPQM5cVAMv8a7N3SPUly+K/9h1EVHc5tYxR2mS4WaA7emYKPctJl5XmE5K31jK0bzJbEj2ATvuHlx6b+xFFHCsALeYVOHy3O1ghVrtClXxVIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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=ShWWw2wVhhkH4z6IvzIsoi7Ih8udnCG50Wc55BRZPCw=; b=FqOB5e9AvuK7VUYkvJaAWDNnJTrfZSLJ7x37OsyuyBPKutU1hPzgUjHfyCkQtQ6AB4Nz1JrWhnTN3Ix0jVL+AjYVsVtQeeCvgGq5EhD6f/C7KVAlJ47FI+8c/VYYdaotKboreutg4/haF0RXeILwM7VbRD8m8tFxT/woEGzugWw= Received: from DM6PR06CA0045.namprd06.prod.outlook.com (2603:10b6:5:54::22) by DM4PR12MB5913.namprd12.prod.outlook.com (2603:10b6:8:66::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.36; Wed, 12 Apr 2023 19:49:37 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::1d) by DM6PR06CA0045.outlook.office365.com (2603:10b6:5:54::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 19:49:37 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.31 via Frontend Transport; Wed, 12 Apr 2023 19:49:37 +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; Wed, 12 Apr 2023 14:49:33 -0500 From: Mario Limonciello To: Box David E , , , , "Rafael J. Wysocki" , Len Brown CC: , , Jain Rajat , , Mario Limonciello , , Subject: [PATCH v8 1/4] PM: Add sysfs files to represent time spent in hardware sleep state Date: Wed, 12 Apr 2023 14:49:13 -0500 Message-ID: <20230412194917.7164-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230412194917.7164-1-mario.limonciello@amd.com> References: <20230412194917.7164-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT070:EE_|DM4PR12MB5913:EE_ X-MS-Office365-Filtering-Correlation-Id: 1aec9210-6ccd-473b-0b4e-08db3b8f0c4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Eftf5+JUKxiBMA62Aw/JJvooY8ext03p8JlCnVJy7S3J7MqDG0ARpm6nenN+lrgHlEbQ+T2AUtiICYGfqqzryce69rRxpMQP5L+lVFFNrjQveotxvAie/gMSbui0P1dDa6JzDn79ZFVjwD5EUyt/Nw2ACvvxk4kH4LG3r/j/fFJ9gxrBDibVlgDURUTnihKcJnzPU7HQvodkXXTWhwbDgY8nXyfSL0xgAKzV6wZxLkWjHLqFus+lumhg+cGWZunP+zH1MdR/33WCtEDtnxTdIdaDdBEY2DbWGgl2lrwXTdSyA5sMBFKm6cbe4mlDa50gjazYJ6ra00v42exJzyQePMJdY5y+VKeeu/HfiUAVnYqpZbp6nToL4u3K4I5/NgGSnY6Hin1KS7D14tUGIT4rOIFPmFIYMRme0Zm4qBD03KpKzY8H03PsJAZiMGn0fvXZ7U0LcBqGLu26qte5F8N/3mjCIp9r+pfMw2onp+BkdlXK9FeeZzlNViAlVJi+G8NQPBiqrq43VyDRcj8QyalizPk0C7zimVWKHMtJQ3cz7DCYvGvh0AHhiE9MOmvs8uO3MpIwcwculwcxPvAY03+746XFfSihwdgLL8njUO2DANCkoBmVjYpQBdeIC+AOPjbKILmJcr/G7KxFNKCAKxlFqEKEPSgqopJ3ldhvZmcBp3FHrAisBEMFYzhjgTlWRdpbdAu3IOsNnEV4BtalWOXznLD8gGNe48cHek5KRgUBvNA= 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:(13230028)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(478600001)(7696005)(26005)(110136005)(186003)(16526019)(5660300002)(44832011)(54906003)(1076003)(316002)(2906002)(4326008)(70586007)(70206006)(6666004)(82310400005)(7416002)(8676002)(8936002)(41300700001)(40460700003)(81166007)(356005)(82740400003)(47076005)(83380400001)(40480700001)(36756003)(2616005)(336012)(426003)(86362001)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 19:49:37.5144 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1aec9210-6ccd-473b-0b4e-08db3b8f0c4f 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: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5913 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Userspace can't easily discover how much of a sleep cycle was spent in a hardware sleep state without using kernel tracing and vendor specific sysfs or debugfs files. To make this information more discoverable, introduce 3 new sysfs files: 1) The time spent in a hw sleep state for last cycle. 2) The time spent in a hw sleep state since the kernel booted 3) The maximum time that the hardware can report for a sleep cycle. All of these files will be present only if the system supports s2idle. Signed-off-by: Mario Limonciello --- v7-v8: * Add max_hw_sleep sysfs file * Add function for drivers to set max_hw_sleep * Modify macro to display attributes --- Documentation/ABI/testing/sysfs-power | 29 +++++++++++++ include/linux/suspend.h | 8 ++++ kernel/power/main.c | 59 +++++++++++++++++++++------ 3 files changed, 84 insertions(+), 12 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/test= ing/sysfs-power index f99d433ff311..a3942b1036e2 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power @@ -413,6 +413,35 @@ Description: The /sys/power/suspend_stats/last_failed_step file contains the last failed step in the suspend/resume path. =20 +What: /sys/power/suspend_stats/last_hw_sleep +Date: June 2023 +Contact: Mario Limonciello +Description: + The /sys/power/suspend_stats/last_hw_sleep file + contains the duration of time spent in a hardware sleep + state in the most recent system suspend-resume cycle. + This number is measured in microseconds. + +What: /sys/power/suspend_stats/total_hw_sleep +Date: June 2023 +Contact: Mario Limonciello +Description: + The /sys/power/suspend_stats/total_hw_sleep file + contains the aggregate of time spent in a hardware sleep + state since the kernel was booted. This number + is measured in microseconds. + +What: /sys/power/suspend_stats/max_hw_sleep +Date: June 2023 +Contact: Mario Limonciello +Description: + The /sys/power/suspend_stats/max_hw_sleep file + contains the maximum amount of time that the hardware can + report for time spent in a hardware sleep state. When sleep + cycles are longer than this time, the values for + 'total_hw_sleep' and 'last_hw_sleep' may not be accurate. + This number 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..d0d4598a7b3f 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -68,6 +68,9 @@ struct suspend_stats { int last_failed_errno; int errno[REC_FAILED_NUM]; int last_failed_step; + u64 last_hw_sleep; + u64 total_hw_sleep; + u64 max_hw_sleep; enum suspend_stat_step failed_steps[REC_FAILED_NUM]; }; =20 @@ -489,6 +492,8 @@ 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_report_hw_sleep_time(u64 t); +extern void pm_report_max_hw_sleep(u64 t); =20 #define pm_notifier(fn, pri) { \ static struct notifier_block fn##_nb =3D \ @@ -526,6 +531,9 @@ static inline int unregister_pm_notifier(struct notifie= r_block *nb) return 0; } =20 +static inline void pm_report_hw_sleep_time(u64 t) {}; +static inline void pm_report_max_hw_sleep(u64 t) {}; + static inline void ksys_sync_helper(void) {} =20 #define pm_notifier(fn, pri) do { (void)(fn); } while (0) diff --git a/kernel/power/main.c b/kernel/power/main.c index 31ec4a9b9d70..3113ec2f1db4 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -6,6 +6,7 @@ * Copyright (c) 2003 Open Source Development Lab */ =20 +#include #include #include #include @@ -83,6 +84,19 @@ int unregister_pm_notifier(struct notifier_block *nb) } EXPORT_SYMBOL_GPL(unregister_pm_notifier); =20 +void pm_report_hw_sleep_time(u64 t) +{ + suspend_stats.last_hw_sleep =3D t; + suspend_stats.total_hw_sleep +=3D t; +} +EXPORT_SYMBOL_GPL(pm_report_hw_sleep_time); + +void pm_report_max_hw_sleep(u64 t) +{ + suspend_stats.max_hw_sleep =3D t; +} +EXPORT_SYMBOL_GPL(pm_report_max_hw_sleep); + int pm_notifier_call_chain_robust(unsigned long val_up, unsigned long val_= down) { int ret; @@ -314,24 +328,27 @@ static char *suspend_step_name(enum suspend_stat_step= step) } } =20 -#define suspend_attr(_name) \ +#define suspend_attr(_name, format_str) \ static ssize_t _name##_show(struct kobject *kobj, \ struct kobj_attribute *attr, char *buf) \ { \ - return sprintf(buf, "%d\n", suspend_stats._name); \ + return sprintf(buf, format_str, suspend_stats._name); \ } \ static struct kobj_attribute _name =3D __ATTR_RO(_name) =20 -suspend_attr(success); -suspend_attr(fail); -suspend_attr(failed_freeze); -suspend_attr(failed_prepare); -suspend_attr(failed_suspend); -suspend_attr(failed_suspend_late); -suspend_attr(failed_suspend_noirq); -suspend_attr(failed_resume); -suspend_attr(failed_resume_early); -suspend_attr(failed_resume_noirq); +suspend_attr(success, "%d\n"); +suspend_attr(fail, "%d\n"); +suspend_attr(failed_freeze, "%d\n"); +suspend_attr(failed_prepare, "%d\n"); +suspend_attr(failed_suspend, "%d\n"); +suspend_attr(failed_suspend_late, "%d\n"); +suspend_attr(failed_suspend_noirq, "%d\n"); +suspend_attr(failed_resume, "%d\n"); +suspend_attr(failed_resume_early, "%d\n"); +suspend_attr(failed_resume_noirq, "%d\n"); +suspend_attr(last_hw_sleep, "%llu\n"); +suspend_attr(total_hw_sleep, "%llu\n"); +suspend_attr(max_hw_sleep, "%llu\n"); =20 static ssize_t last_failed_dev_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -391,12 +408,30 @@ static struct attribute *suspend_attrs[] =3D { &last_failed_dev.attr, &last_failed_errno.attr, &last_failed_step.attr, + &last_hw_sleep.attr, + &total_hw_sleep.attr, + &max_hw_sleep.attr, NULL, }; =20 +static umode_t suspend_attr_is_visible(struct kobject *kobj, struct attrib= ute *attr, int idx) +{ + if (attr !=3D &last_hw_sleep.attr && + attr !=3D &total_hw_sleep.attr && + attr !=3D &max_hw_sleep.attr) + return 0444; + +#ifdef CONFIG_ACPI + if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) + return 0444; +#endif + return 0; +} + static const struct attribute_group suspend_attr_group =3D { .name =3D "suspend_stats", .attrs =3D suspend_attrs, + .is_visible =3D suspend_attr_is_visible, }; =20 #ifdef CONFIG_DEBUG_FS --=20 2.34.1 From nobody Wed Feb 11 22:55:50 2026 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 CEF9FC77B79 for ; Wed, 12 Apr 2023 19:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbjDLTuL (ORCPT ); Wed, 12 Apr 2023 15:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjDLTtq (ORCPT ); Wed, 12 Apr 2023 15:49:46 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2075.outbound.protection.outlook.com [40.107.243.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388BB7D9B; Wed, 12 Apr 2023 12:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aE0efWOvAkwJxR5D87R4N6oikOzaktzxlVBoWvMnaREG6IhtDdnCJGnXVbpwVO1uidJq1OncTADSxl3J3pklDNlKGEPZXciu2kFJ9xU5Hx8hUOtmtBQakN76zW/YmtrU2BfyXDi6smiBqiG1xdimjieB9efOmUP3fqyFxI/QNOFPonspSsRbYiyxYfhiVUbq4B2GPBaudsrBFvZRbDby2apNv60XoJYMS06G+2zRGrcjV2H4EHsZNtaBecO5gJmRK3qUF7DJjPYc4W2DhRXgyRM8ASOhO+t3EtdIq0OsqwZKQqFPiCNkBVWmPZWHKEfAKbmp1n8hFW57yjgm1hCHcQ== 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=MAqoozhWE/kkT/GmPTdsTtBzAMT4Hd/ynr6EOHD7eUg=; b=AXrkV4WllOrlSGHRLFZgovHJgcd1fdTrravHK2RTLS8ebJZKbiGIkbLgMtAdFOW0/SoYcUuL2A96kkq0SOxR8NFmk2nBNEeZEgcgvHsaBR/xZSAtLlrQKz0GaW/Av1susKl31cI5RzVzL8oyid27G3n5W00ZdvQfC7zgfyyDmD19ijBcK3AGXb2v+3ySbllhTqqB108ktUIVYf0GmiFUw5Zk6wPxfQut+RXQOZFIu8lkROunBtpbcewmnp1XoUou/ZMRrcTOSphbd4ZedFSWHY7k3RvISqSFblk1NJ4d51VD6+CARbN95a8Xt4vtfgORoytKU5VZZHnkguX1Pu6/aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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=MAqoozhWE/kkT/GmPTdsTtBzAMT4Hd/ynr6EOHD7eUg=; b=UrvN3vv8ZGeZ4RjulZpLK3vnZalCHPnJ1qDYGK+NbqpvfU3wNWxwgDDJZG7mF4oXKjxlcoU/L6DyPi9tzQ7ty0wMhiC1mZ8vsQQ04NrB+XEhqhtQYmFEsyLf98/lJJNE+LsAM5zV3cxnSqjjk+z/8B1FBXmTF4ywkF58FyJ4ruo= Received: from DM6PR06CA0052.namprd06.prod.outlook.com (2603:10b6:5:54::29) by BL0PR12MB4931.namprd12.prod.outlook.com (2603:10b6:208:17e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Wed, 12 Apr 2023 19:49:38 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::f5) by DM6PR06CA0052.outlook.office365.com (2603:10b6:5:54::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 19:49:38 +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 DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.31 via Frontend Transport; Wed, 12 Apr 2023 19:49:38 +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; Wed, 12 Apr 2023 14:49:35 -0500 From: Mario Limonciello To: Box David E , , , , Shyam Sundar S K CC: , Jain Rajat , , Mario Limonciello , "Mark Gross" , , Subject: [PATCH v8 2/4] platform/x86/amd: pmc: Report duration of time in hw sleep state Date: Wed, 12 Apr 2023 14:49:14 -0500 Message-ID: <20230412194917.7164-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230412194917.7164-1-mario.limonciello@amd.com> References: <20230412194917.7164-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT070:EE_|BL0PR12MB4931:EE_ X-MS-Office365-Filtering-Correlation-Id: 6be2e253-c8ee-4597-de6f-08db3b8f0ca4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IhxlkEBjf2xoMf3DNl9DGf46ncGoFQkqlJtLWiKtIQMtmuL8D0B1B6soXJN8YOBabNiHSv5mwol/0wbi/iiVxW9Dii7aSvGKM5Cwie6FCj273pkzJL5FhzkfzsZ5nwtc+JyYh9hhbqBo2aNJ4FAvuLJrX2vMLIGm0vNDDk3VI/thfoUxiMZyZVEUYlFFKAMoxF4MAZgQ86JAkULD77DK6sXEqAJMjqWjyEhNYbt68UVxdJx+EA+9/8sKziruNzmRUKbuiOXiXn8HQ+s7VVisCwz2aNIWxqItBgU35bNlgGGirDXKXf3X6x+lii36huDAyUWio+SjkRASZZjk3NloLTzpCwZ1XxnOkEYfbV9QBk7pPWk0kVkdWG/MXj8PV6h9qB3TSaF+9oXVqAdGYUYHOHZxyzqGJCH6cG61lG+Uir+btkLGGeC/tdX2cmEqCndbpvmokogjSb1Ae0DG3Bz17Ea6SPoT3Hlxpv8JFgc6/Sp8UjJ9OpD5ESViXEfORu2ZmPLasy1jnWRGlENwJwVn8qJORtOqIEhaQKYK2nV0W5sXHiqzgxxzQTG7NHSEMCWbt8f20xA7f+qqKgjtbCc3hoXtBvIE4HVP6CiSmRWjFT3HYr2xM3lTzrZzk096OWaDBVz93nyxnEYuKxKwY0P+5T3/GPBH4yq+IqHE+FOUgOv1SoCFenr8BYcsbEb9QjAMGdt2bgMP0V7J+FnvSNNc5xHtUkWN/6S2M1Q/+ZwPJGM= 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:(13230028)(4636009)(136003)(376002)(39860400002)(346002)(396003)(451199021)(40470700004)(46966006)(36840700001)(40460700003)(316002)(41300700001)(26005)(1076003)(81166007)(6666004)(7696005)(186003)(86362001)(47076005)(16526019)(2616005)(356005)(82310400005)(36860700001)(82740400003)(36756003)(426003)(336012)(83380400001)(40480700001)(110136005)(4326008)(54906003)(6636002)(70586007)(70206006)(8676002)(8936002)(5660300002)(2906002)(7416002)(44832011)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 19:49:38.0769 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6be2e253-c8ee-4597-de6f-08db3b8f0ca4 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: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB4931 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 the standard kernel reporting infrastructure so that userspace software can query after the suspend cycle is done. Signed-off-by: Mario Limonciello --- v7->v8: * Report max hw sleep time as well. --- drivers/platform/x86/amd/pmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c index 2edaae04a691..e610457136e6 100644 --- a/drivers/platform/x86/amd/pmc.c +++ b/drivers/platform/x86/amd/pmc.c @@ -393,9 +393,8 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev= *pdev) =20 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); + pm_report_hw_sleep_time(table.s0i3_last_entry_status ? + table.timein_s0i3_lastcapture : 0); } =20 static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev) @@ -1015,6 +1014,7 @@ static int amd_pmc_probe(struct platform_device *pdev) } =20 amd_pmc_dbgfs_register(dev); + pm_report_max_hw_sleep(U64_MAX); return 0; =20 err_pci_dev_put: --=20 2.34.1 From nobody Wed Feb 11 22:55:50 2026 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 EA907C77B6E for ; Wed, 12 Apr 2023 19:50:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230372AbjDLTu0 (ORCPT ); Wed, 12 Apr 2023 15:50:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230177AbjDLTts (ORCPT ); Wed, 12 Apr 2023 15:49:48 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2076.outbound.protection.outlook.com [40.107.223.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D6D47DB4; Wed, 12 Apr 2023 12:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cxWzJviypQ7Y48r+W+VsSFtcyfM7j/v6+zktV8MXxyLLeV27IvdZbMDqvZPvsXiojME2USxyRnCuiMXSRlnpPcVsjtgNA2zJ6CPtNHvtTWQv4w/U7OX1KZnJ7oJxiCZ+JYLEIBPYS34mcChI5mtjqSdGygwniscD3ihpsNM1/PHWT9DdHtIgWGzhBuuAIXQPWcaSblgMvG3VpfXuBR88DXw2CUwK1vpXUc55VEVa41dOdPVNnNGJ1fPtEnpcOyLw0mdSWnCHmthDeWPjDnVtHdmiWiNeaAyRRI/6qMiQsxFuQkgqhVqAFiJm4ckAyjlrZlhtAo80V59xbq+N28sKYw== 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=6uyuYrzpFUD9AAiawcudYbjDPhPlJBKpXwXniY+Li4s=; b=oK3l62FR9GboylsE7YWSIfKl1IUTSk5EOKxQxhQrcpV6n1hf7DG/vmQ8Le//47Wwu+v05SUUnQ0wPhW62ukRPzRk4zMkxT6XRedIECi7T4fnTJuBCM0wp+OMYFRQjWsEGa+i/O+n/yhUTBpn2Vc3qvlAfRdYvQxkPR7Pqz2KVpEAlcsuFsXYRVDJy6FByUoAwpMTJ82R5O/2GzyCelqGKiHx9WttKa9DlqRfcjdzEcLKS7jZJUxtj4IA3VJloiuSYbjjtZWP5TH336Aij495nSJ0QPYOVxYlH57TcUoHRxj8RIiwITLEiakGScyEBq/gmQIVczRkXCfwPdfPhaoeMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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=6uyuYrzpFUD9AAiawcudYbjDPhPlJBKpXwXniY+Li4s=; b=ONJMgcKwsMeg9OjMDEA1S/ikMVnZJumz7bQY9I+NihINTwLe/jnoqjSUOIP1CoTQXyzQXHlIYQE7iZCv3dPHXWGIL0kM2wZ7nTPMhUW0Dw4NxTL3tGhogB+ZSODuGCstcPBjTh6wO7EXrw6EGWWNWTvHxDblvdQyGm/tosxvHhE= Received: from DM6PR06CA0064.namprd06.prod.outlook.com (2603:10b6:5:54::41) by PH7PR12MB6954.namprd12.prod.outlook.com (2603:10b6:510:1b7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Wed, 12 Apr 2023 19:49:38 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::fe) by DM6PR06CA0064.outlook.office365.com (2603:10b6:5:54::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 19:49:38 +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 DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.31 via Frontend Transport; Wed, 12 Apr 2023 19:49:38 +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; Wed, 12 Apr 2023 14:49:36 -0500 From: Mario Limonciello To: Box David E , , , , Rajneesh Bhardwaj CC: , , Jain Rajat , , Mario Limonciello , "David E . Box" , Mark Gross , , Subject: [PATCH v8 3/4] platform/x86/intel/pmc: core: Always capture counters on suspend Date: Wed, 12 Apr 2023 14:49:15 -0500 Message-ID: <20230412194917.7164-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230412194917.7164-1-mario.limonciello@amd.com> References: <20230412194917.7164-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT070:EE_|PH7PR12MB6954:EE_ X-MS-Office365-Filtering-Correlation-Id: 96436eb1-9ae9-41ff-da91-08db3b8f0ce2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s1j8+D8a39sAenBe3VSIQdV96MyQxwm29BxkE85OESQb10JN9c/WZIjr/dhaed+EavCAKpiffFITHnOrKWo4PTH9aEnHXuDbRUYTEey9+WDtT0NyJmWPr9dW2mUux2KZKDv9mD+R8E8Ou10gNqZ/KCN3/RfXzUSlyCV5zcdWL3aQRcl9e8J4Y+al5vW0qmowgZLD0YLrLDhvs+Zby4zVUgzszpCacFro9AfrfyoSeaybtqLmlVuTPBx4fB+qcLpC7RcsQA9ObrEyyevmtwT3aqFjgeiwV84uSaj/4FymBXm5W0njZUlpv+xaWu+W1kyGCGEdKklO06G82Tun0x51dyKlv5Fwa6kHk9kqEVjgKCCecXuJxpRP55HknF3W2qw03AOSd6qEHiJOxioGooIBOc6dFtI/rOoL2IfPLjXZozMPcZDGEg30vY2ho1Wx0r+3yVtXypb+Rt4AKxx88loL/dxiJWu8DJAlNNDi/lyF1q8x8IOsVDNK6L+P2oKYRjC2uA9T30p2awX+Qj7AEb8Y9pPM6KAr8+lRUAyhC+jvXIo18eb/3+3NvYHTlWqQLUD9IRX4nc8IX/SvPBS1rNb5wLu9vvPPr5EYF8j5mIq1qwg1mzeGADle6YaDn9USgrvB9KqmYyAkoDHGSxYyZlpG3AlrVSZz4wUdq5YqtmKreL0Yv1d0ot6So34hU4r3CL9z++SNaN87QgTEVCF6mmbqg7ynoFbYm2XWzOSWr4h4PDU= 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:(13230028)(4636009)(376002)(136003)(396003)(346002)(39860400002)(451199021)(36840700001)(40470700004)(46966006)(44832011)(40460700003)(7416002)(82310400005)(15650500001)(36756003)(2906002)(5660300002)(8936002)(8676002)(40480700001)(86362001)(110136005)(6666004)(7696005)(26005)(1076003)(83380400001)(36860700001)(54906003)(478600001)(47076005)(2616005)(426003)(336012)(16526019)(82740400003)(186003)(70206006)(70586007)(81166007)(41300700001)(356005)(4326008)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 19:49:38.4831 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96436eb1-9ae9-41ff-da91-08db3b8f0ce2 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: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6954 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Currently counters are only captured during suspend when the warn_on_s0ix_failures module parameter is set. In order to relay this counter information to the kernel reporting infrastructure adjust it so that the counters are always captured. warn_on_s0ix_failures will be utilized solely for messaging by the driver instead. Reviewed-by: David E. Box Signed-off-by: Mario Limonciello --- v5->v6: * Pick up tag v4->v5: * Squash patches together * Add extra pm_suspend_via_firmware() check for resume routine too --- drivers/platform/x86/intel/pmc/core.c | 13 +++++-------- drivers/platform/x86/intel/pmc/core.h | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/i= ntel/pmc/core.c index b9591969e0fa..925c5d676a43 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -1179,12 +1179,6 @@ static __maybe_unused int pmc_core_suspend(struct de= vice *dev) { struct pmc_dev *pmcdev =3D dev_get_drvdata(dev); =20 - pmcdev->check_counters =3D false; - - /* No warnings on S0ix failures */ - if (!warn_on_s0ix_failures) - return 0; - /* Check if the syspend will actually use S0ix */ if (pm_suspend_via_firmware()) return 0; @@ -1197,7 +1191,6 @@ static __maybe_unused int pmc_core_suspend(struct dev= ice *dev) if (pmc_core_dev_state_get(pmcdev, &pmcdev->s0ix_counter)) return -EIO; =20 - pmcdev->check_counters =3D true; return 0; } =20 @@ -1233,12 +1226,16 @@ static __maybe_unused int pmc_core_resume(struct de= vice *dev) const struct pmc_bit_map **maps =3D pmcdev->map->lpm_sts; int offset =3D pmcdev->map->lpm_status_offset; =20 - if (!pmcdev->check_counters) + /* Check if the syspend used S0ix */ + if (pm_suspend_via_firmware()) return 0; =20 if (!pmc_core_is_s0ix_failed(pmcdev)) return 0; =20 + if (!warn_on_s0ix_failures) + return 0; + if (pmc_core_is_pc10_failed(pmcdev)) { /* S0ix failed because of PC10 entry failure */ dev_info(dev, "CPU did not enter PC10!!! (PC10 cnt=3D0x%llx)\n", diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/i= ntel/pmc/core.h index 810204d758ab..51d73efceaf3 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -319,7 +319,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 @@ -338,7 +337,6 @@ struct pmc_dev { int pmc_xram_read_bit; struct mutex lock; /* generic mutex lock for PMC Core */ =20 - bool check_counters; /* Check for counter increments on resume */ u64 pc10_counter; u64 s0ix_counter; int num_lpm_modes; --=20 2.34.1 From nobody Wed Feb 11 22:55:50 2026 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 17629C77B6E for ; Wed, 12 Apr 2023 19:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230352AbjDLTuT (ORCPT ); Wed, 12 Apr 2023 15:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230176AbjDLTtr (ORCPT ); Wed, 12 Apr 2023 15:49:47 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2047.outbound.protection.outlook.com [40.107.212.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 079F17A80; Wed, 12 Apr 2023 12:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M4oLoyt2UJuFINE6kDcpyJTpWDJy0rwhIx1JRZunDerfSoYKk/l80JVMMj6aVW/bx+i9goX2BjpnjN15Ya1DdwuGWfuRG/pVEfGI5HqXAbHkdObeIvYXJb/Ez/qnXpKcZpLeepeW30fpNeoqRbh7AMCMWs/QXgZorLVEfTg61+KvQO+A3hq5KqrKR204N7752LICrAAUS1LZK1LmaNfjdRDpEQmtSip33QBTjAdFxKy89Sv/diJYPDS8pI4MkiFqJODcw6NKsqk/9R/ZjBTp8F50re6OelD2HzYKW0smxA7Hx6iXdqQri6e/3O+2SXd+7SOe4bqTjBi42UIsI0Snlw== 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=fCQus717f+zD9JKyXeRkEq1zVYd+Ada2Q2y6ruMT/bM=; b=PL6lgA/epwI+F+Bpr/JRRsgeaOoBAu6YeVuFfVK5d3QQjr0Dt2BKhExOCuSOVab2PSqDRWQ9O2FfRutda3pIc8Tj/6xY92GXfe0g9BAmeS2aOkbQw2D/I+9GGIO+2q2Ye2zIU1pRdoSXBjFemqYM9dfBczwxYNY6/CZ72H2jLS9Z5yn+3seu2VOlmOo7Ri/BX5i9I59NHJiuL1e6D3pVMpuJRjAxy+hzRtLCCsGH9VZMWHBsAi/zt5yHRd2ZA6YZWPpDmysAVPXQ6U10+dOpxmSYzmwv6zRwzLyjWHsN6LfvsaMbpzdiAlDwAKEiigRyGlLfGnkFuulJavJek4RbLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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=fCQus717f+zD9JKyXeRkEq1zVYd+Ada2Q2y6ruMT/bM=; b=frrmy33/ySyssOSk7hUZkk7Ge3eHXY6Bg1VuGVBIu9coc1nx7A0viGl368CBvsI5HP27i3UeZcJuS705Hh/a+2CgwUTrqXmLvOolUqBSav2yiYY2EBv7vJsF6Ga6BUrjdxdEKM4HxFwZW451c1wSlE1pTw1pOYIcgt9TR9Y5zoQ= Received: from DM6PR06CA0064.namprd06.prod.outlook.com (2603:10b6:5:54::41) by SA1PR12MB6728.namprd12.prod.outlook.com (2603:10b6:806:257::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.37; Wed, 12 Apr 2023 19:49:39 +0000 Received: from DM6NAM11FT070.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::fe) by DM6PR06CA0064.outlook.office365.com (2603:10b6:5:54::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 19:49:39 +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 DM6NAM11FT070.mail.protection.outlook.com (10.13.173.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.31 via Frontend Transport; Wed, 12 Apr 2023 19:49:39 +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; Wed, 12 Apr 2023 14:49:37 -0500 From: Mario Limonciello To: Box David E , , , , Rajneesh Bhardwaj CC: , , Jain Rajat , , Mario Limonciello , Mark Gross , , Subject: [PATCH v8 4/4] platform/x86/intel/pmc: core: Report duration of time in HW sleep state Date: Wed, 12 Apr 2023 14:49:16 -0500 Message-ID: <20230412194917.7164-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230412194917.7164-1-mario.limonciello@amd.com> References: <20230412194917.7164-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT070:EE_|SA1PR12MB6728:EE_ X-MS-Office365-Filtering-Correlation-Id: fdaa4028-c203-4f7f-3513-08db3b8f0d61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A6e6vmHmhVjIOtQWlj2HwOOzIe+7faWuATD+cK30c2digTrLKROlstuX3SNxX/2CY+6iR7IhMSzF7VZSBqgzW00Pac6ckzBayGy8WSytFyAg1fU0kb6ck1XwSUKH4j2Im6BU+Lx79SLsFn/fhPHx+JrXZV09cTHpoiEXcHqepXHwKTLbdIWNwXlzHgSdbL3Buhq2imHzfObFBoGZPZxuZclgU5rI4vR2XJD1+3K7Jq6VoLBgJ/oN09aKLTvaJDDiFIMCwogUg+DZ9idlByTrq4tuE2P79EF7rTvXytenrXY+IA6ohAWds4DS6jtirpqe87D+e0tqGgx8gxudNeBXUxi4Fh7xbgiDNwEauYSB9YPenJV+NRhQ/BYA7li49Aei+zdZjIFlbGFYNX4Auo8gsJORBJe/0c5PVNJFF97Y+hkYjMaTmiOD3UnQhwhK2F9jEOB56qEZhtnyWqtpH2nNmX+qy0SjayA6j4UMKBhd8qXswK1ziqZ+YH4t+OTzz4AdPnUOVABEyGW9cprM4NWYFNhIlaLfYLpLwIl0XKITr1U8WX/D5LXQZBTQEUtjIXLRufr7AzzHFpFLfpS8DnEphCB8F+kYzL1XSeZ5BEeyoqTKooOPoKE8r+mdUWcGycsSR5j9rzS37eYZT517kpjdksnxjJRUZDUhIc/gEi7s9zrSZYIXiiVJVuACkwWi5tazKWR2rFbMmPM95Gm5jiqYJWYWMZElEeUonPSM90gVpS0= 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:(13230028)(4636009)(136003)(39860400002)(396003)(376002)(346002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(8676002)(70206006)(41300700001)(54906003)(70586007)(7696005)(478600001)(4326008)(110136005)(316002)(36756003)(86362001)(83380400001)(426003)(47076005)(336012)(1076003)(26005)(6666004)(2616005)(5660300002)(2906002)(8936002)(44832011)(7416002)(82310400005)(40480700001)(356005)(82740400003)(81166007)(16526019)(186003)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 19:49:39.3112 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdaa4028-c203-4f7f-3513-08db3b8f0d61 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: DM6NAM11FT070.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6728 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" intel_pmc_core displays a warning when the module parameter `warn_on_s0ix_failures` is set and a suspend didn't get to a HW sleep state. Report this to the standard kernel reporting infrastructure so that userspace software can query after the suspend cycle is done. Signed-off-by: Mario Limonciello --- v7->v8: * Report max sleep as well --- drivers/platform/x86/intel/pmc/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/i= ntel/pmc/core.c index 925c5d676a43..f9677104353d 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -1153,6 +1153,7 @@ static int pmc_core_probe(struct platform_device *pde= v) pmc_core_do_dmi_quirks(pmcdev); =20 pmc_core_dbgfs_register(pmcdev); + pm_report_max_hw_sleep(((1UL << 32) - 1) * pmc_core_adjust_slp_s0_step(pm= cdev, 1)); =20 device_initialized =3D true; dev_info(&pdev->dev, " initialized\n"); @@ -1214,6 +1215,8 @@ static inline bool pmc_core_is_s0ix_failed(struct pmc= _dev *pmcdev) if (pmc_core_dev_state_get(pmcdev, &s0ix_counter)) return false; =20 + pm_report_hw_sleep_time((u32)(s0ix_counter - pmcdev->s0ix_counter)); + if (s0ix_counter =3D=3D pmcdev->s0ix_counter) return true; =20 --=20 2.34.1