Skip to content

Commit ec88929

Browse files
author
CKI KWF Bot
committed
Merge: update drivers/base to match linux v6.17
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1357 Resolves: RHEL-109250 JIRA: https://issues.redhat.com/browse/RHEL-109250 Maintenance backports to bring RHEL-10.2 drivers/base code in line with upstream v6.17. Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Eric Chanudet <echanude@redhat.com> Approved-by: Eder Zulian <ezulian@redhat.com> Approved-by: Anusha Srivatsa <asrivats@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: Baoquan He <5820488-baoquan_he@users.noreply.gitlab.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 79a2a0e + 1ae64cc commit ec88929

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1019
-348
lines changed

arch/x86/pci/fixup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,13 +970,13 @@ static void amd_rp_pme_suspend(struct pci_dev *dev)
970970
struct pci_dev *rp;
971971

972972
/*
973-
* PM_SUSPEND_ON means we're doing runtime suspend, which means
973+
* If system suspend is not in progress, we're doing runtime suspend, so
974974
* amd-pmc will not be involved so PMEs during D3 work as advertised.
975975
*
976976
* The PMEs *do* work if amd-pmc doesn't put the SoC in the hardware
977977
* sleep state, but we assume amd-pmc is always present.
978978
*/
979-
if (pm_suspend_target_state == PM_SUSPEND_ON)
979+
if (!pm_suspend_in_progress())
980980
return;
981981

982982
rp = pcie_find_root_port(dev);

drivers/amba/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int amba_read_periphid(struct amba_device *dev)
138138
void __iomem *tmp;
139139
int i, ret;
140140

141-
ret = dev_pm_domain_attach(&dev->dev, true);
141+
ret = dev_pm_domain_attach(&dev->dev, PD_FLAG_ATTACH_POWER_ON);
142142
if (ret) {
143143
dev_dbg(&dev->dev, "can't get PM domain: %d\n", ret);
144144
goto err_out;
@@ -291,7 +291,7 @@ static int amba_probe(struct device *dev)
291291
if (ret < 0)
292292
break;
293293

294-
ret = dev_pm_domain_attach(dev, true);
294+
ret = dev_pm_domain_attach(dev, PD_FLAG_ATTACH_POWER_ON);
295295
if (ret)
296296
break;
297297

drivers/base/auxiliary.c

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@
156156
* },
157157
* .ops = my_custom_ops,
158158
* };
159+
*
160+
* Please note that such custom ops approach is valid, but it is hard to implement
161+
* it right without global locks per-device to protect from auxiliary_drv removal
162+
* during call to that ops. In addition, this implementation lacks proper module
163+
* dependency, which causes to load/unload races between auxiliary parent and devices
164+
* modules.
165+
*
166+
* The most easiest way to provide these ops reliably without needing to
167+
* have a lock is to EXPORT_SYMBOL*() them and rely on already existing
168+
* modules infrastructure for validity and correct dependencies chains.
159169
*/
160170

161171
static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
@@ -207,7 +217,7 @@ static int auxiliary_bus_probe(struct device *dev)
207217
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
208218
int ret;
209219

210-
ret = dev_pm_domain_attach(dev, true);
220+
ret = dev_pm_domain_attach(dev, PD_FLAG_ATTACH_POWER_ON);
211221
if (ret) {
212222
dev_warn(dev, "Failed to attach to PM Domain : %d\n", ret);
213223
return ret;
@@ -385,6 +395,116 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv)
385395
}
386396
EXPORT_SYMBOL_GPL(auxiliary_driver_unregister);
387397

398+
static void auxiliary_device_release(struct device *dev)
399+
{
400+
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
401+
402+
of_node_put(dev->of_node);
403+
kfree(auxdev);
404+
}
405+
406+
/**
407+
* auxiliary_device_create - create a device on the auxiliary bus
408+
* @dev: parent device
409+
* @modname: module name used to create the auxiliary driver name.
410+
* @devname: auxiliary bus device name
411+
* @platform_data: auxiliary bus device platform data
412+
* @id: auxiliary bus device id
413+
*
414+
* Helper to create an auxiliary bus device.
415+
* The device created matches driver 'modname.devname' on the auxiliary bus.
416+
*/
417+
struct auxiliary_device *auxiliary_device_create(struct device *dev,
418+
const char *modname,
419+
const char *devname,
420+
void *platform_data,
421+
int id)
422+
{
423+
struct auxiliary_device *auxdev;
424+
int ret;
425+
426+
auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL);
427+
if (!auxdev)
428+
return NULL;
429+
430+
auxdev->id = id;
431+
auxdev->name = devname;
432+
auxdev->dev.parent = dev;
433+
auxdev->dev.platform_data = platform_data;
434+
auxdev->dev.release = auxiliary_device_release;
435+
device_set_of_node_from_dev(&auxdev->dev, dev);
436+
437+
ret = auxiliary_device_init(auxdev);
438+
if (ret) {
439+
of_node_put(auxdev->dev.of_node);
440+
kfree(auxdev);
441+
return NULL;
442+
}
443+
444+
ret = __auxiliary_device_add(auxdev, modname);
445+
if (ret) {
446+
/*
447+
* It may look odd but auxdev should not be freed here.
448+
* auxiliary_device_uninit() calls device_put() which call
449+
* the device release function, freeing auxdev.
450+
*/
451+
auxiliary_device_uninit(auxdev);
452+
return NULL;
453+
}
454+
455+
return auxdev;
456+
}
457+
EXPORT_SYMBOL_GPL(auxiliary_device_create);
458+
459+
/**
460+
* auxiliary_device_destroy - remove an auxiliary device
461+
* @auxdev: pointer to the auxdev to be removed
462+
*
463+
* Helper to remove an auxiliary device created with
464+
* auxiliary_device_create()
465+
*/
466+
void auxiliary_device_destroy(void *auxdev)
467+
{
468+
struct auxiliary_device *_auxdev = auxdev;
469+
470+
auxiliary_device_delete(_auxdev);
471+
auxiliary_device_uninit(_auxdev);
472+
}
473+
EXPORT_SYMBOL_GPL(auxiliary_device_destroy);
474+
475+
/**
476+
* __devm_auxiliary_device_create - create a managed device on the auxiliary bus
477+
* @dev: parent device
478+
* @modname: module name used to create the auxiliary driver name.
479+
* @devname: auxiliary bus device name
480+
* @platform_data: auxiliary bus device platform data
481+
* @id: auxiliary bus device id
482+
*
483+
* Device managed helper to create an auxiliary bus device.
484+
* The device created matches driver 'modname.devname' on the auxiliary bus.
485+
*/
486+
struct auxiliary_device *__devm_auxiliary_device_create(struct device *dev,
487+
const char *modname,
488+
const char *devname,
489+
void *platform_data,
490+
int id)
491+
{
492+
struct auxiliary_device *auxdev;
493+
int ret;
494+
495+
auxdev = auxiliary_device_create(dev, modname, devname, platform_data, id);
496+
if (!auxdev)
497+
return NULL;
498+
499+
ret = devm_add_action_or_reset(dev, auxiliary_device_destroy,
500+
auxdev);
501+
if (ret)
502+
return NULL;
503+
504+
return auxdev;
505+
}
506+
EXPORT_SYMBOL_GPL(__devm_auxiliary_device_create);
507+
388508
void __init auxiliary_bus_init(void)
389509
{
390510
WARN_ON(bus_register(&auxiliary_bus_type));

drivers/base/base.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ static inline void subsys_put(struct subsys_private *sp)
7373
kset_put(&sp->subsys);
7474
}
7575

76+
struct subsys_private *bus_to_subsys(const struct bus_type *bus);
7677
struct subsys_private *class_to_subsys(const struct class *class);
7778

7879
struct driver_private {
@@ -180,6 +181,22 @@ int driver_add_groups(const struct device_driver *drv, const struct attribute_gr
180181
void driver_remove_groups(const struct device_driver *drv, const struct attribute_group **groups);
181182
void device_driver_detach(struct device *dev);
182183

184+
static inline void device_set_driver(struct device *dev, const struct device_driver *drv)
185+
{
186+
/*
187+
* Majority (all?) read accesses to dev->driver happens either
188+
* while holding device lock or in bus/driver code that is only
189+
* invoked when the device is bound to a driver and there is no
190+
* concern of the pointer being changed while it is being read.
191+
* However when reading device's uevent file we read driver pointer
192+
* without taking device lock (so we do not block there for
193+
* arbitrary amount of time). We use WRITE_ONCE() here to prevent
194+
* tearing so that READ_ONCE() can safely be used in uevent code.
195+
*/
196+
// FIXME - this cast should not be needed "soon"
197+
WRITE_ONCE(dev->driver, (struct device_driver *)drv);
198+
}
199+
183200
int devres_release_all(struct device *dev);
184201
void device_block_probing(void);
185202
void device_unblock_probing(void);

drivers/base/bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int __must_check bus_rescan_devices_helper(struct device *dev,
5757
* NULL. A call to subsys_put() must be done when finished with the pointer in
5858
* order for it to be properly freed.
5959
*/
60-
static struct subsys_private *bus_to_subsys(const struct bus_type *bus)
60+
struct subsys_private *bus_to_subsys(const struct bus_type *bus)
6161
{
6262
struct subsys_private *sp = NULL;
6363
struct kobject *kobj;

drivers/base/cacheinfo.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
99

1010
#include <linux/acpi.h>
11+
#include <linux/bitfield.h>
1112
#include <linux/bitops.h>
1213
#include <linux/cacheinfo.h>
1314
#include <linux/compiler.h>
@@ -183,6 +184,54 @@ static bool cache_node_is_unified(struct cacheinfo *this_leaf,
183184
return of_property_read_bool(np, "cache-unified");
184185
}
185186

187+
static bool match_cache_node(struct device_node *cpu,
188+
const struct device_node *cache_node)
189+
{
190+
struct device_node *prev, *cache = of_find_next_cache_node(cpu);
191+
192+
while (cache) {
193+
if (cache == cache_node) {
194+
of_node_put(cache);
195+
return true;
196+
}
197+
198+
prev = cache;
199+
cache = of_find_next_cache_node(cache);
200+
of_node_put(prev);
201+
}
202+
203+
return false;
204+
}
205+
206+
#ifndef arch_compact_of_hwid
207+
#define arch_compact_of_hwid(_x) (_x)
208+
#endif
209+
210+
static void cache_of_set_id(struct cacheinfo *this_leaf,
211+
struct device_node *cache_node)
212+
{
213+
struct device_node *cpu;
214+
u32 min_id = ~0;
215+
216+
for_each_of_cpu_node(cpu) {
217+
u64 id = of_get_cpu_hwid(cpu, 0);
218+
219+
id = arch_compact_of_hwid(id);
220+
if (FIELD_GET(GENMASK_ULL(63, 32), id)) {
221+
of_node_put(cpu);
222+
return;
223+
}
224+
225+
if (match_cache_node(cpu, cache_node))
226+
min_id = min(min_id, id);
227+
}
228+
229+
if (min_id != ~0) {
230+
this_leaf->id = min_id;
231+
this_leaf->attributes |= CACHE_ID;
232+
}
233+
}
234+
186235
static void cache_of_set_props(struct cacheinfo *this_leaf,
187236
struct device_node *np)
188237
{
@@ -198,6 +247,7 @@ static void cache_of_set_props(struct cacheinfo *this_leaf,
198247
cache_get_line_size(this_leaf, np);
199248
cache_nr_sets(this_leaf, np);
200249
cache_associativity(this_leaf);
250+
cache_of_set_id(this_leaf, np);
201251
}
202252

203253
static int cache_setup_of_node(unsigned int cpu)

drivers/base/component.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ EXPORT_SYMBOL_GPL(component_master_is_bound);
586586
static void component_unbind(struct component *component,
587587
struct aggregate_device *adev, void *data)
588588
{
589-
WARN_ON(!component->bound);
589+
if (WARN_ON(!component->bound))
590+
return;
590591

591592
dev_dbg(adev->parent, "unbinding %s component %p (ops %ps)\n",
592593
dev_name(component->dev), component, component->ops);

0 commit comments

Comments
 (0)