arch_topology.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * include/linux/arch_topology.h - arch specific cpu topology information
  4. */
  5. #ifndef _LINUX_ARCH_TOPOLOGY_H_
  6. #define _LINUX_ARCH_TOPOLOGY_H_
  7. #include <linux/types.h>
  8. #include <linux/percpu.h>
  9. #include <linux/android_vendor.h>
  10. void topology_normalize_cpu_scale(void);
  11. int topology_update_cpu_topology(void);
  12. #ifdef CONFIG_ACPI_CPPC_LIB
  13. void topology_init_cpu_capacity_cppc(void);
  14. #endif
  15. struct device_node;
  16. bool topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu);
  17. DECLARE_PER_CPU(unsigned long, cpu_scale);
  18. static inline unsigned long topology_get_cpu_scale(int cpu)
  19. {
  20. return per_cpu(cpu_scale, cpu);
  21. }
  22. void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
  23. DECLARE_PER_CPU(unsigned long, arch_freq_scale);
  24. static inline unsigned long topology_get_freq_scale(int cpu)
  25. {
  26. return per_cpu(arch_freq_scale, cpu);
  27. }
  28. void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq,
  29. unsigned long max_freq);
  30. bool topology_scale_freq_invariant(void);
  31. enum scale_freq_source {
  32. SCALE_FREQ_SOURCE_CPUFREQ = 0,
  33. SCALE_FREQ_SOURCE_ARCH,
  34. SCALE_FREQ_SOURCE_CPPC,
  35. };
  36. struct scale_freq_data {
  37. enum scale_freq_source source;
  38. void (*set_freq_scale)(void);
  39. };
  40. void topology_scale_freq_tick(void);
  41. void topology_set_scale_freq_source(struct scale_freq_data *data, const struct cpumask *cpus);
  42. void topology_clear_scale_freq_source(enum scale_freq_source source, const struct cpumask *cpus);
  43. DECLARE_PER_CPU(unsigned long, thermal_pressure);
  44. static inline unsigned long topology_get_thermal_pressure(int cpu)
  45. {
  46. return per_cpu(thermal_pressure, cpu);
  47. }
  48. void topology_update_thermal_pressure(const struct cpumask *cpus,
  49. unsigned long capped_freq);
  50. struct cpu_topology {
  51. int thread_id;
  52. int core_id;
  53. int cluster_id;
  54. int package_id;
  55. cpumask_t thread_sibling;
  56. cpumask_t core_sibling;
  57. cpumask_t cluster_sibling;
  58. cpumask_t llc_sibling;
  59. ANDROID_VENDOR_DATA_ARRAY(1, 1);
  60. };
  61. #ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
  62. extern struct cpu_topology cpu_topology[NR_CPUS];
  63. #define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id)
  64. #define topology_cluster_id(cpu) (cpu_topology[cpu].cluster_id)
  65. #define topology_core_id(cpu) (cpu_topology[cpu].core_id)
  66. #define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling)
  67. #define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling)
  68. #define topology_cluster_cpumask(cpu) (&cpu_topology[cpu].cluster_sibling)
  69. #define topology_llc_cpumask(cpu) (&cpu_topology[cpu].llc_sibling)
  70. void init_cpu_topology(void);
  71. void store_cpu_topology(unsigned int cpuid);
  72. const struct cpumask *cpu_coregroup_mask(int cpu);
  73. const struct cpumask *cpu_clustergroup_mask(int cpu);
  74. void update_siblings_masks(unsigned int cpu);
  75. void remove_cpu_topology(unsigned int cpuid);
  76. void reset_cpu_topology(void);
  77. int parse_acpi_topology(void);
  78. #endif
  79. extern bool topology_update_done;
  80. #endif /* _LINUX_ARCH_TOPOLOGY_H_ */