From patchwork Thu Apr 12 11:14:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 133247 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1573617ljb; Thu, 12 Apr 2018 04:14:54 -0700 (PDT) X-Received: by 10.46.101.16 with SMTP id z16mr389539ljb.72.1523531694415; Thu, 12 Apr 2018 04:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523531694; cv=none; d=google.com; s=arc-20160816; b=rrs2A170tX09BToe4Ic8ihfgAqLlZhJ5FOZOiqIqjXsjIe69gokrfI1We9L/Zf8qtP eJN3dI5QVmjBUWwDoiMIHjBSH5widpUraQIPUxIKD7L/mN8vjgnsHcpzgmCy4B3PZFHe wWs2odOuDNNyL0z6I9MkWrbzzBbE/UF1/gGXNpTrnWb0EugPQnK1UsdD8RY/IleQmXEp T2AYc0RumBkgIuhNN21SQJhhAFoi6dCvvEaDI+YZwZM89+QRp6UR6jO6Wpr73p0KWje6 8ndqz4Tnazlf5zhfjtvZ86G00tjx+A9myAs3Rf4vZtw25/Gp6bEnaJrPffNRTTiT0Vlj q2lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=3/F6tv2h3FNcd/Gi/Phy9kHc/BZznWra5waqp09Zxaw=; b=pN2/GpaflLLieyQ1pr27noQo/dpHTDofMpAFeAn5geIie+Ud6VzLnHaQq90hhlkHod GvbWNsLzYTBUln00M2soTYnBTh2U6/YIkdt4UAZPeOUOAUtNPURhdwMXL7wYubLBGBBF bJ9VZ7Ka9KMckK0k2cLZET102anUrHu8ItvWZ/5AuDKkeJH3SpMNBWlaOqt3blvGRPFQ 7pU/31XPHKKHQbB3PjzXKW0XbRQ2OL+pSl+hK96FLIorc1A3F6ESgVo/Y0vn4JxEYApZ KOvx1Hync7diC5pshPSd82XUJEt23ZO3F2CLsYFXTQbAw9r59dv+MZuyr2feM0dfRuQn DWmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OPzMN2wB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 73-v6sor922466lfz.85.2018.04.12.04.14.54 for (Google Transport Security); Thu, 12 Apr 2018 04:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OPzMN2wB; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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:in-reply-to:references; bh=3/F6tv2h3FNcd/Gi/Phy9kHc/BZznWra5waqp09Zxaw=; b=OPzMN2wBKjEx5I4b4BZ5k9aBPrH3R56Ykx0mfQuR5qkhFXuPfX32xINdUNDszDnPZe 65TbgkpZXh430TxYbVGPsHzZXfEK7+o8BtmTRSbBwN+NQKVsNBhhYgFX7OD50O5crA98 3MVCdFTowyPX4TnFX9G/O/THvITArB2on3BOY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3/F6tv2h3FNcd/Gi/Phy9kHc/BZznWra5waqp09Zxaw=; b=ug/45Th1FNq+5sKH9wctb5X9OZ9aWAsjpmJRw01uDikEvuAel67JMo4sr0nJT1OwM6 znKa/Wmek67ut7oPojYAZWoHAuOlU6zp0tG7MITbnUwfnC/3B2CfCdozNFTWrU+D9ELW IgS81+ef1rsvDj+mfoRuw60IdFoKmSIGPJSfrSmu+wYmHPhHuA9cJOy9Brkg3x0xn8fe gQVCQiCmfm4dkXErjD5gkQefYmm5DvtLYDfguBmjEAIllstU05xT0Z8vxB9MramiXr2s PCcrrurCe4Ay9CfJINPqLg+651ijqYCCcMbW8xw6WEfHn6T/bs0trF+JnQlzqRhSZXam bXMw== X-Gm-Message-State: ALQs6tBAlYsQ76lXa+/AcrcmEDBumCQtz7HmsD9f7RZMLZjbQwNtsqU6 wamEIZI3SLxFhJORjJUyJhBoWZxY X-Google-Smtp-Source: AIpwx4/tP4nAMUxM3HEPkP+qVLfV0fd/5tP+cN+B79UG1TH5FvaY4a2n6IYPvp5hG5+pxSdt2amqRA== X-Received: by 2002:a19:1a86:: with SMTP id a128-v6mr5476616lfa.80.1523531694189; Thu, 12 Apr 2018 04:14:54 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.14.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:14:53 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 09/26] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Thu, 12 Apr 2018 13:14:14 +0200 Message-Id: <1523531671-27491-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> To allow CPUs being power managed by PM domains, let's deploy support for runtime PM for the CPU's corresponding struct device. More precisely, at the point when the CPU is about to enter an idle state, decrease the runtime PM usage count for its corresponding struct device, via calling pm_runtime_put_sync_suspend(). Then, at the point when the CPU resumes from idle, let's increase the runtime PM usage count, via calling pm_runtime_get_sync(). Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- kernel/cpu_pm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.7.4 diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 67b02e1..492d4a8 100644 --- a/kernel/cpu_pm.c +++ b/kernel/cpu_pm.c @@ -16,9 +16,11 @@ */ #include +#include #include #include #include +#include #include #include @@ -91,6 +93,7 @@ int cpu_pm_enter(void) { int nr_calls; int ret = 0; + struct device *dev = get_cpu_device(smp_processor_id()); ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); if (ret) @@ -100,6 +103,9 @@ int cpu_pm_enter(void) */ cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL); + if (!ret && dev && dev->pm_domain) + pm_runtime_put_sync_suspend(dev); + return ret; } EXPORT_SYMBOL_GPL(cpu_pm_enter); @@ -118,6 +124,11 @@ EXPORT_SYMBOL_GPL(cpu_pm_enter); */ int cpu_pm_exit(void) { + struct device *dev = get_cpu_device(smp_processor_id()); + + if (dev && dev->pm_domain) + pm_runtime_get_sync(dev); + return cpu_pm_notify(CPU_PM_EXIT, -1, NULL); } EXPORT_SYMBOL_GPL(cpu_pm_exit);