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: 516453 Delivered-To: patches@linaro.org Received: by 2002:ad5:5208:0:0:0:0:0 with SMTP id p8csp35221iml; Fri, 29 Oct 2021 05:39:27 -0700 (PDT) X-Received: by 2002:a2e:b8d6:: with SMTP id s22mr11301439ljp.517.1635511167161; Fri, 29 Oct 2021 05:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635511167; cv=none; d=google.com; s=arc-20160816; b=d2VoP7hZDbVQKsb2uHF0c6dBHOfEo2WKRQyFl1qRzTNi093FZ5GMTEfxhth6xVYNL2 HQXO8DqufRJlSR8m+Pe8x0LdjThR7T7/rrJLWLirCYps5B19Bzdv1/ht4JbxIzLI1BDN 9yIR6oYe+ZuQigJhvZVvGBx3EPhpVLP7a8jcv9OblsABZl5jowldVEWr8uVPlNI4MIZP GlBNqn0lMLMvdttsml9OQ4KfPQut0zDDmveQyiF2Scn+NUz+OCHCWrTy7Slj0agqqTPn i6Em0z6P3EvcKeQgb5m3Vdef/Rf9aqkIJlay+jZBprwYK1R8awcrtHH6O4jEu1g0aTu9 E2Ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=B2T3v4jXO25JT49qo2reiE0rneUAVuElVzG5JppoEM8=; b=TXLT2iZFvsJ3+QV3HqcDf2+eTXxcmlcRwHLy+0wktAVceHkHSw9xALz5aSlvaF7Szw m8T+EPwSVq6kVdpsdMY9GrdtvvTlvpve/kwqSAjHS6Z7TG9tFL3ExQlxSxXK+/xjEVpK WGxfhHAX2sTYraD5aGQ0FrabYi3TEl4Umlf8RYNVFQRuV5mFECZsNOfgg3/YoE3ni8Ha epZlow80gztC5QAQpx3ZdcA03cx7UFZ2afDRSOkGtltUV2AYevYysftc0XqbM5RHY9Tf Fp8oRntWA18ynHCsqIKutE12gEyBY1HsPs39mHTaIM70O5NceV4f4Cs/Ba8PGHINPzAZ /ejw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jxD6biwT; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id y40sor1697401lfa.162.2021.10.29.05.39.27 for (Google Transport Security); Fri, 29 Oct 2021 05:39:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jxD6biwT; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=apDt8kt/bu8GjMw0yykl/s6tXHdzfiFfB/pC2/pUcHnD3NRxknZBysAtrtG2u66oNQ 2dJ1bueZ3JbWbxYG+2PxWkRsH2scTGXgJZz6uPS4nH4I1Krca6WY8JL/nebNI1IqH31k gBm7gt79xyL75l5F1ZZpHervGIyYtIWu+65WyIUUmM7x8h46wetH5CUWtDYQDyjZmdPe bZvM9TAc0woDU66erD1DtoJriAbuPeMxlnt7wJfWt1SDvaVWZmEpDeUeqvv6DuVWHoja heVHNItjR79muIQeCuuFrUOtfXyjGe1Dnkp4eGSs9co6Ff62zNyU6/uF+6t740L7VhkW QIPA== X-Gm-Message-State: AOAM533f1uMwBoRmEyDM7CE8KX9/ydyfi2Su5JymkVzOKDPN0gyQ3T6H lNobUJzA8HtfBXmBCmZNtGIKt57B 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) Return-Path: 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 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(+) -- 2.25.1 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;