Lines Matching +full:cpu +full:- +full:ns
1 // SPDX-License-Identifier: GPL-2.0-only
3 #include <linux/cpu.h>
33 static DEFINE_PER_CPU(struct cpu, cpu_devices);
39 * smt-snooze-delay cleanup.") and has been broken even longer. As was foretold in
45 * powerpc-utils stopped using it as of 1.3.8. At some point in the future this
55 current->comm, current->pid); in store_smt_snooze_delay()
64 current->comm, current->pid); in show_smt_snooze_delay()
76 pr_warn("smt-snooze-delay command line option has no effect\n"); in setup_smt_snooze_delay()
79 __setup("smt-snooze-delay=", setup_smt_snooze_delay);
99 struct cpu *cpu = container_of(dev, struct cpu, dev); \
101 smp_call_function_single(cpu->dev.id, read_##NAME, &val, 1); \
108 struct cpu *cpu = container_of(dev, struct cpu, dev); \
112 return -EINVAL; \
113 smp_call_function_single(cpu->dev.id, write_##NAME, &val, 1); \
132 * will update all per cpu DSCR default values across the
138 * read_dscr() - Fetch the cpu specific DSCR default
139 * @val: Returned cpu specific DSCR default value
141 * This function returns the per cpu DSCR default value
142 * for any cpu which is contained in its PACA structure.
146 *(unsigned long *)val = get_paca()->dscr_default; in read_dscr()
151 * write_dscr() - Update the cpu specific DSCR default
152 * @val: New cpu specific DSCR default value to update
154 * This function updates the per cpu DSCR default value
155 * for any cpu which is contained in its PACA structure.
159 get_paca()->dscr_default = *(unsigned long *)val; in write_dscr()
160 if (!current->thread.dscr_inherit) { in write_dscr()
161 current->thread.dscr = *(unsigned long *)val; in write_dscr()
171 attr->attr.mode |= 0200; in add_write_permission_dev_attr()
175 * show_dscr_default() - Fetch the system wide DSCR default
189 * store_dscr_default() - Update the system wide DSCR default
206 return -EINVAL; in store_dscr_default()
221 int cpu; in sysfs_create_dscr_default() local
224 for_each_possible_cpu(cpu) in sysfs_create_dscr_default()
225 paca_ptrs[cpu]->dscr_default = dscr_default; in sysfs_create_dscr_default()
242 static unsigned int get_idle_ticks_bit(u64 ns) in get_idle_ticks_bit() argument
246 if (ns >= 10000) in get_idle_ticks_bit()
247 cycle = div_u64(ns + 500, 1000) * tb_ticks_per_usec; in get_idle_ticks_bit()
249 cycle = div_u64(ns * tb_ticks_per_usec, 1000); in get_idle_ticks_bit()
268 unsigned int cpu = dev->id; in show_pw20_state() local
270 smp_call_function_single(cpu, do_show_pwrmgtcr0, &value, 1); in show_pw20_state()
297 unsigned int cpu = dev->id; in store_pw20_state() local
300 return -EINVAL; in store_pw20_state()
303 return -EINVAL; in store_pw20_state()
305 smp_call_function_single(cpu, do_store_pw20_state, &value, 1); in store_pw20_state()
317 unsigned int cpu = dev->id; in show_pw20_wait_time() local
320 smp_call_function_single(cpu, do_show_pwrmgtcr0, &value, 1); in show_pw20_wait_time()
324 tb_cycle = (tb_cycle << (MAX_BIT - value + 1)); in show_pw20_wait_time()
325 /* convert ms to ns */ in show_pw20_wait_time()
354 pw20_idle |= ((MAX_BIT - *value) << PWRMGTCR0_PW20_ENT_SHIFT); in set_pw20_wait_entry_bit()
366 unsigned int cpu = dev->id; in store_pw20_wait_time() local
369 return -EINVAL; in store_pw20_wait_time()
372 return -EINVAL; in store_pw20_wait_time()
376 return -EINVAL; in store_pw20_wait_time()
380 smp_call_function_single(cpu, set_pw20_wait_entry_bit, in store_pw20_wait_time()
390 unsigned int cpu = dev->id; in show_altivec_idle() local
392 smp_call_function_single(cpu, do_show_pwrmgtcr0, &value, 1); in show_altivec_idle()
419 unsigned int cpu = dev->id; in store_altivec_idle() local
422 return -EINVAL; in store_altivec_idle()
425 return -EINVAL; in store_altivec_idle()
427 smp_call_function_single(cpu, do_store_altivec_idle, &value, 1); in store_altivec_idle()
439 unsigned int cpu = dev->id; in show_altivec_idle_wait_time() local
442 smp_call_function_single(cpu, do_show_pwrmgtcr0, &value, 1); in show_altivec_idle_wait_time()
446 tb_cycle = (tb_cycle << (MAX_BIT - value + 1)); in show_altivec_idle_wait_time()
447 /* convert ms to ns */ in show_altivec_idle_wait_time()
476 altivec_idle |= ((MAX_BIT - *value) << PWRMGTCR0_AV_IDLE_CNT_SHIFT); in set_altivec_idle_wait_entry_bit()
488 unsigned int cpu = dev->id; in store_altivec_idle_wait_time() local
491 return -EINVAL; in store_altivec_idle_wait_time()
494 return -EINVAL; in store_altivec_idle_wait_time()
498 return -EINVAL; in store_altivec_idle_wait_time()
502 smp_call_function_single(cpu, set_altivec_idle_wait_entry_bit, in store_altivec_idle_wait_time()
518 * 1~48(ns): TB[63]
519 * 49~97(ns): TB[62]
520 * 98~195(ns): TB[61]
521 * 196~390(ns): TB[60]
522 * 391~780(ns): TB[59]
523 * 781~1560(ns): TB[58]
778 struct cpu *cpu = container_of(dev, struct cpu, dev); in idle_purr_show() local
781 smp_call_function_single(cpu->dev.id, read_idle_purr, &val, 1); in idle_purr_show()
808 struct cpu *cpu = container_of(dev, struct cpu, dev); in idle_spurr_show() local
811 smp_call_function_single(cpu->dev.id, read_idle_spurr, &val, 1); in idle_spurr_show()
835 static int register_cpu_online(unsigned int cpu) in register_cpu_online() argument
837 struct cpu *c = &per_cpu(cpu_devices, cpu); in register_cpu_online()
838 struct device *s = &c->dev; in register_cpu_online()
843 if (!s->of_node) in register_cpu_online()
844 s->of_node = of_get_cpu_node(cpu, NULL); in register_cpu_online()
852 switch (cur_cpu_spec->pmc_type) { in register_cpu_online()
885 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) in register_cpu_online()
921 if (PVR_VER(cur_cpu_spec->pvr_value) == PVR_VER_E6500) { in register_cpu_online()
929 cacheinfo_cpu_online(cpu); in register_cpu_online()
934 static int unregister_cpu_online(unsigned int cpu) in unregister_cpu_online() argument
936 struct cpu *c = &per_cpu(cpu_devices, cpu); in unregister_cpu_online()
937 struct device *s = &c->dev; in unregister_cpu_online()
941 if (WARN_RATELIMIT(!c->hotpluggable, "cpu %d can't be offlined\n", cpu)) in unregister_cpu_online()
942 return -EBUSY; in unregister_cpu_online()
950 switch (cur_cpu_spec->pmc_type) { in unregister_cpu_online()
983 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) in unregister_cpu_online()
1017 if (PVR_VER(cur_cpu_spec->pvr_value) == PVR_VER_E6500) { in unregister_cpu_online()
1025 cacheinfo_cpu_offline(cpu); in unregister_cpu_online()
1026 of_node_put(s->of_node); in unregister_cpu_online()
1027 s->of_node = NULL; in unregister_cpu_online()
1040 return -EINVAL; in arch_cpu_probe()
1048 return -EINVAL; in arch_cpu_release()
1056 int cpu; in cpu_add_dev_attr() local
1060 for_each_possible_cpu(cpu) { in cpu_add_dev_attr()
1061 device_create_file(get_cpu_device(cpu), attr); in cpu_add_dev_attr()
1071 int cpu; in cpu_add_dev_attr_group() local
1077 for_each_possible_cpu(cpu) { in cpu_add_dev_attr_group()
1078 dev = get_cpu_device(cpu); in cpu_add_dev_attr_group()
1079 ret = sysfs_create_group(&dev->kobj, attrs); in cpu_add_dev_attr_group()
1091 int cpu; in cpu_remove_dev_attr() local
1095 for_each_possible_cpu(cpu) { in cpu_remove_dev_attr()
1096 device_remove_file(get_cpu_device(cpu), attr); in cpu_remove_dev_attr()
1105 int cpu; in cpu_remove_dev_attr_group() local
1110 for_each_possible_cpu(cpu) { in cpu_remove_dev_attr_group()
1111 dev = get_cpu_device(cpu); in cpu_remove_dev_attr_group()
1112 sysfs_remove_group(&dev->kobj, attrs); in cpu_remove_dev_attr_group()
1126 return sysfs_create_link(&node->dev.kobj, &dev->kobj, in sysfs_add_device_to_node()
1127 kobject_name(&dev->kobj)); in sysfs_add_device_to_node()
1134 sysfs_remove_link(&node->dev.kobj, kobject_name(&dev->kobj)); in sysfs_remove_device_from_node()
1139 /* Only valid if CPU is present. */
1143 struct cpu *cpu = container_of(dev, struct cpu, dev); in show_physical_id() local
1145 return sprintf(buf, "%d\n", get_hard_smp_processor_id(cpu->dev.id)); in show_physical_id()
1151 int cpu, r; in topology_init() local
1153 for_each_possible_cpu(cpu) { in topology_init()
1154 struct cpu *c = &per_cpu(cpu_devices, cpu); in topology_init()
1159 * the RTAS calls for CPU hotplug. But, there may be a in topology_init()
1161 * CPU. For instance, the boot cpu might never be valid in topology_init()
1164 if (smp_ops && smp_ops->cpu_offline_self) in topology_init()
1165 c->hotpluggable = 1; in topology_init()
1168 if (cpu_online(cpu) || c->hotpluggable) { in topology_init()
1169 register_cpu(c, cpu); in topology_init()
1171 device_create_file(&c->dev, &dev_attr_physical_id); in topology_init()