Skip to content

Commit 26e49a1

Browse files
committed
Merge: update drivers/base to match Linux v6.15
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/826 JIRA: https://issues.redhat.com/browse/RHEL-88904 Depends: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/420 Omitted-fix: c94cf02 Fix for an unsupported architecture Includes a dozen or so hrtimers commits that introduce and support hrtimer_setup() Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Guillaume Nault <gnault@redhat.com> Approved-by: Phil Auld <pauld@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Julio Faracco <jfaracco@redhat.com>
2 parents 99d8bad + 3b42052 commit 26e49a1

File tree

35 files changed

+415
-318
lines changed

35 files changed

+415
-318
lines changed

arch/x86/kvm/xen.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,6 @@ static void kvm_xen_stop_timer(struct kvm_vcpu *vcpu)
318318
atomic_set(&vcpu->arch.xen.timer_pending, 0);
319319
}
320320

321-
static void kvm_xen_init_timer(struct kvm_vcpu *vcpu)
322-
{
323-
hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC,
324-
HRTIMER_MODE_ABS_HARD);
325-
vcpu->arch.xen.timer.function = xen_timer_callback;
326-
}
327-
328321
static void kvm_xen_update_runstate_guest(struct kvm_vcpu *v, bool atomic)
329322
{
330323
struct kvm_vcpu_xen *vx = &v->arch.xen;
@@ -1125,9 +1118,6 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
11251118
break;
11261119
}
11271120

1128-
if (!vcpu->arch.xen.timer.function)
1129-
kvm_xen_init_timer(vcpu);
1130-
11311121
/* Stop the timer (if it's running) before changing the vector */
11321122
kvm_xen_stop_timer(vcpu);
11331123
vcpu->arch.xen.timer_virq = data->u.timer.port;
@@ -2299,6 +2289,8 @@ void kvm_xen_init_vcpu(struct kvm_vcpu *vcpu)
22992289
vcpu->arch.xen.poll_evtchn = 0;
23002290

23012291
timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0);
2292+
hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD);
2293+
vcpu->arch.xen.timer.function = xen_timer_callback;
23022294

23032295
kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm);
23042296
kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm);

drivers/base/arch_topology.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/cleanup.h>
1212
#include <linux/cpu.h>
1313
#include <linux/cpufreq.h>
14+
#include <linux/cpu_smt.h>
1415
#include <linux/device.h>
1516
#include <linux/of.h>
1617
#include <linux/slab.h>
@@ -508,6 +509,10 @@ core_initcall(free_raw_capacity);
508509
#endif
509510

510511
#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
512+
513+
/* Used to enable the SMT control */
514+
static unsigned int max_smt_thread_num = 1;
515+
511516
/*
512517
* This function returns the logic cpu number of the node.
513518
* There are basically three kinds of return values:
@@ -567,6 +572,8 @@ static int __init parse_core(struct device_node *core, int package_id,
567572
i++;
568573
} while (1);
569574

575+
max_smt_thread_num = max_t(unsigned int, max_smt_thread_num, i);
576+
570577
cpu = get_cpu_for_node(core);
571578
if (cpu >= 0) {
572579
if (!leaf) {
@@ -679,6 +686,17 @@ static int __init parse_socket(struct device_node *socket)
679686
if (!has_socket)
680687
ret = parse_cluster(socket, 0, -1, 0);
681688

689+
/*
690+
* Reset the max_smt_thread_num to 1 on failure. Since on failure
691+
* we need to notify the framework the SMT is not supported, but
692+
* max_smt_thread_num can be initialized to the SMT thread number
693+
* of the cores which are successfully parsed.
694+
*/
695+
if (ret)
696+
max_smt_thread_num = 1;
697+
698+
cpu_smt_set_num_threads(max_smt_thread_num, max_smt_thread_num);
699+
682700
return ret;
683701
}
684702

drivers/base/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ EXPORT_SYMBOL_GPL(subsys_system_register);
12911291
* @groups: default attributes for the root device
12921292
*
12931293
* All 'virtual' subsystems have a /sys/devices/system/<name> root device
1294-
* with the name of the subystem. The root device can carry subsystem-wide
1294+
* with the name of the subsystem. The root device can carry subsystem-wide
12951295
* attributes. All registered devices are below this single root device.
12961296
* There's no restriction on device naming. This is for kernel software
12971297
* constructs which need sysfs interface.

drivers/base/component.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ static int component_devices_show(struct seq_file *s, void *data)
8787
size_t i;
8888

8989
mutex_lock(&component_mutex);
90-
seq_printf(s, "%-40s %20s\n", "aggregate_device name", "status");
91-
seq_puts(s, "-------------------------------------------------------------\n");
92-
seq_printf(s, "%-40s %20s\n\n",
90+
seq_printf(s, "%-50s %20s\n", "aggregate_device name", "status");
91+
seq_puts(s, "-----------------------------------------------------------------------\n");
92+
seq_printf(s, "%-50s %20s\n\n",
9393
dev_name(m->parent), m->bound ? "bound" : "not bound");
9494

95-
seq_printf(s, "%-40s %20s\n", "device name", "status");
96-
seq_puts(s, "-------------------------------------------------------------\n");
95+
seq_printf(s, "%-50s %20s\n", "device name", "status");
96+
seq_puts(s, "-----------------------------------------------------------------------\n");
9797
for (i = 0; i < match->num; i++) {
9898
struct component *component = match->compare[i].component;
9999

100-
seq_printf(s, "%-40s %20s\n",
100+
seq_printf(s, "%-50s %20s\n",
101101
component ? dev_name(component->dev) : "(unknown)",
102102
component ? (component->bound ? "bound" : "not bound") : "not registered");
103103
}
@@ -569,11 +569,28 @@ void component_master_del(struct device *parent,
569569
}
570570
EXPORT_SYMBOL_GPL(component_master_del);
571571

572+
bool component_master_is_bound(struct device *parent,
573+
const struct component_master_ops *ops)
574+
{
575+
struct aggregate_device *adev;
576+
577+
guard(mutex)(&component_mutex);
578+
adev = __aggregate_find(parent, ops);
579+
if (!adev)
580+
return 0;
581+
582+
return adev->bound;
583+
}
584+
EXPORT_SYMBOL_GPL(component_master_is_bound);
585+
572586
static void component_unbind(struct component *component,
573587
struct aggregate_device *adev, void *data)
574588
{
575589
WARN_ON(!component->bound);
576590

591+
dev_dbg(adev->parent, "unbinding %s component %p (ops %ps)\n",
592+
dev_name(component->dev), component, component->ops);
593+
577594
if (component->ops && component->ops->unbind)
578595
component->ops->unbind(component->dev, adev->parent, data);
579596
component->bound = false;

drivers/base/core.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5171,6 +5171,67 @@ void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
51715171
}
51725172
EXPORT_SYMBOL_GPL(set_secondary_fwnode);
51735173

5174+
/**
5175+
* device_remove_of_node - Remove an of_node from a device
5176+
* @dev: device whose device tree node is being removed
5177+
*/
5178+
void device_remove_of_node(struct device *dev)
5179+
{
5180+
dev = get_device(dev);
5181+
if (!dev)
5182+
return;
5183+
5184+
if (!dev->of_node)
5185+
goto end;
5186+
5187+
if (dev->fwnode == of_fwnode_handle(dev->of_node))
5188+
dev->fwnode = NULL;
5189+
5190+
of_node_put(dev->of_node);
5191+
dev->of_node = NULL;
5192+
5193+
end:
5194+
put_device(dev);
5195+
}
5196+
EXPORT_SYMBOL_GPL(device_remove_of_node);
5197+
5198+
/**
5199+
* device_add_of_node - Add an of_node to an existing device
5200+
* @dev: device whose device tree node is being added
5201+
* @of_node: of_node to add
5202+
*
5203+
* Return: 0 on success or error code on failure.
5204+
*/
5205+
int device_add_of_node(struct device *dev, struct device_node *of_node)
5206+
{
5207+
int ret;
5208+
5209+
if (!of_node)
5210+
return -EINVAL;
5211+
5212+
dev = get_device(dev);
5213+
if (!dev)
5214+
return -EINVAL;
5215+
5216+
if (dev->of_node) {
5217+
dev_err(dev, "Cannot replace node %pOF with %pOF\n",
5218+
dev->of_node, of_node);
5219+
ret = -EBUSY;
5220+
goto end;
5221+
}
5222+
5223+
dev->of_node = of_node_get(of_node);
5224+
5225+
if (!dev->fwnode)
5226+
dev->fwnode = of_fwnode_handle(of_node);
5227+
5228+
ret = 0;
5229+
end:
5230+
put_device(dev);
5231+
return ret;
5232+
}
5233+
EXPORT_SYMBOL_GPL(device_add_of_node);
5234+
51745235
/**
51755236
* device_set_of_node_from_dev - reuse device-tree node of another device
51765237
* @dev: device whose device-tree node is being set

drivers/base/devres.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,10 @@ void *devres_open_group(struct device *dev, void *id, gfp_t gfp)
576576
}
577577
EXPORT_SYMBOL_GPL(devres_open_group);
578578

579-
/* Find devres group with ID @id. If @id is NULL, look for the latest. */
579+
/*
580+
* Find devres group with ID @id. If @id is NULL, look for the latest open
581+
* group.
582+
*/
580583
static struct devres_group *find_group(struct device *dev, void *id)
581584
{
582585
struct devres_node *node;
@@ -687,6 +690,13 @@ int devres_release_group(struct device *dev, void *id)
687690
spin_unlock_irqrestore(&dev->devres_lock, flags);
688691

689692
release_nodes(dev, &todo);
693+
} else if (list_empty(&dev->devres_head)) {
694+
/*
695+
* dev is probably dying via devres_release_all(): groups
696+
* have already been removed and are on the process of
697+
* being released - don't touch and don't warn.
698+
*/
699+
spin_unlock_irqrestore(&dev->devres_lock, flags);
690700
} else {
691701
WARN_ON(1);
692702
spin_unlock_irqrestore(&dev->devres_lock, flags);

drivers/base/devtmpfs.c

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ __setup("devtmpfs.mount=", mount_param);
6363

6464
static struct vfsmount *mnt;
6565

66-
static struct dentry *public_dev_mount(struct file_system_type *fs_type, int flags,
67-
const char *dev_name, void *data)
68-
{
69-
struct super_block *s = mnt->mnt_sb;
70-
int err;
71-
72-
atomic_inc(&s->s_active);
73-
down_write(&s->s_umount);
74-
err = reconfigure_single(s, flags, data);
75-
if (err < 0) {
76-
deactivate_locked_super(s);
77-
return ERR_PTR(err);
78-
}
79-
return dget(s->s_root);
80-
}
81-
8266
static struct file_system_type internal_fs_type = {
8367
.name = "devtmpfs",
8468
#ifdef CONFIG_TMPFS
@@ -89,9 +73,40 @@ static struct file_system_type internal_fs_type = {
8973
.kill_sb = kill_litter_super,
9074
};
9175

76+
/* Simply take a ref on the existing mount */
77+
static int devtmpfs_get_tree(struct fs_context *fc)
78+
{
79+
struct super_block *sb = mnt->mnt_sb;
80+
81+
atomic_inc(&sb->s_active);
82+
down_write(&sb->s_umount);
83+
fc->root = dget(sb->s_root);
84+
return 0;
85+
}
86+
87+
/* Ops are filled in during init depending on underlying shmem or ramfs type */
88+
struct fs_context_operations devtmpfs_context_ops = {};
89+
90+
/* Call the underlying initialization and set to our ops */
91+
static int devtmpfs_init_fs_context(struct fs_context *fc)
92+
{
93+
int ret;
94+
#ifdef CONFIG_TMPFS
95+
ret = shmem_init_fs_context(fc);
96+
#else
97+
ret = ramfs_init_fs_context(fc);
98+
#endif
99+
if (ret < 0)
100+
return ret;
101+
102+
fc->ops = &devtmpfs_context_ops;
103+
104+
return 0;
105+
}
106+
92107
static struct file_system_type dev_fs_type = {
93108
.name = "devtmpfs",
94-
.mount = public_dev_mount,
109+
.init_fs_context = devtmpfs_init_fs_context,
95110
};
96111

97112
static int devtmpfs_submit_req(struct req *req, const char *tmp)
@@ -433,6 +448,31 @@ static int __ref devtmpfsd(void *p)
433448
return 0;
434449
}
435450

451+
/*
452+
* Get the underlying (shmem/ramfs) context ops to build ours
453+
*/
454+
static int devtmpfs_configure_context(void)
455+
{
456+
struct fs_context *fc;
457+
458+
fc = fs_context_for_reconfigure(mnt->mnt_root, mnt->mnt_sb->s_flags,
459+
MS_RMT_MASK);
460+
if (IS_ERR(fc))
461+
return PTR_ERR(fc);
462+
463+
/* Set up devtmpfs_context_ops based on underlying type */
464+
devtmpfs_context_ops.free = fc->ops->free;
465+
devtmpfs_context_ops.dup = fc->ops->dup;
466+
devtmpfs_context_ops.parse_param = fc->ops->parse_param;
467+
devtmpfs_context_ops.parse_monolithic = fc->ops->parse_monolithic;
468+
devtmpfs_context_ops.get_tree = &devtmpfs_get_tree;
469+
devtmpfs_context_ops.reconfigure = fc->ops->reconfigure;
470+
471+
put_fs_context(fc);
472+
473+
return 0;
474+
}
475+
436476
/*
437477
* Create devtmpfs instance, driver-core devices will add their device
438478
* nodes here.
@@ -447,6 +487,13 @@ int __init devtmpfs_init(void)
447487
pr_err("unable to create devtmpfs %ld\n", PTR_ERR(mnt));
448488
return PTR_ERR(mnt);
449489
}
490+
491+
err = devtmpfs_configure_context();
492+
if (err) {
493+
pr_err("unable to configure devtmpfs type %d\n", err);
494+
return err;
495+
}
496+
450497
err = register_filesystem(&dev_fs_type);
451498
if (err) {
452499
pr_err("unable to register devtmpfs type %d\n", err);

drivers/base/faux.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ static void faux_device_release(struct device *dev)
102102
*
103103
* Note, when this function is called, the functions specified in struct
104104
* faux_ops can be called before the function returns, so be prepared for
105-
* everything to be properly initialized before that point in time.
105+
* everything to be properly initialized before that point in time. If the
106+
* probe callback (if one is present) does NOT succeed, the creation of the
107+
* device will fail and NULL will be returned.
106108
*
107109
* Return:
108110
* * NULL if an error happened with creating the device
@@ -147,6 +149,17 @@ struct faux_device *faux_device_create_with_groups(const char *name,
147149
return NULL;
148150
}
149151

152+
/*
153+
* Verify that we did bind the driver to the device (i.e. probe worked),
154+
* if not, let's fail the creation as trying to guess if probe was
155+
* successful is almost impossible to determine by the caller.
156+
*/
157+
if (!dev->driver) {
158+
dev_err(dev, "probe did not succeed, tearing down the device\n");
159+
faux_device_destroy(faux_dev);
160+
faux_dev = NULL;
161+
}
162+
150163
return faux_dev;
151164
}
152165
EXPORT_SYMBOL_GPL(faux_device_create_with_groups);

0 commit comments

Comments
 (0)