All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM list <linux-pm@vger.kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Len Brown <len.brown@intel.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 2/5] ACPI / cpuidle: Clean up fallback to C1 checks
Date: Thu, 29 Jan 2015 19:27:50 +0100	[thread overview]
Message-ID: <3686267.GOVk0HSzaS@vostro.rjw.lan> (raw)
In-Reply-To: <8966777.6Ih8y2AWPy@vostro.rjw.lan>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

acpi_idle_enter_simple() and acpi_idle_enter_bm() both check
if C2/C3 type entry is supported on MP in the same way, so move
those checks to a separate function and call it from both
places (and it doesn't need to check if the state type is not
C1, because the functions in question won't be called otherwise).

While at it, use IS_ENABLED() for the CONFIG_HOTPLUG_CPU check.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/processor_idle.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Index: linux-pm/drivers/acpi/processor_idle.c
===================================================================
--- linux-pm.orig/drivers/acpi/processor_idle.c
+++ linux-pm/drivers/acpi/processor_idle.c
@@ -758,6 +758,13 @@ static int acpi_idle_play_dead(struct cp
 	return 0;
 }
 
+static bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)
+{
+	return IS_ENABLED(CONFIG_HOTPLUG_CPU) && num_online_cpus() > 1 &&
+		!(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED) &&
+		!pr->flags.has_cst;
+}
+
 /**
  * acpi_idle_enter_simple - enters an ACPI state without BM handling
  * @dev: the target CPU
@@ -775,12 +782,8 @@ static int acpi_idle_enter_simple(struct
 	if (unlikely(!pr))
 		return -EINVAL;
 
-#ifdef CONFIG_HOTPLUG_CPU
-	if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
-	    !pr->flags.has_cst &&
-	    !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
+	if (acpi_idle_fallback_to_c1(pr))
 		return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
-#endif
 
 	/*
 	 * Must be done before busmaster disable as we might need to
@@ -819,12 +822,8 @@ static int acpi_idle_enter_bm(struct cpu
 	if (unlikely(!pr))
 		return -EINVAL;
 
-#ifdef CONFIG_HOTPLUG_CPU
-	if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
-	    !pr->flags.has_cst &&
-	    !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
+	if (acpi_idle_fallback_to_c1(pr))
 		return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
-#endif
 
 	if (!cx->bm_sts_skip && acpi_idle_bm_check()) {
 		if (drv->safe_state_index >= 0) {

  parent reply	other threads:[~2015-01-29 18:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 18:22 [PATCH 0/5] ACPI / cpuidle: More driver cleanups Rafael J. Wysocki
2015-01-29 18:26 ` [PATCH 1/5] ACPI / cpuidle: Drop unnecessary calls from ->enter callback routines Rafael J. Wysocki
2015-01-29 18:27 ` Rafael J. Wysocki [this message]
2015-01-29 18:28 ` [PATCH 3/5] ACPI / cpuidle: Drop irrelevant comment from acpi_idle_enter_simple() Rafael J. Wysocki
2015-01-29 18:29 ` [PATCH 4/5] ACPI / cpuidle: Clean up white space in a switch statement Rafael J. Wysocki
2015-01-29 18:30 ` [PATCH 5/5] ACPI / cpuidle: Drop flags.bm_check tests from acpi_idle_enter_bm() Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3686267.GOVk0HSzaS@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.