From patchwork Mon Apr 17 15:27:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 674944 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 7FDA1C77B79 for ; Mon, 17 Apr 2023 15:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbjDQP2V (ORCPT ); Mon, 17 Apr 2023 11:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231130AbjDQP2J (ORCPT ); Mon, 17 Apr 2023 11:28:09 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2085.outbound.protection.outlook.com [40.107.212.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6CE5BBAE; Mon, 17 Apr 2023 08:27:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lFoDYg/2YryYmMr3rS3eigEKJ22c7vgw8cPJ08okcDcjapTMUIuPHnQjNlNV3Fx688zyy+5n/VBVw33HKB9nAfGM87Ke8vl5DYk2Kqe03X1c7zmH7yx4IHFsc73oLj0Qcvy8rnDS7GegdB/xb3bAfsrQu9vrNczSBktiL7PKggZttz6raAwS5ptqoN9AOLaLMaqR6/X3++DgByYSnSKow3DxRrorNLNsLH8rCjdcTyFVgky7woatN94wOMZm2AC/5VAt60y0oEzp5xVIRWIKLf7rbKrYj++IAi2jrHv/7QtuLw06a6v7EPwSXuzyoXOz/UJ1Q6DaCnWY2Jt042UOlw== 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=Iz/F4CiSjm5AbQBzF+Y2/+001VLhR97nY5lT9pCJ9gM=; b=W8lJh0pJNPzZ0/CPqZ3Ds0u08SdZGPgI/LpQT1eFlQhXeOfMTZlA7L2zM3IEnSp6v7C2spdG9lG6bzRecyv4L1AjlZNsN68JnUCesqVYN9ZlxW2m+Wdir7Prc5y/t5fcMPglaOTueC9XDalnfza+8GOlrjl6vY92rRMfHiGNMuv1T9A3Y/ZwrOAVeAj58FHRZ2qDFDylSEiDpjOsz7idF8+6wEMjXtQhiAsFSQjxGg+8LKP0jTt/0kZHO5MmARMWe+ZxsQiSwljzVkfaK/s+tYkA980cxQ3VN88pNTmEJJz2fAvoq9pBPiwfnnHp+p7iKMNMQvcO0fmS99XTpKJcug== 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=Iz/F4CiSjm5AbQBzF+Y2/+001VLhR97nY5lT9pCJ9gM=; b=BXuF2c2k77G9o7GYpdbAp2qiv0gS2D+AAm2kWLoCfV+aevmUPg396sQvC0dqXNpe4PPOSZpmM/+A5SYO8Amxma3WITvT0O4b3jY9LoHC54TjYlBF2sClLWJAMW+I8YoR5jAxDmpwDUaW8zsXGSrx9xju/J98YzPccL34Q+wWSAg= Received: from SJ0PR03CA0105.namprd03.prod.outlook.com (2603:10b6:a03:333::20) by IA1PR12MB7640.namprd12.prod.outlook.com (2603:10b6:208:424::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Mon, 17 Apr 2023 15:27:28 +0000 Received: from CO1PEPF00001A5D.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::a8) by SJ0PR03CA0105.outlook.office365.com (2603:10b6:a03:333::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Mon, 17 Apr 2023 15:27: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 CO1PEPF00001A5D.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.14 via Frontend Transport; Mon, 17 Apr 2023 15:27: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; Mon, 17 Apr 2023 10:27:23 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: Box David E , , , , , , S-k Shyam-sundar , , Jain Rajat , , , Mario Limonciello Subject: [PATCH v10 1/4] PM: Add sysfs files to represent time spent in hardware sleep state Date: Mon, 17 Apr 2023 10:27:05 -0500 Message-ID: <20230417152708.3599-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417152708.3599-1-mario.limonciello@amd.com> References: <20230417152708.3599-1-mario.limonciello@amd.com> MIME-Version: 1.0 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: CO1PEPF00001A5D:EE_|IA1PR12MB7640:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c04b0a7-6775-47b7-e182-08db3f58409c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nlbl3/soZP6SCZP42pwFdopVrCqfDWnM5+WpSKXRESu9xgYZsEsbBluElVExsbyJePjsV+uhfSvN4DjpPnmkYajFdxGxhaVCGYj303mPMqVCdFXNq69oKGBrMDqOXiMwSh5kJrXHsn5C+XOo9C9RUzxCY6md7zep1r+y+KJtYh2EIMKbbdKcwBq/5zCQv0eR6HCgJk7sGs4YCxHVj89Nw/VAph0yHPlzjiqSsrKmwTyjRwFAqIf0pvjXDT/smsjQb65Qn5gf5Sc9dBbmqC521gxaEUQoH2D/tVByYoeZeDxT280ozxTC951tYMZYXi6AsrOYCqZ1tGcSjLzPrSJvq6I+MGOHvT4QoEX6glcpKsAociERvVYWXp03Rw1MfL5zqhFuNOVYuTsNJroAbBiaUXlbzo7GkfkgyitX9oL+OAmC23zP/W5bAiG5DYYdAvK9WGATwDinQDqJOf9uABQdJbggdl/LFZ0yxH7dUAoqoaDR98Z7kcauzgdx1xgRW12VReyZACipBg/KdCvZpdAvsbntNXbtKk/RcQGJAb9A4mcw0NxMQDJq9zCdV2vY4fTBZjTn88dwpWR4fFmx9+3jaGa3tzGZofVW3rrgpi5vKGItG6B1SYbcAkpQRfOjZHnn3x91S74x1nAe9+DVN+r2tgTo4JEpEm8Bzz2Tdsil46qX9yEkgCg5qynU1eObRgNDbbmIg+YHRhwNCiqvrGEEjkLXGHib58XgJF+IXGVHKNk= 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)(46966006)(36840700001)(40470700004)(478600001)(6666004)(8936002)(8676002)(316002)(41300700001)(82740400003)(6916009)(4326008)(40480700001)(70586007)(70206006)(81166007)(54906003)(356005)(40460700003)(16526019)(186003)(2906002)(36756003)(26005)(1076003)(336012)(86362001)(83380400001)(426003)(47076005)(82310400005)(2616005)(36860700001)(5660300002)(7696005)(44832011)(7416002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 15:27:27.5189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0c04b0a7-6775-47b7-e182-08db3f58409c 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: CO1PEPF00001A5D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7640 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. Reviewed-by: Hans de Goede Signed-off-by: Mario Limonciello --- 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/testing/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. +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]; }; @@ -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); #define pm_notifier(fn, pri) { \ static struct notifier_block fn##_nb = \ @@ -526,6 +531,9 @@ static inline int unregister_pm_notifier(struct notifier_block *nb) return 0; } +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) {} #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 */ +#include #include #include #include @@ -83,6 +84,19 @@ int unregister_pm_notifier(struct notifier_block *nb) } EXPORT_SYMBOL_GPL(unregister_pm_notifier); +void pm_report_hw_sleep_time(u64 t) +{ + suspend_stats.last_hw_sleep = t; + suspend_stats.total_hw_sleep += t; +} +EXPORT_SYMBOL_GPL(pm_report_hw_sleep_time); + +void pm_report_max_hw_sleep(u64 t) +{ + suspend_stats.max_hw_sleep = 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) } } -#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 = __ATTR_RO(_name) -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"); 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[] = { &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, }; +static umode_t suspend_attr_is_visible(struct kobject *kobj, struct attribute *attr, int idx) +{ + if (attr != &last_hw_sleep.attr && + attr != &total_hw_sleep.attr && + attr != &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 = { .name = "suspend_stats", .attrs = suspend_attrs, + .is_visible = suspend_attr_is_visible, }; #ifdef CONFIG_DEBUG_FS From patchwork Mon Apr 17 15:27:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 674405 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 758DEC77B7A for ; Mon, 17 Apr 2023 15:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231343AbjDQP2W (ORCPT ); Mon, 17 Apr 2023 11:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230463AbjDQP2K (ORCPT ); Mon, 17 Apr 2023 11:28:10 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2049.outbound.protection.outlook.com [40.107.93.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08AEE91; Mon, 17 Apr 2023 08:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h2ZWGmSZZggPKzPvAbpQR4ippu1od8hyY+oZwBWbJ2ZXBWpZ1Jy/2zl3dnymVi9Z6gCE06iIrcYXKrEMV7B+kvXioW6PpP4UmlqpKEJ2Ww/Pm9GVrfDoQSGNI1mgcMLlHhK2Pcy84jMryoac9Vd6Zxr5/F9su+itOgbss5plB4ILU2yI/OPD2EiYEj+8W29EEIXPKU/tnpm8ZRP7W4TOIScKuJpygW4cWq229v+cnS5BIp+YLon20tHvUVn42sA812jj9rrKyV5QyM3oDh7rP3jX85EryIHWmjEcpxq09gSt08bu5IFaHNBHERO1RYBZqvljGsZ4qZ5CzVzzwmkaMg== 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=H6fbg24Ws5/6z6CB9XfcKUwM5vz/CPdbV6Hj6+qrwp4=; b=HzIpS8LzlVuBd/UdAA20FX5aq1KNlniZxxf+X72Y6uPDWm3W1iAdJoQUHoIAw3GZ+BvWW0RU0Uq8/ZlnqKrriFEK3XLbzJD4VKNQBUfjlJmVPyncyjxgeZ+S9KQ2Tj+0ZSHG+urY9vtctic3BEVJ7j7EWwoqwRKhbHZTlN4SczGxIKH2ytu/L/n0eo32tUogAiS2QLnzmaYEFro0FuBCSy7Pf03/wHzB5crkSIexU304F3e94+4mxF77wQT+wc+U4GWWRoWx1fb9Vmdqdvon8GuQKfF2Y6WON2Nyi2tmDjqP8xtDRnzMGgt2hF5ywMJqQ8nbbPQ0izLpJJSpHukr0A== 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=H6fbg24Ws5/6z6CB9XfcKUwM5vz/CPdbV6Hj6+qrwp4=; b=zE2vkbj3+vCgk8vl5NcxGf1qqOAqpddIOOXSaRzR68oRa+zEJFf0kdl77JLiTY5DuyuX+Z+nag8guwyDTMgJLUrXq/kKrplqsMtA+ud3cq01PV1Keb2lMikfl3SIEdw8rBuaybIeUBF7Pu2/gY44y77jhpeuTG11iMc/XgCQBgQ= Received: from SJ0PR03CA0105.namprd03.prod.outlook.com (2603:10b6:a03:333::20) by SN7PR12MB6887.namprd12.prod.outlook.com (2603:10b6:806:261::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Mon, 17 Apr 2023 15:27:31 +0000 Received: from CO1PEPF00001A5D.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::a8) by SJ0PR03CA0105.outlook.office365.com (2603:10b6:a03:333::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Mon, 17 Apr 2023 15:27:31 +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 CO1PEPF00001A5D.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.14 via Frontend Transport; Mon, 17 Apr 2023 15:27:31 +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; Mon, 17 Apr 2023 10:27:24 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: Box David E , , , , , , S-k Shyam-sundar , , Jain Rajat , , , Mario Limonciello Subject: [PATCH v10 2/4] platform/x86/amd: pmc: Report duration of time in hw sleep state Date: Mon, 17 Apr 2023 10:27:06 -0500 Message-ID: <20230417152708.3599-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417152708.3599-1-mario.limonciello@amd.com> References: <20230417152708.3599-1-mario.limonciello@amd.com> MIME-Version: 1.0 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: CO1PEPF00001A5D:EE_|SN7PR12MB6887:EE_ X-MS-Office365-Filtering-Correlation-Id: f1aa1261-ee39-4eb1-b44a-08db3f5842d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CIU5+L7donW3wls9TXY7EmOiIgSCpOpsKZd6Mr/RAdsLhIq4P6lkjDytawqm/pSaoLfeNrkMROxwgENBaZhDiPchZJXYqezhLMsXuSfOBtwc64KR8lD2niXIR0T0i9iKTdaNO/aRYTfHgZbwVDAbpsCcPX1LztVyb/RjaUIV01rY3gW4fvjouckIPDq1ds/dOVfuo7E1miacf7v21BWV+FIp8gesM5R8b0Ml6jQj9549XvJyfB2VGa8mebZmSsIroFI0TII95mSIn2OaC0ajgFcgYv77IhZYKkUjZtNyT+tXHXPqgjM0D0xc9TO2fAgDdllurQqM4Xw50x/F/DBR3YhJCoJJXpcelD63Kf7O63pWyuICCh4qSJ4wxcA3Jf42znNmjIhAUONoOCrgM0V6/8HXTKceLlFpHdimVqfGC4sy/fwcMbfjMrDydciXvTBH4+mrYW/WYWTTxFpgDzRBzanytJXV/27G6v5YHPCkV25vamdrTMlp4LQwpqeyJhZwfGEb82dILNzT23defkdHsDq63E5UtYtoSr9sUePvTzNxEjJTp6zaXqOiyIAVnK9YmvsHZWNP3yCNbccGjVgFNYnXwyWRMXnsvbxNPK4vff922zuB+6jqoncU8oE/naoAkOXQfARCw/xntKo/NUaO6GjZZNYl2BgYlfgB63VZ43UxgT0G7ETC117pOuENE3XlfgocAJ9+bs/NJpiQZ+huoLGa8QEuD5nB+fLpLiPztBk= 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)(346002)(39860400002)(396003)(376002)(451199021)(40470700004)(36840700001)(46966006)(86362001)(336012)(426003)(83380400001)(36756003)(1076003)(26005)(47076005)(82310400005)(16526019)(186003)(40460700003)(2906002)(44832011)(7416002)(2616005)(36860700001)(7696005)(5660300002)(6666004)(8936002)(8676002)(478600001)(54906003)(81166007)(356005)(82740400003)(41300700001)(316002)(40480700001)(70586007)(70206006)(6916009)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 15:27:31.2534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1aa1261-ee39-4eb1-b44a-08db3f5842d6 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: CO1PEPF00001A5D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6887 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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. Reviewed-by: Hans de Goede Signed-off-by: Mario Limonciello --- 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) 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); } 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) } amd_pmc_dbgfs_register(dev); + pm_report_max_hw_sleep(U64_MAX); return 0; err_pci_dev_put: From patchwork Mon Apr 17 15:27:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 674404 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 B1AB0C77B7C for ; Mon, 17 Apr 2023 15:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231267AbjDQP2Y (ORCPT ); Mon, 17 Apr 2023 11:28:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjDQP2U (ORCPT ); Mon, 17 Apr 2023 11:28:20 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D2DF7683; Mon, 17 Apr 2023 08:27:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SMjHnbGpYUCdG+xR6r3efWKrcJozlUiwVriRx63dTYygz3DN3hYLp0KaOhfYzMMBP+L+iYjmig9sjp+bzmj5ApE1MzfxXHZRb/SgjexTOTcXgEZ8vJ0yNqoVKCcPQ8Y3y4qt2r++0SbJwnYtyKkhaWqudUX+OG/btomLcek18/iYj6fkt1T+da5KmVNu0iB+aGQL/OCfJ9iSuEXnGhNqEZs1D67fZpBjONlz76SQbXA5fYhc7p0Tr7qCWMwEQ2vcXA2aHdYRFopTkEtFmapY1ZDWKhz20/poysHXa7qUBTSUwnTcJzyBvLo8FnFocTOTpBGtsgxxeyQEXckSGWMDJQ== 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=aLqQQatTCDsDQf68uUAaQQVpsjvmPexAs/ETpYIVPFI=; b=CSWPxCtHm9dZ/uY8YAm4p5rb6QQn1QUXKnW4y4HLDgbXB14KYB0JdPukwhGF8hZUvl309r+Cq7LpIQqQiFQ/uyQc4m/+vQMYRVeblqJ6xQowBB59sIBba1/B2q0CA5SulrsdE6/gzkKWzG/9vk5oTzxcMMZ26aqBdJUyP/yYHKeVLXO6WV4sFymrgmJ+5eiK50sy+uDfpw3RE9JVY6RtaKnb1EPWjwwTFYqo+WSDlFtg+4lQutrcL03lExlCNPzdx4d7esddpp5uh7pQhYCmnYt4LTx7c1x8Q12NYfrX8tANHZl/H5xmni11m8ri4cjbH+59GsuJnuCfSSrXrWxEyA== 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=aLqQQatTCDsDQf68uUAaQQVpsjvmPexAs/ETpYIVPFI=; b=MtnkApYJ8pnESswIMl338kcW4SqxPuHcsCnb3tQsrHBzuTx6N7JTWOhxpPGh0Iz8K/6dAVD4ewg/Pl5Gfy/VP6dOZt1DzkIORSv4sUkKmEGkGlTOdXnChLKlRphdnIONvLIVPb+EqU/UaSTShsS/B7SehvITaw/deeCE4vWQDhY= Received: from SJ0PR03CA0107.namprd03.prod.outlook.com (2603:10b6:a03:333::22) by BL1PR12MB5972.namprd12.prod.outlook.com (2603:10b6:208:39b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Mon, 17 Apr 2023 15:27:33 +0000 Received: from CO1PEPF00001A5D.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::6d) by SJ0PR03CA0107.outlook.office365.com (2603:10b6:a03:333::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Mon, 17 Apr 2023 15:27:32 +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 CO1PEPF00001A5D.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.14 via Frontend Transport; Mon, 17 Apr 2023 15:27:32 +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; Mon, 17 Apr 2023 10:27:25 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: Box David E , , , , , , S-k Shyam-sundar , , Jain Rajat , , , Mario Limonciello , "David E . Box" Subject: [PATCH v10 3/4] platform/x86/intel/pmc: core: Always capture counters on suspend Date: Mon, 17 Apr 2023 10:27:07 -0500 Message-ID: <20230417152708.3599-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417152708.3599-1-mario.limonciello@amd.com> References: <20230417152708.3599-1-mario.limonciello@amd.com> MIME-Version: 1.0 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: CO1PEPF00001A5D:EE_|BL1PR12MB5972:EE_ X-MS-Office365-Filtering-Correlation-Id: ae23293f-fe06-46ee-ebf2-08db3f58436c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b//nMak9QZVGXeHyWCjoW+Js63DyU86Hs0A9dQTkp8xEV1SSFLIL+ab/xtsBCghyLZMM5aUNuz8mRin8x+UPmO/dAp9WvVelaJNYE3OZUr8uDLbHl84O9FaOvaIeDUCvVmaNhnnb91DsKw/hCMvPy9PB8ruoRsHRxfBa/oNWfgFtMpQQKbNnhgwPhx+bbLH8svmQ1CCR7BO+NCH4KWo9cLnTXhxLvwRn92Gzq6EYw+L1XZiIse0OgAVtbhTEorlExN+lB+w9g0s3cxONXZpc8DZT1vg5Wgn+7rBa0EhWmEJMXD0NqqPN049yPNAhAla14MvCmd1lq0gEV66x2lnLLrJHXs1xmrXdQMlh1/hAWVjJ/KyniJ8NJmLt6i3FJuCZnbaGj8noiCuOdA7wfig2tiuCzcE+DO4KpaQm69Y0kZgRQXcMKsMQ62YfLsIlw+JPC/iA4IXIxFRgkIwnBYGpVFSL2cpqCi8/qcsTh1sR498i45tJMWVaKmED1pxrwLyoF3nL/mVXjlvgBKwnF2yxnl4FGH5v80BnOQFNh9BcKb14S5dkNVF99Fd/RMayfYW7oBcQZ+zaDBPGJjTrJb6YD4wZE0LqP2YhE2zGtt2tSfhw6PIhaZHASK632KpNAuZ8oP4Xue+vb6IcG8dR1leW9xAB5h2DbUlh5tly8EIQQq7j/FXuUURo6XidCDQiBhKmTI0cohRljjZ2i8sqi16KKjOxZy1as1wBbbOuWySuQmk= 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)(376002)(396003)(346002)(451199021)(40470700004)(36840700001)(46966006)(86362001)(7416002)(54906003)(44832011)(15650500001)(40460700003)(478600001)(316002)(356005)(81166007)(41300700001)(8676002)(8936002)(5660300002)(70206006)(70586007)(40480700001)(36756003)(426003)(336012)(26005)(1076003)(16526019)(186003)(36860700001)(6916009)(4326008)(82740400003)(6666004)(83380400001)(2906002)(7696005)(2616005)(82310400005)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 15:27:32.2378 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae23293f-fe06-46ee-ebf2-08db3f58436c 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: CO1PEPF00001A5D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5972 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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: Hans de Goede Reviewed-by: David E. Box Signed-off-by: Mario Limonciello --- 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/intel/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 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; - /* 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 device *dev) if (pmc_core_dev_state_get(pmcdev, &pmcdev->s0ix_counter)) return -EIO; - pmcdev->check_counters = true; return 0; } @@ -1233,12 +1226,16 @@ 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) + /* Check if the syspend used S0ix */ + if (pm_suspend_via_firmware()) return 0; if (!pmc_core_is_s0ix_failed(pmcdev)) return 0; + 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=0x%llx)\n", diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/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 */ - bool check_counters; /* Check for counter increments on resume */ u64 pc10_counter; u64 s0ix_counter; int num_lpm_modes; From patchwork Mon Apr 17 15:27:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 674943 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 6A03CC77B77 for ; Mon, 17 Apr 2023 15:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231401AbjDQP2Z (ORCPT ); Mon, 17 Apr 2023 11:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230509AbjDQP2U (ORCPT ); Mon, 17 Apr 2023 11:28:20 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2044.outbound.protection.outlook.com [40.107.95.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57EE293D1; Mon, 17 Apr 2023 08:27:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FkB9JMqv+uT18q3scEVJ2VG1frlmdji/90gxmC7GwdGj4FIJAjerGc8NxsQtkhvV0f+tHkE4dOB/g4kUaA5WdcPIyWGV5D8t6z/PBj7D47rTn4+bHsREYzXdpa1WdJv2tAEUhmLY3cOiaJMl8x8Ayxj1bAAEI7XBYNOJsRhoKlxde4FOh7/MP0Ij67hoi3qt0saj055XSpBFZk9f1z0xfg0X7FDnbkPpuM0NSuosFoGoicdFfv/uCSiVajFgM6wbNCCH7GhGoflL8lxq7xPcaUjalzA983OXc4nApdcWWiM4rwVXuwnMuFwdbaH+pTXpckqTAdWdWp9AqOWnspvT4A== 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=8/4o3ginl8AgXQwaQyt6cMKrtMTpFY6CC1m6/DQpBRc=; b=GIJGjHC7efoe8dgKAAQseMOT9GCsk7OTdiwmYGRjEVRJS/IwelK84Epqzo3glpJsPBrj+x+pg+z08EuwVZlQd39FAAX7isDPi7Ba92wVGWJGZXzFMuhNSLxXd6f/pqlAkJ2VG7EwsSwtKEqass2Ruk5L8VP2IIBbKlxq4AoMb0zGn5ii88QyHFwEIAQ0OMJmLbnJdEqfnUUOYpJYV3XccAEYAZJgvGLNcfxwJiTx2C9kVnVF3WXnzWRfX6XqeeUGf8acyDsmMiiVMuIcKicZUTQqoCr7OfUnr2lYoMU5IednUz2+lfrZgWvn2Ow1lhz9H+OAwKarvYsIi73BUa6PIg== 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=8/4o3ginl8AgXQwaQyt6cMKrtMTpFY6CC1m6/DQpBRc=; b=NbHmDTNJpJpkq0I6H/qxrE29ia9W1L8KHzhbhsE6TsP0veXDCP0WdXcsekYzex74UkdIWDMBW/q4dVahOR/p5/OEHoyGNrIqyo4LPAXOFQJQFi9WZmMd4rD8F8uBMIIxhzF6Cu0k/yoBqx64/YaUTw33ft9Gex5fsYR7RsaulYs= Received: from SJ0PR03CA0101.namprd03.prod.outlook.com (2603:10b6:a03:333::16) by PH0PR12MB8007.namprd12.prod.outlook.com (2603:10b6:510:28e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.45; Mon, 17 Apr 2023 15:27:34 +0000 Received: from CO1PEPF00001A5D.namprd05.prod.outlook.com (2603:10b6:a03:333:cafe::48) by SJ0PR03CA0101.outlook.office365.com (2603:10b6:a03:333::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.46 via Frontend Transport; Mon, 17 Apr 2023 15:27:33 +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 CO1PEPF00001A5D.mail.protection.outlook.com (10.167.241.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6319.14 via Frontend Transport; Mon, 17 Apr 2023 15:27:33 +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; Mon, 17 Apr 2023 10:27:27 -0500 From: Mario Limonciello To: "Rafael J . Wysocki" CC: Box David E , , , , , , S-k Shyam-sundar , , Jain Rajat , , , Mario Limonciello , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , "David E . Box" Subject: [PATCH v10 4/4] platform/x86/intel/pmc: core: Report duration of time in HW sleep state Date: Mon, 17 Apr 2023 10:27:08 -0500 Message-ID: <20230417152708.3599-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230417152708.3599-1-mario.limonciello@amd.com> References: <20230417152708.3599-1-mario.limonciello@amd.com> MIME-Version: 1.0 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: CO1PEPF00001A5D:EE_|PH0PR12MB8007:EE_ X-MS-Office365-Filtering-Correlation-Id: c8431eb7-c4cf-4070-310f-08db3f584435 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rApc3+AEuzwSi9SWSWZgjovSmoKys2/YLmQkAKu1iHYOWP7dUl99NB/Coprhph/Ac8hrQss8G3Yrqplqj2cMHUg7NrHdmgww7qmaKdF1L//dZn8FGUICBiO2lHwck+rq28C0mXXkTSHJMr+BamE62LPnSabPV2dn4rec/gaHdJ97afVpb0juBCFuzBp5A3UT7k15MYsGd/ICxaBU9+QK7uxbc1XB8Sf8hkTBvAB0Yz/HJYaoXaFpLiLFmgQvjMuxCl7+i06FOU26lRkYGbHtCiyK7ZF0YAtJIDImREUjNQvVQJqQRANrxPAO3bV1g5JOQjLauVShkXaXywaz2qp3bAbhr58U44qW+c5CTn1667yhTwZ4RwyR53Eh1yCTBFLECTcEyRsP4k2fSomIIQ/VWFEuvjnVyxbhVXmMINBfVRgZCo+ZgYehBCWz3EYx40JSMmw8GNPgL/LPdkbgTQnn4d4JBnqPg00ix1heY4smHXXTv8YnGN4tap7H/EHBwgHx1/IIfdytUFAoWZ3z3ym/zkpoexKOhBWnQ4GTBdYEcs1qvn6FvhsWUtIfmD5o4H+p5fLepr7nqQaWnPHCd4eDz3KBYUpM2TqI/5HkTmQTJe78W3YEzygFdqzEGtY6/vA0Dx8nVyOGtMByMyDuUGaD+QfQLZCQw93W8AIL/PxSI3yQyaU1QyX5If3rLGQTUmvZHdvVM+Kx79NiQ7XN+l5JZwGztc2vmtSCxPdLnc/c19U= 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)(40470700004)(46966006)(36860700001)(82310400005)(4326008)(1076003)(26005)(8936002)(8676002)(36756003)(41300700001)(86362001)(316002)(44832011)(7416002)(5660300002)(70586007)(70206006)(6916009)(54906003)(40460700003)(81166007)(2906002)(7696005)(356005)(82740400003)(6666004)(47076005)(66574015)(186003)(16526019)(2616005)(478600001)(40480700001)(336012)(426003)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 15:27:33.5502 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8431eb7-c4cf-4070-310f-08db3f584435 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: CO1PEPF00001A5D.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8007 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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. Reviewed-by: Hans de Goede Suggested-by: Ilpo Järvinen Reviewed-by: David E. Box Signed-off-by: Mario Limonciello --- 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/intel/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 *pdev) pmc_core_do_dmi_quirks(pmcdev); 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)); device_initialized = 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; + pm_report_hw_sleep_time((u32)(s0ix_counter - pmcdev->s0ix_counter)); + if (s0ix_counter == pmcdev->s0ix_counter) return true; diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/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 +#define SLP_S0_RES_COUNTER_MASK GENMASK(31, 0) + #define PMC_BASE_ADDR_DEFAULT 0xFE000000 /* Sunrise Point Power Management Controller PCI Device ID */