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 91F92C64ED9 for ; Tue, 21 Feb 2023 03:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233013AbjBUDpC (ORCPT ); Mon, 20 Feb 2023 22:45:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbjBUDpA (ORCPT ); Mon, 20 Feb 2023 22:45:00 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A6B893CF; Mon, 20 Feb 2023 19:44:58 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: marcan@marcan.st) by mail.marcansoft.com (Postfix) with ESMTPSA id 096B13FB17; Tue, 21 Feb 2023 03:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1676951095; bh=z+58+QJcVH0GSU4dfnKJG6sV0atAJpJZM0PmOGOrpCQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Da/coslVKVT6AdPdmAYnct7dZRD12T6oYTiHeIULtD51snXB2Mymh71IWg53mC/cc GRka1nODAzTUYdyDW/a0HsZODL342C+GIxiL+S4CqlDqLQfIkaI2d+jaAJusjiP48p L8eJhtLt5fSDYDIMP4nTCnLBAp52VQ2pseRkCe+b5kaPWjQxBxnlgdLCn4ZXRHOiqV KSGyUMqxA26rP0jpT1vdWINbo9+N9xiVc5m7hHp8vVtp206gT1B0P7yOwSryVvJvTz M8FGKeRqlaTPn75koHA2HJizkLzZXTd1pB+dGs74ADJsI50oKYVWt3NJZcsyNvSZS5 CLjwgdqkR1EFA== Message-ID: <19938ad0-9dde-560c-2e4f-a697b5323051@marcan.st> Date: Tue, 21 Feb 2023 12:44:50 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] PM: s2idle: Don't allow s2idle when cpuidle isn't supported Content-Language: en-US To: Kazuki Hashimoto , linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sudeep Holla , "Rafael J. Wysocki" , Daniel Lezcano , Lorenzo Pieralisi , Sven Peter , Len Brown , Pavel Machek References: <20230214215003.70683-1-kazukih0205@gmail.com> From: Hector Martin In-Reply-To: <20230214215003.70683-1-kazukih0205@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/02/2023 06.50, Kazuki Hashimoto wrote: > s2idle isn't supported on platforms that don't support cpuidle as of > 31a3409065d1 ("cpuidle / sleep: Do sanity checks in cpuidle_enter_freeze() > too"), so update the suspend framework to reflect this in order to avoid > breakages. > > Link: https://lore.kernel.org/all/20230204152747.drte4uitljzngdt6@kazuki-mac > Fixes: 31a3409065d1 ("cpuidle / sleep: Do sanity checks in cpuidle_enter_freeze() too") > Signed-off-by: Kazuki Hashimoto > --- > kernel/power/suspend.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c > index 3f436282547c..27507ae7c9c9 100644 > --- a/kernel/power/suspend.c > +++ b/kernel/power/suspend.c > @@ -556,6 +556,12 @@ static int enter_state(suspend_state_t state) > > trace_suspend_resume(TPS("suspend_enter"), state, true); > if (state == PM_SUSPEND_TO_IDLE) { > + struct cpuidle_device *dev = cpuidle_get_device(); > + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); > + > + if (cpuidle_not_available(drv, dev)) > + return -EINVAL; > + > #ifdef CONFIG_PM_DEBUG > if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) { > pr_warn("Unsupported test mode for suspend to idle, please choose none/freezer/devices/platform.\n"); Well... this turns s2idle from "slighly broken" to "fully broken". I'm not sure that's a good idea. If this (or something equivalent) goes in, we'll have to carry a revert in the Asahi tree until the PSCI-replacement story goes in, because lots of people are using the current somewhat broken s2idle. It's a lot better than having no sleep modes at all. Also, if you intend to disable s2idle on these platforms, you have to actually stop advertising it. Advertising it and then refusing to enter s2idle is not acceptable, it means people will get "sleep" buttons and expect sleep to work and then it won't. But then that could also introduce race conditions with userspace checking for sleep support before the cpuidle driver loads. So there is definitely a can of worms here. - Hector