From patchwork Wed Aug 23 21:22:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9918411 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F09D7603FF for ; Wed, 23 Aug 2017 21:31:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2BE528A77 for ; Wed, 23 Aug 2017 21:31:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D739828A85; Wed, 23 Aug 2017 21:31:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47B8028A77 for ; Wed, 23 Aug 2017 21:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751003AbdHWVb3 (ORCPT ); Wed, 23 Aug 2017 17:31:29 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:50548 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750715AbdHWVb2 (ORCPT ); Wed, 23 Aug 2017 17:31:28 -0400 Received: from 79.184.253.199.ipv4.supernova.orange.pl (79.184.253.199) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.82) id 4d66ce90bb03ccfc; Wed, 23 Aug 2017 23:31:27 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Len Brown , Linux ACPI , Peter Zijlstra , Jacob Pan , Daniel Lezcano , Sudeep Holla Subject: [PATCH 3/3] cpuidle: Make drivers initialize polling state Date: Wed, 23 Aug 2017 23:22:20 +0200 Message-ID: <3097942.7PMynB0Xpq@aspire.rjw.lan> In-Reply-To: <21794463.WNaOdcSnfv@aspire.rjw.lan> References: <21794463.WNaOdcSnfv@aspire.rjw.lan> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki Make the drivers that want to include the polling state into their states table initialize it explicitly and drop the initialization of it (which in fact is conditional, but that is not obvious from the code) from the core. Signed-off-by: Rafael J. Wysocki --- drivers/acpi/processor_idle.c | 9 ++++++++- drivers/cpuidle/driver.c | 2 -- drivers/cpuidle/poll_state.c | 3 ++- drivers/idle/intel_idle.c | 1 + include/linux/cpuidle.h | 4 +--- 5 files changed, 12 insertions(+), 7 deletions(-) Index: linux-pm/drivers/acpi/processor_idle.c =================================================================== --- linux-pm.orig/drivers/acpi/processor_idle.c +++ linux-pm/drivers/acpi/processor_idle.c @@ -842,7 +842,7 @@ static int acpi_processor_setup_cpuidle_ static int acpi_processor_setup_cstates(struct acpi_processor *pr) { - int i, count = ACPI_IDLE_STATE_START; + int i, count; struct acpi_processor_cx *cx; struct cpuidle_state *state; struct cpuidle_driver *drv = &acpi_idle_driver; @@ -850,6 +850,13 @@ static int acpi_processor_setup_cstates( if (max_cstate == 0) max_cstate = 1; + if (IS_ENABLED(CONFIG_ARCH_HAS_CPU_RELAX)) { + cpuidle_poll_state_init(drv); + count = 1; + } else { + count = 0; + } + for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { cx = &pr->power.states[i]; Index: linux-pm/drivers/cpuidle/driver.c =================================================================== --- linux-pm.orig/drivers/cpuidle/driver.c +++ linux-pm/drivers/cpuidle/driver.c @@ -216,8 +216,6 @@ static int __cpuidle_register_driver(str on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer, (void *)1, 1); - poll_idle_init(drv); - return 0; } Index: linux-pm/drivers/cpuidle/poll_state.c =================================================================== --- linux-pm.orig/drivers/cpuidle/poll_state.c +++ linux-pm/drivers/cpuidle/poll_state.c @@ -21,7 +21,7 @@ static int __cpuidle poll_idle(struct cp return index; } -void poll_idle_init(struct cpuidle_driver *drv) +void cpuidle_poll_state_init(struct cpuidle_driver *drv) { struct cpuidle_state *state = &drv->states[0]; @@ -34,3 +34,4 @@ void poll_idle_init(struct cpuidle_drive state->disabled = false; state->flags = CPUIDLE_FLAG_POLLING; } +EXPORT_SYMBOL_GPL(cpuidle_poll_state_init); Index: linux-pm/include/linux/cpuidle.h =================================================================== --- linux-pm.orig/include/linux/cpuidle.h +++ linux-pm/include/linux/cpuidle.h @@ -226,9 +226,7 @@ static inline void cpuidle_coupled_paral #endif #ifdef CONFIG_ARCH_HAS_CPU_RELAX -void poll_idle_init(struct cpuidle_driver *drv); -#else -static void poll_idle_init(struct cpuidle_driver *drv) {} +void cpuidle_poll_state_init(struct cpuidle_driver *drv); #endif /****************************** Index: linux-pm/drivers/idle/intel_idle.c =================================================================== --- linux-pm.orig/drivers/idle/intel_idle.c +++ linux-pm/drivers/idle/intel_idle.c @@ -1331,6 +1331,7 @@ static void __init intel_idle_cpuidle_dr intel_idle_state_table_update(); + cpuidle_poll_state_init(drv); drv->state_count = 1; for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {