···88#include <linux/pm_domain.h>99#include <linux/pm_qos.h>1010#include <linux/hrtimer.h>1111+#include <linux/cpu.h>1112#include <linux/cpuidle.h>1213#include <linux/cpumask.h>1314#include <linux/ktime.h>···350349 struct cpuidle_device *dev;351350 ktime_t domain_wakeup, next_hrtimer;352351 ktime_t now = ktime_get();352352+ struct device *cpu_dev;353353+ s64 cpu_constraint, global_constraint;353354 s64 idle_duration_ns;354355 int cpu, i;355356···362359 if (!(genpd->flags & GENPD_FLAG_CPU_DOMAIN))363360 return true;364361362362+ global_constraint = cpu_latency_qos_limit();365363 /*366364 * Find the next wakeup for any of the online CPUs within the PM domain367365 * and its subdomains. Note, we only need the genpd->cpus, as it already···376372 if (ktime_before(next_hrtimer, domain_wakeup))377373 domain_wakeup = next_hrtimer;378374 }375375+376376+ cpu_dev = get_cpu_device(cpu);377377+ if (cpu_dev) {378378+ cpu_constraint = dev_pm_qos_raw_resume_latency(cpu_dev);379379+ if (cpu_constraint < global_constraint)380380+ global_constraint = cpu_constraint;381381+ }379382 }380383384384+ global_constraint *= NSEC_PER_USEC;381385 /* The minimum idle duration is from now - until the next wakeup. */382386 idle_duration_ns = ktime_to_ns(ktime_sub(domain_wakeup, now));383387 if (idle_duration_ns <= 0)···401389 */402390 i = genpd->state_idx;403391 do {404404- if (idle_duration_ns >= (genpd->states[i].residency_ns +405405- genpd->states[i].power_off_latency_ns)) {392392+ if ((idle_duration_ns >= (genpd->states[i].residency_ns +393393+ genpd->states[i].power_off_latency_ns)) &&394394+ (global_constraint >= (genpd->states[i].power_on_latency_ns +395395+ genpd->states[i].power_off_latency_ns))) {406396 genpd->state_idx = i;407397 genpd->gd->last_enter = now;408398 genpd->gd->reflect_residency = true;