From patchwork Wed Sep 29 14:44:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 12525701 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 AF3C8C433EF for ; Wed, 29 Sep 2021 14:47:21 +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 7AF0D6103E for ; Wed, 29 Sep 2021 14:47:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7AF0D6103E 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:References:In-Reply-To: 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: List-Owner; bh=cngViD7wFtzb9DygMcYfTLPTRui+aq4OtQdgH0UTHnc=; b=R1Mbe3QsFrHIfn lI2dUzWklGcQq1ri9E9wm/149Tywy3CU5Sdld81NCPIqzFvZKmopd5f11hHrYFE/kBX5VcYqJ5qM8 RYyToQpALCPqf/JGyBLzuLScmTXJT81lWFfg6YTD+y1fnGOxUl00J+7+yUEPErzrqTWvbtSKb0YHP JU2XshtWO+oKrLTmYgIJCcKuqIiWTtapHpeHUlyvgJ3ibz2f+2hiDebbc0kQuaIqeuUG1sjUzGzse Q/GDNYMENT0BY/GMPkWDauc0fPQBkicOm7TsMstTijMnEuYmEA8j8RkPiq1YMydu4TkaoC70/q+GW awiHKC8cz2LoGULjQWzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVapn-00BM2A-Dr; Wed, 29 Sep 2021 14:45:23 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVapO-00BLro-AD for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 14:44:59 +0000 Received: by mail-lf1-x12d.google.com with SMTP id x27so11875010lfu.5 for ; Wed, 29 Sep 2021 07:44:57 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jI512TbeQgh2FYrW2/MewJZ0e3lJuCvLMPJwgkXNatc=; b=uJy2BNUqQw+BJyvO/Zh9fJeegstwdqNEGh1Ckjo/E3TaoDaiOXk7emJ0v4f2cq+KdJ 1hyllL8m7Na7397VPTNeTYOUN0JKOnBSQqT8PXNvL6fvPM4etcvF3talSs1L4MuEOYIj ORbd+bs0RKplK3xfdWSlb2bNOVOOhgZlrmF3MBoh6zbhvqaDRNoirQ0dVCw478a/gPTD KhW6uj0uMsO19BubBS9i5MCUcjN5XHuFbSpOq8pmIR/xbQklgT2g0XgE6YslcomcAmF8 SbfkwV8g5cZcKPss9NjFJKsGNXUvNfYCRCd6i4kNP2AOIoRfLTgQ8MhZFmR4KoGMb274 b/sA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jI512TbeQgh2FYrW2/MewJZ0e3lJuCvLMPJwgkXNatc=; b=qoyO/YDXQDx+O5GVnNMNNx8kSelWtVn5R0hAOUStdHkBr6+eeZkYNs8u1JFZSpWUbo fFueN5tCCW9iSUQDr+gXeyEJ/L5BFLuB1GBrcDlna3Q0L1qICkZ2oqXVgU8HWHRfjX02 YEQmWHezr0OEgk8ZiCEyOUse2jxKNx+y7dfvK5iELNAIiDnkljQ2RThSmH5abVKuTDT1 +bsXKvzKoHWF2MfZ+rN1o+EyzGFVSpI8PkY1WW5AGLMEUV/3tFt49T4osnE9lYCz0m+b gsIfigLh79H09z0XbQf+b8IfdpLq1XmR4HH5gm9fliy7he7vhyuTyuQIhVLB3T5Uuv99 +vpg== X-Gm-Message-State: AOAM533HUHFGYO5cRNtdFP0gGigiFToo3awMxEzkTfQsD769HaL3narN v7G/aahn9wfirfIYafJze5mQHQ== X-Google-Smtp-Source: ABdhPJz81MaqezsB00jcBTdcVIWyNKeqSu5DcUQ8vyT5t7reV63l4XQLO+5zErmsmpzlDbBEZrvCpw== X-Received: by 2002:a2e:9a07:: with SMTP id o7mr302931lji.125.1632926696590; Wed, 29 Sep 2021 07:44:56 -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 g4sm9863ljk.64.2021.09.29.07.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 07:44:55 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org Cc: Maulik Shah , Peter Zijlstra , Vincent Guittot , Len Brown , Bjorn Andersson , Ulf Hansson , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] PM: sleep: Fix runtime PM based cpuidle support Date: Wed, 29 Sep 2021 16:44:51 +0200 Message-Id: <20210929144451.113334-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210929144451.113334-1-ulf.hansson@linaro.org> References: <20210929144451.113334-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_074458_409788_F8EE6815 X-CRM114-Status: GOOD ( 15.30 ) 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 an 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 the dpm_suspend_late() phase, the PM core disables runtime PM for all devices. Beyond this point and until runtime PM becomes re-enabled in the dpm_resume_early() phase, calls to pm_runtime_get|put*() will fail. To make sure the reference counting in genpd becomes correct, we need to prevent cpuidle-psci from using runtime PM when it has been disabled for the device. Therefore, let's move the call to cpuidle_pause() from dpm_suspend_noirq() to dpm_suspend_late() - and cpuidle_resume() from dpm_resume_noirq() into dpm_resume_early(). Diagnosed-by: Maulik Shah Suggested-by: Maulik Shah Signed-off-by: Ulf Hansson --- drivers/base/power/main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index cbea78e79f3d..1c753b651272 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -747,8 +747,6 @@ void dpm_resume_noirq(pm_message_t state) resume_device_irqs(); device_wakeup_disarm_wake_irqs(); - - cpuidle_resume(); } /** @@ -870,6 +868,7 @@ void dpm_resume_early(pm_message_t state) } mutex_unlock(&dpm_list_mtx); async_synchronize_full(); + cpuidle_resume(); dpm_show_time(starttime, state, 0, "early"); trace_suspend_resume(TPS("dpm_resume_early"), state.event, false); } @@ -1336,8 +1335,6 @@ int dpm_suspend_noirq(pm_message_t state) { int ret; - cpuidle_pause(); - device_wakeup_arm_wake_irqs(); suspend_device_irqs(); @@ -1467,6 +1464,7 @@ int dpm_suspend_late(pm_message_t state) int error = 0; trace_suspend_resume(TPS("dpm_suspend_late"), state.event, true); + cpuidle_pause(); mutex_lock(&dpm_list_mtx); pm_transition = state; async_error = 0;