Skip to content

Commit eb3289f

Browse files
committed
Merge tag 'driver-core-6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core
Pull driver core updates from Danilo Krummrich: "Auxiliary: - Drop call to dev_pm_domain_detach() in auxiliary_bus_probe() - Optimize logic of auxiliary_match_id() Rust: - Auxiliary: - Use primitive C types from prelude - DebugFs: - Add debugfs support for simple read/write files and custom callbacks through a File-type-based and directory-scope-based API - Sample driver code for the File-type-based API - Sample module code for the directory-scope-based API - I/O: - Add io::poll module and implement Rust specific read_poll_timeout() helper - IRQ: - Implement support for threaded and non-threaded device IRQs based on (&Device<Bound>, IRQ number) tuples (IrqRequest) - Provide &Device<Bound> cookie in IRQ handlers - PCI: - Support IRQ requests from IRQ vectors for a specific pci::Device<Bound> - Implement accessors for subsystem IDs, revision, devid and resource start - Provide dedicated pci::Vendor and pci::Class types for vendor and class ID numbers - Implement Display to print actual vendor and class names; Debug to print the raw ID numbers - Add pci::DeviceId::from_class_and_vendor() helper - Use primitive C types from prelude - Various minor inline and (safety) comment improvements - Platform: - Support IRQ requests from IRQ vectors for a specific platform::Device<Bound> - Nova: - Use pci::DeviceId::from_class_and_vendor() to avoid probing non-display/compute PCI functions - Misc: - Add helper for cpu_relax() - Update ARef import from sync::aref sysfs: - Remove bin_attrs_new field from struct attribute_group - Remove read_new() and write_new() from struct bin_attribute Misc: - Document potential race condition in get_dev_from_fwnode() - Constify node_group argument in software node registration functions - Fix order of kernel-doc parameters in various functions - Set power.no_pm flag for faux devices - Set power.no_callbacks flag along with the power.no_pm flag - Constify the pmu_bus bus type - Minor spelling fixes" * tag 'driver-core-6.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core: (43 commits) rust: pci: display symbolic PCI vendor names rust: pci: display symbolic PCI class names rust: pci: fix incorrect platform reference in PCI driver probe doc comment rust: pci: fix incorrect platform reference in PCI driver unbind doc comment perf: make pmu_bus const samples: rust: Add scoped debugfs sample driver rust: debugfs: Add support for scoped directories samples: rust: Add debugfs sample driver rust: debugfs: Add support for callback-based files rust: debugfs: Add support for writable files rust: debugfs: Add support for read-only files rust: debugfs: Add initial support for directories driver core: auxiliary bus: Optimize logic of auxiliary_match_id() driver core: auxiliary bus: Drop dev_pm_domain_detach() call driver core: Fix order of the kernel-doc parameters driver core: get_dev_from_fwnode(): document potential race drivers: base: fix "publically"->"publicly" driver core/PM: Set power.no_callbacks along with power.no_pm driver core: faux: Set power.no_pm for faux devices rust: pci: inline several tiny functions ...
2 parents 50c19e2 + 6d97171 commit eb3289f

43 files changed

Lines changed: 3391 additions & 98 deletions

Some content is hidden

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

MAINTAINERS

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7021,6 +7021,21 @@ F: drivers/devfreq/event/
70217021
F: include/dt-bindings/pmu/exynos_ppmu.h
70227022
F: include/linux/devfreq-event.h
70237023

7024+
DEVICE I/O & IRQ [RUST]
7025+
M: Danilo Krummrich <dakr@kernel.org>
7026+
M: Alice Ryhl <aliceryhl@google.com>
7027+
M: Daniel Almeida <daniel.almeida@collabora.com>
7028+
L: rust-for-linux@vger.kernel.org
7029+
S: Supported
7030+
W: https://rust-for-linux.com
7031+
B: https://github.com/Rust-for-Linux/linux/issues
7032+
C: https://rust-for-linux.zulipchat.com
7033+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
7034+
F: rust/kernel/io.rs
7035+
F: rust/kernel/io/
7036+
F: rust/kernel/irq.rs
7037+
F: rust/kernel/irq/
7038+
70247039
DEVICE RESOURCE MANAGEMENT HELPERS
70257040
M: Hans de Goede <hansg@kernel.org>
70267041
R: Matti Vaittinen <mazziesaccount@gmail.com>
@@ -7472,13 +7487,17 @@ F: include/linux/kobj*
74727487
F: include/linux/property.h
74737488
F: include/linux/sysfs.h
74747489
F: lib/kobj*
7490+
F: rust/kernel/debugfs.rs
7491+
F: rust/kernel/debugfs/
74757492
F: rust/kernel/device.rs
74767493
F: rust/kernel/device/
74777494
F: rust/kernel/device_id.rs
74787495
F: rust/kernel/devres.rs
74797496
F: rust/kernel/driver.rs
74807497
F: rust/kernel/faux.rs
74817498
F: rust/kernel/platform.rs
7499+
F: samples/rust/rust_debugfs.rs
7500+
F: samples/rust/rust_debugfs_scoped.rs
74827501
F: samples/rust/rust_driver_platform.rs
74837502
F: samples/rust/rust_driver_faux.rs
74847503

@@ -19574,6 +19593,7 @@ C: irc://irc.oftc.net/linux-pci
1957419593
T: git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git
1957519594
F: rust/helpers/pci.c
1957619595
F: rust/kernel/pci.rs
19596+
F: rust/kernel/pci/
1957719597
F: samples/rust/rust_driver_pci.rs
1957819598

1957919599
PCIE BANDWIDTH CONTROLLER

drivers/base/auxiliary.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,17 +171,18 @@
171171
static const struct auxiliary_device_id *auxiliary_match_id(const struct auxiliary_device_id *id,
172172
const struct auxiliary_device *auxdev)
173173
{
174-
for (; id->name[0]; id++) {
175-
const char *p = strrchr(dev_name(&auxdev->dev), '.');
176-
int match_size;
174+
const char *auxdev_name = dev_name(&auxdev->dev);
175+
const char *p = strrchr(auxdev_name, '.');
176+
int match_size;
177177

178-
if (!p)
179-
continue;
180-
match_size = p - dev_name(&auxdev->dev);
178+
if (!p)
179+
return NULL;
180+
match_size = p - auxdev_name;
181181

182+
for (; id->name[0]; id++) {
182183
/* use dev_name(&auxdev->dev) prefix before last '.' char to match to */
183184
if (strlen(id->name) == match_size &&
184-
!strncmp(dev_name(&auxdev->dev), id->name, match_size))
185+
!strncmp(auxdev_name, id->name, match_size))
185186
return id;
186187
}
187188
return NULL;
@@ -217,17 +218,14 @@ static int auxiliary_bus_probe(struct device *dev)
217218
struct auxiliary_device *auxdev = to_auxiliary_dev(dev);
218219
int ret;
219220

220-
ret = dev_pm_domain_attach(dev, PD_FLAG_ATTACH_POWER_ON);
221+
ret = dev_pm_domain_attach(dev, PD_FLAG_ATTACH_POWER_ON |
222+
PD_FLAG_DETACH_POWER_OFF);
221223
if (ret) {
222224
dev_warn(dev, "Failed to attach to PM Domain : %d\n", ret);
223225
return ret;
224226
}
225227

226-
ret = auxdrv->probe(auxdev, auxiliary_match_id(auxdrv->id_table, auxdev));
227-
if (ret)
228-
dev_pm_domain_detach(dev, true);
229-
230-
return ret;
228+
return auxdrv->probe(auxdev, auxiliary_match_id(auxdrv->id_table, auxdev));
231229
}
232230

233231
static void auxiliary_bus_remove(struct device *dev)
@@ -237,7 +235,6 @@ static void auxiliary_bus_remove(struct device *dev)
237235

238236
if (auxdrv->remove)
239237
auxdrv->remove(auxdev);
240-
dev_pm_domain_detach(dev, true);
241238
}
242239

243240
static void auxiliary_bus_shutdown(struct device *dev)

drivers/base/core.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,8 +3994,8 @@ const char *device_get_devnode(const struct device *dev,
39943994
/**
39953995
* device_for_each_child - device child iterator.
39963996
* @parent: parent struct device.
3997-
* @fn: function to be called for each device.
39983997
* @data: data for the callback.
3998+
* @fn: function to be called for each device.
39993999
*
40004000
* Iterate over @parent's child devices, and call @fn for each,
40014001
* passing it @data.
@@ -4024,8 +4024,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child);
40244024
/**
40254025
* device_for_each_child_reverse - device child iterator in reversed order.
40264026
* @parent: parent struct device.
4027-
* @fn: function to be called for each device.
40284027
* @data: data for the callback.
4028+
* @fn: function to be called for each device.
40294029
*
40304030
* Iterate over @parent's child devices, and call @fn for each,
40314031
* passing it @data.
@@ -4055,8 +4055,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse);
40554055
* device_for_each_child_reverse_from - device child iterator in reversed order.
40564056
* @parent: parent struct device.
40574057
* @from: optional starting point in child list
4058-
* @fn: function to be called for each device.
40594058
* @data: data for the callback.
4059+
* @fn: function to be called for each device.
40604060
*
40614061
* Iterate over @parent's child devices, starting at @from, and call @fn
40624062
* for each, passing it @data. This helper is identical to
@@ -4089,8 +4089,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse_from);
40894089
/**
40904090
* device_find_child - device iterator for locating a particular device.
40914091
* @parent: parent struct device
4092-
* @match: Callback function to check device
40934092
* @data: Data to pass to match function
4093+
* @match: Callback function to check device
40944094
*
40954095
* This is similar to the device_for_each_child() function above, but it
40964096
* returns a reference to a device that is 'found' for later use, as
@@ -5278,6 +5278,25 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
52785278
}
52795279
EXPORT_SYMBOL_GPL(device_set_node);
52805280

5281+
/**
5282+
* get_dev_from_fwnode - Obtain a reference count of the struct device the
5283+
* struct fwnode_handle is associated with.
5284+
* @fwnode: The pointer to the struct fwnode_handle to obtain the struct device
5285+
* reference count of.
5286+
*
5287+
* This function obtains a reference count of the device the device pointer
5288+
* embedded in the struct fwnode_handle points to.
5289+
*
5290+
* Note that the struct device pointer embedded in struct fwnode_handle does
5291+
* *not* have a reference count of the struct device itself.
5292+
*
5293+
* Hence, it is a UAF (and thus a bug) to call this function if the caller can't
5294+
* guarantee that the last reference count of the corresponding struct device is
5295+
* not dropped concurrently.
5296+
*
5297+
* This is possible since struct fwnode_handle has its own reference count and
5298+
* hence can out-live the struct device it is associated with.
5299+
*/
52815300
struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode)
52825301
{
52835302
return get_device((fwnode)->dev);

drivers/base/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static void cpu_device_release(struct device *dev)
325325
* This is an empty function to prevent the driver core from spitting a
326326
* warning at us. Yes, I know this is directly opposite of what the
327327
* documentation for the driver core and kobjects say, and the author
328-
* of this code has already been publically ridiculed for doing
328+
* of this code has already been publicly ridiculed for doing
329329
* something as foolish as this. However, at this point in time, it is
330330
* the only way to handle the issue of statically allocated cpu
331331
* devices. The different architectures will have their cpu device

drivers/base/faux.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ struct faux_device *faux_device_create_with_groups(const char *name,
155155
dev->parent = &faux_bus_root;
156156
dev->bus = &faux_bus_type;
157157
dev_set_name(dev, "%s", name);
158+
device_set_pm_not_required(dev);
158159

159160
ret = device_add(dev);
160161
if (ret) {

drivers/base/swnode.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ swnode_register(const struct software_node *node, struct swnode *parent,
844844
* of this function or by ordering the array such that parent comes before
845845
* child.
846846
*/
847-
int software_node_register_node_group(const struct software_node **node_group)
847+
int software_node_register_node_group(const struct software_node * const *node_group)
848848
{
849849
unsigned int i;
850850
int ret;
@@ -877,8 +877,7 @@ EXPORT_SYMBOL_GPL(software_node_register_node_group);
877877
* remove the nodes individually, in the correct order (child before
878878
* parent).
879879
*/
880-
void software_node_unregister_node_group(
881-
const struct software_node **node_group)
880+
void software_node_unregister_node_group(const struct software_node * const *node_group)
882881
{
883882
unsigned int i = 0;
884883

drivers/gpu/nova-core/driver.rs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// SPDX-License-Identifier: GPL-2.0
22

3-
use kernel::{auxiliary, bindings, c_str, device::Core, pci, prelude::*, sizes::SZ_16M, sync::Arc};
3+
use kernel::{
4+
auxiliary, c_str,
5+
device::Core,
6+
pci,
7+
pci::{Class, ClassMask, Vendor},
8+
prelude::*,
9+
sizes::SZ_16M,
10+
sync::Arc,
11+
};
412

513
use crate::gpu::Gpu;
614

@@ -18,10 +26,25 @@ kernel::pci_device_table!(
1826
PCI_TABLE,
1927
MODULE_PCI_TABLE,
2028
<NovaCore as pci::Driver>::IdInfo,
21-
[(
22-
pci::DeviceId::from_id(bindings::PCI_VENDOR_ID_NVIDIA, bindings::PCI_ANY_ID as u32),
23-
()
24-
)]
29+
[
30+
// Modern NVIDIA GPUs will show up as either VGA or 3D controllers.
31+
(
32+
pci::DeviceId::from_class_and_vendor(
33+
Class::DISPLAY_VGA,
34+
ClassMask::ClassSubclass,
35+
Vendor::NVIDIA
36+
),
37+
()
38+
),
39+
(
40+
pci::DeviceId::from_class_and_vendor(
41+
Class::DISPLAY_3D,
42+
ClassMask::ClassSubclass,
43+
Vendor::NVIDIA
44+
),
45+
()
46+
),
47+
]
2548
);
2649

2750
impl pci::Driver for NovaCore {

fs/sysfs/file.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,9 @@ static ssize_t sysfs_kf_bin_read(struct kernfs_open_file *of, char *buf,
9797
count = size - pos;
9898
}
9999

100-
if (!battr->read && !battr->read_new)
100+
if (!battr->read)
101101
return -EIO;
102102

103-
if (battr->read_new)
104-
return battr->read_new(of->file, kobj, battr, buf, pos, count);
105-
106103
return battr->read(of->file, kobj, battr, buf, pos, count);
107104
}
108105

@@ -161,12 +158,9 @@ static ssize_t sysfs_kf_bin_write(struct kernfs_open_file *of, char *buf,
161158
if (!count)
162159
return 0;
163160

164-
if (!battr->write && !battr->write_new)
161+
if (!battr->write)
165162
return -EIO;
166163

167-
if (battr->write_new)
168-
return battr->write_new(of->file, kobj, battr, buf, pos, count);
169-
170164
return battr->write(of->file, kobj, battr, buf, pos, count);
171165
}
172166

@@ -335,19 +329,13 @@ int sysfs_add_bin_file_mode_ns(struct kernfs_node *parent,
335329
const struct kernfs_ops *ops;
336330
struct kernfs_node *kn;
337331

338-
if (battr->read && battr->read_new)
339-
return -EINVAL;
340-
341-
if (battr->write && battr->write_new)
342-
return -EINVAL;
343-
344332
if (battr->mmap)
345333
ops = &sysfs_bin_kfops_mmap;
346-
else if ((battr->read || battr->read_new) && (battr->write || battr->write_new))
334+
else if (battr->read && battr->write)
347335
ops = &sysfs_bin_kfops_rw;
348-
else if (battr->read || battr->read_new)
336+
else if (battr->read)
349337
ops = &sysfs_bin_kfops_ro;
350-
else if (battr->write || battr->write_new)
338+
else if (battr->write)
351339
ops = &sysfs_bin_kfops_wo;
352340
else
353341
ops = &sysfs_file_kfops_empty;

include/linux/device.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,9 @@ static inline bool device_pm_not_required(struct device *dev)
851851
static inline void device_set_pm_not_required(struct device *dev)
852852
{
853853
dev->power.no_pm = true;
854+
#ifdef CONFIG_PM
855+
dev->power.no_callbacks = true;
856+
#endif
854857
}
855858

856859
static inline void dev_pm_syscore_device(struct device *dev, bool val)

include/linux/property.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,8 @@ const struct software_node *
574574
software_node_find_by_name(const struct software_node *parent,
575575
const char *name);
576576

577-
int software_node_register_node_group(const struct software_node **node_group);
578-
void software_node_unregister_node_group(const struct software_node **node_group);
577+
int software_node_register_node_group(const struct software_node * const *node_group);
578+
void software_node_unregister_node_group(const struct software_node * const *node_group);
579579

580580
int software_node_register(const struct software_node *node);
581581
void software_node_unregister(const struct software_node *node);

0 commit comments

Comments
 (0)