From patchwork Tue Nov 15 20:01:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 625019 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 168C6C4167D for ; Tue, 15 Nov 2022 20:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbiKOUCf (ORCPT ); Tue, 15 Nov 2022 15:02:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231673AbiKOUCS (ORCPT ); Tue, 15 Nov 2022 15:02:18 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2071.outbound.protection.outlook.com [40.107.92.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E24B128E04; Tue, 15 Nov 2022 12:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaMM2a7HMASJsZCKApzI0bsl75wKkxild5Oud/59PHjBdFAI7NokQEVlSRiFD0FAC/fu+R2Vv+UFSxdp+X46MAZpkydCIppE7OAk+Vjay3EaGHS03U7MzZyengl4/R7gl4fSc0JU2Yug48hg1jf4DGVzCGmuMicxN/uq96rp3bOK6yulVNhnPgxwlW1a+00i6l+Cfl6gQl1i6vHe4wKA1MkGiRYwbVzPba5jVtIRN0venwL9into56xrovbyXgAizMLHinPaVIz8sk3QH434158ggT5Lldts9KxVSA3EGenOoMJ/h6Te0L9uOQ1+JPtSIn8K0wBjSl62W7VZ0QZR+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mVMMcO3WWf2cCU/0gNI+bRG3BH7aBwwuOUs+gmWh4R0=; b=KoNq+hlW4qy1X4U1mbzhBh3eJfIqpldUXvqnNDMxjFyjU1NN7BRrQI/0IZUrTCaO+XKND/ch7wjTIlMONqFWvAioBCZ9WMc0ruRTSSymTTSKoVL2Gcr/VVPBTT+XgmB3OmkRQl0NJ08SG05q3UKlrGQnbcf2EHSIdJvhrHnQMRPmTiWjRDsDppYHiMRb/QT8xzEpDZNRdOgPb+abbO0lsnCBfYhxypaxq+bovBiKkMGjwuhojsNjUqart5B2uElWfuFo+GvZAeFBTUK24Wifkg2cMHVk+xqTohqSIOhxufqhoMFWbBnhO0aUJbGPreJ/K/j2lGL+G7PRUpnLvKADew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mVMMcO3WWf2cCU/0gNI+bRG3BH7aBwwuOUs+gmWh4R0=; b=lNzk08AElPweQFTbWtF4wTgYiM9koQutIeXD6ononNX/YHOC/zzJfyP2vja+BVR3aM1EX+LOfyfoPOFqDhO4GfvrB7unrGuo0qQP16r/nj+wfcIONVxeyVdAzqj8dngIuci9OjTOr7n6NfQUjSv3BIwKa6JvJFbCvll/3QyOS4w= Received: from BN8PR07CA0021.namprd07.prod.outlook.com (2603:10b6:408:ac::34) by PH0PR12MB5403.namprd12.prod.outlook.com (2603:10b6:510:eb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Tue, 15 Nov 2022 20:02:08 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::af) by BN8PR07CA0021.outlook.office365.com (2603:10b6:408:ac::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:07 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:06 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Pavel Machek , "Len Brown" , John Stultz , "Thomas Gleixner" , Stephen Boyd CC: Sven van Ashbrook , Raul Rangel , , , Rajneesh Bhardwaj , S-k Shyam-sundar , Rajat Jain , David E Box , "Hans de Goede" , Subject: [RFC v3 1/4] PM: Add a sysfs file to represent the total sleep duration Date: Tue, 15 Nov 2022 14:01:53 -0600 Message-ID: <20221115200156.12218-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT039:EE_|PH0PR12MB5403:EE_ X-MS-Office365-Filtering-Correlation-Id: 12b07378-29a1-453e-9392-08dac7444678 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VQnVWq8m6aQ3IVp0IchLkjzeM/f/SjBANXTeHuMT8ItBEVL54DyoI8t79aUo5RTRTXOJa0axCz56yUihWctoW7MqZDybNJZT7znwKtbgw9Pzwv+PsbKPdg6pNF/zN+iYCRvJLqd6x4krWGfEUUDJFqMQKlf5DPZ3wsvITezr4a2gC1j357t62oJP/7XqQVe22YqytHPQK4RavouF348UCCEmgHf3waEFy3xcMzPc3RY4Ib/xiyljRHOPS/yTvP/u4m0cU+Ak2UD9DUVFHxgNYMb/AM7qkU8qNtEL+Ewk8p6l72r17rJQ3qBR4LInzJfbLYpzqPWEk8sSSqToz7PMcd4bhGVpRjtUj7ko++QkxDPaoBOXxLbqDgjD1rVgLREn5q2CaeumdUYgY4A83NI9ZfTKqrEhONToIWpuD8tjn6RnCK3QSctZYwXsmIcrv67EFoLIY2wDKZLl1qFHCM4MbjzFj3UsNqMAxFdMkkYqfnwPXcjqQO/grcQ94fS2VuTdprcF2biiqwpqFG/da2ZlPMDUmdfa4pzuCM+egccPpMzYHTME4OEZTgleX4EfHB0uT5v7JD2dH9Tjnd5/r4J0MevTYRqo7axKqXd7XAYxT0Oxwfd56Hk8umBbF+ESZyITLSLCQZZWkpGun2jjXD/fZ28vIdeqkDSZiBOnFhG2JnVbHg7N1Y0J6j8AXnlXJIVhglQqKdou3vXeNdPAKh5rRWDRJsEBxhCQWtvQcTW5QtqGhnj9zCpnFVTGqdPkr6Lbhyw2eoI1K+r9uuwY2sXgBgaO8wZEhjegjwcHVu5TBpuQ4uDGeQR4gy+HVoQZPMmw X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(396003)(376002)(346002)(451199015)(46966006)(40470700004)(36840700001)(83380400001)(26005)(478600001)(1076003)(186003)(82310400005)(16526019)(2616005)(6666004)(426003)(336012)(86362001)(40460700003)(82740400003)(7696005)(36860700001)(36756003)(40480700001)(356005)(81166007)(8936002)(47076005)(41300700001)(2906002)(5660300002)(44832011)(7416002)(110136005)(54906003)(8676002)(316002)(70586007)(4326008)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:07.9888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12b07378-29a1-453e-9392-08dac7444678 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5403 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org For userspace to be able to analyze how much of a suspend cycle was spent in the hardware sleep states userspace software has to use kernel trace points paired with the file `low_power_idle_system_residency_us` on supported systems. To make this information more discoverable, introduce a new sysfs file to represent the duration spent in a sleep state. This file will be present and updated during resume for all suspend types. Signed-off-by: Mario Limonciello --- RFC v2->v3 * Drop one of the sysfs files * Use sysfs_emit instead * Fix symbol name (s/type/time/) * Drop is_visible * Use timespec64 type for suspend stats * Update documentation * Update sysfs file name --- Documentation/ABI/testing/sysfs-power | 8 ++++++++ include/linux/suspend.h | 2 ++ kernel/power/main.c | 15 +++++++++++++++ kernel/power/suspend.c | 2 ++ kernel/time/timekeeping.c | 2 ++ 5 files changed, 29 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index f99d433ff311..3abe20c47e08 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power @@ -413,6 +413,14 @@ Description: The /sys/power/suspend_stats/last_failed_step file contains the last failed step in the suspend/resume path. +What: /sys/power/suspend_stats/last_total +Date: December 2022 +Contact: Mario Limonciello +Description: + The /sys/power/suspend_stats/last_total file contains + the total duration of the sleep cycle. + This is measured in microseconds. + What: /sys/power/sync_on_suspend Date: October 2019 Contact: Jonas Meurer diff --git a/include/linux/suspend.h b/include/linux/suspend.h index cfe19a028918..57f29ab4176c 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -68,6 +68,7 @@ struct suspend_stats { int last_failed_errno; int errno[REC_FAILED_NUM]; int last_failed_step; + struct timespec64 last_total; enum suspend_stat_step failed_steps[REC_FAILED_NUM]; }; @@ -489,6 +490,7 @@ void restore_processor_state(void); extern int register_pm_notifier(struct notifier_block *nb); extern int unregister_pm_notifier(struct notifier_block *nb); extern void ksys_sync_helper(void); +extern void pm_account_suspend_time(const struct timespec64 t); #define pm_notifier(fn, pri) { \ static struct notifier_block fn##_nb = \ diff --git a/kernel/power/main.c b/kernel/power/main.c index 31ec4a9b9d70..f33012860699 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -6,6 +6,7 @@ * Copyright (c) 2003 Open Source Development Lab */ +#include #include #include #include @@ -54,6 +55,11 @@ void unlock_system_sleep(unsigned int flags) } EXPORT_SYMBOL_GPL(unlock_system_sleep); +void pm_account_suspend_time(const struct timespec64 t) +{ + suspend_stats.last_total = timespec64_add(suspend_stats.last_total, t); +} + void ksys_sync_helper(void) { ktime_t start; @@ -377,6 +383,14 @@ static ssize_t last_failed_step_show(struct kobject *kobj, } static struct kobj_attribute last_failed_step = __ATTR_RO(last_failed_step); +static ssize_t last_total_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%llu\n", + timespec64_to_ns(&suspend_stats.last_total) / NSEC_PER_USEC); +} +static struct kobj_attribute last_total = __ATTR_RO(last_total); + static struct attribute *suspend_attrs[] = { &success.attr, &fail.attr, @@ -391,6 +405,7 @@ static struct attribute *suspend_attrs[] = { &last_failed_dev.attr, &last_failed_errno.attr, &last_failed_step.attr, + &last_total.attr, NULL, }; diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index fa3bf161d13f..cb0f72f52528 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -423,6 +423,8 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) if (suspend_test(TEST_PLATFORM)) goto Platform_wake; + suspend_stats.last_total = (struct timespec64) { 0, 0 }; + if (state == PM_SUSPEND_TO_IDLE) { s2idle_loop(); goto Platform_wake; diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index f72b9f1de178..f9c8cfef8fc5 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "tick-internal.h" #include "ntp_internal.h" @@ -1698,6 +1699,7 @@ static void __timekeeping_inject_sleeptime(struct timekeeper *tk, tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *delta)); tk_update_sleep_time(tk, timespec64_to_ktime(*delta)); tk_debug_account_sleep_time(delta); + pm_account_suspend_time(*delta); } #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE) From patchwork Tue Nov 15 20:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 625018 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 834C2C352A1 for ; Tue, 15 Nov 2022 20:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbiKOUCh (ORCPT ); Tue, 15 Nov 2022 15:02:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231636AbiKOUCM (ORCPT ); Tue, 15 Nov 2022 15:02:12 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C666928E04; Tue, 15 Nov 2022 12:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ac7q4iwTAQvZrTF+M4dUbfVESK27INcQm7dPUS2qkopyEkZNa32ckVQ4D0Byp8DxNdcpD70GKtHEN1xKCqlQpkhnvAKrU/iQIaElfxM2h/bC+tFBfAX4lGPTza8e+lwpuDSjUXaJ61lSxlWEEpqdo2DKzX4svu641NjQBcgqCOk4CXRSxz1dcPElZLQcwP4196jqDA1Z73jRIQVIVfF1cmxGaoiPEGEHy85lxlXuAejzK/XRzOP+1hpvuFwq5fGdqxZw7ER2lp+F3jfXunqfS36q++AgcdzQfLzZ7QL9qURGaTGz5dv8wqYECMRBZ6LMNxfqnHUvVaCXlKxOgjwm7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BbxBwp6dZXD3CCBU7jCaZkP7td2hc0GmCq8O9URT3qg=; b=XpE1UZMZuj966l/s5T16xmjuAavVV+q2AQ+4NWd6rWYmIfVb11qTUumkHx6k8wef7QtZYOcv1bKYiprreuBVVD8snj2a5bm7u2k1HCyjxDlZ8NeA6OilstbluWoT3FbVZOQHMv1csWri8sfYJXrVT9+pPG0JHtWtD6xRv92XoaLDobHVS+eP+CHyFGFj1YVYOw1IMnryjuPTrDW3gcP9cH0Zf9v5xhl4AugfpsPTHEdMxXcYEdpIAr4BzOc259enyR72lSTqqBKZm6y9Qp9sv1XbYeKcOyVhQsM1tC1Pdn8vDSAGk/UslFt7TdpAZ2LqJsTvIbtJuhnqupk3utVsfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BbxBwp6dZXD3CCBU7jCaZkP7td2hc0GmCq8O9URT3qg=; b=0g0ylU6AK9fRKJnUjO74EWW4gI8bkJza5w1nOGGp91ugyq46Lhfa7qRtoiA8tlQPv2LdByrZW5qEDDefcXNrj+Q4A1H/qsBpTPhqliwyJA8J5VjpoO2WG3VlZ3Dyv+Bl7BfGrFfXNQAXxWWF7b1QwrgAtjgFKLZDxVRJBj66Uhk= Received: from BN8PR07CA0015.namprd07.prod.outlook.com (2603:10b6:408:ac::28) by SJ0PR12MB6710.namprd12.prod.outlook.com (2603:10b6:a03:44c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Tue, 15 Nov 2022 20:02:09 +0000 Received: from BN8NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::fd) by BN8PR07CA0015.outlook.office365.com (2603:10b6:408:ac::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT039.mail.protection.outlook.com (10.13.177.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:09 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:07 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Rajneesh Bhardwaj , David E Box CC: Sven van Ashbrook , Raul Rangel , , , Pavel Machek , Len Brown , John Stultz , Thomas Gleixner , Stephen Boyd , S-k Shyam-sundar , Rajat Jain , Hans de Goede , Subject: [RFC v3 2/4] platform/x86/intel/pmc: core: Drop check_counters Date: Tue, 15 Nov 2022 14:01:54 -0600 Message-ID: <20221115200156.12218-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT039:EE_|SJ0PR12MB6710:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ff52443-d5e3-4744-4f5a-08dac7444718 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cUYSV5DCsWj8Zgc0WYhFwAkGFAbKC85CRpIIMx0/zGFLSdwFLVnaKm4cbBiHVAYL3l5LligkqWp7mteOBIzyc6B64MeseeqgRSXT4Gy4DKmjx3pRQVNT0XT7r2F1V1n8lDQYdCR3PwCPaTWVYx81QExiVptAdQhcam8vwzwEjPNzCNIOZsq94ZpShpglY6XTdJAQKwfhIOfPw73ko51gm3dLYVzDzu5v1QGDLZorWiIFy/LZt0b1dGECufcUAmqRc5798FvsF0GUdK7F1Mer3OYyVHvw4oel3YD2PFhCX2m+s+e7wjmyQgZqp3aST75n5fjJTVzh744fhq4DtXb+vjksuOxff93MjELXe1df/1QtoMqs+UZX+tNxC1DLsGA5mdOYdd3sznclENVSklRQ/BGRm9DyUdc8EreUijEcru2foXsxpE7ft9gzjVi28J/XjpZVLnU80SEgQ2OO1E8w9C/TZ++YfKBjOGi7F6ZUb+TjXrkeqntz8WctevuRACC7d4w0yuLaC/6pPD2o7MoEbBMwAULGXtG5dUrB66S9ML4ieN5k1+BaWxx6qiJ7eMNDvZNO1A2fORmzfpA09TCYfBzo7IE2WhRExReNF61g6aQXvggLgZkriMs3RjCinDI4g92VztMp/HpWIVZSQLt8sgKtl+EoyGaPGToypEYvtqkiTjRFapngR1Qc4SbGGQwyQBFlWerpra4OMfMDpSfyo1Kkf7DShYjptYCQ301Wi0mxRyR+4RZqRJbNRh1ge681sLpQButHW1WBtMkLK+Vbmso9y5dXiafNhIWvsPthVGM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199015)(40470700004)(36840700001)(46966006)(86362001)(36756003)(2906002)(36860700001)(8936002)(44832011)(7416002)(83380400001)(426003)(186003)(1076003)(356005)(47076005)(2616005)(82740400003)(81166007)(16526019)(336012)(110136005)(5660300002)(316002)(54906003)(478600001)(40480700001)(8676002)(82310400005)(26005)(70586007)(4326008)(70206006)(6666004)(40460700003)(41300700001)(7696005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:09.0356 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6ff52443-d5e3-4744-4f5a-08dac7444718 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6710 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org `check_counters` is a stateful variable for indicating whether or not to be checking if counters incremented on resume from s2idle. As the module already has code to gate whether to check the counters that will fail the suspend when this is enabled, use that instead. Signed-off-by: Mario Limonciello --- RFC v2->v3: * New patch --- drivers/platform/x86/intel/pmc/core.c | 7 ++----- drivers/platform/x86/intel/pmc/core.h | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c index 17ec5825d13d..adc2cae4db28 100644 --- a/drivers/platform/x86/intel/pmc/core.c +++ b/drivers/platform/x86/intel/pmc/core.c @@ -2059,8 +2059,6 @@ static __maybe_unused int pmc_core_suspend(struct device *dev) { struct pmc_dev *pmcdev = dev_get_drvdata(dev); - pmcdev->check_counters = false; - /* No warnings on S0ix failures */ if (!warn_on_s0ix_failures) return 0; @@ -2077,7 +2075,6 @@ static __maybe_unused int pmc_core_suspend(struct device *dev) if (pmc_core_dev_state_get(pmcdev, &pmcdev->s0ix_counter)) return -EIO; - pmcdev->check_counters = true; return 0; } @@ -2113,10 +2110,10 @@ static __maybe_unused int pmc_core_resume(struct device *dev) const struct pmc_bit_map **maps = pmcdev->map->lpm_sts; int offset = pmcdev->map->lpm_status_offset; - if (!pmcdev->check_counters) + if (!pmc_core_is_s0ix_failed(pmcdev)) return 0; - if (!pmc_core_is_s0ix_failed(pmcdev)) + if (!warn_on_s0ix_failures) return 0; if (pmc_core_is_pc10_failed(pmcdev)) { diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index 7a059e02c265..5687e91e884c 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -316,7 +316,6 @@ struct pmc_reg_map { * @pmc_xram_read_bit: flag to indicate whether PMC XRAM shadow registers * used to read MPHY PG and PLL status are available * @mutex_lock: mutex to complete one transcation - * @check_counters: On resume, check if counters are getting incremented * @pc10_counter: PC10 residency counter * @s0ix_counter: S0ix residency (step adjusted) * @num_lpm_modes: Count of enabled modes From patchwork Tue Nov 15 20:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 625020 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 4CF70C4332F for ; Tue, 15 Nov 2022 20:02:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbiKOUCc (ORCPT ); Tue, 15 Nov 2022 15:02:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231645AbiKOUCO (ORCPT ); Tue, 15 Nov 2022 15:02:14 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2072.outbound.protection.outlook.com [40.107.94.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F00A28E0D; Tue, 15 Nov 2022 12:02:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iSswiwgBwZqeyJvN9ecdAMltKJOUtnSaCZ3Iw35Qd0UqzBFsK8j+g6xfYWkKcO6HR9A9SXuY63tu17iRhyheoiLW+hGciDti/VsdnSBlKSVyfPh9hToIM1ANNHEW2AJ56yF0yvw66QhWNGsN7UNcIDGl1ddN5DjSc9Zz38nMoV2xlUqjPQqCDEkKtF1ntOFwjirVUh4tLZLzyFGLVmNX5HV+XEDUj+9VFxehzBPLe1WAxO9zjWcWkd4w8Qxx3GJglZCkfeuO9g06IKT3zQnFtXDlpPrt9FvKw18e1+/PFZA6jeUE1pmWB4X9Smga0DOuoE4qnXAq/L98BOF/TLO3nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jR4HJCIssg6ApayI+7cqqOPLB8XH6rZSsae7Nm9cJ7I=; b=Nh6eMXn7tGr207pBeI+1OEifUFGpiB0eB2IVfPwCzDhFcC84aroH/hpWBMHRDsJ8/dhZcelLIhNFQz6QB29kK8Q1jPolxuu6ZD+c/gyMbsxnrGX2in5IL1QmO5exfmb8fgnB4T5bYAAm74MmxUOL39zTHp8qORXCaP3uG96pHt9hNzbjHFAQD+KLYuXTmSIeWeH0mKj4QwB8wK6YUui/Q42QnGKLE1R6A84owA5xoplWi8QTpA1QkKoLLyoeBEUpfe5oDRV8OutmN3wfJ7iAv1XRsxtl+AcifGSCG3X0gWaJO950M+P52tsrFy8B59BU9Z/JIeayDhgWURl0KxLEig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jR4HJCIssg6ApayI+7cqqOPLB8XH6rZSsae7Nm9cJ7I=; b=TVUlygJmdgvBv8+UQPoVEmIRkZ2Lzzq5cBdgU73nlZTaAnw+yYsUWGNEovTTftqZKUhKRCeFaY372MNNNxmN/XyVv/AZ4GWMrCdzQz5/mUCPBzYt2BP2QgT5ho+iA+juMVsHLnLMvTKBXhhLvOLoiY/esyewxebRpbIaxgZpUTs= Received: from BN9PR03CA0247.namprd03.prod.outlook.com (2603:10b6:408:ff::12) by CY5PR12MB6384.namprd12.prod.outlook.com (2603:10b6:930:3c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.18; Tue, 15 Nov 2022 20:02:10 +0000 Received: from BN8NAM11FT114.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ff:cafe::99) by BN9PR03CA0247.outlook.office365.com (2603:10b6:408:ff::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Tue, 15 Nov 2022 20:02:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT114.mail.protection.outlook.com (10.13.177.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5834.8 via Frontend Transport; Tue, 15 Nov 2022 20:02:10 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 15 Nov 2022 14:02:09 -0600 From: Mario Limonciello To: "Rafael J . Wysocki" , Shyam Sundar S K CC: Sven van Ashbrook , Raul Rangel , , , Pavel Machek , Len Brown , John Stultz , Thomas Gleixner , Stephen Boyd , Rajneesh Bhardwaj , Rajat Jain , David E Box , Hans de Goede , Subject: [RFC v3 3/4] platform/x86/amd: pmc: Report duration of time in deepest hw state Date: Tue, 15 Nov 2022 14:01:55 -0600 Message-ID: <20221115200156.12218-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115200156.12218-1-mario.limonciello@amd.com> References: <20221115200156.12218-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT114:EE_|CY5PR12MB6384:EE_ X-MS-Office365-Filtering-Correlation-Id: b439e362-1d89-41ae-cd0c-08dac74447e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D+NAMeEtuA2U66AkPvlUTce2m9kXAAwn2Wv2OSJNWmQ8nKsBhNcLt0ympTMzWA+bFYBpHFFMWS/YHXu+Xrce/ZvUsEPadPANmZlNgb8Ws4fjdp0Oq/RW8Cu1XfN+SQyPx6HfJfc/X7qR54Ne4Ienx/YSipvqwqGURaajfEfzvBG7Admzx+Zv/rif4DdKr7lu9nnsW2GVhQPTP9zPZi/4eRDLmz8XbC0qDvoEVaEs2yHQL/dDR0gczbob18XpfIAMqVZDDzWQdECDglsqzjTS9OTknx2Zt0bZkLc0IkGVM22+ALfLXZ5au17e+pmJhWc/tbDCsfMVQPyAk3frHXZCyJpl8AfS7zh0tF/eJ52Q4WNZwviLY2iB8SqXWNRUW7emuJBddwtzEzvw14gMf7k51PEZ70RK2l52CBJ430ru1M3QK3yX2BSL292G9n1UT/fanrZREfpljehX1L8f36/X765c049nxgpvTlEpvRUCvJKYZCc/PPEw7augidt4+K1aTJxjidn3ecTlK57/hN3dwpHMnI02Y1C4b4pAS3AtSyPpEaSWdLzRst7SBFPuPHd/yBrQHHWzwaHidIFtmdLXXkqwxlV/r/W1bWS4TxMnVP2bKcpEDhjy4F/9F77aSuQBIHn0Bimgesdd1UR15KQilu+heKpQhWwTErSR9vKyxQDqXNvJXYw3FMer3WIM8EGpmBKI2jiUv+lnqVO+L9p6QSzqZoGd8kKuF3+cN7lDXcubCVCBsf1LW7FVPn4L2XQrG2cHuH0oAR7ElYv88FuMH9D3aefR9fe7xzGNkjPy+clseGxf5vGu0JqdLhQb7dFQ X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(41300700001)(186003)(1076003)(40460700003)(2616005)(7416002)(5660300002)(16526019)(336012)(2906002)(8936002)(26005)(316002)(8676002)(36756003)(70206006)(70586007)(4326008)(110136005)(6636002)(7696005)(82310400005)(54906003)(356005)(36860700001)(81166007)(44832011)(82740400003)(83380400001)(47076005)(426003)(40480700001)(86362001)(6666004)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 20:02:10.3692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b439e362-1d89-41ae-cd0c-08dac74447e3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT114.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6384 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 a file in sysfs. Signed-off-by: Mario Limonciello --- RFC v2->v3: * Create new sysfs file instead of reporting using kernel symbol --- Documentation/ABI/testing/sysfs-amd-pmc | 6 ++++++ drivers/platform/x86/amd/pmc.c | 22 +++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-amd-pmc b/Documentation/ABI/testing/sysfs-amd-pmc index c421b72844f1..89354da8e680 100644 --- a/Documentation/ABI/testing/sysfs-amd-pmc +++ b/Documentation/ABI/testing/sysfs-amd-pmc @@ -11,3 +11,9 @@ Contact: Mario Limonciello Description: Reading this file reports the program corresponding to the SMU firmware version. The program field is used to disambiguate two APU/CPU models that can share the same firmware binary. + +What: /sys/bus/platform/drivers/amd_pmc/*/low_power_idle_system_residency_us +Date: December 2022 +Contact: Mario Limonciello +Description: Reading this file reports the duration of the last suspend that + was spent in the deepest hardware sleep state in microseconds. diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c index 96e790e639a2..2550ba6d28f5 100644 --- a/drivers/platform/x86/amd/pmc.c +++ b/drivers/platform/x86/amd/pmc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -363,9 +364,6 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev) if (!table.s0i3_last_entry_status) dev_warn(pdev->dev, "Last suspend didn't reach deepest state\n"); - else - dev_dbg(pdev->dev, "Last suspend in deepest state for %lluus\n", - table.timein_s0i3_lastcapture); } #endif @@ -417,12 +415,30 @@ static ssize_t smu_program_show(struct device *d, struct device_attribute *attr, return sysfs_emit(buf, "%u\n", dev->smu_program); } +static ssize_t low_power_idle_system_residency_us_show(struct device *d, + struct device_attribute *attr, + char *buf) +{ + struct amd_pmc_dev *dev = &pmc; + struct smu_metrics table; + int ret; + + ret = get_metrics_table(dev, &table); + if (ret) + return ret; + + return sysfs_emit(buf, "%llu\n", table.s0i3_last_entry_status ? + table.timein_s0i3_lastcapture : 0); +} + static DEVICE_ATTR_RO(smu_fw_version); static DEVICE_ATTR_RO(smu_program); +static DEVICE_ATTR_RO(low_power_idle_system_residency_us); static struct attribute *pmc_attrs[] = { &dev_attr_smu_fw_version.attr, &dev_attr_smu_program.attr, + &dev_attr_low_power_idle_system_residency_us.attr, NULL, }; ATTRIBUTE_GROUPS(pmc);