From patchwork Wed Mar 14 16:58:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 131678 Delivered-To: patches@linaro.org Received: by 10.80.210.197 with SMTP id q5csp410436edg; Wed, 14 Mar 2018 09:59:18 -0700 (PDT) X-Received: by 2002:a19:57c1:: with SMTP id l184-v6mr3837349lfb.2.1521046758737; Wed, 14 Mar 2018 09:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521046758; cv=none; d=google.com; s=arc-20160816; b=LMn6Lvm3FGq26RxzjDQPGlJz1Va7XuT3urGkS99AFEMWtYVef5h/C6Y8wE+iI601v7 RsARuvy0GebT+6hQIGW+5VmADX8eYvJo7Y8wl8ceURFo5dSfG2TQAdwAYV6DM/pZ3tYb 79xWFp2udRPb1UhJ2W/wpE+zPgUNObU4dBRWt/+WPWtc8FY2eBlque3JxwsxpFuIAYXB 8d2DrkflTFnFAOAGjVP5BKFkptR7Zkrntq35ZZ5aFQTf+vDnahlozpYI6m2yaDH0aIVK cDaZNqCh6J4VljvYPnLkQ+jj4XRvRbAFEu+N0YMFbIK8t1MNJlvCRBguuLwuImDNs5P9 HDpw== 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=JW7egLf3y2HcSk/A1UhronrOVsVD2i1fr+JMe/QaNq8=; b=mF2XH/lHH8vCDxBCDouDzhqecuJCwRvdtEIOdjMeWEuG2X6kcmV5+sLMUKDVU5e6n2 Ge45IDgdQ4BPIy0jCGTA2baYraMlRfhfYDtT3KRFJQwzbZ6M//ZL0EWhGFrS7D4BIXue eX4zmgvRddT63EmWCtmRLvyEwtZhYlUHURXSSoJOLtXtOKMaL3iAe5//lHYQLudVi+dC BRhn5mI4seGDJW+9pMjGy6d6a+5aDvWtBW7rU06xmqSH4gwa34cNfejouL+WgjHgFoqd eMuftaDj1IArifxF+nTCk5BXVbYSziT+AVcCpt5oKzVGYwJpuYUmNeIL6WhX4bUDvGMt DIiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPIor21g; 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 b86-v6sor890369lfl.4.2018.03.14.09.59.18 for (Google Transport Security); Wed, 14 Mar 2018 09:59:18 -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=WPIor21g; 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=JW7egLf3y2HcSk/A1UhronrOVsVD2i1fr+JMe/QaNq8=; b=WPIor21g1FbZWjThDqR4x4IYnjw7Tf2CotV6jsMalrryNJewfS2rMqlnaLqJyESmwW M0N4anTr2EtsQSYgBKEAxIatt4w6wZkEKbS54S8DfWcJ7BlzGDZSwqdjWCgdg6PL5/c5 GYVf3XCvL/x1+WSH2RtUdV3oA3r5tzXmv3SrE= 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=JW7egLf3y2HcSk/A1UhronrOVsVD2i1fr+JMe/QaNq8=; b=CXB55f0lbHPpvxP7Gm81ekMGGTWSEZL3yceRhVoQG4vy1TNo6XOarkZwlWCz0c9k3q WJu5qI0xDgf8Ulht7SYFx0IM++293XE6d0vREmPiXES2XJvKWlZIVe6WtKUs2EQvvq/4 kKVQ9T6kPY9Ss50rCMc1Fvry50708HyED4lMLqOLQwcVCxrjywg3eZT//YSQ86p5T2AW EHPY+X72Ic26oWeNbOUZr8BO+7EIdlCpvRxNRI2lI2i5+XNADdH1070ryZzTbU5i7tfK S8uNR+hfV4Wk9s+OtNyaROkyu9izpcDrgoYIJ4tj6Kr/PHmpqFliyqSacIIa+h6CrtIy XVug== X-Gm-Message-State: AElRT7EaGkFvtIcspLRxmClxc4JR0rpV9DMWTLdHz3aBn5Wiyl7n6K16 70uf6wq4RM+lPLg6Nb52aElyJuCS X-Google-Smtp-Source: AG47ELvHaaFCQFX++JU99VZySuZCgsiDWNbqHWg72ELY9+wH/mnR8n7FKfxSv8PphX6a4l1vWZIFDQ== X-Received: by 2002:a19:dd89:: with SMTP id w9-v6mr4127272lfi.82.1521046758436; Wed, 14 Mar 2018 09:59:18 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:17 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , 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 v6 09/25] kernel/cpu_pm: Manage runtime PM in the idle path for CPUs Date: Wed, 14 Mar 2018 17:58:19 +0100 Message-Id: <1521046715-30683-10-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-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..71317ff 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) + 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) + pm_runtime_get_sync(dev); + return cpu_pm_notify(CPU_PM_EXIT, -1, NULL); } EXPORT_SYMBOL_GPL(cpu_pm_exit);