aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-02-02 17:55:42 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-02-02 17:55:42 -0500
commitadcb2623f149abd4d4783ecada543a01e25d1c04 (patch)
treea89e14ec1a6e68ac8163224a720bb529ab9b0e1c
parent67f592c8f681061d69c621b97a868e679c8a77be (diff)
ACPI / cpuidle: Clean up fallback to C1 checks
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>
-rw-r--r--drivers/acpi/processor_idle.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index ceeff3d473f1..94c85ff2d123 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -758,6 +758,13 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
758 return 0; 758 return 0;
759} 759}
760 760
761static bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)
762{
763 return IS_ENABLED(CONFIG_HOTPLUG_CPU) && num_online_cpus() > 1 &&
764 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED) &&
765 !pr->flags.has_cst;
766}
767
761/** 768/**
762 * acpi_idle_enter_simple - enters an ACPI state without BM handling 769 * acpi_idle_enter_simple - enters an ACPI state without BM handling
763 * @dev: the target CPU 770 * @dev: the target CPU
@@ -775,12 +782,8 @@ static int acpi_idle_enter_simple(struct cpuidle_device *dev,
775 if (unlikely(!pr)) 782 if (unlikely(!pr))
776 return -EINVAL; 783 return -EINVAL;
777 784
778#ifdef CONFIG_HOTPLUG_CPU 785 if (acpi_idle_fallback_to_c1(pr))
779 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
780 !pr->flags.has_cst &&
781 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
782 return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START); 786 return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
783#endif
784 787
785 /* 788 /*
786 * Must be done before busmaster disable as we might need to 789 * Must be done before busmaster disable as we might need to
@@ -819,12 +822,8 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
819 if (unlikely(!pr)) 822 if (unlikely(!pr))
820 return -EINVAL; 823 return -EINVAL;
821 824
822#ifdef CONFIG_HOTPLUG_CPU 825 if (acpi_idle_fallback_to_c1(pr))
823 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
824 !pr->flags.has_cst &&
825 !(acpi_gbl_FADT.flags & ACPI_FADT_C2_MP_SUPPORTED))
826 return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START); 826 return acpi_idle_enter_c1(dev, drv, CPUIDLE_DRIVER_STATE_START);
827#endif
828 827
829 if (!cx->bm_sts_skip && acpi_idle_bm_check()) { 828 if (!cx->bm_sts_skip && acpi_idle_bm_check()) {
830 if (drv->safe_state_index >= 0) { 829 if (drv->safe_state_index >= 0) {