pm_qos.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #ifdef CONFIG_PM
  41. void pm_qos_add_request(struct pm_qos_request *req, int pm_qos_class,
  42. s32 value);
  43. void pm_qos_update_request(struct pm_qos_request *req,
  44. s32 new_value);
  45. void pm_qos_remove_request(struct pm_qos_request *req);
  46. int pm_qos_request(int pm_qos_class);
  47. int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier);
  48. int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier);
  49. int pm_qos_request_active(struct pm_qos_request *req);
  50. #else
  51. static inline void pm_qos_add_request(struct pm_qos_request *req,
  52. int pm_qos_class, s32 value)
  53. { return; }
  54. static inline void pm_qos_update_request(struct pm_qos_request *req,
  55. s32 new_value)
  56. { return; }
  57. static inline void pm_qos_remove_request(struct pm_qos_request *req)
  58. { return; }
  59. static inline int pm_qos_request(int pm_qos_class)
  60. { return 0; }
  61. static inline int pm_qos_add_notifier(int pm_qos_class,
  62. struct notifier_block *notifier)
  63. { return 0; }
  64. static inline int pm_qos_remove_notifier(int pm_qos_class,
  65. struct notifier_block *notifier)
  66. { return 0; }
  67. static inline int pm_qos_request_active(struct pm_qos_request *req)
  68. { return 0; }
  69. #endif
  70. #endif