From patchwork Mon Apr 3 21:18:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 669989 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 1E74AC76196 for ; Mon, 3 Apr 2023 21:18:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233672AbjDCVSz (ORCPT ); Mon, 3 Apr 2023 17:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233674AbjDCVSy (ORCPT ); Mon, 3 Apr 2023 17:18:54 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071.outbound.protection.outlook.com [40.107.243.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFB603AB9; Mon, 3 Apr 2023 14:18:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KnIe7DAirxQQBzWEHS2DtjC6169Gu8Auy9hnyzdIruIlLzowoxtZ7KHbQXTXRgO35emhs6Xg1rxddJfFPOi+dVdD1B6oChMh5+YwvEmoPD0S/0qCdPcg9EsfAiL3C23qp3jzTqbUhX1Ci2Ohg3IgU/2muUEMcae7kVoP3ks3QEVPcyVzfUhkCpOHnh6xpUbhpFTegyQoodvIkyHHrwUqwu3scqRaeXbVtimvIVOIyZ+bAgdT3b4vBsxTFvJRqDKUp7Fy9hoTcmvJJYa/5n4cBbZAwXE8bWU4MqZAj3nkiDhPtFSl2kqJh6KwswVLBgG1Etl4FC+KRa6PcpcLe7MFKA== 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=X39arzUJ4HO1T4FqdMCbR+xipWwoAq8sO6b5G2BYq3g=; b=lb8e687cJgaG9Xp+Gyz0AkP1r5G86Ya358FqBHFt+vQX6w0mudCCn5O5ook6XffYD270QXD5WYH3ruI5brfLShw3mCw2sVcmxgP9mX3Mj4pQ717Nk22xa3eF8TIA1X/Q+N1rZhnByAHGpnIXvkPQJO1GRhx8XXKucLFy8jnZw4xCwPoWVuEdaCJvVF834MEkLObEr29CS9aEVz/9qf73F6o59PK0zZBf0pJwz0Wi5ZrlLSVypfeMoHptRBtJ+0aTz675VvhjZ6LdvVGe2NaGj7MYRSAQIH4L8KN55ijLrUW8hz7QkUWMKlgVzSQ0+nJKoFNQnXBk+eUgN8l8uLEvLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.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=X39arzUJ4HO1T4FqdMCbR+xipWwoAq8sO6b5G2BYq3g=; b=bwjNbJ92cnqbkhuTjmnrYweH/2kDiUwQawNsylUapMFmRB25kdGmZRyah6ACTpn8QgOGk6v/W4XMTH0C/Jm6kAPOyI8ZlV6XD9gE9ikFY2A3lo2FMsg5WLHpZlc5bsQyKV8TI6/xRaSAo1/FAnFXDcOqQUUZP4I7eKeB/a2sMtU= Received: from BLAPR03CA0105.namprd03.prod.outlook.com (2603:10b6:208:32a::20) by MN0PR12MB5884.namprd12.prod.outlook.com (2603:10b6:208:37c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 21:18:48 +0000 Received: from BL02EPF000100D0.namprd05.prod.outlook.com (2603:10b6:208:32a:cafe::8c) by BLAPR03CA0105.outlook.office365.com (2603:10b6:208:32a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Mon, 3 Apr 2023 21:18:48 +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 BL02EPF000100D0.mail.protection.outlook.com (10.167.241.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.30 via Frontend Transport; Mon, 3 Apr 2023 21:18:48 +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, 3 Apr 2023 16:18:47 -0500 From: Mario Limonciello To: Sven van Ashbrook , John Stultz , "Rafael J. Wysocki" , Len Brown , Pavel Machek CC: Raul Rangel , David E Box , Rajat Jain , S-k Shyam-sundar , Hans de Goede , , , , "Mario Limonciello" Subject: [PATCH v6 1/4] PM: Add sysfs files to represent time spent in hardware sleep state Date: Mon, 3 Apr 2023 16:18:27 -0500 Message-ID: <20230403211831.4010-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403211831.4010-1-mario.limonciello@amd.com> References: <20230403211831.4010-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: BL02EPF000100D0:EE_|MN0PR12MB5884:EE_ X-MS-Office365-Filtering-Correlation-Id: b0c8ee78-71e0-4288-3cde-08db348903ed X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJ3MwNRvmGXNbSlIYvJaU900Qi173F1hIkSMWVi6GD6TfUfuGV4lBXVzO0zgVxFEZna/uD7PxfKhOs9wfO2rAEb609Jbl11YCcadR0EHj5XW/BxSLid3Gbtw4MDFzvk2bo+PSiGLSGfCEDGtRBl8xyrC1K+uMMDlVKwLruToL15jPvTSJVxL8GynNDFKARTPJl4Ur89nBzwgd5quTUTLIBp0/SIQ67ZuLkCmeqWwk/gLWHabq4RfjvTbSXQkXowx8Bu/zh8ZMMLkGS3C+eX/1GqyiB3rDa4XE57y1byhDAUSSVWDZhueP9uA2AZTh42nAV6m6eT48eHDcxoqH59fY3pwvUTS/94OjSWlnxSdniQ2m/ExOmNQF7PnX7wgE+5Z/JJHjwEKDPuT7Vnu7IIxfY7dgMBLRPvBHsMhjFEPvXj8TS3NNz5mO3LpZp+iWwAmvCiY79WIYr0oglPUkcGiNEUcAikjhPNRnAdWWiBYs9KrTWvZyuzuKDeHZMjEQVhSkE1QjdVd8ZXSmSrn9H9L/HulHc2HLCsAKhJC0SPADOOAaUGZtZ/q/MezNKqq+DoWcjTffAwlzRRW4UvuxrxjQLau1DjUo8LuT7LvWB/9CjSeiIxC3sVDHx0LsGjv/tbjjyxQiGPcWB2hrzj3ecKR4J+3kEkPa/EZTb5UJ90b1KrDNf2bSzDGZCK83ihCvozikgRQssMqmV6x4IUqKavYN/4dLo6tIqB3BVyhHRMJ6fA= 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)(39860400002)(396003)(376002)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(2906002)(44832011)(81166007)(7416002)(356005)(5660300002)(82740400003)(70206006)(8936002)(70586007)(41300700001)(4326008)(8676002)(36860700001)(1076003)(40460700003)(36756003)(110136005)(54906003)(316002)(2616005)(83380400001)(82310400005)(47076005)(336012)(426003)(86362001)(478600001)(16526019)(186003)(6666004)(26005)(40480700001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 21:18:48.3631 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0c8ee78-71e0-4288-3cde-08db348903ed 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: BL02EPF000100D0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5884 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 two 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 Both of these files will be present only if the system supports s2idle. Signed-off-by: Mario Limonciello --- v5->v6: * Add total attribute as well * Change text for documentation * Adjust flow of is_visible callback. * If overflow was detected in total attribute return -EOVERFLOW * Rename symbol * Add stub for symbol for builds without CONFIG_PM_SLEEP v4->v5: * Provide time in microseconds instead of percent. Userspace can convert this if desirable. --- Documentation/ABI/testing/sysfs-power | 27 ++++++++++++++++ include/linux/suspend.h | 5 +++ kernel/power/main.c | 45 +++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index f99d433ff311..37240575d282 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power @@ -413,6 +413,33 @@ 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. + + NOTE: Limitations in the size of the hardware counters may + cause this value to be inaccurate in longer sleep cycles. + +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. + + NOTE: Limitations in the size of the hardware counters may + cause this value to be inaccurate in longer sleep cycles. + + If an overflow has been detected this file will return + -EOVERFLOW. + 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..069ef0c0ae57 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -68,6 +68,8 @@ struct suspend_stats { int last_failed_errno; int errno[REC_FAILED_NUM]; int last_failed_step; + u64 last_hw_sleep; + u64 total_hw_sleep; enum suspend_stat_step failed_steps[REC_FAILED_NUM]; }; @@ -489,6 +491,7 @@ void restore_processor_state(void); extern int register_pm_notifier(struct notifier_block *nb); extern int unregister_pm_notifier(struct notifier_block *nb); extern void ksys_sync_helper(void); +extern void pm_report_hw_sleep_time(u64 t); #define pm_notifier(fn, pri) { \ static struct notifier_block fn##_nb = \ @@ -526,6 +529,8 @@ 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 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..ffd4dd43cbdd 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,18 @@ 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; + if (suspend_stats.total_hw_sleep == -EOVERFLOW) + return; + if (suspend_stats.total_hw_sleep + t < suspend_stats.total_hw_sleep) + suspend_stats.total_hw_sleep = -EOVERFLOW; + else + suspend_stats.total_hw_sleep += t; +} +EXPORT_SYMBOL_GPL(pm_report_hw_sleep_time); + int pm_notifier_call_chain_robust(unsigned long val_up, unsigned long val_down) { int ret; @@ -377,6 +390,22 @@ static ssize_t last_failed_step_show(struct kobject *kobj, } static struct kobj_attribute last_failed_step = __ATTR_RO(last_failed_step); +static ssize_t last_hw_sleep_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%llu\n", suspend_stats.last_hw_sleep); +} +static struct kobj_attribute last_hw_sleep = __ATTR_RO(last_hw_sleep); + +static ssize_t total_hw_sleep_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + if (suspend_stats.total_hw_sleep == -EOVERFLOW) + return suspend_stats.total_hw_sleep; + return sysfs_emit(buf, "%llu\n", suspend_stats.total_hw_sleep); +} +static struct kobj_attribute total_hw_sleep = __ATTR_RO(total_hw_sleep); + static struct attribute *suspend_attrs[] = { &success.attr, &fail.attr, @@ -391,12 +420,28 @@ 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, 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) + 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 3 21:18:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 670705 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 8E26FC761AF for ; Mon, 3 Apr 2023 21:19:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233689AbjDCVS7 (ORCPT ); Mon, 3 Apr 2023 17:18:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233680AbjDCVS4 (ORCPT ); Mon, 3 Apr 2023 17:18:56 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B1D43A8E; Mon, 3 Apr 2023 14:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e5/nnsJwXlu7q9Xc3VC0SdvimiQze6KwFGIroANnJ02EJTDDxoSmu5EE6SgAvm3BxBwWxBX3V6WRF+vEqcEpLYI0No3rvVOfiFd/9oE+m9hHyNXoF1k+tNkVqzPFaKV5+qap0PTIddSwdao8vVsvwA3G3bZfZ3lc285oRuxJUlf8uvtXsL04bXblQ8bfSehzxTbwDCs9GBx8Ox/eZmsoPlBF9BeT4vst1SpayFvsyUU482eOTXPnX5vynrzpMCnGTGfN0R9IvwSC/EsdVllMnRuadmcFyKBbr3TRaMFtPTfMmk0Nra9z/sIiQt/EsGYsYFxG3LMGlaTO0UcFO7rSoA== 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=wnHrV1lWkLBUvshwq6Zj32NSdVLSIDtQyqWdZ8MAdcg=; b=UAEO6bjq//s5/70RRJNAkRDrPSYxvnBqQXUmIcs9J9+Uq/NnA9GNPVi8Ml6xshemSjx9uoaMBt1hgqz7Kdq6YIbVVJ6DQHIJiHRE/zfGJAyAz5uhNjvv0tJ0sUjrM1B4BYnwzUGp7MfRoBOqaJL9Xsw5+CV2qFySoEwKbHzRmQdkBaUIXnErCiWuufQMFzETBHW/nsH2+s2yIJaUw1y7SQNVKVrKiyDyYWldIYpdYH5SFFcn1DT6rR+0Zz/QwZ0odd5u8fJC7py7hI33Bt9Dmhz+mG8KY9wh8UrRh4W4uuHW1pHb9TCqGIlbSLCepzt8fZbbTRL76a6jvxCVKnq/PQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.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=wnHrV1lWkLBUvshwq6Zj32NSdVLSIDtQyqWdZ8MAdcg=; b=ZvAOp6iQ3LFKITxgHhKdd2dYODH4bChxKZd+TShwwJpQxKSqzaFIHvtADu7AMXK/1qNRzO/uyM5sseEZO27E+1/1G6o9udHY2UUn1B3EQhvgK9Ur4swvT9C7s2CEC1FiPw9vLyZhNx3CD5W+n/rN6dxOuYjg4yShkBiBPtymt9Y= Received: from BLAPR03CA0005.namprd03.prod.outlook.com (2603:10b6:208:32b::10) by DM6PR12MB4926.namprd12.prod.outlook.com (2603:10b6:5:1bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.29; Mon, 3 Apr 2023 21:18:49 +0000 Received: from BL02EPF000100D3.namprd05.prod.outlook.com (2603:10b6:208:32b:cafe::5e) by BLAPR03CA0005.outlook.office365.com (2603:10b6:208:32b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Mon, 3 Apr 2023 21:18:49 +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 BL02EPF000100D3.mail.protection.outlook.com (10.167.241.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.30 via Frontend Transport; Mon, 3 Apr 2023 21:18:49 +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, 3 Apr 2023 16:18:48 -0500 From: Mario Limonciello To: Sven van Ashbrook , John Stultz , Shyam Sundar S K CC: Raul Rangel , David E Box , Rajat Jain , "Rafael J . Wysocki" , Hans de Goede , , , , "Mario Limonciello" , Mark Gross Subject: [PATCH v6 2/4] platform/x86/amd: pmc: Report duration of time in hw sleep state Date: Mon, 3 Apr 2023 16:18:28 -0500 Message-ID: <20230403211831.4010-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403211831.4010-1-mario.limonciello@amd.com> References: <20230403211831.4010-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: BL02EPF000100D3:EE_|DM6PR12MB4926:EE_ X-MS-Office365-Filtering-Correlation-Id: 48fce2e5-3a42-47fc-7d2d-08db34890484 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vrse34GZWfoTFztftg6QWFylmTYAYgR0dwqXi5d2N5VJ4anTjTXG7KIWaRjAWf5MzeXQM/IZCzEAQBeFNoqwvrv/899sVjge8fvHs51I/fZgO7m6ec3sfWhL9WOr47uP+M8DFYvnMq5/hb9440SQ7OCQzZOp/o4c0LSN7uCb6vuICR6Btb5x8Ml4gMT3otN6L3aFnmaFgCP9qlhnywp5UOmq7CrFSFd7nlzydkPlD5dhdSOgqtXrTBlcLyHBtXjm1qKi8in02K7BNXPL73tWyJAJJthG8Fzt75eSBznkmvi6M3Tn/QqF695RSn/DUirsnjT1c+nSfH0xburRRRz6R2SDMIKUgyjMQ4BkWtKumZpKeCbcm9AM9nL0j+BE8dZzUvUftNCZgi61RjSHK/Ns9+4zGvySF6bZIMAjpfIzBT+2cxH/sgDhvNC3orQyWMLG06sm1d9aIItqlggGLNQq4qz8BgCzsv6KiChbhOtIRLV7QY2YLPg5EDq5nz9Xz3drXdbNDAsA0h4YVeTuJhpxTS69llcFl1U8U3MqB7QB/4Ci9b5TuXu4KGOe7Q14jQKQcsaOktS7DWm/IVkDRyU+yU2KatnGuq0CswRLPw3SGmPb7zU8pghgpTMT+/1hqdsKl5/njY3RwZOsWyOTXlqDIizxvquc6AnmKjgfXlfj1PgJDRWLZM65FTaYP1N8rBBHY6aT1JR5t0qxk6NKc6qfzR2KkYsURqLKobRmrvN9PbY= 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)(346002)(136003)(376002)(451199021)(46966006)(36840700001)(40470700004)(40480700001)(40460700003)(41300700001)(478600001)(36860700001)(70586007)(4326008)(70206006)(8676002)(81166007)(6636002)(316002)(110136005)(356005)(8936002)(426003)(54906003)(82740400003)(5660300002)(7416002)(186003)(16526019)(47076005)(83380400001)(336012)(7696005)(2616005)(44832011)(6666004)(1076003)(26005)(86362001)(36756003)(2906002)(82310400005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 21:18:49.3543 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48fce2e5-3a42-47fc-7d2d-08db34890484 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: BL02EPF000100D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4926 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. Signed-off-by: Mario Limonciello --- drivers/platform/x86/amd/pmc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c index 2edaae04a691..6aa474657845 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) From patchwork Mon Apr 3 21:18:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 669988 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 8154EC76188 for ; Mon, 3 Apr 2023 21:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232329AbjDCVS6 (ORCPT ); Mon, 3 Apr 2023 17:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233681AbjDCVS4 (ORCPT ); Mon, 3 Apr 2023 17:18:56 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0318B3AAB; Mon, 3 Apr 2023 14:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DElE3wI18WYooNUq7V2tFLet+k6jHzq6ZO5DQSUTRZCt7WWtArhYiiypxbyauRKdfop71Ij2tT8ZwiUmVxQeni7XkQIW8UkFMMd3w/u6L8ET4Y0le/fQomUM1TjoZK4O1G+6emumljVPmp5UzyPmz0AA59HLl5EYhPlCBOdFciSKIkERlXmksympCmGbWO34ypKsoNi+CjNu5qYabXw45EFEEdKfW7Pz1vj8ekUAeOAIVfW3n2ie2Vg2zccFmjpOlhz/THyKXdp1J3Ifcs+ggA9CCn73SSb9UV2QYhpWEzDc6jETwG5PIoXHLmulsaClb05jlL9i5XzPfEQdtvh+/w== 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=I6T0VcclJ00TPYixxyWlaSEVq36/R5GwEe0sSyIdpZOOYkX1mDzDzGTCRHBLO1TILI+1y3NuC37CVaNRuuGvuKzYKhn50QW77gpfh0f8NnTf6W/8qoHTRINHXDkYnXO2kGrrGSvGCz81J0Btd9zeQrt35X82S5E5eq3WyvJFFQQvI4WrwZazqcxpj7Gj89c/iZJJHxTDZtTrj093X0cqQ9Si8ZtUYnVY3lJO0asgp8ZlYbb+WlAQU+RnXhOSfxwJYU59Z3x9FuWLUrJv5ZLRU0+RP9bBMqzaEn5U4+DyF4XZbP+cnGMdc0EvTvjQxVwh7MG18/fGHXdFKPm+ZskbiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.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=6uyuYrzpFUD9AAiawcudYbjDPhPlJBKpXwXniY+Li4s=; b=u4BdtQax0cSngILdzZRZ/LJKYXeF5CYD03cN2Q+t0UKpNVOG29xmtW2BU3+/i5+R3fwWOqocsECGPYUe72awVvHX6/0Rm+WpJC1TrOk8v4iySATHoyj7KRPQB1s14eAPtMgpFFxMHCHB2f/UsR9NNhy2667wOfDSRt4bJtgh0Y0= Received: from BLAPR03CA0027.namprd03.prod.outlook.com (2603:10b6:208:32b::32) by IA1PR12MB6602.namprd12.prod.outlook.com (2603:10b6:208:3a2::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.30; Mon, 3 Apr 2023 21:18:52 +0000 Received: from BL02EPF000100D3.namprd05.prod.outlook.com (2603:10b6:208:32b:cafe::87) by BLAPR03CA0027.outlook.office365.com (2603:10b6:208:32b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Mon, 3 Apr 2023 21:18:50 +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 BL02EPF000100D3.mail.protection.outlook.com (10.167.241.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.30 via Frontend Transport; Mon, 3 Apr 2023 21:18:50 +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, 3 Apr 2023 16:18:49 -0500 From: Mario Limonciello To: Sven van Ashbrook , John Stultz , Rajneesh Bhardwaj , David E Box CC: Raul Rangel , Rajat Jain , "S-k Shyam-sundar" , "Rafael J . Wysocki" , Hans de Goede , , , , Mario Limonciello , "David E . Box" , Mark Gross Subject: [PATCH v6 3/4] platform/x86/intel/pmc: core: Always capture counters on suspend Date: Mon, 3 Apr 2023 16:18:29 -0500 Message-ID: <20230403211831.4010-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403211831.4010-1-mario.limonciello@amd.com> References: <20230403211831.4010-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: BL02EPF000100D3:EE_|IA1PR12MB6602:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e90e549-4909-45dc-258a-08db3489054f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /yPOmecdpwAsSRx4xZSRhLZ//O0qKowhcv/BdlxKDLeKfnOFElmNH/FIFEi69pSnYKvsx7RvCW5OUIvf2+XtH16IYiQr4XcJ5zTPyveAxGzAx5maA6dHQU4tonjgbkeVeo+4BnDarCGY/PeXe55105qbHCAmrPeQhan4pWJXQaVXtKMlNgxZ4off/bwqeblTz6G7cWB8sCXe4fMlwI+NEMXJsi+tpNU4ZmM+YrbsxDNUDXHyqPaQVCf5VwdYhK/IXtSH65DTqLS91gtYbTfzhYqDosag8Mb+giHeK6lrMZEZJnhuevgxxkdHo3EpODOnalqcZyCul5Vir28p/onsK6L5V2F/8s8uUdki+q38aPqzIUFLQeJESO+VrSdzt6lb6C6w30iDo4V928gNKqoBy9QSqbfX/GtypyJV4M3ezjDSDSrBjjM1LElyzVom4la66S7F7dk0SKEMrfSCA4y+WqFybhCVI0DrFU3uhd4B4E1m2LvhKgKgp0PYJI1JqdEGlTIvAh1h73OGmpIfPVBg2NbjokgCNaHQHT3vlkUuPxBh0QzRiTGap3+Gh8yUQY4di9e+YoJZySYgf83Zo1Zfn1hGwSuD9XRhamoZ+R5eDjX5H/U3/lNYcIdtuHxRXVUloYyYvKVzTx4MRRAbxGx7gXLYGOXNyJR11jdyBZ9RlKR5dNPC8Nr+wscfhwqEVve8jDtikCnB87Q2bCohtwrIem/VXilGchjFh9x69PSiYIs= 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)(40470700004)(36840700001)(7416002)(186003)(16526019)(1076003)(26005)(40460700003)(44832011)(40480700001)(6666004)(478600001)(426003)(54906003)(36756003)(82310400005)(7696005)(15650500001)(36860700001)(110136005)(86362001)(70206006)(70586007)(47076005)(82740400003)(8676002)(4326008)(83380400001)(316002)(2906002)(356005)(41300700001)(81166007)(336012)(5660300002)(2616005)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 21:18:50.6825 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e90e549-4909-45dc-258a-08db3489054f 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: BL02EPF000100D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6602 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: 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/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 3 21:18:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 669987 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 CCA02C77B62 for ; Mon, 3 Apr 2023 21:19:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233554AbjDCVTB (ORCPT ); Mon, 3 Apr 2023 17:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233684AbjDCVS5 (ORCPT ); Mon, 3 Apr 2023 17:18:57 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 737783AA0; Mon, 3 Apr 2023 14:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hOHosssfIs/wAEMb+XJ8sBacp4tEwJzsS67tzIo1YrGCTMrpuaaU1YYRDTLZejThAlmwAhjPHh69l5t36PRzVHcDq9w2XiFwoWTGM7Tz5rkB80XWdGikMGDcwaWkmIidBvSD7rixc2EIBmvkryqY88qx5sBNRqzbDYSCncDi4HfmOC0v6rOsF6LmsMS84G6WEbTSG3MaPGnzQV891uxYsXJ0x5zKKLTWMfO/VqSn78atCFYpIg1ciMVgntu2JUkF5HRXGAU0HBqnhPbqllzFioNnyhf1XjYlvzw9gHh+Aiw9/nA/07voik2oorFvvDiin5Kc67+M2GJycijnTkqnrg== 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=kaarnB3Al5XNIfHeX1L9mcdX+Pz0wZHei+uhYR7bzBY=; b=cmW+rga+Cx/89bZtyw+AciYz/CPCZKUwxZCfnw8zaci2DzDjHWBr8Mf6mE6CdHLupoj9Qq+nCqDvc0b34n1jcbmvypoHPrbBkeqY/FotIzvitaqnghEyS6aTCA3GB2C9KrGidKrI7Gg3FyWOI+jt6n27j26MwJ0JEyd3c16lIq9gvQRM9iHTX+zmThck0aPHHZ5X2GombT4mjnFC7Ev3bPfsnTG5Ya9rl3os68+EXSzCVnuK0jSuyoRFouA0VRsy47YbBWLTOXvqAP1dHRBMMullu5HZE1+0sceE/4Wa2gad3EcsYcBHyrTZy3i8H/h8H1QoFrX1vWhs2nwPs79bPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=chromium.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=kaarnB3Al5XNIfHeX1L9mcdX+Pz0wZHei+uhYR7bzBY=; b=nvej99YP5GyApAAGuLRZ6TucTEH95cGIDHZBAqf2/IrlVBOhgKfa4QJ3pLToUB2aT1bC5XLUDngg0iVHbo4B2OC0OWR3HyINLaoJ8Hn8IawXD+pb91h+dJ0bq6R44LO87nKOzTbs8G9ry3oHjzzXQC7chQ+oxhkHg4xwdJir2vM= Received: from BLAPR03CA0012.namprd03.prod.outlook.com (2603:10b6:208:32b::17) by MN2PR12MB4567.namprd12.prod.outlook.com (2603:10b6:208:263::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Mon, 3 Apr 2023 21:18:52 +0000 Received: from BL02EPF000100D3.namprd05.prod.outlook.com (2603:10b6:208:32b:cafe::58) by BLAPR03CA0012.outlook.office365.com (2603:10b6:208:32b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.20 via Frontend Transport; Mon, 3 Apr 2023 21:18:52 +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 BL02EPF000100D3.mail.protection.outlook.com (10.167.241.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.30 via Frontend Transport; Mon, 3 Apr 2023 21:18:52 +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, 3 Apr 2023 16:18:50 -0500 From: Mario Limonciello To: Sven van Ashbrook , John Stultz , Rajneesh Bhardwaj , David E Box CC: Raul Rangel , Rajat Jain , "S-k Shyam-sundar" , "Rafael J . Wysocki" , Hans de Goede , , , , Mario Limonciello , Mark Gross Subject: [PATCH v6 4/4] platform/x86/intel/pmc: core: Report duration of time in HW sleep state Date: Mon, 3 Apr 2023 16:18:30 -0500 Message-ID: <20230403211831.4010-5-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403211831.4010-1-mario.limonciello@amd.com> References: <20230403211831.4010-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: BL02EPF000100D3:EE_|MN2PR12MB4567:EE_ X-MS-Office365-Filtering-Correlation-Id: 17177358-c525-4ffd-7b25-08db34890668 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D5pRxkAXxzckmRkk5Gqw83Gf6I294yfiYvjiugS6vy7w5eUKicfiGF6RxNDzaBUoaQvunXYYl8SkIm9gAmQO3p/zzZhnrvs5Itvi2YHtRZ0vMTtzMHJjHOMNvziAr9IaqS/MrVHhnpwHn0/zF2SmRXTAeOh7JjmvviqHY7sEEw8A7D+Zy33MC8AFVRXtS0XzWBy27U+l/DdboLFt7jedVCbASNtuxiR0Ent9bzqVtUg+1dhyytQIn3ip+9MfKU1wnt1wPmdX0XqDwQGTB69GbmLI70m6b9d61MAB6ccry2FMDtaml8fquRxLeCesEbL+4IOuHM6wEY3T2+9jzLB3Tj3J9JmfmTNKuEebqxWzXaGqiat+S1xvchMaNEKf/wzdqzSe/tp8LtAAf/KQFl3SbIVZU6S6+7tppvuHbuUwAOJJMmZdvo8JfKbisoZ2iyuEeXSibeafSCNZsKRI9qcsXD6xfnX+G3tgJcfTkdcx3jJWhCFQZAlgDFZHL4t+zLfNpuaVcYU3wZ8blWwtkXjUo6lJ/n8M8cCYJgIa526AHqRWoWNEMjVollGQo1EoWnCKDAVA6L2/PcnZ1KHkkzDK2ZlywRTa4BFgjrUtsdOU3suo8g8z4DdzdaFp0P1QId3CKqGmASpME+23LYX+EZsDI+NhORvRoYBK2e3oCX3ic+GaUeQlrEwpKhkVsfdF8WhAl5y5uQMGIZOIb5o/yAagGAjLpv5qZK722HQhGYzpW1A= 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)(376002)(39860400002)(136003)(396003)(451199021)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(36860700001)(316002)(4326008)(8676002)(70586007)(70206006)(478600001)(110136005)(8936002)(54906003)(41300700001)(356005)(82740400003)(81166007)(44832011)(5660300002)(7416002)(426003)(186003)(47076005)(83380400001)(16526019)(2616005)(336012)(6666004)(26005)(1076003)(86362001)(36756003)(2906002)(82310400005)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Apr 2023 21:18:52.5262 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17177358-c525-4ffd-7b25-08db34890668 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: BL02EPF000100D3.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4567 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. Signed-off-by: Mario Limonciello --- v5->v6: * Handle overflow case * Use renamed symbol v4->v5: * Reword commit message --- drivers/platform/x86/intel/pmc/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index 925c5d676a43..0621756792c8 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -1214,6 +1214,11 @@ static inline bool pmc_core_is_s0ix_failed(struct pmc_dev *pmcdev) if (pmc_core_dev_state_get(pmcdev, &s0ix_counter)) return false; + if (s0ix_counter >= pmcdev->s0ix_counter) + pm_report_hw_sleep_time(s0ix_counter - pmcdev->s0ix_counter); + else + pm_report_hw_sleep_time(U64_MAX); + if (s0ix_counter == pmcdev->s0ix_counter) return true;