Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1688916pxb; Fri, 22 Oct 2021 05:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNpFLocJu5Ij5VAG9h/dU/xmjn8ZVE6P4M+CTxqqLK/UTUKDl3nEByHd9ihFUlBxB1V8eZ X-Received: by 2002:a63:af49:: with SMTP id s9mr9282214pgo.25.1634907585791; Fri, 22 Oct 2021 05:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634907585; cv=none; d=google.com; s=arc-20160816; b=ynqCH8KDNClekw1eSs+LCoQqXVXFwGMyiWDe7jg9eNPNhIXHaB7TXbsLxCVIgGiBLE rxk1VXHsvMZL1Udw9+QCYHbAYqIDQTaIabMW7ilOGcyjmd4urIReQgVTBnmjZ2t3NJjN P2fL4S1onPX+SjvS2UGnnrO+TXUaDGnXXWPRI0Q3vAXdwjy8J0Gsn36G8oK+uZEvNMc6 5b0mV+Ag2uyoh1S/e4IQgcOd7tFCNA8n1wdPLYMJgQn8R2bsYD1v0zXCjdrxQ1OwAL75 ++sgR5mqFeNAs4lEc4OnrFV+yUFH8tQVoFMtWPliDcrGy1FDXu12gr3UTD7JyFjgkAMx XC2w== 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=Abf1EK7igg1BriA0e8T8lClrB5y9+Gsf1155IsU+KtY=; b=IBrekSqFJfTDefSlucVSNM+5zuvOd4sDX+6w50qhzJiiFOa2wLoCVZZyol+dZJxZv9 iRljCm5lkGwsfnHrghZvElLIQ9OiI4Cg3QjNlLJNtu0j9RJHZ64WfGtIbIqDWQIzGrw7 uNhH4V44c8hkCdbfGvdJ85eAQxt/KjIbD2xJig1IzoWBd+ivTCOvr25hBpKP8SJ2wDVE nXxCwrHUpMbDLIosm+JKmfWosFdhOEZ3ciwr6uS0WXhr8DotAVf6jUJ8TLjklt2jI5Im +Y+RGDMe2gWmUwRojKPWAZM3HCsH6fCK4NvxaE0AeBHhn2wESqpCFqK/gCl672RDUbfR 4stQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NDAlECpK; 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 72si11013064pgb.591.2021.10.22.05.59.32; Fri, 22 Oct 2021 05:59:45 -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=NDAlECpK; 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 S231564AbhJVM7V (ORCPT + 99 others); Fri, 22 Oct 2021 08:59:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232813AbhJVM7U (ORCPT ); Fri, 22 Oct 2021 08:59:20 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D968C061766 for ; Fri, 22 Oct 2021 05:57:02 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id d13so1424237ljg.0 for ; Fri, 22 Oct 2021 05:57:02 -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=Abf1EK7igg1BriA0e8T8lClrB5y9+Gsf1155IsU+KtY=; b=NDAlECpKEoiIXNYVnBNLY5NGNcMxFCHaLejYCd70ls9LFrXyETzW/5O6sak6RhKhpE z9rnKUJgTkXrHxWIVXuEX21lw9NoZWfYt3x2yye4Rv4Nri3ncHigWjRscrje4fW/vCpB mWb49t+5KXxRNBcvehuydsu4RS2BSyzqWRThr4EB7IofCuCQjc6t5JgIA1s+4MbVx4dD NednvzaqcjCw9wIX9wD35vJfdZKSc5T5jr1+lH/TpqSwaxlaCzkB7LgFHqR9YgQ+jz+p rCSN/m7TsqqPFpMjHIc1T32xKDFIqJlZ4knZgmXQD1xbmy4zG5DS+MnqY97tO6FMqdDe C64g== 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=Abf1EK7igg1BriA0e8T8lClrB5y9+Gsf1155IsU+KtY=; b=wygrrVLpXo6VawtwFdW05gcoxsuliqFs0hpfkqaraqyMB0yuOX4EUjz7jSZUMu1QDS Sg594BJIFk2oGF83D+/jgJExETQyJ6UUOWoQwYoQh0rd9fWGWckCxXR+Ia+O6do8D2+H 5aZkOmqvzzqeBdhO9q47ayzC/vFixCcrJTk7psYEZqrxHEmGl5cOTzbjyquWMRgIdA77 yX564AvbvDYoHxGONSQreY1SaudGjrrvGMwJjf6C2XdHZNGPKajZTKrekids4ORi5Qt3 D+NSnEqmaZFmH+qovN0MWXU63U11LbqbFoP3wfEmpfGPivulmMY5S9cojK5JO/geo7/y 7PAA== X-Gm-Message-State: AOAM531WekF4B7A7MI3UE+7racYSY+vC0VG5wCEz0g7z3TaGhJOBeTbI llK0uzuNi+Ay4+IVwIJ2cN6cahnDA8jKvH/9kcW8kQ== X-Received: by 2002:a05:651c:11c4:: with SMTP id z4mr12755222ljo.463.1634907420771; Fri, 22 Oct 2021 05:57:00 -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 14:56:23 +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 Fri, 22 Oct 2021 at 14:02, Rafael J. Wysocki wrote: > > On Fri, Oct 22, 2021 at 12:18 PM Ulf Hansson wrote: > > > > 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. > > It need not be optional. > > For suspend-to-idle it doesn't matter, because all CPUs will be woken > up from idle shortly anyway. > > For other suspend variants this doesn't matter, because all secondary > CPUs will be taken offline shortly and the primary CPU will call into > the platform "sleep" handler. > > > > > > > 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(). > > This needs to be fixed, then. So bumping the usage count even if the dev->power.syscore is set, should be fine? (And of course dropping it in the complete phase). I can work with that, let me try! Kind regards Uffe