Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp922562pxb; Thu, 21 Oct 2021 12:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOeP4f1o0Q+AVlprl4n78hGFHPPLmxsB6QIiVnX3rw8oyhebx7DuoHK4FZG4GzWUqYXGGB X-Received: by 2002:a63:b21a:: with SMTP id x26mr5861159pge.418.1634843154726; Thu, 21 Oct 2021 12:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634843154; cv=none; d=google.com; s=arc-20160816; b=1DWQ5h3ZviJU+q5tVudtGPY09rDqP5AueQE9dl8jWeqn2PcfQBlRtyMJqecaM4X3M9 7Ko0ljfJ7yyuT+Zt8K21XBPs2OF+FzkufaZfYe0JUAkjrsPfgJ1sCky3ocvPXtfcoy/G gryXKLu6B9zGyV3OjntD33aaIL9hXyAPQ4FeyxN6EdlqxY/mAh/ZlLKD6zZbIFxU6I1j 50Enki4+EuaEY9gPwEtuO+RAnzu0Ka9601UHvVCUqApKU8qGQs41uEMxNgd7iAtv3tyQ m1VVsltNW+ghtl1fq68AZL2Hak3/R3rZ8IoYWHabE2UMO9t+MaKbnmJQk7xd/goA4GAq MMQA== 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; bh=W7TkRZBg0XypFSbXfRFIpqf6ScvCTqPGc+rgARxQ4LA=; b=B9jMsGwjre52NTt1/VXnsFasPDNRixMt+nfKm6HQIb+xZE25O+MgKw/NfIpVpYCmfd fy1e+O1QG+u4dJ0ICtfgr+C1D6Ih8n4cjYRDwFeVm0nvR4ZH9zCJmG4TPV8P5VtcVKEY H0q08SDIfDrRWU76cb9+xYBrXiOeCRjMFceZAo0ZWnQk2I6QnX4dc3d7FikIGQhPHL+5 eVMVQlrNuNaOMWxQyk2uOvNYzMs5ionxGyh8QBXY/AEVez60jJdcHSMS5Hr/R/ZapVeH 3r8hdGMePFqG1OKxOQxDTe9Rc9Gk/dDLEUjOpBQQwTXbGYLbXdNVoziej++l2TDxbTUh +AqQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si8332710pls.271.2021.10.21.12.05.40; Thu, 21 Oct 2021 12:05:54 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbhJUTEx (ORCPT + 99 others); Thu, 21 Oct 2021 15:04:53 -0400 Received: from mail-oi1-f182.google.com ([209.85.167.182]:35509 "EHLO mail-oi1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231336AbhJUTEw (ORCPT ); Thu, 21 Oct 2021 15:04:52 -0400 Received: by mail-oi1-f182.google.com with SMTP id r6so2108084oiw.2; Thu, 21 Oct 2021 12:02:36 -0700 (PDT) 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=W7TkRZBg0XypFSbXfRFIpqf6ScvCTqPGc+rgARxQ4LA=; b=7shygzSLatyQFc44/gtRSOGVC8NPc412I8P4OTBPmXvMiAzwgH9N7jPHqfl5cEOJRf zm/A8cUqFpOkrvc2tqoQO38F8Lpwe/B7UMt4V7x1P3oFpC5Lzth3p9zSuHKEQBmOcivP 74c4ZkZnP9NjWPf7gMOh/gPSNA8b+wIdXLHerpN74PeQ+ocdbTHKVuaMtL+ylWUHZMQc WPkn1UcJionNMX/WBXcBvXN/olcvOI47PjPTCfIUIPD5bIVNIwdfr134JrLFkiULE3/j Cf/bpTHWVTo3CPMsT9EYi3RMKEXql48VsFBsUpJ3BD+ay1mB7xo0HhhSGv6cxwZYGYGR +ciw== X-Gm-Message-State: AOAM530Emf5rLwe7fNO9E2KQuXCaXZlhfVqdvOh1JMeYsx5jSucdZHs6 YJQq0IJVaWSeR7pg8qJvLaNCXQgih98zHd5AkSE= X-Received: by 2002:a05:6808:e87:: with SMTP id k7mr2165504oil.166.1634842956087; Thu, 21 Oct 2021 12:02:36 -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: "Rafael J. Wysocki" Date: Thu, 21 Oct 2021 21:02:24 +0200 Message-ID: Subject: Re: [PATCH 2/2] PM: sleep: Fix runtime PM based cpuidle support To: Ulf Hansson 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 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. > 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.