From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82550C433EF for ; Fri, 22 Oct 2021 13:13:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 512D0610D0 for ; Fri, 22 Oct 2021 13:13:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 512D0610D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VzrVjoud6b3CHOFvZxugpPoMsv0iZBlr6NSPnqD4JuQ=; b=aNW/gtuFlzkHzm DK5tyDcngMmiBvRDaWbDC0Pax7g3FOKqpPn+DBj4SIH2Boiflie5KzNokth4yzbNkaV+zQteCyV48 f4jhcmr0rOUHj5CQU5cho1iL0s2HAvRx/SY4PEoDPqfaV7uhfJTBwYyKJ05TpjsahVO/ezien6LoV VGQFc+3aQf7PPqwGXUr0sK6tOblLhjnGtsgDBjY1QnSutx3slshTlzVfsLNiBZM/s1yvhwowOEUj1 AfMKppnW0q+WnWJPxH+mGBn5tQ2xWcogrTJJrFLgB1UM2KmWuIF4RVFdObSGJ740Xm0CRwvMbCwKC q+HVVtH0UMXgESXysgdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mduKA-00B2gB-1S; Fri, 22 Oct 2021 13:11:07 +0000 Received: from mail-ot1-f52.google.com ([209.85.210.52]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mduHT-00B203-8Y for linux-arm-kernel@lists.infradead.org; Fri, 22 Oct 2021 13:08:21 +0000 Received: by mail-ot1-f52.google.com with SMTP id p6-20020a9d7446000000b0054e6bb223f3so4319765otk.3 for ; Fri, 22 Oct 2021 06:08:18 -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=ea+dffKzojjtHMbhrke+o7EPuvNXQWSumCl4dU8Qqig=; b=uc1hNc8pn1wELlX9SfNCeew23PhFGtwtLynVIMae+PxVnOrHK3D9Cp0Y4D75OtF2Wn OReVDyTG7Jp0G6YlGNgKdl7w5VdhsS9DdOrt+UgzWtJ0NICFjZemp8BO17rH0OxMrkUF ybr81MAbIbahwlOcKlC78gLGNc1FxDWWPT4pzPjDgVt0ai51ljF+rkYVfarPhrHIsUzD ggOMwxH6Ayb8ZCPgAdRqJd7+If/FmS1Wk9KUEfQbpS0emSzEHKJ85fa8Yz1Fd9ChEJA/ zxqY65CoS/NZQ7hYZ8l97cZjL0CJhBoTbAuxC7IYWUHJQZdqXk81ILQ5KwNhUrE4Yf/k KEcw== X-Gm-Message-State: AOAM53330+Kmm6fyEh+cP/ksMMjI70DpSDs8IGfYdO49MbE8kuqO2xLu 2SdRauJh1hK1huFxLWOlO35VCQNZ5cmyTHsY6bU= X-Google-Smtp-Source: ABdhPJwVN538gMKknUUa3nQaPjG1oX9Ha/E3NnrsQHxPcgMmQ76YFoE9DYKjOzQgSqA45RqB9kS6R7iNphBQyTsWI9o= X-Received: by 2002:a05:6830:90b:: with SMTP id v11mr10046614ott.254.1634908097786; Fri, 22 Oct 2021 06:08:17 -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: Fri, 22 Oct 2021 15:08:06 +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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211022_060819_355985_F64BFE6B X-CRM114-Status: GOOD ( 41.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Oct 22, 2021 at 2:57 PM Ulf Hansson wrote: > > 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). Yes, please see https://patchwork.kernel.org/project/linux-pm/patch/5773062.lOV4Wx5bFT@kreacher/ It should have been done this way from the outset, but I messed up a merge (and said that it was "trivial" :-/). > I can work with that, let me try! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel