Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1460894pxb; Mon, 11 Oct 2021 06:33:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymJTJhPXK3LH2SegfSTmNln8v7ix/ehadENpOZ29JYPTd4Z8UKfclspB88kOlo/PRZIQo9 X-Received: by 2002:a17:906:fb91:: with SMTP id lr17mr25048351ejb.256.1633959210580; Mon, 11 Oct 2021 06:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633959210; cv=none; d=google.com; s=arc-20160816; b=KmOzrwLAT2DWMlpWpGI5792wl78Am9z37Nl4YX6xUmOJYgJl0CNf+ja9wrvwUB2RZG OQEnhlYdjiqo2yuYLKFOt8simH4OgaNmOeqzVHE57qftOceEIC/fwXcRWxYenZ6VY1a3 bfyOGnrvdHZZl7hhzpNluCwwUDto+3PLnMSwhxwMzQ2nl7oyaQg59E1zXWiEiKtqNnKo mpCZ3a+COdokMexc1lXu9Xg5BSH2HEmnp02Jlsz3AuWHo/Lg4+1xXrLkN0t448ya8WdG KNFkmo7bY3W2c3oShJU2RdZrNbSpT7E/R9/cZXXLgjlV/BALA5WMifqtYK6xZuPgZRQO 7QGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=y7cA9NqfV+l2ldiwKTZK6iXcHWSwpaV4+LaQNy+YSxw=; b=pGlzeiuY0cSKYrakLtNx59uiN+evftdss59j/H2aCx7LuKz5h55N+BJTeCGtnmcTvG NwYCU0WQiR9/9luGjnRnLiiyCTZhf8F/xh5vQQ4b1AR1OG3cNnzZlUghD6JGmgDLpXeA 2iHUgB9YQ8NOdyczjUNtsjQBRCoGudAboqbuG8OrvhgKkuk2tMzaXIP5/g46aizHZsnX AiDXqhFENRmPh61zL5wlKPadx55suay4aEssB7Eqo8tzt/Ui/RWuXtQLiUJAWi3hx/Ds vnV6yXHPS5FCHxpZ8BX6DselATmjHiB2Z/8CWqUjEd2MQOMI/a8r+gAN9JskRspDWqnJ KxjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DHJRAlQ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s16si10942552edq.488.2021.10.11.06.32.53; Mon, 11 Oct 2021 06:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="DHJRAlQ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235796AbhJKKHX (ORCPT + 99 others); Mon, 11 Oct 2021 06:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235784AbhJKKHX (ORCPT ); Mon, 11 Oct 2021 06:07:23 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32232C06161C for ; Mon, 11 Oct 2021 03:05:22 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id r19so69332815lfe.10 for ; Mon, 11 Oct 2021 03:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y7cA9NqfV+l2ldiwKTZK6iXcHWSwpaV4+LaQNy+YSxw=; b=DHJRAlQ/cdsO002wqdk9U35i1vwGEsuhUrydew3ZbfwrGMuiHim3q+FY/zgXSjLtBJ bkOjFr1Wy76JZM8vj4HnCj3tY9Qrm7dKaTbPkD8i8DjItqI6mzVKOZn4knA/v6hBV3tZ Qkl3bH4Z7EChWg8dbSHD05ONtYISW2TnjlXsRVTyzGhb830HwXGEK45nYPRJOooqBYDG WQ4D6924TpZNHKEX+2/gx/dR/cDffPWK3Bs1KnPaoKqnx+++sx2OhHITerwerl9R3fwr Itaf1J67i0H6VXb8KyGDuSAB1vqynd2jLyj6Hlst+KUULBnuNi92Ugb3LLu4RujqNJAV AJLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=y7cA9NqfV+l2ldiwKTZK6iXcHWSwpaV4+LaQNy+YSxw=; b=e/u+h9lmSwiS/9HeSr1ZsN9Cmu0CmTwgfy4aBc/0hz9IzvY/LkGwxO8tE5lNwvLUyY OPbQQBwkctLizq6Yp3AuWAWMHJlVUCkQf9I3ErvSH6KnAMEe7E+d9AhUwz98v7OOny3i P72+DsV864oKmfyHtEelvsvCsKm6QIdPGfUDK/knmIZdg3uV79eSG2CIfFki2x40lFQ7 GZT9uXFLMjyI9X3y30lDLa7iBFrf+LCbd+2PAlOpgVH3xl61NfupcKSbVSFTFtwLFQN7 kJ9mRWIld08Ip2+ENMNEh72UHDApDjLRVp2FnZ3adOYLd0vU2Czl6IDP8pdjYBhFt+wE bRsQ== X-Gm-Message-State: AOAM531WdUrJ7iDTWKzRjeoYZQ1SMBIVcSZZrDrCYYD2wrQeePrvb6RM TSozOX1QsV/LQqoUoxoT06CsASyt4yEcBbRc+25p1A== X-Received: by 2002:a05:6512:1515:: with SMTP id bq21mr26262661lfb.71.1633946720249; Mon, 11 Oct 2021 03:05:20 -0700 (PDT) MIME-Version: 1.0 References: <20210929144451.113334-1-ulf.hansson@linaro.org> <20210929144451.113334-2-ulf.hansson@linaro.org> <4692163.31r3eYUQgx@kreacher> In-Reply-To: <4692163.31r3eYUQgx@kreacher> From: Ulf Hansson Date: Mon, 11 Oct 2021 12:04:44 +0200 Message-ID: Subject: Re: [PATCH 1/2] cpuidle: Avoid calls to cpuidle_resume|pause() for s2idle To: "Rafael J. Wysocki" Cc: "Rafael J . Wysocki" , Daniel Lezcano , Linux PM , Maulik Shah , Peter Zijlstra , Vincent Guittot , Len Brown , Bjorn Andersson , Linux ARM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 9 Oct 2021 at 17:39, Rafael J. Wysocki wrote: > > On Wednesday, September 29, 2021 4:44:50 PM CEST Ulf Hansson wrote: > > In s2idle_enter(), cpuidle_resume|pause() are invoked to re-allow calls to > > the cpuidle callbacks during s2idle operations. This is needed because > > cpuidle is paused in-between in dpm_suspend_noirq() and dpm_resume_noirq(). > > Well, in fact, doing that last thing for s2idle is pointless, because cpuidle > is going to be resumed eventually anyway in that case and the breakage expected > to be prevented by the pausing will still occur. > > So I would rather do something like the patch below (untested). Hi Rafael, From a standalone change point of view, what you suggest seems reasonable to me. However, the main issue I am really trying to fix in this series is being done in patch2/2. And unfortunately, the below change doesn't really fit with what I suggest in patch2/2. Can you please have a look at patch2 as well? If you think it may be better, I squash the two patches? Kind regards Uffe > > --- > drivers/base/power/main.c | 11 ++++++----- > kernel/power/suspend.c | 8 ++++++-- > 2 files changed, 12 insertions(+), 7 deletions(-) > > Index: linux-pm/drivers/base/power/main.c > =================================================================== > --- linux-pm.orig/drivers/base/power/main.c > +++ linux-pm/drivers/base/power/main.c > @@ -747,8 +747,6 @@ void dpm_resume_noirq(pm_message_t state > > resume_device_irqs(); > device_wakeup_disarm_wake_irqs(); > - > - cpuidle_resume(); > } > > /** > @@ -881,6 +879,7 @@ void dpm_resume_early(pm_message_t state > void dpm_resume_start(pm_message_t state) > { > dpm_resume_noirq(state); > + cpuidle_resume(); > dpm_resume_early(state); > } > EXPORT_SYMBOL_GPL(dpm_resume_start); > @@ -1336,8 +1335,6 @@ int dpm_suspend_noirq(pm_message_t state > { > int ret; > > - cpuidle_pause(); > - > device_wakeup_arm_wake_irqs(); > suspend_device_irqs(); > > @@ -1521,9 +1518,13 @@ int dpm_suspend_end(pm_message_t state) > if (error) > goto out; > > + cpuidle_pause(); > + > error = dpm_suspend_noirq(state); > - if (error) > + if (error) { > + cpuidle_resume(); > dpm_resume_early(resume_event(state)); > + } > > out: > dpm_show_time(starttime, state, error, "end"); > Index: linux-pm/kernel/power/suspend.c > =================================================================== > --- linux-pm.orig/kernel/power/suspend.c > +++ linux-pm/kernel/power/suspend.c > @@ -97,7 +97,6 @@ static void s2idle_enter(void) > raw_spin_unlock_irq(&s2idle_lock); > > cpus_read_lock(); > - cpuidle_resume(); > > /* Push all the CPUs into the idle loop. */ > wake_up_all_idle_cpus(); > @@ -105,7 +104,6 @@ static void s2idle_enter(void) > swait_event_exclusive(s2idle_wait_head, > s2idle_state == S2IDLE_STATE_WAKE); > > - cpuidle_pause(); > cpus_read_unlock(); > > raw_spin_lock_irq(&s2idle_lock); > @@ -405,6 +403,9 @@ static int suspend_enter(suspend_state_t > if (error) > goto Devices_early_resume; > > + if (state != PM_SUSPEND_TO_IDLE) > + cpuidle_pause(); > + > error = dpm_suspend_noirq(PMSG_SUSPEND); > if (error) { > pr_err("noirq suspend of devices failed\n"); > @@ -459,6 +460,9 @@ static int suspend_enter(suspend_state_t > dpm_resume_noirq(PMSG_RESUME); > > Platform_early_resume: > + if (state != PM_SUSPEND_TO_IDLE) > + cpuidle_resume(); > + > platform_resume_early(state); > > Devices_early_resume: >