arch_topology.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. struct device_node;
  13. bool topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu);
  14. DECLARE_PER_CPU(unsigned long, cpu_scale);
  15. static inline unsigned long topology_get_cpu_scale(int cpu)
  16. {
  17. return per_cpu(cpu_scale, cpu);
  18. }
  19. void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
  20. DECLARE_PER_CPU(unsigned long, freq_scale);
  21. static inline unsigned long topology_get_freq_scale(int cpu)
  22. {
  23. return per_cpu(freq_scale, cpu);
  24. }
  25. void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq,
  26. unsigned long max_freq);
  27. bool topology_scale_freq_invariant(void);
  28. bool arch_freq_counters_available(const struct cpumask *cpus);
  29. DECLARE_PER_CPU(unsigned long, thermal_pressure);
  30. static inline unsigned long topology_get_thermal_pressure(int cpu)
  31. {
  32. return per_cpu(thermal_pressure, cpu);
  33. }
  34. void topology_set_thermal_pressure(const struct cpumask *cpus,
  35. unsigned long th_pressure);
  36. struct cpu_topology {
  37. int thread_id;
  38. int core_id;
  39. int package_id;
  40. int llc_id;
  41. cpumask_t thread_sibling;
  42. cpumask_t core_sibling;
  43. cpumask_t llc_sibling;
  44. cpumask_t android_vendor_data1;
  45. };
  46. #ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
  47. extern struct cpu_topology cpu_topology[NR_CPUS];
  48. #define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id)
  49. #define topology_core_id(cpu) (cpu_topology[cpu].core_id)
  50. #define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling)
  51. #define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling)
  52. #define topology_llc_cpumask(cpu) (&cpu_topology[cpu].llc_sibling)
  53. void init_cpu_topology(void);
  54. void store_cpu_topology(unsigned int cpuid);
  55. const struct cpumask *cpu_coregroup_mask(int cpu);
  56. void update_siblings_masks(unsigned int cpu);
  57. void remove_cpu_topology(unsigned int cpuid);
  58. void reset_cpu_topology(void);
  59. int parse_acpi_topology(void);
  60. #endif
  61. extern bool topology_update_done;
  62. #endif /* _LINUX_ARCH_TOPOLOGY_H_ */