Skip to content

Commit

Permalink
Merge tag 'driver-core-6.8-rc1' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/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()
  ...
  • Loading branch information
torvalds committed Jan 18, 2024
2 parents 296455a + e3977e0 commit 80955ae
Show file tree
Hide file tree
Showing 51 changed files with 207 additions and 253 deletions.
8 changes: 8 additions & 0 deletions Documentation/ABI/testing/sysfs-firmware-initrd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
What: /sys/firmware/initrd
Date: December 2023
Contact: Alexander Graf <graf@amazon.com>
Description:
When the kernel was booted with an initrd and the
"retain_initrd" option is set on the kernel command
line, /sys/firmware/initrd contains the contents of the
initrd that the kernel was booted with.
5 changes: 3 additions & 2 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@
between unregistering the boot console and initializing
the real console.

keepinitrd [HW,ARM]
keepinitrd [HW,ARM] See retain_initrd.

kernelcore= [KNL,X86,IA-64,PPC]
Format: nn[KMGTPE] | nn% | "mirror"
Expand Down Expand Up @@ -5604,7 +5604,8 @@
Useful for devices that are detected asynchronously
(e.g. USB and MMC devices).

retain_initrd [RAM] Keep initrd memory after extraction
retain_initrd [RAM] Keep initrd memory after extraction. After boot, it will
be accessible via /sys/firmware/initrd.

retbleed= [X86] Control mitigation of RETBleed (Arbitrary
Speculative Code Execution with Return Instructions)
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ config ARM64
select GENERIC_ARCH_TOPOLOGY
select GENERIC_CLOCKEVENTS_BROADCAST
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_DEVICES
select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
select GENERIC_IDLE_POLL_SETUP
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/include/asm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct cpuinfo_32bit {
};

struct cpuinfo_arm64 {
struct cpu cpu;
struct kobject kobj;
u64 reg_ctr;
u64 reg_cntfrq;
Expand Down
13 changes: 2 additions & 11 deletions arch/arm64/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,19 +402,10 @@ static inline bool cpu_can_disable(unsigned int cpu)
return false;
}

static int __init topology_init(void)
bool arch_cpu_is_hotpluggable(int num)
{
int i;

for_each_possible_cpu(i) {
struct cpu *cpu = &per_cpu(cpu_data.cpu, i);
cpu->hotpluggable = cpu_can_disable(i);
register_cpu(cpu, i);
}

return 0;
return cpu_can_disable(num);
}
subsys_initcall(topology_init);

static void dump_kernel_offset(void)
{
Expand Down
2 changes: 2 additions & 0 deletions arch/loongarch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config LOONGARCH
select ACPI
select ACPI_GENERIC_GSI if ACPI
select ACPI_MCFG if ACPI
select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
select ACPI_PPTT if ACPI
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
select ARCH_BINFMT_ELF_STATE
Expand Down Expand Up @@ -71,6 +72,7 @@ config LOONGARCH
select GENERIC_CLOCKEVENTS
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_DEVICES
select GENERIC_ENTRY
select GENERIC_GETTIMEOFDAY
select GENERIC_IOREMAP if !ARCH_IOREMAP
Expand Down
42 changes: 2 additions & 40 deletions arch/loongarch/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,9 @@

#include <acpi/processor.h>

static DEFINE_PER_CPU(struct cpu, cpu_devices);

#ifdef CONFIG_HOTPLUG_CPU
int arch_register_cpu(int cpu)
bool arch_cpu_is_hotpluggable(int cpu)
{
int ret;
struct cpu *c = &per_cpu(cpu_devices, cpu);

c->hotpluggable = 1;
ret = register_cpu(c, cpu);
if (ret < 0)
pr_warn("register_cpu %d failed (%d)\n", cpu, ret);

return ret;
}
EXPORT_SYMBOL(arch_register_cpu);

void arch_unregister_cpu(int cpu)
{
struct cpu *c = &per_cpu(cpu_devices, cpu);

c->hotpluggable = 0;
unregister_cpu(c);
return !io_master(cpu);
}
EXPORT_SYMBOL(arch_unregister_cpu);
#endif

static int __init topology_init(void)
{
int i, ret;

for_each_present_cpu(i) {
struct cpu *c = &per_cpu(cpu_devices, i);

c->hotpluggable = !io_master(i);
ret = register_cpu(c, i);
if (ret < 0)
pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret);
}

return 0;
}

subsys_initcall(topology_init);
1 change: 1 addition & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ config RISCV
select GENERIC_ARCH_TOPOLOGY
select GENERIC_ATOMIC64 if !64BIT
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
select GENERIC_CPU_DEVICES
select GENERIC_EARLY_IOREMAP
select GENERIC_ENTRY
select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
Expand Down
18 changes: 2 additions & 16 deletions arch/riscv/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ atomic_t hart_lottery __section(".sdata")
#endif
;
unsigned long boot_cpu_hartid;
static DEFINE_PER_CPU(struct cpu, cpu_devices);

/*
* Place kernel memory regions on the resource tree so that
Expand Down Expand Up @@ -298,23 +297,10 @@ void __init setup_arch(char **cmdline_p)
riscv_user_isa_enable();
}

static int __init topology_init(void)
bool arch_cpu_is_hotpluggable(int cpu)
{
int i, ret;

for_each_possible_cpu(i) {
struct cpu *cpu = &per_cpu(cpu_devices, i);

cpu->hotpluggable = cpu_has_hotplug(i);
ret = register_cpu(cpu, i);
if (unlikely(ret))
pr_warn("Warning: %s: register_cpu %d failed (%d)\n",
__func__, i, ret);
}

return 0;
return cpu_has_hotplug(cpu);
}
subsys_initcall(topology_init);

void free_initmem(void)
{
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ config X86
#
select ACPI_LEGACY_TABLES_LOOKUP if ACPI
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
select ARCH_32BIT_OFF_T if X86_32
select ARCH_CLOCKSOURCE_INIT
select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
Expand Down Expand Up @@ -148,6 +149,7 @@ config X86
select GENERIC_CLOCKEVENTS_MIN_ADJUST
select GENERIC_CMOS_UPDATE
select GENERIC_CPU_AUTOPROBE
select GENERIC_CPU_DEVICES
select GENERIC_CPU_VULNERABILITIES
select GENERIC_EARLY_IOREMAP
select GENERIC_ENTRY
Expand Down
4 changes: 0 additions & 4 deletions arch/x86/include/asm/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ static inline void prefill_possible_map(void) {}

#endif /* CONFIG_SMP */

struct x86_cpu {
struct cpu cpu;
};

#ifdef CONFIG_HOTPLUG_CPU
extern void soft_restart_cpu(void);
#endif
Expand Down
33 changes: 2 additions & 31 deletions arch/x86/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,9 @@
#include <asm/io_apic.h>
#include <asm/cpu.h>

static DEFINE_PER_CPU(struct x86_cpu, cpu_devices);

#ifdef CONFIG_HOTPLUG_CPU
int arch_register_cpu(int cpu)
bool arch_cpu_is_hotpluggable(int cpu)
{
struct x86_cpu *xc = per_cpu_ptr(&cpu_devices, cpu);

xc->cpu.hotpluggable = cpu > 0;
return register_cpu(&xc->cpu, cpu);
}
EXPORT_SYMBOL(arch_register_cpu);

void arch_unregister_cpu(int num)
{
unregister_cpu(&per_cpu(cpu_devices, num).cpu);
}
EXPORT_SYMBOL(arch_unregister_cpu);
#else /* CONFIG_HOTPLUG_CPU */

int __init arch_register_cpu(int num)
{
return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
return cpu > 0;
}
#endif /* CONFIG_HOTPLUG_CPU */

static int __init topology_init(void)
{
int i;

for_each_present_cpu(i)
arch_register_cpu(i);

return 0;
}
subsys_initcall(topology_init);
1 change: 0 additions & 1 deletion drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ config ACPI_HOTPLUG_CPU
bool
depends on ACPI_PROCESSOR && HOTPLUG_CPU
select ACPI_CONTAINER
default y

config ACPI_PROCESSOR_AGGREGATOR
tristate "Processor Aggregator"
Expand Down
18 changes: 0 additions & 18 deletions drivers/acpi/acpi_processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,6 @@ static void __init acpi_pcc_cpufreq_init(void) {}

/* Initialization */
#ifdef CONFIG_ACPI_HOTPLUG_CPU
int __weak acpi_map_cpu(acpi_handle handle,
phys_cpuid_t physid, u32 acpi_id, int *pcpu)
{
return -ENODEV;
}

int __weak acpi_unmap_cpu(int cpu)
{
return -ENODEV;
}

int __weak arch_register_cpu(int cpu)
{
return -ENODEV;
}

void __weak arch_unregister_cpu(int cpu) {}

static int acpi_processor_hotadd_init(struct acpi_processor *pr)
{
unsigned long long sta;
Expand Down
4 changes: 4 additions & 0 deletions drivers/acpi/property.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f
* @index: Index of the reference to return
* @num_args: Maximum number of arguments after each reference
* @args: Location to store the returned reference with optional arguments
* (may be NULL)
*
* Find property with @name, verifify that it is a package containing at least
* one object reference and if so, store the ACPI device object pointer to the
Expand Down Expand Up @@ -938,6 +939,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode,
if (!device)
return -EINVAL;

if (!args)
return 0;

args->fwnode = acpi_fwnode_handle(device);
args->nargs = 0;

Expand Down
38 changes: 26 additions & 12 deletions drivers/base/arch_topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,20 +219,34 @@ static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn);

static DEVICE_ATTR_RO(cpu_capacity);

static int register_cpu_capacity_sysctl(void)
static int cpu_capacity_sysctl_add(unsigned int cpu)
{
int i;
struct device *cpu;
struct device *cpu_dev = get_cpu_device(cpu);

for_each_possible_cpu(i) {
cpu = get_cpu_device(i);
if (!cpu) {
pr_err("%s: too early to get CPU%d device!\n",
__func__, i);
continue;
}
device_create_file(cpu, &dev_attr_cpu_capacity);
}
if (!cpu_dev)
return -ENOENT;

device_create_file(cpu_dev, &dev_attr_cpu_capacity);

return 0;
}

static int cpu_capacity_sysctl_remove(unsigned int cpu)
{
struct device *cpu_dev = get_cpu_device(cpu);

if (!cpu_dev)
return -ENOENT;

device_remove_file(cpu_dev, &dev_attr_cpu_capacity);

return 0;
}

static int register_cpu_capacity_sysctl(void)
{
cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "topology/cpu-capacity",
cpu_capacity_sysctl_add, cpu_capacity_sysctl_remove);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/base/auxiliary.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static void auxiliary_bus_shutdown(struct device *dev)
auxdrv->shutdown(auxdev);
}

static struct bus_type auxiliary_bus_type = {
static const struct bus_type auxiliary_bus_type = {
.name = "auxiliary",
.probe = auxiliary_bus_probe,
.remove = auxiliary_bus_remove,
Expand Down
8 changes: 4 additions & 4 deletions drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list
list_move_tail(&a->p->knode_bus.n_node, list);
}

void bus_sort_breadthfirst(struct bus_type *bus,
void bus_sort_breadthfirst(const struct bus_type *bus,
int (*compare)(const struct device *a,
const struct device *b))
{
Expand Down Expand Up @@ -1194,7 +1194,7 @@ static void system_root_device_release(struct device *dev)
kfree(dev);
}

static int subsys_register(struct bus_type *subsys,
static int subsys_register(const struct bus_type *subsys,
const struct attribute_group **groups,
struct kobject *parent_of_root)
{
Expand Down Expand Up @@ -1264,7 +1264,7 @@ static int subsys_register(struct bus_type *subsys,
* directory itself and not some create fake root-device placed in
* /sys/devices/system/<name>.
*/
int subsys_system_register(struct bus_type *subsys,
int subsys_system_register(const struct bus_type *subsys,
const struct attribute_group **groups)
{
return subsys_register(subsys, groups, &system_kset->kobj);
Expand All @@ -1282,7 +1282,7 @@ EXPORT_SYMBOL_GPL(subsys_system_register);
* There's no restriction on device naming. This is for kernel software
* constructs which need sysfs interface.
*/
int subsys_virtual_register(struct bus_type *subsys,
int subsys_virtual_register(const struct bus_type *subsys,
const struct attribute_group **groups)
{
struct kobject *virtual_dir;
Expand Down
1 change: 1 addition & 0 deletions drivers/base/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ int class_register(const struct class *cls)
return 0;

err_out:
lockdep_unregister_key(key);
kfree(cp);
return error;
}
Expand Down
Loading

0 comments on commit 80955ae

Please sign in to comment.