From patchwork Fri Nov 15 20:58:31 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: 844458 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 AD9BA187876; Fri, 15 Nov 2024 21:01:13 +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=1731704477; cv=none; b=BnGAWcTbS/i5OYYpkNhJKdxkTX2cISjF9CeyVgBVuVqx6H8U/DNdJFG8P1WmW0r5393/Vy2LIyARLzigOTLXHx1Zv1ZsqNJz7ekGYbgAxd6E6yX2zXNqE9rM4ZaP+8w/11Kedw6Y8ajozZ6rq8Hap9bRrkWsEtKXlP5UxBLKzRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731704477; c=relaxed/simple; bh=yK9zm26dZQmpqsVLsOYysVBEsX34ShNxGUog0gTn6/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tw+0iP+cAESt/F0J7TdyiaCjK6emgz3jrfHXhWAt/LR283nYEbY/XjFf044FP+PHCxrIduUCRNrZaSPcDoXQbW06BUhzf51HePsprBj4e+Y7aWkfUAi6p1M7pxw0urcezEkuQjWtR+F3GbiQPlBD3uDuBpGfGGd1aWg6L5uRM3w= 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; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=XwGHXTes reason="signature verification failed"; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="XwGHXTes" 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 6.2.1) id 6c6606f39a3dc5a1; Fri, 15 Nov 2024 22:01:06 +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 3A3D4851B10; Fri, 15 Nov 2024 22:01:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1731704466; bh=yK9zm26dZQmpqsVLsOYysVBEsX34ShNxGUog0gTn6/8=; h=From:Subject:Date; b=XwGHXTesMJsrOHtToV4Ym4i3kAV8WR4W8Mmea+la4z0NBwHxoirfWuUYmo9yBFNb9 kaiVYegHoU7G49PRklSi4oy+9SUO06TjPRyFIa6GTN9CW5cebC8gZHkMUs3Em0f7Va UVQ0aA0/iEqGDwzZLhDJsfFwX0Yz3FZDvzDVPRJq2Ai3lgCwZYDVWRaanDpsynIE8L w5Z+CfhYVdnkcjZGrKL2CYAs++IgMDed2aWxowERc5gXzvPxF/tMM1y6No8MHdBQIb 5fJe/glavIHrhyVnKMY08XHjqATah+Nsyx3NJQM+7DanR6ex3gNRzJmLWWjrprnOxW wdS4LTYTWT9Fw== From: "Rafael J. Wysocki" To: Linux PM , Peter Zijlstra Cc: LKML , x86 Maintainers , Patryk Wlazlyn , "Gautham R. Shenoy" , Artem Bityutskiy , Mario Limonciello , Linux ACPI Subject: [PATCH v2 1/2] cpuidle: Do not return from cpuidle_play_dead() on callback failures Date: Fri, 15 Nov 2024 21:58:31 +0100 Message-ID: <3318440.aeNJFYEL58@rjwysocki.net> In-Reply-To: <13636465.uLZWGnKmhe@rjwysocki.net> References: <13636465.uLZWGnKmhe@rjwysocki.net> Precedence: bulk X-Mailing-List: linux-pm@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: gggruggvucftvghtrhhoucdtuddrgeefuddrvdeggddugeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomheprhhjfiesrhhjfiihshhotghkihdrnhgvthdpnhgspghrtghpthhtohepledprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopeigkeeisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehprghtrhihkhdrfihlrgiilhihnheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphh X-DCC--Metrics: v370.home.net.pl 0; Body=9 Fuz1=9 Fuz2=9 From: Rafael J. Wysocki If the :enter_dead() idle state callback fails for a certain state, there may be still a shallower state for which it will work. Because the only caller of cpuidle_play_dead(), native_play_dead(), falls back to hlt_play_dead() if it returns an error, it should better try all of the idle states for which :enter_dead() is present before failing, so change it accordingly. Also notice that the :enter_dead() state callback is not expected to return on success (the CPU should be "dead" then), so make cpuidle_play_dead() ignore its return value. Signed-off-by: Rafael J. Wysocki Reviewed-by: Mario Limonciello Tested-by: Mario Limonciello # 6.12-rc7 --- v1 -> v2: * Make cpuidle_play_dead() never return 0. * Add tags from Mario (I have added them because the change of the patch should not make a practical difference, but if you want them to be dropped, please let me know). --- drivers/cpuidle/cpuidle.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) Index: linux-pm/drivers/cpuidle/cpuidle.c =================================================================== --- linux-pm.orig/drivers/cpuidle/cpuidle.c +++ linux-pm/drivers/cpuidle/cpuidle.c @@ -69,11 +69,15 @@ int cpuidle_play_dead(void) if (!drv) return -ENODEV; - /* Find lowest-power state that supports long-term idle */ - for (i = drv->state_count - 1; i >= 0; i--) + for (i = drv->state_count - 1; i >= 0; i--) { if (drv->states[i].enter_dead) - return drv->states[i].enter_dead(dev, i); + drv->states[i].enter_dead(dev, i); + } + /* + * If :enter_dead() is successful, it will never return, so reaching + * here means that all of them failed above or were not present. + */ return -ENODEV; } From patchwork Fri Nov 15 21:00:25 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: 843688 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 AD9FE18C031; Fri, 15 Nov 2024 21:01:13 +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=1731704476; cv=none; b=CCpqY2E3YSK+dcEz14nPiUckzz5I+ijeCKJYFAK4B4gqSZsrMXKr4E9z6t69IJszvlMMM9UrThGcvwPRK0/vKaKkO6+ujQaRJzJphJAe9o7iKEmjTPWOF2YdK0oFRO2IU1zBCIxQY4ouSEzdiCIFLK93YpMFqk2PNBAxNC3wqww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731704476; c=relaxed/simple; bh=upJvO75RZUD4V28E2J8nhVTj4rALy/xtpQVUlI5PaSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jiTDXsJaG5Q0bsvp0P5LxdxENlqD/hE5nf0hCqlFNZXknrxC0C0vi+owMFRCaHLfxRXgSFDVFkBBYTpwe3+Ri1hwZ1aHFKLTOaSN9HqlKfVJ620JJKw6NyCdydFJ3YRYQ8aQFGgbUYB4K3h0/WPyq0d75ds3K6XXtH824qB/tjo= 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; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=g+L3x3j/ reason="signature verification failed"; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="g+L3x3j/" 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 6.2.1) id 86c8986785aa934d; Fri, 15 Nov 2024 22:01:05 +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 AAB74851B10; Fri, 15 Nov 2024 22:01:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1731704465; bh=upJvO75RZUD4V28E2J8nhVTj4rALy/xtpQVUlI5PaSc=; h=From:Subject:Date; b=g+L3x3j/85bJtbCypqMyylThaWK3nNPdKQLVZuyO/7w/xK7dRLdqS5uJBwcTvXSiP /TvGi5YgjdJYEBm00pZhJFg+fzsjD87xNts0r90ByLvqoXr9p6lpY4fDPAS9xfwGWp Y1q4jzBPSUs6ZcC+PChdwEry1jP+Oz/5QxRI1UOf4lx+Id5DZY0V9ybMLL7yxQZhkL oKKMQVjGYeQr9XV+/bo9m3nhfxSeMwDyt2pVXHylVeACq2t5157XyjSx24kPcs/s0E Evy69a8cv5XGtwbz18tDZFnyGigFkr4G+2h4zCRQRvQXBbgHv9Rs6Jvz4y5SefFM1g s2G8gM2Izq3cA== From: "Rafael J. Wysocki" To: Linux PM , Peter Zijlstra Cc: LKML , x86 Maintainers , Patryk Wlazlyn , "Gautham R. Shenoy" , Artem Bityutskiy , Mario Limonciello , Linux ACPI Subject: [PATCH v2 2/2] cpuidle: Change :enter_dead() driver callback return type to void Date: Fri, 15 Nov 2024 22:00:25 +0100 Message-ID: <2285569.iZASKD2KPV@rjwysocki.net> In-Reply-To: <13636465.uLZWGnKmhe@rjwysocki.net> References: <13636465.uLZWGnKmhe@rjwysocki.net> Precedence: bulk X-Mailing-List: linux-pm@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: gggruggvucftvghtrhhoucdtuddrgeefuddrvdeggddugeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomheprhhjfiesrhhjfiihshhotghkihdrnhgvthdpnhgspghrtghpthhtohepledprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehpvghtvghriiesihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopeigkeeisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehprghtrhihkhdrfihlrgiilhihnheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphh X-DCC--Metrics: v370.home.net.pl 0; Body=9 Fuz1=9 Fuz2=9 From: Rafael J. Wysocki After a previous change, cpuidle_play_dead(), which is the only caller of idle state :enter_dead() callbacks, ignores their return values, so they may as well be void. Suggested-by: Peter Zijlstra Signed-off-by: Rafael J. Wysocki Reviewed-by: Gautham R. Shenoy Reviewed-by: Mario Limonciello --- v1 -> v2: New patch Interestingly enough, the only user of :enter_dead() idle state callbacks in the current mainline turns out to be ACPI idle. --- drivers/acpi/processor_idle.c | 7 ++----- include/linux/cpuidle.h | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) Index: linux-pm/include/linux/cpuidle.h =================================================================== --- linux-pm.orig/include/linux/cpuidle.h +++ linux-pm/include/linux/cpuidle.h @@ -61,7 +61,7 @@ struct cpuidle_state { struct cpuidle_driver *drv, int index); - int (*enter_dead) (struct cpuidle_device *dev, int index); + void (*enter_dead) (struct cpuidle_device *dev, int index); /* * CPUs execute ->enter_s2idle with the local tick or entire timekeeping Index: linux-pm/drivers/acpi/processor_idle.c =================================================================== --- linux-pm.orig/drivers/acpi/processor_idle.c +++ linux-pm/drivers/acpi/processor_idle.c @@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry * @dev: the target CPU * @index: the index of suggested state */ -static int acpi_idle_play_dead(struct cpuidle_device *dev, int index) +static void acpi_idle_play_dead(struct cpuidle_device *dev, int index) { struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu); @@ -591,11 +591,8 @@ static int acpi_idle_play_dead(struct cp else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) { io_idle(cx->address); } else - return -ENODEV; + return; } - - /* Never reached */ - return 0; } static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)