From patchwork Mon Jan 22 11:32:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 190117 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2514007dyb; Mon, 22 Jan 2024 03:48:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF51N5UI6jJmuNLDqGbJX6hrRVj2WSTs33zsBCBQm0w72oYq1xDWa2IZ1gRK7jqR2AomTs4 X-Received: by 2002:ac8:5e4e:0:b0:42a:2fa0:2382 with SMTP id i14-20020ac85e4e000000b0042a2fa02382mr5560397qtx.1.1705924103519; Mon, 22 Jan 2024 03:48:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705924103; cv=pass; d=google.com; s=arc-20160816; b=AzpW/qhI8+yHdwITljaoJpVMkFlAIQ5blCOnXktP/Fyc2fXv3Zegbm1N4NsygfMfAY 8sGR02WV3BZwW0gb8arOLNZ38PZRf7x3zIVCG17ddbYwIWRiqJry3RsryOlE/0iPR7ur vSm9TkV2L3Be1D6S3+4Iu7WQSwCpUB78D95pfw6gPyKOAKQx1+So359DGwkeN0Sv0pUx jrxO2UBmeaDbvm9shw8yl42jMN0aFPt+S0sMR62ryVZ+oSNt3w/ZTWnv7h2U0Fr6xzwN HvtPeVaStIvHcxvVK+hOSH8IYRJpoq01tl5FnYF3hLLlFI30r7JjQYF2HOcXRgojezmz 370A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=TAZvRXdZYgSkHYDwjrxoik7NmRb36OK8nSYDJZjXoho=; fh=4LIu5opAwLV7NEWuWaesW8kxXXZagKTitwg1cEZexpE=; b=aynTseZqOQuDaytJwoStULjwavL9FpuWuaMK2Ku7gAkFIs+dx8zuqdYuTu3Kh8/fEV HvC9Tn/xk+S7b6GxpBWldKOJiHVl62srP57BvoKuvQ3u1X4aCT5dHh3w0usWgNQprf+g a1cmnI0ygDPY5NcDiicfEL2L6QuutAEhWEHZCtg5TOe8q7Z5XUFq25OHM1psHHfXlN5S WS93lOHnJ6YnmYRFRvDAYa6G9n40aWYuBJr5/sNALGcTXIHAhVK8MVk4BtCCxrB5Gacu 1yT6XyFWo5Z8/enbsTsxcqpiV6wCE+7AMJfd7fmEiWqPNHnnTGlTuGznwr0h9XBGJh5f 1EeQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-32949-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32949-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r9-20020ac85c89000000b00429b94a7090si5332523qta.596.2024.01.22.03.48.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 03:48:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32949-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-32949-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32949-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 32C121C281E6 for ; Mon, 22 Jan 2024 11:47:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9189B3D57A; Mon, 22 Jan 2024 11:44:33 +0000 (UTC) Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 849913C48D; Mon, 22 Jan 2024 11:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705923871; cv=none; b=Y+vkmrjaVx39iSU53KNIjKRwjmNZrK1nCTt0VcnFBPifly2CpPZhA0MrXh5OsMKZGzYrsvmziFZCQZ9IWWT5SJgEcrBKXNjjumb1HTOV/H4nLhTGTFfYIoFC2ao6Fz4WJq9JcBjiTv7TpiWnZp7Lo3DSsqUqfm8KuRWXdENweoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705923871; c=relaxed/simple; bh=7eySJOq/vVh2sQLWmwb6KJeThhebMt/tVZTV26u+S6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cjOJru8Q5nYs/gC39YCjzlya/qZCkqD0GbScpbEzQmoLnT1dTgbIkavnOgxrpR1JrOFu6TNFJ5unVQbsxHKmN4adtBFhV4yE939UohI0waXK3u+gf5ahwyB/F7aODhxsv3Gxrs3aoz7EaWWENpllDasUUuX5FEgk4yI0SMbLUnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id 3c9ee59df0d63310; Mon, 22 Jan 2024 12:44:25 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id B9DF2669540; Mon, 22 Jan 2024 12:44:24 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Ulf Hansson , Stanislaw Gruszka Subject: [PATCH v1 07/12] PM: sleep: stats: Call dpm_save_failed_step() at most once per phase Date: Mon, 22 Jan 2024 12:32:46 +0100 Message-ID: <22171159.EfDdHjke4D@kreacher> In-Reply-To: <5760158.DvuYhMxLoT@kreacher> References: <5760158.DvuYhMxLoT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrvdekiedgfedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrghdprhgtphhtthhopehsthgrnhhishhlrgifrdhgrhhushiikhgrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788791072586483864 X-GMAIL-MSGID: 1788791072586483864 From: Rafael J. Wysocki If the handling of two or more devices fails in one suspend-resume phase, it should be counted once in the statistics which is not guaranteed to happen during system-wide resume of devices due to the possible asynchronous execution of device callbacks. Address this by using the async_error static variable during system-wide device resume to indicate that there has been a device resume error and the given suspend-resume phase should be counted as failing. Signed-off-by: Rafael J. Wysocki --- drivers/base/power/main.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) Index: linux-pm/drivers/base/power/main.c =================================================================== --- linux-pm.orig/drivers/base/power/main.c +++ linux-pm/drivers/base/power/main.c @@ -685,7 +685,7 @@ Out: TRACE_RESUME(error); if (error) { - dpm_save_failed_step(SUSPEND_RESUME_NOIRQ); + async_error = error; dpm_save_failed_dev(dev_name(dev)); pm_dev_err(dev, state, async ? " async noirq" : " noirq", error); } @@ -705,6 +705,9 @@ static void dpm_noirq_resume_devices(pm_ ktime_t starttime = ktime_get(); trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, true); + + async_error = 0; + mutex_lock(&dpm_list_mtx); pm_transition = state; @@ -734,6 +737,9 @@ static void dpm_noirq_resume_devices(pm_ mutex_unlock(&dpm_list_mtx); async_synchronize_full(); dpm_show_time(starttime, state, 0, "noirq"); + if (async_error) + dpm_save_failed_step(SUSPEND_RESUME_NOIRQ); + trace_suspend_resume(TPS("dpm_resume_noirq"), state.event, false); } @@ -815,7 +821,7 @@ Out: complete_all(&dev->power.completion); if (error) { - dpm_save_failed_step(SUSPEND_RESUME_EARLY); + async_error = error; dpm_save_failed_dev(dev_name(dev)); pm_dev_err(dev, state, async ? " async early" : " early", error); } @@ -839,6 +845,9 @@ void dpm_resume_early(pm_message_t state ktime_t starttime = ktime_get(); trace_suspend_resume(TPS("dpm_resume_early"), state.event, true); + + async_error = 0; + mutex_lock(&dpm_list_mtx); pm_transition = state; @@ -868,6 +877,9 @@ void dpm_resume_early(pm_message_t state mutex_unlock(&dpm_list_mtx); async_synchronize_full(); dpm_show_time(starttime, state, 0, "early"); + if (async_error) + dpm_save_failed_step(SUSPEND_RESUME_EARLY); + trace_suspend_resume(TPS("dpm_resume_early"), state.event, false); } @@ -971,7 +983,7 @@ static void device_resume(struct device TRACE_RESUME(error); if (error) { - dpm_save_failed_step(SUSPEND_RESUME); + async_error = error; dpm_save_failed_dev(dev_name(dev)); pm_dev_err(dev, state, async ? " async" : "", error); } @@ -1030,6 +1042,8 @@ void dpm_resume(pm_message_t state) mutex_unlock(&dpm_list_mtx); async_synchronize_full(); dpm_show_time(starttime, state, 0, NULL); + if (async_error) + dpm_save_failed_step(SUSPEND_RESUME); cpufreq_resume(); devfreq_resume();