pm_qos.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _LINUX_PM_QOS_H
  2. #define _LINUX_PM_QOS_H
  3. /* interface for the pm_qos_power infrastructure of the linux kernel.
  4. *
  5. * Mark Gross <mgross@linux.intel.com>
  6. */
  7. #include <linux/plist.h>
  8. #include <linux/notifier.h>
  9. #include <linux/miscdevice.h>
  10. #define PM_QOS_RESERVED 0
  11. #define PM_QOS_CPU_DMA_LATENCY 1
  12. #define PM_QOS_NETWORK_LATENCY 2
  13. #define PM_QOS_NETWORK_THROUGHPUT 3
  14. #define PM_QOS_NUM_CLASSES 4
  15. #define PM_QOS_DEFAULT_VALUE -1
  16. #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
  17. #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC)
  18. #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0
  19. struct pm_qos_request {
  20. struct plist_node node;
  21. int pm_qos_class;
  22. };
  23. enum pm_qos_type {
  24. PM_QOS_UNITIALIZED,
  25. PM_QOS_MAX, /* return the largest value */
  26. PM_QOS_MIN /* return the smallest value */
  27. };
  28. /*
  29. * Note: The lockless read path depends on the CPU accessing
  30. * target_value atomically. Atomic access is only guaranteed on all CPU
  31. * types linux supports for 32 bit quantites
  32. */
  33. struct pm_qos_constraints {
  34. struct plist_head list;
  35. s32 target_value; /* Do not change to 64 bit */
  36. s32 default_value;
  37. enum pm_qos_type type;
  38. struct blocking_notifier_head *notifiers;
  39. };
  40. /* Action requested to pm_qos_update_target */
  41. enum pm_qos_req_action {
  42. PM_QOS_ADD_REQ, /* Add a new request */
  43. PM_QOS_UPDATE_REQ, /* Update an existing request */
  44. PM_QOS_REMOVE_REQ /* Remove an existing request */
  45. };
  46. #ifdef CONFIG_PM
  47. int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
  48. enum pm_qos_req_action action, int value);
  49. void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
  50. s32 value);
  51. void pm_qos_update_request(struct pm_qos_request *req,
  52. s32 new_value);
  53. void pm_qos_remove_request(struct pm_qos_request *req);
  54. int pm_qos_request(int pm_qos_class);
  55. int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
  56. int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
  57. int pm_qos_request_active(struct pm_qos_request *req);
  58. #else
  59. static inline int pm_qos_update_target(struct pm_qos_constraints *c,
  60. struct plist_node *node,
  61. enum pm_qos_req_action action,
  62. int value)
  63. { return 0; }
  64. static inline void pm_qos_add_request(struct pm_qos_request *req,
  65. int pm_qos_class, s32 value)
  66. { return; }
  67. static inline void pm_qos_update_request(struct pm_qos_request *req,
  68. s32 new_value)
  69. { return; }
  70. static inline void pm_qos_remove_request(struct pm_qos_request *req)
  71. { return; }
  72. static inline int pm_qos_request(int pm_qos_class)
  73. { return 0; }
  74. static inline int pm_qos_add_notifier(int pm_qos_class,
  75. struct notifier_block *notifier)
  76. { return 0; }
  77. static inline int pm_qos_remove_notifier(int pm_qos_class,
  78. struct notifier_block *notifier)
  79. { return 0; }
  80. static inline int pm_qos_request_active(struct pm_qos_request *req)
  81. { return 0; }
  82. #endif
  83. #endif