From nobody Thu Dec 18 18:53:21 2025 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 00EA6C77B6E for ; Fri, 14 Apr 2023 01:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229493AbjDNBYk (ORCPT ); Thu, 13 Apr 2023 21:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjDNBYb (ORCPT ); Thu, 13 Apr 2023 21:24:31 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2064.outbound.protection.outlook.com [40.107.243.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBD9110C9; Thu, 13 Apr 2023 18:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fRfVnT375pEzDJbdT1sNJ/JZdy2qEdx/v0XEJ/Em0cYzcQNYKKKXlOWBo46TmZ0an43D0Sl7ROUqCr91mvu2VC+H8p9tlg6DCQOdntblYhGO80zK9ol7e1p4TEGTp9ZTp1bIM/rtjiJgapy9ixE6KSfI6Ar0p/EHz94PoTjWYpCpFHm9kCfgJzOLML7aSZjQ2HKqDgBZY/bvwLC3viaj+noAxaA8xGrHGXz7rWsiqoNRpofTWzjMHhZvfWF66sJUo/8ROrjASQnDmeUGbCKBIGM45RkDDxVcSk713Vip2OMdEHre46ZxzXr9kDFLSzg7HLI+AvQCAWvYfzMhxdLNzQ== 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=mLuiLxppwb8B1K6fM5aKfOY1Mv2OWxpFKEmaUUh1lGF6MBInrRo3OSsOCyksQt36mad/V5AabK+iEaDEoF7N4NYvBvR/ed8WmaxBF6iLkuoSPk58hAT5dNqNeiV6gjWiAaSkKZIGLRWypu9mtI/i8em7vgqQnL0nT41d+PKMsIDAQiJB8s4keYpMIpuk0bWKQvRO+mu/XZl8xSL8CZEw9DwQoezMZlItdNI2C2uFS5gmfx5YFtcqrvP13EvkKNMuD7CfeWVsLs9WNgtMckhd8GHAXWnLuOF73X5/0CP9unB7SZs4tXpujrtyme4/x3vIHjl5heV32gGFlDX25JpLvA== 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=JYaMY72VxhKItestMbyzjyu5Cp/+UuyeGplFk0UoIc6tjwJP0AguC5VuKlTFHtJcRyCZDwNl3VTw5DEOJzwXgIWHvhNaLYIm8ScCm8f3A4bUxqzbGPLjft7etl7Jd4JP/leOPTOzttikP1b4hFQ70IogxD6ixlRKeE1ZF4RR7EQ= Received: from DS7PR03CA0111.namprd03.prod.outlook.com (2603:10b6:5:3b7::26) by BY5PR12MB4870.namprd12.prod.outlook.com (2603:10b6:a03:1de::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 01:24:25 +0000 Received: from DM6NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::ab) by DS7PR03CA0111.outlook.office365.com (2603:10b6:5:3b7::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.33 via Frontend Transport; Fri, 14 Apr 2023 01:24:25 +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 DM6NAM11FT019.mail.protection.outlook.com (10.13.172.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 01:24:25 +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; Thu, 13 Apr 2023 20:24:20 -0500 From: Mario Limonciello To: Box David E , , , , "Rafael J. Wysocki" , Len Brown CC: , , Jain Rajat , , Mario Limonciello , , Subject: [PATCH v9 1/4] PM: Add sysfs files to represent time spent in hardware sleep state Date: Thu, 13 Apr 2023 20:23:42 -0500 Message-ID: <20230414012346.1946-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414012346.1946-1-mario.limonciello@amd.com> References: <20230414012346.1946-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: DM6NAM11FT019:EE_|BY5PR12MB4870:EE_ X-MS-Office365-Filtering-Correlation-Id: d7e0ab2c-58f5-43e1-2034-08db3c86fbe6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TwWmoXMB1zPWSnACm2qg3N70sQXMQcisbG2P/zb6jhIbITnIQXo4RaGWimsszr/Wc3UbGGl7Tj/qc8frGdvgrlmhuiPUn3JMBa/liwSybWnJdukTZEk5EnmCrPy5faxw5Scw9k39XVb21F42YjuLLhauE/IJWfUZajRQu6KaXF6+TbYRdgQ0WRANqlccolpCELNUAdS0e36qy2QkIbf6GxG2Ct7iqnlgEtNMYZeph+IT2pf74ioEyFGHDJaVNxd/i+vU8yJyoLZsKQqorYK4JeUqoajmMqUtSL9JpyzrQGC0rxkvdD66NDbvO38w2rcfRcSOybVFlVXU8PbH73NkRPP5zZklpqwbWe/6arS5Jd0UTAYoeGnc/kX/p4A6owiZLMxf+0KtW6TzXQBQG+00QBXDA0omyYcCrs8WBSFDQcwvwmjAYGWfiW84WlOPw2LBjGNv/NQGVkVrpklEZPmTbPrMalNm3/ZUn8dFGdFuL7HLEZlTdfYpe6xknprngGaDtIBXxuVK1ng8izSw8R36qpxGulCr6C1qrqm0z/5GiCI4bBs4QhqNZi7hd/A9Kt+pybw7No/3IQ0fa8QV0jzlwdhK/jWXGd/TXiBZ22RCLj7UH8PTcSrnjElQKOz33cMmdON3QiZ0SiMnIc6SakUsNbOqt06IVJgpEDgNQK3OZXp32g+Z+rX8CIfRUuPCIpLGunCbEEEIIAF741viga+VClDP7COfTfWgN1ilK52p+XA= 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)(39860400002)(376002)(346002)(136003)(451199021)(36840700001)(46966006)(40470700004)(8936002)(82310400005)(36756003)(5660300002)(44832011)(7416002)(40460700003)(356005)(4326008)(81166007)(82740400003)(40480700001)(41300700001)(2906002)(86362001)(26005)(1076003)(6666004)(36860700001)(7696005)(8676002)(336012)(426003)(83380400001)(47076005)(186003)(16526019)(2616005)(54906003)(110136005)(316002)(70206006)(70586007)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 01:24:25.1722 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7e0ab2c-58f5-43e1-2034-08db3c86fbe6 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: DM6NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4870 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 Reviewed-by: Hans de Goede --- 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 Thu Dec 18 18:53:21 2025 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 77B9AC77B76 for ; Fri, 14 Apr 2023 01:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229546AbjDNBYd (ORCPT ); Thu, 13 Apr 2023 21:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjDNBY3 (ORCPT ); Thu, 13 Apr 2023 21:24:29 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2084.outbound.protection.outlook.com [40.107.237.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B11AF7; Thu, 13 Apr 2023 18:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SWNDt2gh6+hvIFP2+2BF7dT1OzPs5zRlVSSC+GMkqoEvjASd9bjUdmJD1ldb0YcxeBqAjAYHY82IVknMqZhmYe8y7zIRbqvZc9hSpaP2YaQoZ3CTsbNaRPZCVk2JY/qCuU5XoCeOG4ew3n4Oo0G18i4QOy8DhLb+q0hgmc6EBhgb9cqxWSKiju3OPLF7hY3tJCyvpdB/NwWLj3rxEPjaMKkKB2G5xvfyA84UMkl/k+B3oYciwOqN1a1W7gzIwvX2Gf5cTCadKs9oDMTGZfcuirDNhHm22CZmlFGL+gTDhqic+9k8y5inKJfI1UxqZgWTb+/AO6/D/1AVvCOfu3YQqw== 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=CWZ3PW+SyqiajzR6HkFBQBbv9UGsHdsayozyuXkeSlrvmynhmtWxr7aU83yoSmyGXR8P/e7uRsupUJFfnXrh/U+EEHV5nJTUNkRSQhOOG1nkqgw7bdz7gq4oGy0ETXcOaJBY19PLjsDXyMBSZfj0dtbH+iOBJARsplgoaaobDBLUdRFPPbPozCFW6qLSEdXwPWmfqZn51hVmzPFm9rZFZcYDMNyRnS6KEebEpLrndIZ6VJaukCVwm304Z+3QNeMYPLRAJPw7Xe0H4SlXtY4rhTxpIntvUqnPt+Ti930P7R9O9YY5sFNm/eIyMcbxDOBftgz3Su6a701u1tZkZoLEjg== 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=QUFcjJvTBRdcAPqEBychE90Zfpzp0T7+T4biEUS6wnOfh6pABCGmCX8Z/SppFcq8z+0OZ8tEeZsvnut/on8XnfTq1Jto2mv+q96QXzjK8gvVFh6VOCiJu1ZZp0ZsSoA4AkQXe/l2Tlk/c+9TwWzv495E9z0jO7MFAKUcsSCQw8A= Received: from DS7PR03CA0119.namprd03.prod.outlook.com (2603:10b6:5:3b7::34) by CH3PR12MB9027.namprd12.prod.outlook.com (2603:10b6:610:120::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 01:24:26 +0000 Received: from DM6NAM11FT019.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::3e) by DS7PR03CA0119.outlook.office365.com (2603:10b6:5:3b7::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.32 via Frontend Transport; Fri, 14 Apr 2023 01:24:26 +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 DM6NAM11FT019.mail.protection.outlook.com (10.13.172.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.36 via Frontend Transport; Fri, 14 Apr 2023 01:24:25 +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; Thu, 13 Apr 2023 20:24:21 -0500 From: Mario Limonciello To: Box David E , , , , Shyam Sundar S K CC: , Jain Rajat , , Mario Limonciello , "Mark Gross" , , Subject: [PATCH v9 2/4] platform/x86/amd: pmc: Report duration of time in hw sleep state Date: Thu, 13 Apr 2023 20:23:43 -0500 Message-ID: <20230414012346.1946-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414012346.1946-1-mario.limonciello@amd.com> References: <20230414012346.1946-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: DM6NAM11FT019:EE_|CH3PR12MB9027:EE_ X-MS-Office365-Filtering-Correlation-Id: 681d6fae-0a1b-4a0f-8ef9-08db3c86fc58 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Svv/iEMFIpd6r/QJlaO/S4DL5iCQBMpjxOHk/Us2J0CcYBmN0/ZYGNatkXUEGFsoR+p1dDODN0gKA0uL4s8yTN1k+1G7jfg9ZPPGBa803tWw7QecNV0RTnQhYcvcRMIM4zTqiyPF1vcQXKopxefg9nlXOqtwHELoADuUsBaG0rArINoa2Y0LKwjyraMe+WXNfgPoTl1ywesRWtW99+NNbjiTWMXTv60vKqz5s5AbT3UQ3kLYEgfmu3dFyqxCKIo8hl7lyQkgcCW9rcMcProLPnJD7ea93bPQlTf6jXg9ZTHwQUEKJrf93kkvE08oJvJPtCgOWaRpRnvje6yXndK2TkjIi9QZVr9eoInZPDPpMlWHBMxOvQ7nKwdIZ3GmnJ67rPx/JQshxkNZTTUzBR/b/mB/TOTDgapUTIEpX5i4ci9SobhlSrtfgoy6s3DAjwyLjenDeElpH+Gzss9vuxBICiB9CA6iJyaIzFyqO3NLh8eRGIRTzM7zFOHm8N4LHE7Sepc6fRRPO9Y/3+KH5KflrZ3T1XmNEr3zQREe+Q90vr9JF+z3M73AQgHpyzJ5C6+yYDmcqRIbLdKTVIM54QNqbZGy+wZEutIH8xi63Ab8HznIyUWMr95UmLYHxfkR0C8/gE/z1LYiVf0fxJJSj6lblCdoLZd16K7wIAXYS8me1R6EL5HUCmUlE0Ax4L8Qf7XpDer7M6MhDPIGnuaSI+ZoXYOycdvxqkvWBUFFKkHGHQM= 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)(346002)(136003)(39860400002)(376002)(396003)(451199021)(46966006)(40470700004)(36840700001)(8936002)(186003)(16526019)(1076003)(26005)(40480700001)(7416002)(6666004)(5660300002)(44832011)(40460700003)(82310400005)(86362001)(426003)(336012)(478600001)(36860700001)(316002)(83380400001)(54906003)(41300700001)(6636002)(110136005)(356005)(47076005)(2906002)(2616005)(7696005)(70206006)(36756003)(70586007)(82740400003)(81166007)(8676002)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 01:24:25.9222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 681d6fae-0a1b-4a0f-8ef9-08db3c86fc58 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: DM6NAM11FT019.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9027 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 Reviewed-by: Hans de Goede --- 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 Thu Dec 18 18:53:21 2025 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 B93A2C77B61 for ; Fri, 14 Apr 2023 01:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229910AbjDNBYh (ORCPT ); Thu, 13 Apr 2023 21:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjDNBYb (ORCPT ); Thu, 13 Apr 2023 21:24:31 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2088.outbound.protection.outlook.com [40.107.93.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28E1E69; Thu, 13 Apr 2023 18:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dpoxlqB7DTLLYqyx6Mf0DrGdahCkbTGhriyeyBwzHyKKKEF+iqLmTwX/M5YDKxqwwXW79iVWWHBgpzbsTQ5vAI6YxewixQYUGnYaulHsDnFqZHv9hZ4yg9b4g0ZOj5aVzXNmE3r/KtjrrbpWxHCF81/VBJdEaeFMG3okf48mM+4YsY9KX04NEUQq5ii32R4HhdI9Ddf2YnUcEdr+xD/uovIfZXEatui30jeQjy/nkuVNsjI+usVDEPKV+9Qe+WIGira5wvFCZ19igXbV0zL1WOxwUAqWthX44mk1tLSgF5E2P1nQSwuts34X1cKdTwc5EtGNJeX6pb8DmvEaCurSVg== 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=aLxyqIs1SlaMOqnty4CS7CXYFxAuirc6bSeypO0Mh70GdrApheGvKRCw5eHLCQoaDa12WyaKLK/2IdA1QQKTZdJTgtH31TyUcJ9nSPl6a5OWjn7grGSekOlFg/Wle7mT5PeMdXvJNGiUwbaz8n1LcbG1ezM+qF6GuPOwZfHzelBbnuUAgElHF0FHpaJeNhJUyxLuL6jNaCRrzEC+BBdE8QMFrCF6myz3N2ZmLt4kJfetzp2VYay7wQtXSY3m3Df+cUyBO+o4B5rWOi1HBuqk9VuQU2+cS8j86U7sHZRxtdWctUS5WFxAPrCKYxGky7rACeruQnTZ1KL+3Yy6bOcSWA== 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=sPCG3ThX+0vOyxfSewCrhsJWBWaa/EAM2xJpNUcOQ3eVcZwWQDi7YSh8YhZ8KqrlRjyd4NKcSIQD4BLJasRM9QDek9fJazUIazRp2/I3mj5PPbGF5YX5QjtP8Gi7iiO33ohsvGYM3Q6HQ1OswvqF9CaXv822qPrqm97NhKY1H0A= Received: from DM6PR02CA0080.namprd02.prod.outlook.com (2603:10b6:5:1f4::21) by PH8PR12MB6817.namprd12.prod.outlook.com (2603:10b6:510:1c8::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Fri, 14 Apr 2023 01:24:27 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1f4:cafe::3) by DM6PR02CA0080.outlook.office365.com (2603:10b6:5:1f4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.31 via Frontend Transport; Fri, 14 Apr 2023 01:24:26 +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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.33 via Frontend Transport; Fri, 14 Apr 2023 01:24:26 +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; Thu, 13 Apr 2023 20:24:23 -0500 From: Mario Limonciello To: Box David E , , , , Rajneesh Bhardwaj CC: , , Jain Rajat , , Mario Limonciello , "David E . Box" , Mark Gross , , Subject: [PATCH v9 3/4] platform/x86/intel/pmc: core: Always capture counters on suspend Date: Thu, 13 Apr 2023 20:23:44 -0500 Message-ID: <20230414012346.1946-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414012346.1946-1-mario.limonciello@amd.com> References: <20230414012346.1946-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: DM6NAM11FT050:EE_|PH8PR12MB6817:EE_ X-MS-Office365-Filtering-Correlation-Id: e6f8e632-ff93-49f9-b085-08db3c86fc80 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OoZfYjm9cncJ90fyvrkTNsH6zgqwW8MxIxmoyXLSUvc2r8HJn2+6alJcptXOG0Mqsrakabsb33LVYkUHiABHzMJ3n5rgFiMF9KR39DInL0CvxufXP4bnm50XR0fjlyiTqrDL2UHgdTnBj9VKYJyk0LAQhCdDbt1O46YIQCeYcJA3QMGGHMOSYTxU7/Htn/izgXnVYAalzpZt9tufVTrjmv8Ji6feqieVKYXjorFxNZNb2ec4gwW/Ox1yxz0Bvsc1kiy5sedKYz2KruZCY1rPyT7HKYLgH9YimOdOpE6EYR3Or64ncKBwnt7MVYMHHIrKOJEiOTKx76GMhhAbY4sw241HENxkt32Jl21GrAxSEwnxAid6Ct/7ecOgny3FtRt7nvrpzR7WxVA5syU3nMnETxLDMkCm2lo/8AY31xCan4e+FAu8frrhB0yYJuYdKWjPXt6R4JUcJriWlzOWoCxKpKXxnRpua7it4R5JFwiQH2lIL03jsxkEq1Bc+FreO8GAP/+AiDSnBU95xUjZa7lHWoomxnKn4eJWdWeU9JyrMv+N96B38SldOOroM4w+JK01oYrL/eoYt6mqaxs7z9AY8GXvpwFcCv9E8eoRmI+shrkzDh9LeNDuTC5BuMr3BwomTRKFgLGURA4+ylsdFJsXGDyNY6Cv6SYmhbA5xEY3drUd6Q2Cjolbk9uL0HvMB+wFjxXzSlDRNF2VA2aFfg1LLQl4MKydzkqZB8eJ9U5JQw4= 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)(346002)(396003)(136003)(39860400002)(376002)(451199021)(40470700004)(36840700001)(46966006)(336012)(426003)(26005)(1076003)(40480700001)(70586007)(70206006)(36756003)(2906002)(6666004)(83380400001)(82310400005)(47076005)(7696005)(2616005)(186003)(16526019)(36860700001)(4326008)(15650500001)(40460700003)(110136005)(44832011)(54906003)(7416002)(86362001)(5660300002)(8936002)(8676002)(81166007)(316002)(356005)(478600001)(41300700001)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 01:24:26.1539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e6f8e632-ff93-49f9-b085-08db3c86fc80 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6817 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 Reviewed-by: Hans de Goede --- 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 Thu Dec 18 18:53:21 2025 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 64EDDC77B6E for ; Fri, 14 Apr 2023 01:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbjDNBYo (ORCPT ); Thu, 13 Apr 2023 21:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbjDNBYc (ORCPT ); Thu, 13 Apr 2023 21:24:32 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2054.outbound.protection.outlook.com [40.107.100.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C813E40FD; Thu, 13 Apr 2023 18:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lA0SPL5yq06GRlTwRFKWkhq87uKmUk80BxgyRkNBHcDx6VH2lwRxgsPBvIpSq9zFhGWao7YyO5zN+3IMRa63Ro5jTYCfj4KicbaJMkgVZ8nmDrbdwKFmuevtCao9CqFhua4vs1nEzL8RNi8i3QIogVv6b4I437aYkJxUbdbCQ7gSnXriRbGzam6y69ThxnllAUo4ASKHI0VMy/dER1OsOMO1NTdBGPRkreK9hAXgyBdSxSPUDxWt7OflF3id7x+oeqnBFVMCf0P9XHF3cevxfkBgL/gFr5kEBauiknzbs/eaozwjFjUL1OWFjLoGsYFORGsc/QnWnUeD6sV7xiDdWA== 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=uEGYGPy5OjPx1cD0EI26wT4NCdlfHrDRRS1jFg0AECw=; b=lybRjdR8mMIqmsMs1eMdIk2OHzwdMkHKvEM/evf1fUz39ZJ2/rmgi/u3mAMBCM5Vok+thsbrW+obKZvz7wtvATGFWUJPNzKrh1nEMOLGeHj1Pu4oHdY2dvxsnZe9aVZwqc5rteitt76ltxOKVGSjo4P+NEN+HxdvGrjKQqwHsy5VVe9mfEEtXcpNz5aLy/H2Ij33Yix1sarOY5LYBvfFATuJG1CYvs/UWjQ4il6AVxEaVwNdrDPt7V5gyjS1UXkouCvl2x3Wyzs17kTw8sQJmHGoPdjpLk8aNctjuxPNfMB/cEl5YC+WrTUcMHuudUkg3y7tbybxqBUwRSpuyLwBWQ== 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=uEGYGPy5OjPx1cD0EI26wT4NCdlfHrDRRS1jFg0AECw=; b=XWtE5E6DEZgADQtUy/Hm/QwOFJcdVZaluPrcptG+erKnj8uIeDzkBBIHrkEHkveQI2YnrodB7OE/AY6GT1qBBB7TOTmf6Ekn9VuLLHXWflldXd/AOIu5NHMm7G+AnJPliW0k0ER31sAXTXV27zKA/g1ue/Js7pLdcDdoqmWNlgg= Received: from DM6PR02CA0105.namprd02.prod.outlook.com (2603:10b6:5:1f4::46) by MW4PR12MB7189.namprd12.prod.outlook.com (2603:10b6:303:224::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.35; Fri, 14 Apr 2023 01:24:27 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:1f4:cafe::15) by DM6PR02CA0105.outlook.office365.com (2603:10b6:5:1f4::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.32 via Frontend Transport; Fri, 14 Apr 2023 01:24:27 +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 DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.33 via Frontend Transport; Fri, 14 Apr 2023 01:24:27 +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; Thu, 13 Apr 2023 20:24:25 -0500 From: Mario Limonciello To: Box David E , , , , Rajneesh Bhardwaj CC: , , Jain Rajat , , Mario Limonciello , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "David E . Box" , Mark Gross , , Subject: [PATCH v9 4/4] platform/x86/intel/pmc: core: Report duration of time in HW sleep state Date: Thu, 13 Apr 2023 20:23:45 -0500 Message-ID: <20230414012346.1946-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414012346.1946-1-mario.limonciello@amd.com> References: <20230414012346.1946-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: DM6NAM11FT050:EE_|MW4PR12MB7189:EE_ X-MS-Office365-Filtering-Correlation-Id: 72991e36-f0ee-40ce-41e2-08db3c86fd38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s+1tIQJGxEMVlkVrnZPzlNhaicA4vBpV6P5b8H3dTEx9UQ2fKMTTM06q5bpIXNN0/yyCEuqvrFHryGfbnrJy0U0KlcF6p1Vur1YCoNGxf5NLRasRIgm8L24gwZh/9GynWDXez4ZRhbLn7YaFgMIDUhnlS9024c7eXKxX+2W1auPy/BD/b4z6T5Bk44op1JSYMxpvxpmth2ghLAYGvK/G83fMKPFZv9wrwAaTFnxWDCjAgf9uRNIolSSjnXUcmRSIpcvamMCnF9yUwe37J+FJrzFBQIGOttg4ISJ7+Qo3irT3WJFECxpBr+hWmPTg5nW5NUAAaRHHjuGR+JuXv4RYirKnzm4BxKVefxqYakBDDCWJv7EdjY2oSMsndOJk2DrUOsFWFjx+2zKGafc2X+UoUSWdP5NvfIBEYZsl6yNswm3fmUwiQiz9lg1N2h95t08lPNpO4tnJk/FULacMYEBqQyrP6Fe7KgcicY1SQUJkscGk8nR8Qlj1UcZgr5m+QfvxgT5Wr5lV1u+PtMZ7utstW8e9GpaZHSrOzZRemQ/3k4G8OX/oLiNsg/zfQ/eryWrXjWHbxbG4wSinAwPPH9HTP9SDKMlhGR/UDUJrmh52imR4Q5hOGtIYhGjmAG4pbX1wc4H8BRDwC9B39HICyVOlEKfrLJCp34WFeEENYjhoxE7xirj0pKL94k5BCxgSwHJpELUyuNtwxlIz3wYafQkr2+X4wKxY8JAGAX75ycNwqOc= 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)(346002)(136003)(376002)(39860400002)(396003)(451199021)(46966006)(36840700001)(40470700004)(7416002)(110136005)(4326008)(44832011)(5660300002)(8936002)(54906003)(2906002)(316002)(16526019)(478600001)(70586007)(41300700001)(8676002)(70206006)(186003)(7696005)(6666004)(81166007)(1076003)(356005)(82740400003)(40460700003)(26005)(47076005)(2616005)(83380400001)(66574015)(36756003)(426003)(336012)(82310400005)(40480700001)(86362001)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2023 01:24:27.3414 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72991e36-f0ee-40ce-41e2-08db3c86fd38 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: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7189 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Suggested-by: Ilpo J=C3=A4rvinen Reviewed-by: David E. Box Signed-off-by: Mario Limonciello Reviewed-by: Hans de Goede --- v8->v9: * Use FIELD_MAX and GENMASK * Add tags v7->v8: * Report max sleep as well --- drivers/platform/x86/intel/pmc/core.c | 4 ++++ drivers/platform/x86/intel/pmc/core.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/i= ntel/pmc/core.c index 925c5d676a43..298f27ba1e10 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -1153,6 +1153,8 @@ 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(FIELD_MAX(SLP_S0_RES_COUNTER_MASK) * + pmc_core_adjust_slp_s0_step(pmcdev, 1)); =20 device_initialized =3D true; dev_info(&pdev->dev, " initialized\n"); @@ -1214,6 +1216,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 diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/i= ntel/pmc/core.h index 51d73efceaf3..9ca9b9746719 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -16,6 +16,8 @@ #include #include =20 +#define SLP_S0_RES_COUNTER_MASK GENMASK(31, 0) + #define PMC_BASE_ADDR_DEFAULT 0xFE000000 =20 /* Sunrise Point Power Management Controller PCI Device ID */ --=20 2.34.1