]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/cpuidle/cpuidle.c
Merge tag 'rproc-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson...
[linux.git] / drivers / cpuidle / cpuidle.c
index 0f4b7c45df3e103cba0a5a617b782cee522a44be..0895b988fa92246d655b35d3af6e11f237f243e3 100644 (file)
@@ -361,6 +361,36 @@ void cpuidle_reflect(struct cpuidle_device *dev, int index)
                cpuidle_curr_governor->reflect(dev, index);
 }
 
+/**
+ * cpuidle_poll_time - return amount of time to poll for,
+ * governors can override dev->poll_limit_ns if necessary
+ *
+ * @drv:   the cpuidle driver tied with the cpu
+ * @dev:   the cpuidle device
+ *
+ */
+u64 cpuidle_poll_time(struct cpuidle_driver *drv,
+                     struct cpuidle_device *dev)
+{
+       int i;
+       u64 limit_ns;
+
+       if (dev->poll_limit_ns)
+               return dev->poll_limit_ns;
+
+       limit_ns = TICK_NSEC;
+       for (i = 1; i < drv->state_count; i++) {
+               if (drv->states[i].disabled || dev->states_usage[i].disable)
+                       continue;
+
+               limit_ns = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
+       }
+
+       dev->poll_limit_ns = limit_ns;
+
+       return dev->poll_limit_ns;
+}
+
 /**
  * cpuidle_install_idle_handler - installs the cpuidle idle loop handler
  */