History

Merge tag 'driver-core-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH: "Here are the set of driver core and kernfs changes for 6.8-rc1. Nothing major in here this release cycle, just lots of small cleanups and some tweaks on kernfs that in the very end, got reverted and will come back in a safer way next release cycle. Included in here are: - more driver core 'const' cleanups and fixes - fw_devlink=rpm is now the default behavior - kernfs tiny changes to remove some string functions - cpu handling in the driver core is updated to work better on many systems that add topologies and cpus after booting - other minor changes and cleanups All of the cpu handling patches have been acked by the respective maintainers and are coming in here in one series. Everything has been in linux-next for a while with no reported issues" * tag 'driver-core-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (51 commits) Revert "kernfs: convert kernfs_idr_lock to an irq safe raw spinlock" kernfs: convert kernfs_idr_lock to an irq safe raw spinlock class: fix use-after-free in class_register() PM: clk: make pm_clk_add_notifier() take a const pointer EDAC: constantify the struct bus_type usage kernfs: fix reference to renamed function driver core: device.h: fix Excess kernel-doc description warning driver core: class: fix Excess kernel-doc description warning driver core: mark remaining local bus_type variables as const driver core: container: make container_subsys const driver core: bus: constantify subsys_register() calls driver core: bus: make bus_sort_breadthfirst() take a const pointer kernfs: d_obtain_alias(NULL) will do the right thing... driver core: Better advertise dev_err_probe() kernfs: Convert kernfs_path_from_node_locked() from strlcpy() to strscpy() kernfs: Convert kernfs_name_locked() from strlcpy() to strscpy() kernfs: Convert kernfs_walk_ns() from strlcpy() to strscpy() initramfs: Expose retained initrd as sysfs file fs/kernfs/dir: obey S_ISGID kernel/cgroup: use kernfs_create_dir_ns() ...

Linus Torvalds committed 2 years ago

Commit 80955ae2 parents 296455a e3977e051 files · +207 −253Browse files

Unified · Split

51 files
  1. Documentation/ABI/testing/sysfs-firmware-initrd +8 −0
  2. Documentation/admin-guide/kernel-parameters.txt +3 −2
  3. arch/arm64/Kconfig +1 −0
  4. arch/arm64/include/asm/cpu.h +0 −1
  5. arch/arm64/kernel/setup.c +2 −11
  6. arch/loongarch/Kconfig +2 −0
  7. arch/loongarch/kernel/topology.c +2 −40
  8. arch/riscv/Kconfig +1 −0
  9. arch/riscv/kernel/setup.c +2 −16
  10. arch/x86/Kconfig +2 −0
  11. arch/x86/include/asm/cpu.h +0 −4
  12. arch/x86/kernel/topology.c +2 −31
  13. drivers/acpi/Kconfig +0 −1
  14. drivers/acpi/acpi_processor.c +0 −18
  15. drivers/acpi/property.c +4 −0
  16. drivers/base/arch_topology.c +26 −12
  17. drivers/base/auxiliary.c +1 −1
  18. drivers/base/bus.c +4 −4
  19. drivers/base/class.c +1 −0
  20. drivers/base/container.c +1 −1
  21. drivers/base/core.c +7 −6
  22. drivers/base/cpu.c +31 −8
  23. drivers/base/dd.c +1 −1
  24. drivers/base/init.c +1 −1
  25. drivers/base/isa.c +1 −1
  26. drivers/base/memory.c +1 −1
  27. drivers/base/node.c +7 −4
  28. drivers/base/power/clock_ops.c +1 −1
  29. drivers/base/property.c +1 −0
  30. drivers/base/soc.c +3 −3
  31. drivers/base/swnode.c +7 −4
  32. drivers/edac/edac_device.h +1 −1
  33. drivers/edac/edac_device_sysfs.c +1 −1
  34. drivers/edac/edac_module.c +2 −2
  35. drivers/edac/edac_pci_sysfs.c +1 −1
  36. drivers/pmdomain/core.c +1 −1
  37. fs/kernfs/dir.c +37 −25
  38. fs/kernfs/file.c +1 −1
  39. fs/kernfs/mount.c +0 −3
  40. fs/sysfs/dir.c +1 −1
  41. include/linux/container.h +1 −1
  42. include/linux/cpu.h +5 −0
  43. include/linux/device.h +3 −5
  44. include/linux/device/bus.h +1 −1
  45. include/linux/device/class.h +0 −2
  46. include/linux/edac.h +2 −2
  47. include/linux/pm_clock.h +2 −2
  48. init/initramfs.c +17 −1
  49. kernel/cgroup/cgroup-v1.c +1 −1
  50. kernel/cgroup/cgroup.c +6 −29
  51. kernel/cgroup/cpuset.c +1 −1
Documentation/ABI/testing/sysfs-firmware-initrd+8−0
@@ -0,0 +1,8 @@
1What: /sys/firmware/initrd
2Date: December 2023
3Contact: Alexander Graf <graf@amazon.com>
4Description:
5 When the kernel was booted with an initrd and the
6 "retain_initrd" option is set on the kernel command
7 line, /sys/firmware/initrd contains the contents of the
8 initrd that the kernel was booted with.
Documentation/admin-guide/kernel-parameters.txt+3−2
@@ -2449,7 +2449,7 @@ · 2448 unmodified lines
2449 between unregistering the boot console and initializing2449 between unregistering the boot console and initializing
2450 the real console.2450 the real console.
2451 2451
2452 keepinitrd [HW,ARM]2452 keepinitrd [HW,ARM] See retain_initrd.
2453 2453
2454 kernelcore= [KNL,X86,IA-64,PPC]2454 kernelcore= [KNL,X86,IA-64,PPC]
2455 Format: nn[KMGTPE] | nn% | "mirror"2455 Format: nn[KMGTPE] | nn% | "mirror"
@@ -5604,7 +5604,8 @@ · 3148 unmodified lines
5604 Useful for devices that are detected asynchronously5604 Useful for devices that are detected asynchronously
5605 (e.g. USB and MMC devices).5605 (e.g. USB and MMC devices).
5606 5606
5607 retain_initrd [RAM] Keep initrd memory after extraction5607 retain_initrd [RAM] Keep initrd memory after extraction. After boot, it will
5608 be accessible via /sys/firmware/initrd.
5608 5609
5609 retbleed= [X86] Control mitigation of RETBleed (Arbitrary5610 retbleed= [X86] Control mitigation of RETBleed (Arbitrary
5610 Speculative Code Execution with Return Instructions)5611 Speculative Code Execution with Return Instructions)
arch/arm64/Kconfig+1−0
@@ -133,6 +133,7 @@ config ARM64 · 132 unmodified lines
133 select GENERIC_ARCH_TOPOLOGY133 select GENERIC_ARCH_TOPOLOGY
134 select GENERIC_CLOCKEVENTS_BROADCAST134 select GENERIC_CLOCKEVENTS_BROADCAST
135 select GENERIC_CPU_AUTOPROBE135 select GENERIC_CPU_AUTOPROBE
136 select GENERIC_CPU_DEVICES
136 select GENERIC_CPU_VULNERABILITIES137 select GENERIC_CPU_VULNERABILITIES
137 select GENERIC_EARLY_IOREMAP138 select GENERIC_EARLY_IOREMAP
138 select GENERIC_IDLE_POLL_SETUP139 select GENERIC_IDLE_POLL_SETUP
arch/arm64/include/asm/cpu.h+0−1
@@ -38,7 +38,6 @@ struct cpuinfo_32bit { · 37 unmodified lines
38};38};
39 39
40struct cpuinfo_arm64 {40struct cpuinfo_arm64 {
41 struct cpu cpu;
42 struct kobject kobj;41 struct kobject kobj;
43 u64 reg_ctr;42 u64 reg_ctr;
44 u64 reg_cntfrq;43 u64 reg_cntfrq;
arch/arm64/kernel/setup.c+2−11
@@ -402,19 +402,10 @@ static inline bool cpu_can_disable(unsigned int cpu) · 401 unmodified lines
402 return false;402 return false;
403}403}
404 404
405static int __init topology_init(void)405bool arch_cpu_is_hotpluggable(int num)
406{406{
407 int i;407 return cpu_can_disable(num);
408
409 for_each_possible_cpu(i) {
410 struct cpu *cpu = &per_cpu(cpu_data.cpu, i);
411 cpu->hotpluggable = cpu_can_disable(i);
412 register_cpu(cpu, i);
413 }
414
415 return 0;
416}408}
417subsys_initcall(topology_init);
418 409
419static void dump_kernel_offset(void)410static void dump_kernel_offset(void)
420{411{
arch/loongarch/Kconfig+2−0
@@ -5,6 +5,7 @@ config LOONGARCH · 4 unmodified lines
5 select ACPI5 select ACPI
6 select ACPI_GENERIC_GSI if ACPI6 select ACPI_GENERIC_GSI if ACPI
7 select ACPI_MCFG if ACPI7 select ACPI_MCFG if ACPI
8 select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
8 select ACPI_PPTT if ACPI9 select ACPI_PPTT if ACPI
9 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI10 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
10 select ARCH_BINFMT_ELF_STATE11 select ARCH_BINFMT_ELF_STATE
@@ -71,6 +72,7 @@ config LOONGARCH · 60 unmodified lines
71 select GENERIC_CLOCKEVENTS72 select GENERIC_CLOCKEVENTS
72 select GENERIC_CMOS_UPDATE73 select GENERIC_CMOS_UPDATE
73 select GENERIC_CPU_AUTOPROBE74 select GENERIC_CPU_AUTOPROBE
75 select GENERIC_CPU_DEVICES
74 select GENERIC_ENTRY76 select GENERIC_ENTRY
75 select GENERIC_GETTIMEOFDAY77 select GENERIC_GETTIMEOFDAY
76 select GENERIC_IOREMAP if !ARCH_IOREMAP78 select GENERIC_IOREMAP if !ARCH_IOREMAP
arch/loongarch/kernel/topology.c+2−40
@@ -10,47 +10,9 @@ · 9 unmodified lines
10 10
11#include <acpi/processor.h>11#include <acpi/processor.h>
12 12
13static DEFINE_PER_CPU(struct cpu, cpu_devices);
14
15#ifdef CONFIG_HOTPLUG_CPU13#ifdef CONFIG_HOTPLUG_CPU
16int arch_register_cpu(int cpu)14bool arch_cpu_is_hotpluggable(int cpu)
17{15{
18 int ret;16 return !io_master(cpu);
19 struct cpu *c = &per_cpu(cpu_devices, cpu);
20
21 c->hotpluggable = 1;
22 ret = register_cpu(c, cpu);
23 if (ret < 0)
24 pr_warn("register_cpu %d failed (%d)\n", cpu, ret);
25
26 return ret;
27}
28EXPORT_SYMBOL(arch_register_cpu);
29
30void arch_unregister_cpu(int cpu)
31{
32 struct cpu *c = &per_cpu(cpu_devices, cpu);
33
34 c->hotpluggable = 0;
35 unregister_cpu(c);
36}17}
37EXPORT_SYMBOL(arch_unregister_cpu);
38#endif18#endif
39
40static int __init topology_init(void)
41{
42 int i, ret;
43
44 for_each_present_cpu(i) {
45 struct cpu *c = &per_cpu(cpu_devices, i);
46
47 c->hotpluggable = !io_master(i);
48 ret = register_cpu(c, i);
49 if (ret < 0)
50 pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret);
51 }
52
53 return 0;
54}
55
56subsys_initcall(topology_init);
arch/riscv/Kconfig+1−0
@@ -72,6 +72,7 @@ config RISCV · 71 unmodified lines
72 select GENERIC_ARCH_TOPOLOGY72 select GENERIC_ARCH_TOPOLOGY
73 select GENERIC_ATOMIC64 if !64BIT73 select GENERIC_ATOMIC64 if !64BIT
74 select GENERIC_CLOCKEVENTS_BROADCAST if SMP74 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
75 select GENERIC_CPU_DEVICES
75 select GENERIC_EARLY_IOREMAP76 select GENERIC_EARLY_IOREMAP
76 select GENERIC_ENTRY77 select GENERIC_ENTRY
77 select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO78 select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
arch/riscv/kernel/setup.c+2−16
@@ -50,7 +50,6 @@ atomic_t hart_lottery __section(".sdata") · 49 unmodified lines
50#endif50#endif
51;51;
52unsigned long boot_cpu_hartid;52unsigned long boot_cpu_hartid;
53static DEFINE_PER_CPU(struct cpu, cpu_devices);
54 53
55/*54/*
56 * Place kernel memory regions on the resource tree so that55 * Place kernel memory regions on the resource tree so that
@@ -298,23 +297,10 @@ void __init setup_arch(char **cmdline_p) · 241 unmodified lines
298 riscv_user_isa_enable();297 riscv_user_isa_enable();
299}298}
300 299
301static int __init topology_init(void)300bool arch_cpu_is_hotpluggable(int cpu)
302{301{
303 int i, ret;302 return cpu_has_hotplug(cpu);
304
305 for_each_possible_cpu(i) {
306 struct cpu *cpu = &per_cpu(cpu_devices, i);
307
308 cpu->hotpluggable = cpu_has_hotplug(i);
309 ret = register_cpu(cpu, i);
310 if (unlikely(ret))
311 pr_warn("Warning: %s: register_cpu %d failed (%d)\n",
312 __func__, i, ret);
313 }
314
315 return 0;
316}303}
317subsys_initcall(topology_init);
318 304
319void free_initmem(void)305void free_initmem(void)
320{306{
arch/x86/Kconfig+2−0
@@ -59,6 +59,7 @@ config X86 · 58 unmodified lines
59 #59 #
60 select ACPI_LEGACY_TABLES_LOOKUP if ACPI60 select ACPI_LEGACY_TABLES_LOOKUP if ACPI
61 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI61 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
62 select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
62 select ARCH_32BIT_OFF_T if X86_3263 select ARCH_32BIT_OFF_T if X86_32
63 select ARCH_CLOCKSOURCE_INIT64 select ARCH_CLOCKSOURCE_INIT
64 select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE65 select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
@@ -148,6 +149,7 @@ config X86 · 83 unmodified lines
148 select GENERIC_CLOCKEVENTS_MIN_ADJUST149 select GENERIC_CLOCKEVENTS_MIN_ADJUST
149 select GENERIC_CMOS_UPDATE150 select GENERIC_CMOS_UPDATE
150 select GENERIC_CPU_AUTOPROBE151 select GENERIC_CPU_AUTOPROBE
152 select GENERIC_CPU_DEVICES
151 select GENERIC_CPU_VULNERABILITIES153 select GENERIC_CPU_VULNERABILITIES
152 select GENERIC_EARLY_IOREMAP154 select GENERIC_EARLY_IOREMAP
153 select GENERIC_ENTRY155 select GENERIC_ENTRY
arch/x86/include/asm/cpu.h+0−4
@@ -23,10 +23,6 @@ static inline void prefill_possible_map(void) {} · 22 unmodified lines
23 23
24#endif /* CONFIG_SMP */24#endif /* CONFIG_SMP */
25 25
26struct x86_cpu {
27 struct cpu cpu;
28};
29
30#ifdef CONFIG_HOTPLUG_CPU26#ifdef CONFIG_HOTPLUG_CPU
31extern void soft_restart_cpu(void);27extern void soft_restart_cpu(void);
32#endif28#endif
arch/x86/kernel/topology.c+2−31
@@ -35,38 +35,9 @@ · 34 unmodified lines
35#include <asm/io_apic.h>35#include <asm/io_apic.h>
36#include <asm/cpu.h>36#include <asm/cpu.h>
37 37
38static DEFINE_PER_CPU(struct x86_cpu, cpu_devices);
39
40#ifdef CONFIG_HOTPLUG_CPU38#ifdef CONFIG_HOTPLUG_CPU
41int arch_register_cpu(int cpu)39bool arch_cpu_is_hotpluggable(int cpu)
42{40{
43 struct x86_cpu *xc = per_cpu_ptr(&cpu_devices, cpu);41 return cpu > 0;
44
45 xc->cpu.hotpluggable = cpu > 0;
46 return register_cpu(&xc->cpu, cpu);
47}
48EXPORT_SYMBOL(arch_register_cpu);
49
50void arch_unregister_cpu(int num)
51{
52 unregister_cpu(&per_cpu(cpu_devices, num).cpu);
53}
54EXPORT_SYMBOL(arch_unregister_cpu);
55#else /* CONFIG_HOTPLUG_CPU */
56
57int __init arch_register_cpu(int num)
58{
59 return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
60}42}
61#endif /* CONFIG_HOTPLUG_CPU */43#endif /* CONFIG_HOTPLUG_CPU */
62
63static int __init topology_init(void)
64{
65 int i;
66
67 for_each_present_cpu(i)
68 arch_register_cpu(i);
69
70 return 0;
71}
72subsys_initcall(topology_init);
drivers/acpi/Kconfig+0−1
@@ -314,7 +314,6 @@ config ACPI_HOTPLUG_CPU · 313 unmodified lines
314 bool314 bool
315 depends on ACPI_PROCESSOR && HOTPLUG_CPU315 depends on ACPI_PROCESSOR && HOTPLUG_CPU
316 select ACPI_CONTAINER316 select ACPI_CONTAINER
317 default y
318 317
319config ACPI_PROCESSOR_AGGREGATOR318config ACPI_PROCESSOR_AGGREGATOR
320 tristate "Processor Aggregator"319 tristate "Processor Aggregator"
drivers/acpi/acpi_processor.c+0−18
@@ -184,24 +184,6 @@ static void __init acpi_pcc_cpufreq_init(void) {} · 183 unmodified lines
184 184
185/* Initialization */185/* Initialization */
186#ifdef CONFIG_ACPI_HOTPLUG_CPU186#ifdef CONFIG_ACPI_HOTPLUG_CPU
187int __weak acpi_map_cpu(acpi_handle handle,
188 phys_cpuid_t physid, u32 acpi_id, int *pcpu)
189{
190 return -ENODEV;
191}
192
193int __weak acpi_unmap_cpu(int cpu)
194{
195 return -ENODEV;
196}
197
198int __weak arch_register_cpu(int cpu)
199{
200 return -ENODEV;
201}
202
203void __weak arch_unregister_cpu(int cpu) {}
204
205static int acpi_processor_hotadd_init(struct acpi_processor *pr)187static int acpi_processor_hotadd_init(struct acpi_processor *pr)
206{188{
207 unsigned long long sta;189 unsigned long long sta;
drivers/acpi/property.c+4−0
@@ -881,6 +881,7 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f · 880 unmodified lines
881 * @index: Index of the reference to return881 * @index: Index of the reference to return
882 * @num_args: Maximum number of arguments after each reference882 * @num_args: Maximum number of arguments after each reference
883 * @args: Location to store the returned reference with optional arguments883 * @args: Location to store the returned reference with optional arguments
884 * (may be NULL)
884 *885 *
885 * Find property with @name, verifify that it is a package containing at least886 * Find property with @name, verifify that it is a package containing at least
886 * one object reference and if so, store the ACPI device object pointer to the887 * one object reference and if so, store the ACPI device object pointer to the
@@ -938,6 +939,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, · 51 unmodified lines
938 if (!device)939 if (!device)
939 return -EINVAL;940 return -EINVAL;
940 941
942 if (!args)
943 return 0;
944
941 args->fwnode = acpi_fwnode_handle(device);945 args->fwnode = acpi_fwnode_handle(device);
942 args->nargs = 0;946 args->nargs = 0;
943 947
drivers/base/arch_topology.c+26−12
@@ -219,20 +219,34 @@ static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn); · 218 unmodified lines
219 219
220static DEVICE_ATTR_RO(cpu_capacity);220static DEVICE_ATTR_RO(cpu_capacity);
221 221
222static int register_cpu_capacity_sysctl(void)222static int cpu_capacity_sysctl_add(unsigned int cpu)
223{223{
224 int i;224 struct device *cpu_dev = get_cpu_device(cpu);
225 struct device *cpu;
226 225
227 for_each_possible_cpu(i) {226 if (!cpu_dev)
228 cpu = get_cpu_device(i);227 return -ENOENT;
229 if (!cpu) {228
230 pr_err("%s: too early to get CPU%d device!\n",229 device_create_file(cpu_dev, &dev_attr_cpu_capacity);
231 __func__, i);230
232 continue;231 return 0;
233 }232}
234 device_create_file(cpu, &dev_attr_cpu_capacity);233
235 }234static int cpu_capacity_sysctl_remove(unsigned int cpu)
235{
236 struct device *cpu_dev = get_cpu_device(cpu);
237
238 if (!cpu_dev)
239 return -ENOENT;
240
241 device_remove_file(cpu_dev, &dev_attr_cpu_capacity);
242
243 return 0;
244}
245
246static int register_cpu_capacity_sysctl(void)
247{
248 cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "topology/cpu-capacity",
249 cpu_capacity_sysctl_add, cpu_capacity_sysctl_remove);
236 250
237 return 0;251 return 0;
238}252}
drivers/base/auxiliary.c+1−1
@@ -244,7 +244,7 @@ static void auxiliary_bus_shutdown(struct device *dev) · 243 unmodified lines
244 auxdrv->shutdown(auxdev);244 auxdrv->shutdown(auxdev);
245}245}
246 246
247static struct bus_type auxiliary_bus_type = {247static const struct bus_type auxiliary_bus_type = {
248 .name = "auxiliary",248 .name = "auxiliary",
249 .probe = auxiliary_bus_probe,249 .probe = auxiliary_bus_probe,
250 .remove = auxiliary_bus_remove,250 .remove = auxiliary_bus_remove,
drivers/base/bus.c+4−4
@@ -1030,7 +1030,7 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list · 1029 unmodified lines
1030 list_move_tail(&a->p->knode_bus.n_node, list);1030 list_move_tail(&a->p->knode_bus.n_node, list);
1031}1031}
1032 1032
1033void bus_sort_breadthfirst(struct bus_type *bus,1033void bus_sort_breadthfirst(const struct bus_type *bus,
1034 int (*compare)(const struct device *a,1034 int (*compare)(const struct device *a,
1035 const struct device *b))1035 const struct device *b))
1036{1036{
@@ -1194,7 +1194,7 @@ static void system_root_device_release(struct device *dev) · 157 unmodified lines
1194 kfree(dev);1194 kfree(dev);
1195}1195}
1196 1196
1197static int subsys_register(struct bus_type *subsys,1197static int subsys_register(const struct bus_type *subsys,
1198 const struct attribute_group **groups,1198 const struct attribute_group **groups,
1199 struct kobject *parent_of_root)1199 struct kobject *parent_of_root)
1200{1200{
@@ -1264,7 +1264,7 @@ err_sp: · 63 unmodified lines
1264 * directory itself and not some create fake root-device placed in1264 * directory itself and not some create fake root-device placed in
1265 * /sys/devices/system/<name>.1265 * /sys/devices/system/<name>.
1266 */1266 */
1267int subsys_system_register(struct bus_type *subsys,1267int subsys_system_register(const struct bus_type *subsys,
1268 const struct attribute_group **groups)1268 const struct attribute_group **groups)
1269{1269{
1270 return subsys_register(subsys, groups, &system_kset->kobj);1270 return subsys_register(subsys, groups, &system_kset->kobj);
@@ -1282,7 +1282,7 @@ EXPORT_SYMBOL_GPL(subsys_system_register); · 11 unmodified lines
1282 * There's no restriction on device naming. This is for kernel software1282 * There's no restriction on device naming. This is for kernel software
1283 * constructs which need sysfs interface.1283 * constructs which need sysfs interface.
1284 */1284 */
1285int subsys_virtual_register(struct bus_type *subsys,1285int subsys_virtual_register(const struct bus_type *subsys,
1286 const struct attribute_group **groups)1286 const struct attribute_group **groups)
1287{1287{
1288 struct kobject *virtual_dir;1288 struct kobject *virtual_dir;
drivers/base/class.c+1−0
@@ -213,6 +213,7 @@ int class_register(const struct class *cls) · 212 unmodified lines
213 return 0;213 return 0;
214 214
215err_out:215err_out:
216 lockdep_unregister_key(key);
216 kfree(cp);217 kfree(cp);
217 return error;218 return error;
218}219}
drivers/base/container.c+1−1
@@ -24,7 +24,7 @@ static int container_offline(struct device *dev) · 23 unmodified lines
24 return cdev->offline ? cdev->offline(cdev) : 0;24 return cdev->offline ? cdev->offline(cdev) : 0;
25}25}
26 26
27struct bus_type container_subsys = {27const struct bus_type container_subsys = {
28 .name = CONTAINER_BUS_NAME,28 .name = CONTAINER_BUS_NAME,
29 .dev_name = CONTAINER_BUS_NAME,29 .dev_name = CONTAINER_BUS_NAME,
30 .online = trivial_online,30 .online = trivial_online,
drivers/base/core.c+7−6
@@ -298,7 +298,7 @@ static inline bool device_link_flag_is_sync_state_only(u32 flags) · 297 unmodified lines
298 * Check if @target depends on @dev or any device dependent on it (its child or298 * Check if @target depends on @dev or any device dependent on it (its child or
299 * its consumer etc). Return 1 if that is the case or 0 otherwise.299 * its consumer etc). Return 1 if that is the case or 0 otherwise.
300 */300 */
301int device_is_dependent(struct device *dev, void *target)301static int device_is_dependent(struct device *dev, void *target)
302{302{
303 struct device_link *link;303 struct device_link *link;
304 int ret;304 int ret;
@@ -1641,7 +1641,7 @@ static void device_links_purge(struct device *dev) · 1336 unmodified lines
1641#define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \1641#define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \
1642 DL_FLAG_PM_RUNTIME)1642 DL_FLAG_PM_RUNTIME)
1643 1643
1644static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_ON;1644static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_RPM;
1645static int __init fw_devlink_setup(char *arg)1645static int __init fw_devlink_setup(char *arg)
1646{1646{
1647 if (!arg)1647 if (!arg)
@@ -4944,13 +4944,14 @@ define_dev_printk_level(_dev_info, KERN_INFO); · 3296 unmodified lines
4944 *4944 *
4945 * return dev_err_probe(dev, err, ...);4945 * return dev_err_probe(dev, err, ...);
4946 *4946 *
4947 * Note that it is deemed acceptable to use this function for error4947 * Using this helper in your probe function is totally fine even if @err is
4948 * prints during probe even if the @err is known to never be -EPROBE_DEFER.4948 * known to never be -EPROBE_DEFER.
4949 * The benefit compared to a normal dev_err() is the standardized format4949 * The benefit compared to a normal dev_err() is the standardized format
4950 * of the error code and the fact that the error code is returned.4950 * of the error code, it being emitted symbolically (i.e. you get "EAGAIN"
4951 * instead of "-35") and the fact that the error code is returned which allows
4952 * more compact error paths.
4951 *4953 *
4952 * Returns @err.4954 * Returns @err.
4953 *
4954 */4955 */
4955int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)4956int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
4956{4957{
drivers/base/cpu.c+31−8
@@ -525,19 +525,42 @@ bool cpu_is_hotpluggable(unsigned int cpu) · 524 unmodified lines
525EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);525EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
526 526
527#ifdef CONFIG_GENERIC_CPU_DEVICES527#ifdef CONFIG_GENERIC_CPU_DEVICES
528static DEFINE_PER_CPU(struct cpu, cpu_devices);528DEFINE_PER_CPU(struct cpu, cpu_devices);
529#endif529
530bool __weak arch_cpu_is_hotpluggable(int cpu)
531{
532 return false;
533}
534
535int __weak arch_register_cpu(int cpu)
536{
537 struct cpu *c = &per_cpu(cpu_devices, cpu);
538
539 c->hotpluggable = arch_cpu_is_hotpluggable(cpu);
540
541 return register_cpu(c, cpu);
542}
543
544#ifdef CONFIG_HOTPLUG_CPU
545void __weak arch_unregister_cpu(int num)
546{
547 unregister_cpu(&per_cpu(cpu_devices, num));
548}
549#endif /* CONFIG_HOTPLUG_CPU */
550#endif /* CONFIG_GENERIC_CPU_DEVICES */
530 551
531static void __init cpu_dev_register_generic(void)552static void __init cpu_dev_register_generic(void)
532{553{
533#ifdef CONFIG_GENERIC_CPU_DEVICES554 int i, ret;
534 int i;
535 555
536 for_each_possible_cpu(i) {556 if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES))
537 if (register_cpu(&per_cpu(cpu_devices, i), i))557 return;
538 panic("Failed to register CPU device");558
559 for_each_present_cpu(i) {
560 ret = arch_register_cpu(i);
561 if (ret)
562 pr_warn("register_cpu %d failed (%d)\n", i, ret);
539 }563 }
540#endif
541}564}
542 565
543#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES566#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
drivers/base/dd.c+1−1
@@ -313,7 +313,7 @@ static void deferred_probe_timeout_work_func(struct work_struct *work) · 312 unmodified lines
313 313
314 mutex_lock(&deferred_probe_mutex);314 mutex_lock(&deferred_probe_mutex);
315 list_for_each_entry(p, &deferred_probe_pending_list, deferred_probe)315 list_for_each_entry(p, &deferred_probe_pending_list, deferred_probe)
316 dev_info(p->device, "deferred probe pending\n");316 dev_info(p->device, "deferred probe pending: %s", p->deferred_probe_reason ?: "(reason unknown)\n");
317 mutex_unlock(&deferred_probe_mutex);317 mutex_unlock(&deferred_probe_mutex);
318 318
319 fw_devlink_probing_done();319 fw_devlink_probing_done();
drivers/base/init.c+1−1
@@ -35,8 +35,8 @@ void __init driver_init(void) · 34 unmodified lines
35 of_core_init();35 of_core_init();
36 platform_bus_init();36 platform_bus_init();
37 auxiliary_bus_init();37 auxiliary_bus_init();
38 cpu_dev_init();
39 memory_dev_init();38 memory_dev_init();
40 node_dev_init();39 node_dev_init();
40 cpu_dev_init();
41 container_dev_init();41 container_dev_init();
42}42}
drivers/base/isa.c+1−1
@@ -82,7 +82,7 @@ static int isa_bus_resume(struct device *dev) · 81 unmodified lines
82 return 0;82 return 0;
83}83}
84 84
85static struct bus_type isa_bus_type = {85static const struct bus_type isa_bus_type = {
86 .name = "isa",86 .name = "isa",
87 .match = isa_bus_match,87 .match = isa_bus_match,
88 .probe = isa_bus_probe,88 .probe = isa_bus_probe,
drivers/base/memory.c+1−1
@@ -68,7 +68,7 @@ static inline unsigned long phys_to_block_id(unsigned long phys) · 67 unmodified lines
68static int memory_subsys_online(struct device *dev);68static int memory_subsys_online(struct device *dev);
69static int memory_subsys_offline(struct device *dev);69static int memory_subsys_offline(struct device *dev);
70 70
71static struct bus_type memory_subsys = {71static const struct bus_type memory_subsys = {
72 .name = MEMORY_CLASS_NAME,72 .name = MEMORY_CLASS_NAME,
73 .dev_name = MEMORY_CLASS_NAME,73 .dev_name = MEMORY_CLASS_NAME,
74 .online = memory_subsys_online,74 .online = memory_subsys_online,
drivers/base/node.c+7−4
@@ -21,7 +21,7 @@ · 20 unmodified lines
21#include <linux/swap.h>21#include <linux/swap.h>
22#include <linux/slab.h>22#include <linux/slab.h>
23 23
24static struct bus_type node_subsys = {24static const struct bus_type node_subsys = {
25 .name = "node",25 .name = "node",
26 .dev_name = "node",26 .dev_name = "node",
27};27};
@@ -868,11 +868,15 @@ int __register_one_node(int nid) · 840 unmodified lines
868{868{
869 int error;869 int error;
870 int cpu;870 int cpu;
871 struct node *node;
871 872
872 node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL);873 node = kzalloc(sizeof(struct node), GFP_KERNEL);
873 if (!node_devices[nid])874 if (!node)
874 return -ENOMEM;875 return -ENOMEM;
875 876
877 INIT_LIST_HEAD(&node->access_list);
878 node_devices[nid] = node;
879
876 error = register_node(node_devices[nid], nid);880 error = register_node(node_devices[nid], nid);
877 881
878 /* link cpu under this node */882 /* link cpu under this node */
@@ -881,7 +885,6 @@ int __register_one_node(int nid) · 2 unmodified lines
881 register_cpu_under_node(cpu, nid);885 register_cpu_under_node(cpu, nid);
882 }886 }
883 887
884 INIT_LIST_HEAD(&node_devices[nid]->access_list);
885 node_init_caches(nid);888 node_init_caches(nid);
886 889
887 return error;890 return error;
drivers/base/power/clock_ops.c+1−1
@@ -793,7 +793,7 @@ static int pm_clk_notify(struct notifier_block *nb, · 792 unmodified lines
793 * the remaining members of @clknb should be populated prior to calling this793 * the remaining members of @clknb should be populated prior to calling this
794 * routine.794 * routine.
795 */795 */
796void pm_clk_add_notifier(struct bus_type *bus,796void pm_clk_add_notifier(const struct bus_type *bus,
797 struct pm_clk_notifier_block *clknb)797 struct pm_clk_notifier_block *clknb)
798{798{
799 if (!bus || !clknb)799 if (!bus || !clknb)
drivers/base/property.c+1−0
@@ -543,6 +543,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_property_string); · 542 unmodified lines
543 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.543 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
544 * @index: Index of the reference, from zero onwards.544 * @index: Index of the reference, from zero onwards.
545 * @args: Result structure with reference and integer arguments.545 * @args: Result structure with reference and integer arguments.
546 * May be NULL.
546 *547 *
547 * Obtain a reference based on a named property in an fwnode, with548 * Obtain a reference based on a named property in an fwnode, with
548 * integer arguments.549 * integer arguments.
drivers/base/soc.c+3−3
@@ -28,7 +28,7 @@ struct soc_device { · 27 unmodified lines
28 int soc_dev_num;28 int soc_dev_num;
29};29};
30 30
31static struct bus_type soc_bus_type = {31static const struct bus_type soc_bus_type = {
32 .name = "soc",32 .name = "soc",
33};33};
34static bool soc_bus_registered;34static bool soc_bus_registered;
@@ -106,7 +106,7 @@ static void soc_release(struct device *dev) · 71 unmodified lines
106{106{
107 struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);107 struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
108 108
109 ida_simple_remove(&soc_ida, soc_dev->soc_dev_num);109 ida_free(&soc_ida, soc_dev->soc_dev_num);
110 kfree(soc_dev->dev.groups);110 kfree(soc_dev->dev.groups);
111 kfree(soc_dev);111 kfree(soc_dev);
112}112}
@@ -155,7 +155,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr · 42 unmodified lines
155 soc_attr_groups[1] = soc_dev_attr->custom_attr_group;155 soc_attr_groups[1] = soc_dev_attr->custom_attr_group;
156 156
157 /* Fetch a unique (reclaimable) SOC ID. */157 /* Fetch a unique (reclaimable) SOC ID. */
158 ret = ida_simple_get(&soc_ida, 0, 0, GFP_KERNEL);158 ret = ida_alloc(&soc_ida, GFP_KERNEL);
159 if (ret < 0)159 if (ret < 0)
160 goto out3;160 goto out3;
161 soc_dev->soc_dev_num = ret;161 soc_dev->soc_dev_num = ret;
drivers/base/swnode.c+7−4
@@ -541,6 +541,9 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode, · 540 unmodified lines
541 if (nargs > NR_FWNODE_REFERENCE_ARGS)541 if (nargs > NR_FWNODE_REFERENCE_ARGS)
542 return -EINVAL;542 return -EINVAL;
543 543
544 if (!args)
545 return 0;
546
544 args->fwnode = software_node_get(refnode);547 args->fwnode = software_node_get(refnode);
545 args->nargs = nargs;548 args->nargs = nargs;
546 549
@@ -747,10 +750,10 @@ static void software_node_release(struct kobject *kobj) · 200 unmodified lines
747 struct swnode *swnode = kobj_to_swnode(kobj);750 struct swnode *swnode = kobj_to_swnode(kobj);
748 751
749 if (swnode->parent) {752 if (swnode->parent) {
750 ida_simple_remove(&swnode->parent->child_ids, swnode->id);753 ida_free(&swnode->parent->child_ids, swnode->id);
751 list_del(&swnode->entry);754 list_del(&swnode->entry);
752 } else {755 } else {
753 ida_simple_remove(&swnode_root_ids, swnode->id);756 ida_free(&swnode_root_ids, swnode->id);
754 }757 }
755 758
756 if (swnode->allocated)759 if (swnode->allocated)
@@ -776,8 +779,8 @@ swnode_register(const struct software_node *node, struct swnode *parent, · 19 unmodified lines
776 if (!swnode)779 if (!swnode)
777 return ERR_PTR(-ENOMEM);780 return ERR_PTR(-ENOMEM);
778 781
779 ret = ida_simple_get(parent ? &parent->child_ids : &swnode_root_ids,782 ret = ida_alloc(parent ? &parent->child_ids : &swnode_root_ids,
780 0, 0, GFP_KERNEL);783 GFP_KERNEL);
781 if (ret < 0) {784 if (ret < 0) {
782 kfree(swnode);785 kfree(swnode);
783 return ERR_PTR(ret);786 return ERR_PTR(ret);
drivers/edac/edac_device.h+1−1
@@ -176,7 +176,7 @@ struct edac_device_ctl_info { · 175 unmodified lines
176 struct edac_dev_sysfs_attribute *sysfs_attributes;176 struct edac_dev_sysfs_attribute *sysfs_attributes;
177 177
178 /* pointer to main 'edac' subsys in sysfs */178 /* pointer to main 'edac' subsys in sysfs */
179 struct bus_type *edac_subsys;179 const struct bus_type *edac_subsys;
180 180
181 /* the internal state of this controller instance */181 /* the internal state of this controller instance */
182 int op_state;182 int op_state;
drivers/edac/edac_device_sysfs.c+1−1
@@ -229,7 +229,7 @@ static struct kobj_type ktype_device_ctrl = { · 228 unmodified lines
229int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)229int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
230{230{
231 struct device *dev_root;231 struct device *dev_root;
232 struct bus_type *edac_subsys;232 const struct bus_type *edac_subsys;
233 int err = -ENODEV;233 int err = -ENODEV;
234 234
235 edac_dbg(1, "\n");235 edac_dbg(1, "\n");
drivers/edac/edac_module.c+2−2
@@ -67,7 +67,7 @@ char *edac_op_state_to_string(int opstate) · 66 unmodified lines
67 * sysfs object: /sys/devices/system/edac67 * sysfs object: /sys/devices/system/edac
68 * need to export to other files68 * need to export to other files
69 */69 */
70static struct bus_type edac_subsys = {70static const struct bus_type edac_subsys = {
71 .name = "edac",71 .name = "edac",
72 .dev_name = "edac",72 .dev_name = "edac",
73};73};
@@ -90,7 +90,7 @@ static void edac_subsys_exit(void) · 16 unmodified lines
90}90}
91 91
92/* return pointer to the 'edac' node in sysfs */92/* return pointer to the 'edac' node in sysfs */
93struct bus_type *edac_get_sysfs_subsys(void)93const struct bus_type *edac_get_sysfs_subsys(void)
94{94{
95 return &edac_subsys;95 return &edac_subsys;
96}96}
drivers/edac/edac_pci_sysfs.c+1−1
@@ -338,7 +338,7 @@ static struct kobj_type ktype_edac_pci_main_kobj = { · 337 unmodified lines
338static int edac_pci_main_kobj_setup(void)338static int edac_pci_main_kobj_setup(void)
339{339{
340 int err = -ENODEV;340 int err = -ENODEV;
341 struct bus_type *edac_subsys;341 const struct bus_type *edac_subsys;
342 struct device *dev_root;342 struct device *dev_root;
343 343
344 edac_dbg(0, "\n");344 edac_dbg(0, "\n");
drivers/pmdomain/core.c+1−1
@@ -2668,7 +2668,7 @@ static void genpd_release_dev(struct device *dev) · 2667 unmodified lines
2668 kfree(dev);2668 kfree(dev);
2669}2669}
2670 2670
2671static struct bus_type genpd_bus_type = {2671static const struct bus_type genpd_bus_type = {
2672 .name = "genpd",2672 .name = "genpd",
2673};2673};
2674 2674
fs/kernfs/dir.c+37−25
@@ -54,9 +54,9 @@ static bool kernfs_lockdep(struct kernfs_node *kn) · 53 unmodified lines
54static int kernfs_name_locked(struct kernfs_node *kn, char *buf, size_t buflen)54static int kernfs_name_locked(struct kernfs_node *kn, char *buf, size_t buflen)
55{55{
56 if (!kn)56 if (!kn)
57 return strlcpy(buf, "(null)", buflen);57 return strscpy(buf, "(null)", buflen);
58 58
59 return strlcpy(buf, kn->parent ? kn->name : "/", buflen);59 return strscpy(buf, kn->parent ? kn->name : "/", buflen);
60}60}
61 61
62/* kernfs_node_depth - compute depth from @from to @to */62/* kernfs_node_depth - compute depth from @from to @to */
@@ -127,7 +127,7 @@ static struct kernfs_node *kernfs_common_ancestor(struct kernfs_node *a, · 64 unmodified lines
127 *127 *
128 * [3] when @kn_to is %NULL result will be "(null)"128 * [3] when @kn_to is %NULL result will be "(null)"
129 *129 *
130 * Return: the length of the full path. If the full length is equal to or130 * Return: the length of the constructed path. If the path would have been
131 * greater than @buflen, @buf contains the truncated path with the trailing131 * greater than @buflen, @buf contains the truncated path with the trailing
132 * '\0'. On error, -errno is returned.132 * '\0'. On error, -errno is returned.
133 */133 */
@@ -138,16 +138,17 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to, · 4 unmodified lines
138 struct kernfs_node *kn, *common;138 struct kernfs_node *kn, *common;
139 const char parent_str[] = "/..";139 const char parent_str[] = "/..";
140 size_t depth_from, depth_to, len = 0;140 size_t depth_from, depth_to, len = 0;
141 ssize_t copied;
141 int i, j;142 int i, j;
142 143
143 if (!kn_to)144 if (!kn_to)
144 return strlcpy(buf, "(null)", buflen);145 return strscpy(buf, "(null)", buflen);
145 146
146 if (!kn_from)147 if (!kn_from)
147 kn_from = kernfs_root(kn_to)->kn;148 kn_from = kernfs_root(kn_to)->kn;
148 149
149 if (kn_from == kn_to)150 if (kn_from == kn_to)
150 return strlcpy(buf, "/", buflen);151 return strscpy(buf, "/", buflen);
151 152
152 common = kernfs_common_ancestor(kn_from, kn_to);153 common = kernfs_common_ancestor(kn_from, kn_to);
153 if (WARN_ON(!common))154 if (WARN_ON(!common))
@@ -158,18 +159,19 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to, · 4 unmodified lines
158 159
159 buf[0] = '\0';160 buf[0] = '\0';
160 161
161 for (i = 0; i < depth_from; i++)162 for (i = 0; i < depth_from; i++) {
162 len += strlcpy(buf + len, parent_str,163 copied = strscpy(buf + len, parent_str, buflen - len);
163 len < buflen ? buflen - len : 0);164 if (copied < 0)
165 return copied;
166 len += copied;
167 }
164 168
165 /* Calculate how many bytes we need for the rest */169 /* Calculate how many bytes we need for the rest */
166 for (i = depth_to - 1; i >= 0; i--) {170 for (i = depth_to - 1; i >= 0; i--) {
167 for (kn = kn_to, j = 0; j < i; j++)171 for (kn = kn_to, j = 0; j < i; j++)
168 kn = kn->parent;172 kn = kn->parent;
169 len += strlcpy(buf + len, "/",173
170 len < buflen ? buflen - len : 0);174 len += scnprintf(buf + len, buflen - len, "/%s", kn->name);
171 len += strlcpy(buf + len, kn->name,
172 len < buflen ? buflen - len : 0);
173 }175 }
174 176
175 return len;177 return len;
@@ -182,12 +184,12 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to, · 6 unmodified lines
182 * @buflen: size of @buf184 * @buflen: size of @buf
183 *185 *
184 * Copies the name of @kn into @buf of @buflen bytes. The behavior is186 * Copies the name of @kn into @buf of @buflen bytes. The behavior is
185 * similar to strlcpy().187 * similar to strscpy().
186 *188 *
187 * Fills buffer with "(null)" if @kn is %NULL.189 * Fills buffer with "(null)" if @kn is %NULL.
188 *190 *
189 * Return: the length of @kn's name and if @buf isn't long enough,191 * Return: the resulting length of @buf. If @buf isn't long enough,
190 * it's filled up to @buflen-1 and nul terminated.192 * it's filled up to @buflen-1 and nul terminated, and returns -E2BIG.
191 *193 *
192 * This function can be called from any context.194 * This function can be called from any context.
193 */195 */
@@ -214,7 +216,7 @@ int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen) · 20 unmodified lines
214 * path (which includes '..'s) as needed to reach from @from to @to is216 * path (which includes '..'s) as needed to reach from @from to @to is
215 * returned.217 * returned.
216 *218 *
217 * Return: the length of the full path. If the full length is equal to or219 * Return: the length of the constructed path. If the path would have been
218 * greater than @buflen, @buf contains the truncated path with the trailing220 * greater than @buflen, @buf contains the truncated path with the trailing
219 * '\0'. On error, -errno is returned.221 * '\0'. On error, -errno is returned.
220 */222 */
@@ -265,12 +267,10 @@ void pr_cont_kernfs_path(struct kernfs_node *kn) · 44 unmodified lines
265 sz = kernfs_path_from_node(kn, NULL, kernfs_pr_cont_buf,267 sz = kernfs_path_from_node(kn, NULL, kernfs_pr_cont_buf,
266 sizeof(kernfs_pr_cont_buf));268 sizeof(kernfs_pr_cont_buf));
267 if (sz < 0) {269 if (sz < 0) {
268 pr_cont("(error)");270 if (sz == -E2BIG)
269 goto out;271 pr_cont("(name too long)");
270 }272 else
271 273 pr_cont("(error)");
272 if (sz >= sizeof(kernfs_pr_cont_buf)) {
273 pr_cont("(name too long)");
274 goto out;274 goto out;
275 }275 }
276 276
@@ -676,6 +676,18 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, · 399 unmodified lines
676{676{
677 struct kernfs_node *kn;677 struct kernfs_node *kn;
678 678
679 if (parent->mode & S_ISGID) {
680 /* this code block imitates inode_init_owner() for
681 * kernfs
682 */
683
684 if (parent->iattr)
685 gid = parent->iattr->ia_gid;
686
687 if (flags & KERNFS_DIR)
688 mode |= S_ISGID;
689 }
690
679 kn = __kernfs_new_node(kernfs_root(parent), parent,691 kn = __kernfs_new_node(kernfs_root(parent), parent,
680 name, mode, uid, gid, flags);692 name, mode, uid, gid, flags);
681 if (kn) {693 if (kn) {
@@ -850,16 +862,16 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, · 168 unmodified lines
850 const unsigned char *path,862 const unsigned char *path,
851 const void *ns)863 const void *ns)
852{864{
853 size_t len;865 ssize_t len;
854 char *p, *name;866 char *p, *name;
855 867
856 lockdep_assert_held_read(&kernfs_root(parent)->kernfs_rwsem);868 lockdep_assert_held_read(&kernfs_root(parent)->kernfs_rwsem);
857 869
858 spin_lock_irq(&kernfs_pr_cont_lock);870 spin_lock_irq(&kernfs_pr_cont_lock);
859 871
860 len = strlcpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));872 len = strscpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
861 873
862 if (len >= sizeof(kernfs_pr_cont_buf)) {874 if (len < 0) {
863 spin_unlock_irq(&kernfs_pr_cont_lock);875 spin_unlock_irq(&kernfs_pr_cont_lock);
864 return NULL;876 return NULL;
865 }877 }
fs/kernfs/file.c+1−1
@@ -447,7 +447,7 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) · 446 unmodified lines
447 * warnings and we don't want to add spurious locking dependency447 * warnings and we don't want to add spurious locking dependency
448 * between the two. Check whether mmap is actually implemented448 * between the two. Check whether mmap is actually implemented
449 * without grabbing @of->mutex by testing HAS_MMAP flag. See the449 * without grabbing @of->mutex by testing HAS_MMAP flag. See the
450 * comment in kernfs_file_open() for more details.450 * comment in kernfs_fop_open() for more details.
451 */451 */
452 if (!(of->kn->flags & KERNFS_HAS_MMAP))452 if (!(of->kn->flags & KERNFS_HAS_MMAP))
453 return -ENODEV;453 return -ENODEV;
fs/kernfs/mount.c+0−3
@@ -125,9 +125,6 @@ static struct dentry *__kernfs_fh_to_dentry(struct super_block *sb, · 124 unmodified lines
125 125
126 inode = kernfs_get_inode(sb, kn);126 inode = kernfs_get_inode(sb, kn);
127 kernfs_put(kn);127 kernfs_put(kn);
128 if (!inode)
129 return ERR_PTR(-ESTALE);
130
131 return d_obtain_alias(inode);128 return d_obtain_alias(inode);
132}129}
133 130
fs/sysfs/dir.c+1−1
@@ -81,7 +81,7 @@ void sysfs_remove_dir(struct kobject *kobj) · 80 unmodified lines
81 struct kernfs_node *kn = kobj->sd;81 struct kernfs_node *kn = kobj->sd;
82 82
83 /*83 /*
84 * In general, kboject owner is responsible for ensuring removal84 * In general, kobject owner is responsible for ensuring removal
85 * doesn't race with other operations and sysfs doesn't provide any85 * doesn't race with other operations and sysfs doesn't provide any
86 * protection; however, when @kobj is used as a symlink target, the86 * protection; however, when @kobj is used as a symlink target, the
87 * symlinking entity usually doesn't own @kobj and thus has no87 * symlinking entity usually doesn't own @kobj and thus has no
include/linux/container.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12#include <linux/device.h>12#include <linux/device.h>
13 13
14/* drivers/base/power/container.c */14/* drivers/base/power/container.c */
15extern struct bus_type container_subsys;15extern const struct bus_type container_subsys;
16 16
17struct container_dev {17struct container_dev {
18 struct device dev;18 struct device dev;
include/linux/cpu.h+5−0
@@ -80,6 +80,7 @@ extern __printf(4, 5) · 79 unmodified lines
80struct device *cpu_device_create(struct device *parent, void *drvdata,80struct device *cpu_device_create(struct device *parent, void *drvdata,
81 const struct attribute_group **groups,81 const struct attribute_group **groups,
82 const char *fmt, ...);82 const char *fmt, ...);
83extern bool arch_cpu_is_hotpluggable(int cpu);
83extern int arch_register_cpu(int cpu);84extern int arch_register_cpu(int cpu);
84extern void arch_unregister_cpu(int cpu);85extern void arch_unregister_cpu(int cpu);
85#ifdef CONFIG_HOTPLUG_CPU86#ifdef CONFIG_HOTPLUG_CPU
@@ -88,6 +89,10 @@ extern ssize_t arch_cpu_probe(const char *, size_t); · 2 unmodified lines
88extern ssize_t arch_cpu_release(const char *, size_t);89extern ssize_t arch_cpu_release(const char *, size_t);
89#endif90#endif
90 91
92#ifdef CONFIG_GENERIC_CPU_DEVICES
93DECLARE_PER_CPU(struct cpu, cpu_devices);
94#endif
95
91/*96/*
92 * These states are not related to the core CPU hotplug mechanism. They are97 * These states are not related to the core CPU hotplug mechanism. They are
93 * used by various (sub)architectures to track internal state98 * used by various (sub)architectures to track internal state
include/linux/device.h+3−5
@@ -63,7 +63,7 @@ struct msi_device_data; · 62 unmodified lines
63 */63 */
64struct subsys_interface {64struct subsys_interface {
65 const char *name;65 const char *name;
66 struct bus_type *subsys;66 const struct bus_type *subsys;
67 struct list_head node;67 struct list_head node;
68 int (*add_dev)(struct device *dev, struct subsys_interface *sif);68 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
69 void (*remove_dev)(struct device *dev, struct subsys_interface *sif);69 void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
@@ -72,9 +72,9 @@ struct subsys_interface { · 2 unmodified lines
72int subsys_interface_register(struct subsys_interface *sif);72int subsys_interface_register(struct subsys_interface *sif);
73void subsys_interface_unregister(struct subsys_interface *sif);73void subsys_interface_unregister(struct subsys_interface *sif);
74 74
75int subsys_system_register(struct bus_type *subsys,75int subsys_system_register(const struct bus_type *subsys,
76 const struct attribute_group **groups);76 const struct attribute_group **groups);
77int subsys_virtual_register(struct bus_type *subsys,77int subsys_virtual_register(const struct bus_type *subsys,
78 const struct attribute_group **groups);78 const struct attribute_group **groups);
79 79
80/*80/*
@@ -662,7 +662,6 @@ struct device_physical_location { · 581 unmodified lines
662 * @id: device instance662 * @id: device instance
663 * @devres_lock: Spinlock to protect the resource of the device.663 * @devres_lock: Spinlock to protect the resource of the device.
664 * @devres_head: The resources list of the device.664 * @devres_head: The resources list of the device.
665 * @knode_class: The node used to add the device to the class list.
666 * @class: The class of the device.665 * @class: The class of the device.
667 * @groups: Optional attribute groups.666 * @groups: Optional attribute groups.
668 * @release: Callback to free the device after all references have667 * @release: Callback to free the device after all references have
@@ -1073,7 +1072,6 @@ int device_rename(struct device *dev, const char *new_name); · 404 unmodified lines
1073int device_move(struct device *dev, struct device *new_parent,1072int device_move(struct device *dev, struct device *new_parent,
1074 enum dpm_order dpm_order);1073 enum dpm_order dpm_order);
1075int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);1074int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1076int device_is_dependent(struct device *dev, void *target);
1077 1075
1078static inline bool device_supports_offline(struct device *dev)1076static inline bool device_supports_offline(struct device *dev)
1079{1077{
include/linux/device/bus.h+1−1
@@ -232,7 +232,7 @@ bus_find_device_by_acpi_dev(const struct bus_type *bus, const void *adev) · 231 unmodified lines
232 232
233int bus_for_each_drv(const struct bus_type *bus, struct device_driver *start,233int bus_for_each_drv(const struct bus_type *bus, struct device_driver *start,
234 void *data, int (*fn)(struct device_driver *, void *));234 void *data, int (*fn)(struct device_driver *, void *));
235void bus_sort_breadthfirst(struct bus_type *bus,235void bus_sort_breadthfirst(const struct bus_type *bus,
236 int (*compare)(const struct device *a,236 int (*compare)(const struct device *a,
237 const struct device *b));237 const struct device *b));
238/*238/*
include/linux/device/class.h+0−2
@@ -40,8 +40,6 @@ struct fwnode_handle; · 39 unmodified lines
40 * for the devices belonging to the class. Usually tied to40 * for the devices belonging to the class. Usually tied to
41 * device's namespace.41 * device's namespace.
42 * @pm: The default device power management operations of this class.42 * @pm: The default device power management operations of this class.
43 * @p: The private data of the driver core, no one other than the
44 * driver core can touch this.
45 *43 *
46 * A class is a higher-level view of a device that abstracts out low-level44 * A class is a higher-level view of a device that abstracts out low-level
47 * implementation details. Drivers may see a SCSI disk or an ATA disk, but,45 * implementation details. Drivers may see a SCSI disk or an ATA disk, but,
include/linux/edac.h+2−2
@@ -30,7 +30,7 @@ struct device; · 29 unmodified lines
30 30
31extern int edac_op_state;31extern int edac_op_state;
32 32
33struct bus_type *edac_get_sysfs_subsys(void);33const struct bus_type *edac_get_sysfs_subsys(void);
34 34
35static inline void opstate_init(void)35static inline void opstate_init(void)
36{36{
@@ -495,7 +495,7 @@ struct edac_raw_error_desc { · 458 unmodified lines
495 */495 */
496struct mem_ctl_info {496struct mem_ctl_info {
497 struct device dev;497 struct device dev;
498 struct bus_type *bus;498 const struct bus_type *bus;
499 499
500 struct list_head link; /* for global list of mem_ctl_info structs */500 struct list_head link; /* for global list of mem_ctl_info structs */
501 501
include/linux/pm_clock.h+2−2
@@ -91,10 +91,10 @@ static inline int devm_pm_clk_create(struct device *dev) · 90 unmodified lines
91#endif91#endif
92 92
93#ifdef CONFIG_HAVE_CLK93#ifdef CONFIG_HAVE_CLK
94extern void pm_clk_add_notifier(struct bus_type *bus,94extern void pm_clk_add_notifier(const struct bus_type *bus,
95 struct pm_clk_notifier_block *clknb);95 struct pm_clk_notifier_block *clknb);
96#else96#else
97static inline void pm_clk_add_notifier(struct bus_type *bus,97static inline void pm_clk_add_notifier(const struct bus_type *bus,
98 struct pm_clk_notifier_block *clknb)98 struct pm_clk_notifier_block *clknb)
99{99{
100}100}
init/initramfs.c+17−1
@@ -574,6 +574,16 @@ extern unsigned long __initramfs_size; · 573 unmodified lines
574#include <linux/initrd.h>574#include <linux/initrd.h>
575#include <linux/kexec.h>575#include <linux/kexec.h>
576 576
577static ssize_t raw_read(struct file *file, struct kobject *kobj,
578 struct bin_attribute *attr, char *buf,
579 loff_t pos, size_t count)
580{
581 memcpy(buf, attr->private + pos, count);
582 return count;
583}
584
585static BIN_ATTR(initrd, 0440, raw_read, NULL, 0);
586
577void __init reserve_initrd_mem(void)587void __init reserve_initrd_mem(void)
578{588{
579 phys_addr_t start;589 phys_addr_t start;
@@ -715,8 +725,14 @@ done: · 135 unmodified lines
715 * If the initrd region is overlapped with crashkernel reserved region,725 * If the initrd region is overlapped with crashkernel reserved region,
716 * free only memory that is not part of crashkernel region.726 * free only memory that is not part of crashkernel region.
717 */727 */
718 if (!do_retain_initrd && initrd_start && !kexec_free_initrd())728 if (!do_retain_initrd && initrd_start && !kexec_free_initrd()) {
719 free_initrd_mem(initrd_start, initrd_end);729 free_initrd_mem(initrd_start, initrd_end);
730 } else if (do_retain_initrd && initrd_start) {
731 bin_attr_initrd.size = initrd_end - initrd_start;
732 bin_attr_initrd.private = (void *)initrd_start;
733 if (sysfs_create_bin_file(firmware_kobj, &bin_attr_initrd))
734 pr_err("Failed to create initrd sysfs file");
735 }
720 initrd_start = 0;736 initrd_start = 0;
721 initrd_end = 0;737 initrd_end = 0;
722 738
kernel/cgroup/cgroup-v1.c+1−1
@@ -802,7 +802,7 @@ void cgroup1_release_agent(struct work_struct *work) · 801 unmodified lines
802 goto out_free;802 goto out_free;
803 803
804 ret = cgroup_path_ns(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns);804 ret = cgroup_path_ns(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns);
805 if (ret < 0 || ret >= PATH_MAX)805 if (ret < 0)
806 goto out_free;806 goto out_free;
807 807
808 argv[0] = agentbuf;808 argv[0] = agentbuf;
kernel/cgroup/cgroup.c+6−29
@@ -1906,7 +1906,7 @@ int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node, · 1905 unmodified lines
1906 len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);1906 len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);
1907 spin_unlock_irq(&css_set_lock);1907 spin_unlock_irq(&css_set_lock);
1908 1908
1909 if (len >= PATH_MAX)1909 if (len == -E2BIG)
1910 len = -ERANGE;1910 len = -ERANGE;
1911 else if (len > 0) {1911 else if (len > 0) {
1912 seq_escape(sf, buf, " \t\n\\");1912 seq_escape(sf, buf, " \t\n\\");
@@ -4182,20 +4182,6 @@ static struct kernfs_ops cgroup_kf_ops = { · 2269 unmodified lines
4182 .seq_show = cgroup_seqfile_show,4182 .seq_show = cgroup_seqfile_show,
4183};4183};
4184 4184
4185/* set uid and gid of cgroup dirs and files to that of the creator */
4186static int cgroup_kn_set_ugid(struct kernfs_node *kn)
4187{
4188 struct iattr iattr = { .ia_valid = ATTR_UID | ATTR_GID,
4189 .ia_uid = current_fsuid(),
4190 .ia_gid = current_fsgid(), };
4191
4192 if (uid_eq(iattr.ia_uid, GLOBAL_ROOT_UID) &&
4193 gid_eq(iattr.ia_gid, GLOBAL_ROOT_GID))
4194 return 0;
4195
4196 return kernfs_setattr(kn, &iattr);
4197}
4198
4199static void cgroup_file_notify_timer(struct timer_list *timer)4185static void cgroup_file_notify_timer(struct timer_list *timer)
4200{4186{
4201 cgroup_file_notify(container_of(timer, struct cgroup_file,4187 cgroup_file_notify(container_of(timer, struct cgroup_file,
@@ -4208,25 +4194,18 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, · 6 unmodified lines
4208 char name[CGROUP_FILE_NAME_MAX];4194 char name[CGROUP_FILE_NAME_MAX];
4209 struct kernfs_node *kn;4195 struct kernfs_node *kn;
4210 struct lock_class_key *key = NULL;4196 struct lock_class_key *key = NULL;
4211 int ret;
4212 4197
4213#ifdef CONFIG_DEBUG_LOCK_ALLOC4198#ifdef CONFIG_DEBUG_LOCK_ALLOC
4214 key = &cft->lockdep_key;4199 key = &cft->lockdep_key;
4215#endif4200#endif
4216 kn = __kernfs_create_file(cgrp->kn, cgroup_file_name(cgrp, cft, name),4201 kn = __kernfs_create_file(cgrp->kn, cgroup_file_name(cgrp, cft, name),
4217 cgroup_file_mode(cft),4202 cgroup_file_mode(cft),
4218 GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,4203 current_fsuid(), current_fsgid(),
4219 0, cft->kf_ops, cft,4204 0, cft->kf_ops, cft,
4220 NULL, key);4205 NULL, key);
4221 if (IS_ERR(kn))4206 if (IS_ERR(kn))
4222 return PTR_ERR(kn);4207 return PTR_ERR(kn);
4223 4208
4224 ret = cgroup_kn_set_ugid(kn);
4225 if (ret) {
4226 kernfs_remove(kn);
4227 return ret;
4228 }
4229
4230 if (cft->file_offset) {4209 if (cft->file_offset) {
4231 struct cgroup_file *cfile = (void *)css + cft->file_offset;4210 struct cgroup_file *cfile = (void *)css + cft->file_offset;
4232 4211
@@ -5629,7 +5608,9 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name, · 1396 unmodified lines
5629 goto out_cancel_ref;5608 goto out_cancel_ref;
5630 5609
5631 /* create the directory */5610 /* create the directory */
5632 kn = kernfs_create_dir(parent->kn, name, mode, cgrp);5611 kn = kernfs_create_dir_ns(parent->kn, name, mode,
5612 current_fsuid(), current_fsgid(),
5613 cgrp, NULL);
5633 if (IS_ERR(kn)) {5614 if (IS_ERR(kn)) {
5634 ret = PTR_ERR(kn);5615 ret = PTR_ERR(kn);
5635 goto out_stat_exit;5616 goto out_stat_exit;
@@ -5774,10 +5755,6 @@ int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode) · 138 unmodified lines
5774 */5755 */
5775 kernfs_get(cgrp->kn);5756 kernfs_get(cgrp->kn);
5776 5757
5777 ret = cgroup_kn_set_ugid(cgrp->kn);
5778 if (ret)
5779 goto out_destroy;
5780
5781 ret = css_populate_dir(&cgrp->self);5758 ret = css_populate_dir(&cgrp->self);
5782 if (ret)5759 if (ret)
5783 goto out_destroy;5760 goto out_destroy;
@@ -6316,7 +6293,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, · 532 unmodified lines
6316 if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) {6293 if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) {
6317 retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX,6294 retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX,
6318 current->nsproxy->cgroup_ns);6295 current->nsproxy->cgroup_ns);
6319 if (retval >= PATH_MAX)6296 if (retval == -E2BIG)
6320 retval = -ENAMETOOLONG;6297 retval = -ENAMETOOLONG;
6321 if (retval < 0)6298 if (retval < 0)
6322 goto out_unlock;6299 goto out_unlock;
kernel/cgroup/cpuset.c+1−1
@@ -5092,7 +5092,7 @@ int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, · 5091 unmodified lines
5092 retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX,5092 retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX,
5093 current->nsproxy->cgroup_ns);5093 current->nsproxy->cgroup_ns);
5094 css_put(css);5094 css_put(css);
5095 if (retval >= PATH_MAX)5095 if (retval == -E2BIG)
5096 retval = -ENAMETOOLONG;5096 retval = -ENAMETOOLONG;
5097 if (retval < 0)5097 if (retval < 0)
5098 goto out_free;5098 goto out_free;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t