Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1556153pxb; Fri, 22 Oct 2021 03:21:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC8jixe921d75L0LwdC+b/+xdotFBu87BPS9OgmQjKe/3qMQFktjrTbB26ds6CXq7sLij0 X-Received: by 2002:aa7:c2da:: with SMTP id m26mr16214077edp.89.1634898078511; Fri, 22 Oct 2021 03:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634898078; cv=none; d=google.com; s=arc-20160816; b=Hhz8amPGEBhEdmcJChB87Dso0AEfB1wdkX8O7hvB55SHQr3Qzk8J/L1O5BZEZpc8rs vDtRm0pfQhr5SAOMqrQI7yte48x/aOo3gUL/X7bW4M/kkA/OwbS0aO6kmijvROaP5ih7 5YItCef4/R05Cuz96zNWwZDNm5DNPr/joOYhvQa/ZCxFNuhVwFLVZDhedI/ex802D1Pf S1dpf5RqEedYMDBWGm0HK8QSkSfyHNoNoLdEWN0RVTjmWNeupS8o/2SMvdpDQoUKumPT M1UqBi1rkfQfE0y080n8FsRTYOAJwTS5Xz8MxQuMHPNMAQwjSh+W3ERBvNU6vBE+WlcI tvNQ== 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=9PwSiIQWLcfaolIdxvWwpR3c2+g9ZZvb4TeLeXAtp7I=; b=iPmrJhqnxLIg/xizgBy4LhyMFcxlP6Hau9JZANgk2q+7ukZPFTiugDhk6XIZWv5G7c ECQbkyJ7bYG+9aUD/OyR4E1RV7DFClYDqYO5YVC2hJ08ShCKe8mVn6iawe67qmVJqpSI 6qWnFIzTUnk3Ili0YHOfwEZW+y1wz9rKJoV/HyLDxWa2NtPsWxllAwUpUFe05bYZNAjC 9CSlqVkJPtfx+9ymgIU+udZe9/Aj05UkKSa0SSriwhRg4sAYf9UdhWRTB5znntyWtg5M 1/VdEVomr5eLaEsBlH3wVtDAxbdu5xKzdN4hYVYP0NVdu/kdjUjDEODUoRmwIY6iEYlG 9A6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XlAoxvOj; 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 c11si14759891edx.502.2021.10.22.03.20.55; Fri, 22 Oct 2021 03:21:18 -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=XlAoxvOj; 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 S232518AbhJVKVW (ORCPT + 99 others); Fri, 22 Oct 2021 06:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbhJVKVI (ORCPT ); Fri, 22 Oct 2021 06:21:08 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B36EFC061764 for ; Fri, 22 Oct 2021 03:18:50 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id j21so8265639lfe.0 for ; Fri, 22 Oct 2021 03:18:50 -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=9PwSiIQWLcfaolIdxvWwpR3c2+g9ZZvb4TeLeXAtp7I=; b=XlAoxvOju3kRrEbWVVrkeWXOZBnhXXzBoeAbtV9Om0vy1TUNyfyA3PzQ6slrVOLyTe vclPvp+LJLC4I7H7Cncz0mk63K0J8vLZV7r65bJHi36LPpBxazNGDINrWJLNGoHDNuKV aUC8TSui1v2agtVCH9opYzHAHdM2SeZ+CsFkyWYBL/MOnnf3pVqCx/ITnMyg7j6yDdzV hzcZMDdCIdct4sHD0tv2outF319Ecf7KN/4eDEN5f4wbxPzoQ+3pQ8yc+7nADySxfB+h 97dwhOIhc1DVcK4IeZtIMnB/HDF+dyU9S1HrBTnnMrwGbFaLbRJwj670scjckB5TtRRm Rj5A== 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=9PwSiIQWLcfaolIdxvWwpR3c2+g9ZZvb4TeLeXAtp7I=; b=k0x0Zs9/I0Hr4AXCXbwavSbysILBSjhpj7ULPH5uj5gwAM9VnT9v/XH4Kl6Ox1uZPn fBzGGUaL7j9R2sR0ShMBUkxURy+okJLzvR521eCpL0F/FYLHDyLWHG5jm0d9XmWACbk8 6w45G+RJy5msVZ0Z529LHEeCedek94guB5oGAUJ6m3wImd+K8J2HZEwESed+wOtpAOKv r3P+sfrtvzsxJtaDeO2NVstwZhnA64tTR3DkhMXqkJYFirFl5GJMmI2RTJOnfTDRFRoX h6pP3p3ZQKy3BL5v4nJw+mgvVik4DKeg3s+wRrzKFTjW86WV2H2PrXyGnqDBGI1s9TRy qXZg== X-Gm-Message-State: AOAM5303l6blwD7o6OoEJYNXF6K8vSssBqPatJ2+svYIDGMCkCb7p+AD eco3KMlMBxKHlZiSWWvvYV6TeviiB1vT2BgL8n6bUA== X-Received: by 2002:a05:6512:4029:: with SMTP id br41mr11088973lfb.233.1634897929048; Fri, 22 Oct 2021 03:18:49 -0700 (PDT) MIME-Version: 1.0 References: <20210929144451.113334-1-ulf.hansson@linaro.org> <20210929144451.113334-3-ulf.hansson@linaro.org> In-Reply-To: From: Ulf Hansson Date: Fri, 22 Oct 2021 12:18:12 +0200 Message-ID: Subject: Re: [PATCH 2/2] PM: sleep: Fix runtime PM based cpuidle support To: "Rafael J. Wysocki" Cc: 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 Thu, 21 Oct 2021 at 21:56, Ulf Hansson wrote: > > On Thu, 21 Oct 2021 at 21:02, Rafael J. Wysocki wrote: > > > > On Thu, Oct 21, 2021 at 8:12 PM Ulf Hansson wrote: > > > > > > On Thu, 21 Oct 2021 at 18:33, Rafael J. Wysocki wrote: > > > > > > > > On Thu, Oct 21, 2021 at 6:17 PM Ulf Hansson wrote: > > > > [cut] > > > > > > So in theory you could check the pm_runtime_put_sync_suspend() return > > > > value and fall back to something like WFI if that's an error code. > > > > > > I have already tried that, but it simply got too complicated. The main > > > issue was that runtime PM could become disabled for the device in the > > > middle of executing the ->enter() callback. > > > > So IIUC the problem is that you cannot resume after suspending in that case. > > > > IOW, you need to guarantee that if the suspend is successful, the > > resume also will take place, but if the suspend fails, you basically > > don't care. > > Exactly. > > > > > > For example, if pm_runtime_get_sync() fails, I still need to make sure > > > the reference counting in genpd becomes correct - and I can't do that > > > using dev_pm_genpd_resume(). That's because it's not designed to be > > > called in this "unknown" suspend phase, but should be called after the > > > noirq phase and be properly balanced with dev_pm_genpd_suspend(). > > > > > > In other words, the error path didn't work out for me. > > > > It should be sufficient to call wake_up_all_idle_cpus() in the suspend > > path before dpm_suspend_late(), because system suspend acquires a > > PM-runtime reference on every device. IOW, it won't let any devices > > runtime-suspend, so if your power domain devices are resumed in that > > path, they will never suspend again in it and the > > pm_runtime_put_sync_suspend() in __psci_enter_domain_idle_state() > > becomes a reference counter management call which works regardless of > > whether or not PM runtime is disabled. > > That sounds like a great idea, this should work too! Then the question > is, how to make that call to wake_up_all_idle_cpus() to become > optional - or only invoked for the cpuidle drivers that need it. > > In any case, I will try this out, thanks for the suggestion! I now recall that I have already tried this, but unfortunately it doesn't work. The problem is that the dev->power.syscore flag is set for the device, which makes device_prepare() to bail out early and skip calling pm_runtime_get_noresume(). Kind regards Uffe