From patchwork Mon Jan 29 16:24:04 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: 193596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp696619dyb; Mon, 29 Jan 2024 08:57:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJGxuJa9E1LppXFTjqNsrdNvNolsEo3RBbA1W4GNjehfCxdCmAaNM+uFpWtM6Zzp4jbzk6 X-Received: by 2002:a05:6358:1907:b0:178:67dc:aba8 with SMTP id w7-20020a056358190700b0017867dcaba8mr3139558rwm.17.1706547423221; Mon, 29 Jan 2024 08:57:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706547423; cv=pass; d=google.com; s=arc-20160816; b=LcG/g2+kXPjM2VOu+7PQ1uc1BV6Bg90AQvCfSngpBwf2yt5pea7QxWODJ3Ps17Am5g I3uuuQMYi5pb2ZWjtQEr+DboEFC8iVBxR4M1M5s94DocC3HvTYQXWehHvN0qgNtum/2K 1WgBWNeGmv5q7/fdIwKnw3/Xtfn18KhIsH2f05chQuIDjAkzKekgQV4mTAXbRA7E8M+q iR6hcM5FyEA1pKcmz/UoclGpeKnoB8nPeZS39z3Dbxtk3X4OGfU9qoStfo7NgHrh5CQD Q+SYBEbMV5aqNpZq7I6jLKRYxsILrOk8htywWdzPeK/UJjx+5P7ZqDWUJKslNhNWUvES AgzA== 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=BtHCYDnms+lDpC3RVjb7KdrTtZQdmWrsMfvKwuiITDA=; fh=4LIu5opAwLV7NEWuWaesW8kxXXZagKTitwg1cEZexpE=; b=ygslgX68iGpF7FhM5jAYUWzIYN2WtWayyDxacUzI2Zn+MBS3jCRRjo1M2VZPqXeY3S +fY1TQ9jgk0niGF+rK7mx1AgoyalKiSkivHna2oFKsur/CTrUsZPkVx3tHjAcCs9dGMe 5L+7mYbJ5+aYGYHmiKjLorhKZW+4Q99aqJMzapd4FvdO4nJ6jffC9n16Hn3R+6MBLnHI ia4Rdu4uFFoRyJwM8w9S3gZywEuX75owMPA49tVOMoLjn30vJ/XYB1ic3/Ze7uHdWrad QMIH/hf5FmxpscHYsfpkzW/FQKJPxWw5IjNCeZh1CygLG7ZL+ny3fSgugMUFn/e6WwGF XcIA== 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-43117-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43117-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s191-20020a632cc8000000b005cda6105077si5829416pgs.299.2024.01.29.08.57.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43117-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-43117-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43117-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D9212B2884D for ; Mon, 29 Jan 2024 16:38:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E52F515EAB4; Mon, 29 Jan 2024 16:32:15 +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 B9FE715B0F4; Mon, 29 Jan 2024 16:32:10 +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=1706545933; cv=none; b=UJKFDK1VkaxaedpaMFhw6YcLXsLc5GsKGLE6X6rlTakol5M6QeQfjUUJLGuzQbnta1IMqvNLhJBr6hUX9emBdIeEY7u5Y/O91jL09AcrHj79dS1b3aMenlSbwGtdlum3yqCGPahRrdpq2kK47KR+vXYyR3+j7sUZFuJcALr/nQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706545933; c=relaxed/simple; bh=iyXE7t0eskj3g5+cWmxPvH1tVv8VprKcfE27yahn7mQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FsfR0+9JRt3nNYN1VIOODz0Wwyduxr+1JpMAoVyCohhg1Gk7eAAjqehNQkNOhVq4YFs0B2ezlHoZAi4bOly314P0AKu0ExznrZW/xFjUWDo96VPLMRLOCgulvm1YJwBEWLFUiatW/X+X6g9CLRTeToDlP6fGx5libO8gHV9H1PM= 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 3184fcaa49044cda; Mon, 29 Jan 2024 17:32:03 +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 233A066975C; Mon, 29 Jan 2024 17:32:03 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Ulf Hansson , Stanislaw Gruszka Subject: [PATCH v2 05/10] PM: sleep: stats: Call dpm_save_failed_step() at most once per phase Date: Mon, 29 Jan 2024 17:24:04 +0100 Message-ID: <23401570.6Emhk5qWAg@kreacher> In-Reply-To: <5770175.DvuYhMxLoT@kreacher> References: <5770175.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: gggruggvucftvghtrhhoucdtuddrgedvkedrfedtgedgjeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrghdprhgtphhtthhopehsthgrnhhishhlrgifrdhgrhhushiikhgrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789444670477031265 X-GMAIL-MSGID: 1789444670477031265 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 Reviewed-by: Stanislaw Gruszka --- v1 -> v2: No changes. --- 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();