Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp692015pxb; Wed, 29 Sep 2021 07:47:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIExgWlSle3wH58RlJaMip7LEtk84sxoWTLpNFViOmPkLYJnSUIz/hk2owCEuB/jC88uzp X-Received: by 2002:a17:90a:910:: with SMTP id n16mr6784671pjn.246.1632926876970; Wed, 29 Sep 2021 07:47:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632926876; cv=none; d=google.com; s=arc-20160816; b=kLfqHMYG7Igbce5Ev9q36dKGqamYteE7r3VKvoJejqDUVUcsB0OVd3UvD6ctBH8rCp h1Go5Xv4vl+Fq+cQpkUfxnJ70ne1YIF1OElGP8aBmVy+ktvrQjBqoWlDvs92MjGo1lqJ h/FRGDxrFM1kR5xzVmGgquxOBiswGyt/yRCtIkXLM9HeT4yQM+7SkDUy5OU69UeAqPPR wYKsS4FNfvK6zqWoUMiwsehdgQ/jcp8xaE3ZB1SN20Q+ULi0/n39bcBB32U/UnPnSbNo nmaW0RMQgCVcghOrs/r+ZmzEwSiV2gz+Z8ic3WeWRAvUOJPCKDD8jon8ADaehuavtqdM IZ4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jI512TbeQgh2FYrW2/MewJZ0e3lJuCvLMPJwgkXNatc=; b=H3Vw5fWUfx2lw+27wFclG20VbqVTgPA0vjHDlPOkYUP8Q7QvFObteMWP1yPW8QgcEB 9K+aRb6Y5d0II2fvJDv6MJtcsLG9qQ/tRYd7VtIb7Iu+GQS3f2ujyxVT26MIHT/lVPyb sFlzdUCxvaCntRSQ+jp4zzoxxwK1EhgJPJF/IzgkKd4ZPS74tXT9rD1Gs0hJYYr+lqI/ SNae6/Etm1vTV5tSVbJw8KWt8D3haq6mAl/yZEBNqpQf3nY2+WAR/UoFO1qhbrTye+Eq VSmFFsRneqw0P/UxtamdI6BDbwbm52b97rYFxJIQVf+Avrg7A5D40BUyu/pRKpinG5kw //1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uJy2BNUq; 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 a9si2838304pgj.410.2021.09.29.07.47.43; Wed, 29 Sep 2021 07:47:56 -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=uJy2BNUq; 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 S1344585AbhI2Oqm (ORCPT + 99 others); Wed, 29 Sep 2021 10:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344572AbhI2Oqk (ORCPT ); Wed, 29 Sep 2021 10:46:40 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C18C06161C for ; Wed, 29 Sep 2021 07:44:59 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id m3so11692568lfu.2 for ; Wed, 29 Sep 2021 07:44:58 -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=aajyKyJpAwmKKcdpnkiCQt6iuc+JSid0lvwOI/eVotc4nS3bJ+yjCwKXORerBkVKYC N0mnhz7ievVxLDqd/8O+BEAh7nrE3iGGEeqADQfZVpa/0r0oJ6G4mgbJZT879u09urHj njIATzTM7oLBqtEMz6i3hSFDJF/LdX/m6+TC2dNLAL2DwDeSshHiLyiG+GV1NE2i9oda FDG2JAsJob7VCyrtFy7mQOk252xzBX9E6tbX6mimqbHjVT3NBKlDGEegEbh4WOvvOdIf 0CRFSsnr7/0IRvQSFCi28tJ9HpUfS3miPhHaah5XMhzexRZZElDOjRx8TuhE5HxlhEai 5ITg== X-Gm-Message-State: AOAM531V/RT+v6V2E1MHf/1ZM8IBB6ad56LcZQWD2uoo3HHPD+MltBIS 4tb93nc3m8tuB955EnJKl9zIKg== 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; -- 2.25.1