From patchwork Fri Oct 29 12:38:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 12592627 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 7422EC433F5 for ; Fri, 29 Oct 2021 12:40:58 +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 3642161167 for ; Fri, 29 Oct 2021 12:40:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3642161167 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UJK7nW1x0oHJIxaLlgwz5+Wsbv6QXI6csiMo+75fBjE=; b=aA0F+thJt0Ddvy 1i41e46UwH67nGYEoffFDir92NqW7uzFfy29lU2H1+iXe69F4PwfqNTFjIkGbH0qx8G3oDy+8ClQj NeA1MQez8ycHxDDMqHk91BpZaPOscARa76SddffT8EodFK+GzDS6sqFqVNHgak8ZBGXVtVyvgHN8A NrzR8iP1c7Y6panOWCzvPJSk+d7s3ZDnD5LIvssygRoPWMmHkt4IOFCuTWq+Qa187RZNS7QImBwpL h2VXOC6deFpbFN2vsZoV78ya03srLRBhKTbbbuSJOzf8AEAF2ygaGvtyqJVPm2UhbImm3eXbguchf VBjhk64B9F00jj/adeQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgRAU-00AwT2-99; Fri, 29 Oct 2021 12:39:34 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mgRAP-00AwQG-J7 for linux-arm-kernel@lists.infradead.org; Fri, 29 Oct 2021 12:39:31 +0000 Received: by mail-lf1-x130.google.com with SMTP id j2so20826971lfg.3 for ; Fri, 29 Oct 2021 05:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B2T3v4jXO25JT49qo2reiE0rneUAVuElVzG5JppoEM8=; b=jxD6biwTfe3xu6SqBzLET7VGwK1z+O5kXXr9D9ld+3oXexNknMqaFCW9F2LVUIXD+G ucuVD7vOA4sZwbtUVVm7VzO3veKFGjRJHKI0vsCgqedXMckkcCuS5RX2luse2sdk1Twa WBDj6uMCqZkJ/KYciN73SIqRqEBtCSDSF63zmsvalZsfnmh4tgcEAgjPi9ilrgDdWMVb ZEJT/Qe6glvFD7+mxzhPkUnG56DeqPTqZIJn0EwzCL6fb0mJg+J37Y3J8rVtha2bb88g FhnpS+0RzDdrfPrw09Zk0fIpd8IvICd3VoueJ91jfIvaJiW7UN68emvVY/bbOQyolIXI WutQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B2T3v4jXO25JT49qo2reiE0rneUAVuElVzG5JppoEM8=; b=s9eRn9C+YbODWgvW+R6sjAQBUgBKAZxC8jmoeyd42bzhq3Hj4xkw+whFvRIEKSbMV+ 131H2U+ir8YHHOxorSsorC2TSw83VJcUFDLlSh9vYVbCwspefG/X27f39TNaNJksjLwo UpF5MhMVY9/eUnRd+WiaWkVnrIHz6/pJjTLspmNeAJZc6uZ71ED/NNju2W0CCUiZqxnY mTgHZlDnH8ZbNGR0dh2Jx0u2uMci2HIXuDHNcxR70vG9sahiBpY1pfJEtddmD4QC1vzL JNfuKnu/U/jjUAVWoHCuApuX/tbynGu8KrOB+3c5KqJZwFpx62gXeZ/FL3rIvKT8TyJ2 g9yg== X-Gm-Message-State: AOAM533yfJx+JRFM115h2srNvEgF7sPpZI2YklGJJY8Nf1gnpneKYKi4 /mNUg9cVthYJKxJDqKO9IwAPlQ== X-Google-Smtp-Source: ABdhPJyTjynt3OjUbfPQGjnjOlAGOKmxPdHzyoRf35p2/vo3MySu4coNCsQpIc9on1MRDnXuPapytw== X-Received: by 2002:a05:6512:2309:: with SMTP id o9mr10050460lfu.124.1635511166794; Fri, 29 Oct 2021 05:39:26 -0700 (PDT) Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id y35sm602528lfa.16.2021.10.29.05.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 05:39:25 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Maulik Shah , Anup Patel , Len Brown , Bjorn Andersson , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] PM: sleep: Fix runtime PM based cpuidle support Date: Fri, 29 Oct 2021 14:38:55 +0200 Message-Id: <20211029123855.80344-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211029_053929_663080_0C29353F X-CRM114-Status: GOOD ( 14.00 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In the cpuidle-psci case, runtime PM in combination with the generic PM domain (genpd), may be used when entering/exiting a shared idlestate. More precisely, genpd relies on runtime PM to be enabled for the attached device (in this case it belongs to a CPU), to properly manage the reference counting of its PM domain. This works fine most of the time, but during system suspend in dpm_suspend_late(), the PM core disables runtime PM for all devices. Beyond this point, calls to pm_runtime_get_sync() to runtime resume a device may fail and therefore it could also mess up the reference counting in genpd. To fix this problem, let's call wake_up_all_idle_cpus() in dpm_suspend_late(), prior to disabling runtime PM. In this way a device that belongs to a CPU, becomes runtime resumed through cpuidle-psci and stays like that, because the runtime PM usage count has been bumped in device_prepare(). Diagnosed-by: Maulik Shah Suggested-by: Rafael J. Wysocki Signed-off-by: Ulf Hansson --- Changes in v2: - Moved away from using cpuidle_pause|resume() to solve the problem, but instead just waking up idle CPUs is suffient, due to other recent merged changes. --- drivers/base/power/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index ac4dde8fdb8b..2fb08d4f1aca 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1463,6 +1463,7 @@ int dpm_suspend_late(pm_message_t state) int error = 0; trace_suspend_resume(TPS("dpm_suspend_late"), state.event, true); + wake_up_all_idle_cpus(); mutex_lock(&dpm_list_mtx); pm_transition = state; async_error = 0;