Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1037301imm; Wed, 20 Jun 2018 10:30:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3VvNa22SLeMCVqQLpyykYki242AEyodkZm6R4dzRuaGKdjKc5+A7QxZ5oA8gqdNlxVKuv X-Received: by 2002:a17:902:bb90:: with SMTP id m16-v6mr24719036pls.50.1529515801462; Wed, 20 Jun 2018 10:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529515801; cv=none; d=google.com; s=arc-20160816; b=EDRT48VeF0NbfdgblFbXuawd70AhG3NZDfmiAvWgd2p1VkBkwqDaJWwUBGNvD41SUA kn7z3TOwUM6bNVaWo6hkKkFlKhnrG749S3wGzpjmydw2zxy/705tdjVTJfs1WShFA4gf tY60U/yV2KgQnkFcJuhemM5Zul6Ev7A3VS97VsQhTjagPlGwzkCphXid3ElR5E/uYPN8 USEI5Kdnxkq4P8l0TK6WmIsSqAxZzGSMAhIp34AONCULJSvhHvGVa/fkjYF2bPIEkgfx TT3Kcqt0a3cXPOoON9XspoVjCXmzHTtCPe29L5T3pHwS67EjM4CkQlar86TmUdQgJ/10 uQ/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=VsrvUJTDGIzAP2JjnmZwyxN4uH2kwh446wxu6vSl6h0bxMYM71WEiiA5ee3MPwQjYM 3zto/HHkbnNABsOBTWuK8sSAEMbFTK6pWTChELRqxTe466+uzmC10K4cFDQZIREaswmb y+iujKS6nL2ALfWyahZXtHz/zFZU5HNmSU75KhPRC1efUGykvEVc9p6J+TJ21Z5fKnlX gxEcDbdwPKs1j1k6Ma+Bzv0mTSNCALIMkBktLb4QQnFZOTFSUSc3Sn+l3o9o574ZczMH ToU7UrgeLPatHCu7LU0jjouEXv9N4ZIO060fJ3ukDTP4/EvBHOMpA+tERbLjIxP8E7Ng 4JSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKWyS3hT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si2791018plc.346.2018.06.20.10.29.47; Wed, 20 Jun 2018 10:30:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UKWyS3hT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1754446AbeFTR1m (ORCPT + 99 others); Wed, 20 Jun 2018 13:27:42 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33747 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754501AbeFTRWw (ORCPT ); Wed, 20 Jun 2018 13:22:52 -0400 Received: by mail-lf0-f67.google.com with SMTP id y20-v6so500910lfy.0 for ; Wed, 20 Jun 2018 10:22:51 -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; bh=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=UKWyS3hTToKxrXbPMXXRta1HjAcVNo2/elOmaTz2VWM9HaXeuoPJUWIzqmC4xJmUT6 F8wFz06W1B92R+249KsTGoHBm3XzhB7povwc3EAj6QJn91acb1MKY89vzo4r02bw64rY umdxH5INr3n8kHjJT5+oq7XPYhk7Du3FT4qek= 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=w/YAA8BgJgXeuAB4Wu8EHA4s3RfgYKqr95WAIEacqUs=; b=q+i+mkDSrx7YAFw2+iGNdqwXM3h5AxchLh7gdqYzvXjbhc9nu+IaQsZEyAL6miw7r/ P3qXzQ7mIH34U695gPamkg1jza6I/AUYkXx/q6KELNjtq5nuL4r4bq9f/Ma01Vwu9WZn pI9yrsc9wbwmzjcWMDFccXOf44KUjXE1GfSfA62wRWNu6ksgDxAX6bNizzUfZlyHuQo6 3tWqA0IqSBK9jIGSy4TFB/vaaUd77Yi97mmo2lfcufiz1B1ROd7b6zJJ3qwUlzleDnH1 qe+kmRcRkhEXF3zBv7t/UqTkKEAfusK6oW0s6sjvk8ws0xXxTcz2hAOnG9vWyR3nnyfz r0yg== X-Gm-Message-State: APt69E0bmhN+IPyfuH4Ow/Fg5yep0Y8pj5d1qQn2eejJDIrpk3MJNg7T UCS5sgpQ/wG57N2exx1NtShJ1w== X-Received: by 2002:a2e:594d:: with SMTP id n74-v6mr15420669ljb.128.1529515371181; Wed, 20 Jun 2018 10:22:51 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id b2-v6sm514441lji.85.2018.06.20.10.22.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 10:22:50 -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 v8 09/26] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Wed, 20 Jun 2018 19:22:09 +0200 Message-Id: <20180620172226.15012-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180620172226.15012-1-ulf.hansson@linaro.org> References: <20180620172226.15012-1-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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(+) diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c index 67b02e138a47..492d4a83dca0 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); -- 2.17.1