Lines Matching +full:cpu +full:- +full:release +full:- +full:addr

1 // SPDX-License-Identifier: GPL-2.0
3 * CPU subsystem support
10 #include <linux/cpu.h>
38 static void change_cpu_under_node(struct cpu *cpu, in change_cpu_under_node() argument
41 int cpuid = cpu->dev.id; in change_cpu_under_node()
44 cpu->node_id = to_nid; in change_cpu_under_node()
49 struct cpu *cpu = container_of(dev, struct cpu, dev); in cpu_subsys_online() local
50 int cpuid = dev->id; in cpu_subsys_online()
56 return -ENODEV; in cpu_subsys_online()
60 * When hot adding memory to memoryless node and enabling a cpu in cpu_subsys_online()
61 * on the node, node number of the cpu may internally change. in cpu_subsys_online()
65 change_cpu_under_node(cpu, from_nid, to_nid); in cpu_subsys_online()
75 void unregister_cpu(struct cpu *cpu) in unregister_cpu() argument
77 int logical_cpu = cpu->dev.id; in unregister_cpu()
81 device_unregister(&cpu->dev); in unregister_cpu()
124 static DEVICE_ATTR(release, S_IWUSR, NULL, cpu_release_store);
129 .name = "cpu",
130 .dev_name = "cpu",
146 struct cpu *cpu = container_of(dev, struct cpu, dev); in crash_notes_show() local
147 unsigned long long addr; in crash_notes_show() local
150 cpunum = cpu->dev.id; in crash_notes_show()
153 * Might be reading other cpu's data based on which cpu read thread in crash_notes_show()
154 * has been scheduled. But cpu data (memory) is allocated once during in crash_notes_show()
158 addr = per_cpu_ptr_to_phys(per_cpu_ptr(crash_notes, cpunum)); in crash_notes_show()
160 return sysfs_emit(buf, "%llx\n", addr); in crash_notes_show()
198 * Print cpu online, possible, present, and system maps
212 return cpumap_print_to_pagebuf(true, buf, ca->map); in show_cpus_attr()
231 return sysfs_emit(buf, "%d\n", NR_CPUS - 1); in print_cpus_kernel_max()
235 /* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
246 return -ENOMEM; in print_cpus_offline()
255 if (nr_cpu_ids == total_cpus-1) in print_cpus_offline()
258 len += sysfs_emit_at(buf, len, "%u-%d", in print_cpus_offline()
259 nr_cpu_ids, total_cpus - 1); in print_cpus_offline()
275 return -ENOMEM; in print_cpus_isolated()
304 * the only way to handle the issue of statically allocated cpu in cpu_device_release()
305 * devices. The different architectures will have their cpu device in cpu_device_release()
308 * by the cpu device. in cpu_device_release()
311 * on the linux-kernel list, you have been warned. in cpu_device_release()
324 "cpu:type:" CPU_FEATURE_TYPEFMT ":feature:", in print_cpu_modalias()
330 WARN(1, "CPU features overflow page\n"); in print_cpu_modalias()
352 * register_cpu - Setup a sysfs device for a CPU.
353 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
354 * sysfs for this CPU.
355 * @num - CPU number to use when creating the device.
357 * Initialize and register the CPU device.
359 int register_cpu(struct cpu *cpu, int num) in register_cpu() argument
363 cpu->node_id = cpu_to_node(num); in register_cpu()
364 memset(&cpu->dev, 0x00, sizeof(struct device)); in register_cpu()
365 cpu->dev.id = num; in register_cpu()
366 cpu->dev.bus = &cpu_subsys; in register_cpu()
367 cpu->dev.release = cpu_device_release; in register_cpu()
368 cpu->dev.offline_disabled = !cpu->hotpluggable; in register_cpu()
369 cpu->dev.offline = !cpu_online(num); in register_cpu()
370 cpu->dev.of_node = of_get_cpu_node(num, NULL); in register_cpu()
372 cpu->dev.bus->uevent = cpu_uevent; in register_cpu()
374 cpu->dev.groups = common_cpu_attr_groups; in register_cpu()
375 if (cpu->hotpluggable) in register_cpu()
376 cpu->dev.groups = hotplugable_cpu_attr_groups; in register_cpu()
377 error = device_register(&cpu->dev); in register_cpu()
379 put_device(&cpu->dev); in register_cpu()
383 per_cpu(cpu_sys_devices, num) = &cpu->dev; in register_cpu()
385 dev_pm_qos_expose_latency_limit(&cpu->dev, in register_cpu()
391 struct device *get_cpu_device(unsigned cpu) in get_cpu_device() argument
393 if (cpu < nr_cpu_ids && cpu_possible(cpu)) in get_cpu_device()
394 return per_cpu(cpu_sys_devices, cpu); in get_cpu_device()
412 int retval = -ENODEV; in __cpu_device_create()
416 retval = -ENOMEM; in __cpu_device_create()
421 dev->parent = parent; in __cpu_device_create()
422 dev->groups = groups; in __cpu_device_create()
423 dev->release = device_create_release; in __cpu_device_create()
427 retval = kobject_set_name_vargs(&dev->kobj, fmt, args); in __cpu_device_create()
489 bool cpu_is_hotpluggable(unsigned cpu) in cpu_is_hotpluggable() argument
491 struct device *dev = get_cpu_device(cpu); in cpu_is_hotpluggable()
492 return dev && container_of(dev, struct cpu, dev)->hotpluggable; in cpu_is_hotpluggable()
497 static DEFINE_PER_CPU(struct cpu, cpu_devices);
507 panic("Failed to register CPU device"); in cpu_dev_register_generic()
599 if (sysfs_create_group(&cpu_subsys.dev_root->kobj, in cpu_register_vulnerabilities()
601 pr_err("Unable to register CPU vulnerabilities\n"); in cpu_register_vulnerabilities()
611 panic("Failed to register CPU subsystem"); in cpu_dev_init()