Driver core / debugfs updates for 6.14-rc1
Subsystems (6)
Greg KH
maintainerThe following changes since commit 5bc55a333a2f7316b58edc7573e8e893f7acb532:
Linux 6.13-rc7 (2025-01-12 14:37:56 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git tags/driver-core-6.14-rc1
for you to fetch changes up to 01b3cb620815fc3feb90ee117d9445a5b608a9f7:
rust: device: Use as_char_ptr() to avoid explicit cast (2025-01-16 11:07:27 +0100)
----------------------------------------------------------------
Driver core and debugfs updates
Here is the big set of driver core and debugfs updates for 6.14-rc1. It's coming late in the merge cycle as there are a number of merge conflicts with your tree now, and I wanted to make sure they were working properly. To resolve them, look in linux-next, and I will send the "fixup" patch as a response to the pull request.
Included in here is a bunch of driver core, PCI, OF, and platform rust bindings (all acked by the different subsystem maintainers), hence the merge conflict with the rust tree, and some driver core api updates to mark things as const, which will also require some fixups due to new stuff coming in through other trees in this merge window.
There are also a bunch of debugfs updates from Al, and there is at least one user that does have a regression with these, but Al is working on tracking down the fix for it. In my use (and everyone else's linux-next use), it does not seem like a big issue at the moment.
Here's a short list of the things in here:
- driver core bindings for PCI, platform, OF, and some i/o functions. We are almost at the "write a real driver in rust" stage now, depending on what you want to do.
- misc device rust bindings and a sample driver to show how to use them
- debugfs cleanups in the fs as well as the users of the fs api for places where drivers got it wrong or were unnecessarily doing things in complex ways.
- driver core const work, making more of the api take const * for different parameters to make the rust bindings easier overall.
- other small fixes and updates
All of these have been in linux-next with all of the aforementioned merge conflicts, and the one debugfs issue, which looks to be resolved "soon".
----------------------------------------------------------------
Al Viro (21):
debugfs: separate cache for debugfs inodes
debugfs: move ->automount into debugfs_inode_info
debugfs: get rid of dynamically allocation proxy_ops
debugfs: don't mess with bits in ->d_fsdata
debugfs: allow to store an additional opaque pointer at file creation
debugfs: take debugfs_short_fops definition out of ifdef
carl9170: stop embedding file_operations into their objects
b43: stop embedding struct file_operations into their objects
b43legacy: make use of debugfs_get_aux()
netdevsim: don't embed file_operations into your structs
mediatek: stop messing with ->d_iname
greybus/camera - stop messing with ->d_iname
mtu3: don't mess wiht ->d_iname
xhci: don't mess with ->d_iname
qat: don't mess with ->d_name
sof-client-ipc-flood-test: don't mess with ->d_name
slub: don't mess with ->d_name
arm_scmi: don't mess with ->d_parent->d_name
octeontx2: don't mess with ->d_parent or ->d_parent->d_name
orangefs-debugfs: don't mess with ->d_name
saner replacement for debugfs_rename()Alice Ryhl (4):
rust: miscdevice: access file in fops
rust: miscdevice: access the struct miscdevice from fops->open()
rust: miscdevice: add fops->show_fdinfo() hook
miscdevice: rust: use build_error! macro instead of function
Bartosz Golaszewski (1):
mux: constify mux class
Brian Norris (4):
drivers: base: Don't match devices with NULL of_node/fwnode/etc
drivers: base: test: Enable device model tests with KUNIT_ALL_TESTS
drivers: base: test: Add ...find_device_by...(... NULL) tests
kunit: platform: Resolve 'struct completion' warning
Danilo Krummrich (19):
rust: module: add trait ModuleMetadata
rust: implement generic driver registration
rust: implement IdArray, IdTable and RawDeviceId
rust: types: add Opaque::pin_init
rust: add io::{Io, IoRaw} base types
rust: add devres abstraction
rust: pci: add basic PCI device / driver abstractions
rust: pci: implement I/O mappable pci::Bar
samples: rust: add Rust PCI sample driver
rust: of: add of::DeviceId abstraction
rust: driver: implement Adapter
rust: platform: add basic platform device / driver abstractions
samples: rust: add Rust platform sample driver
MAINTAINERS: add Danilo to DRIVER CORE
rust: pci: do not depend on CONFIG_PCI_MSI
rust: io: move module entry to its correct location
rust: driver: address soundness issue in RegistrationOps
devres: add devm_remove_action_nowarn()
rust: devres: remove action in Devres::drop
Dr. David Alan Gilbert (1):
kobject: Remove unused functions
Greg Kroah-Hartman (1):
Merge 6.13-rc7 into driver-core-next
Heiner Kallweit (1):
drivers: core: remove device_link argument from class_compat_[create|remove]_link
Kunwu Chan (1):
ARM: riscpc: make ecard_bus_type constant
Lee Jones (6):
rust: miscdevice: Provide accessor to pull out miscdevice::this_device
Documentation: ioctl-number: Carve out some identifiers for use by sample drivers
samples: rust: Provide example using the new Rust MiscDevice abstraction
samples: rust_misc_device: Demonstrate additional get/set value functionality
MAINTAINERS: Add Rust Misc Sample to MISC entry
samples: rust_misc_device: Provide an example C program to exercise functionality
Randy Dunlap (1):
devcoredump: cleanup some comments
Ricardo B. Marliere (1):
bus: fsl-mc: constify the struct device_type usage
Thomas Weißschuh (10):
kheaders: Simplify attribute through __BIN_ATTR_SIMPLE_RO() kernel/ksysfs.c: simplify bin_attribute definition
MAINTAINERS: add include/linux/sysfs.h
sysfs: constify macro BIN_ATTRIBUTE_GROUPS()
sysfs: constify bin_attribute argument of sysfs_bin_attr_simple_read()
btf: Switch vmlinux BTF attribute to sysfs_bin_attr_simple_read()
btf: Switch module BTF attribute to sysfs_bin_attr_simple_read()
firmware_loader: Constify 'struct bin_attribute'
devcoredump: Define 'struct bin_attribute' through macro
devcoredump: Constify 'struct bin_attribute'
Viresh Kumar (3):
rust: device: Add property_present()
rust: device: Replace CString with CStr in property_present()
rust: device: Use as_char_ptr() to avoid explicit cast
Wedson Almeida Filho (2):
rust: add rcu abstraction
rust: add Revocable type
Zijun Hu (20):
libnvdimm: Replace namespace_match() with device_find_child_by_name()
slimbus: core: Constify slim_eaddr_equal()
bus: fsl-mc: Constify fsl_mc_device_match()
driver core: Constify API device_find_child() and adapt for various usages driver core: Simplify API device_find_child_by_name() implementation driver core: Remove match_any()
slimbus: core: Remove of_slim_match_dev()
gpio: sim: Remove gpio_sim_dev_match_fwnode()
driver core: Introduce an device matching API device_match_type() cxl/pmem: Replace match_nvdimm_bridge() with API device_match_type() cxl/pmem: Remove is_cxl_nvdimm_bridge()
usb: typec: class: Remove both cable_match() and partner_match() driver core: class: Fix wild pointer dereferences in API class_dev_iter_next()
blk-cgroup: Fix class @block_class's subsystem refcount leakage driver core: Move true expression out of if condition in 3 device finding APIs driver core: Rename declaration parameter name for API device_find_child() cluster driver core: Correct parameter check for API device_for_each_child_reverse_from() driver core: Correct API device_for_each_child_reverse_from() prototype driver core: Introduce device_iter_t for device iterating APIs driver core: Move two simple APIs for finding child device to header
Documentation/filesystems/debugfs.rst | 12 +- Documentation/userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 12 + arch/arm/include/asm/ecard.h | 2 +- arch/arm/mach-rpc/ecard.c | 2 +- arch/powerpc/platforms/powernv/opal.c | 2 +- arch/sparc/kernel/vio.c | 6 +- block/blk-cgroup.c | 1 + drivers/base/bus.c | 9 +- drivers/base/class.c | 42 +- drivers/base/core.c | 83 ++-- drivers/base/devcoredump.c | 22 +- drivers/base/devres.c | 23 +- drivers/base/driver.c | 9 +- drivers/base/firmware_loader/sysfs.c | 14 +- drivers/base/test/Kconfig | 1 + drivers/base/test/platform-device-test.c | 41 +- drivers/block/sunvdc.c | 6 +- drivers/bus/fsl-mc/dprc-driver.c | 8 +- drivers/bus/fsl-mc/fsl-mc-bus.c | 36 +- .../crypto/intel/qat/qat_common/adf_tl_debugfs.c | 36 +- drivers/cxl/core/hdm.c | 2 +- drivers/cxl/core/pci.c | 4 +- drivers/cxl/core/pmem.c | 15 +- drivers/cxl/core/region.c | 23 +- drivers/cxl/cxl.h | 1 - drivers/firewire/core-device.c | 4 +- drivers/firmware/arm_scmi/bus.c | 4 +- drivers/firmware/arm_scmi/raw_mode.c | 12 +- drivers/firmware/efi/dev-path-parser.c | 4 +- drivers/gpio/gpio-sim.c | 7 +- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 +- drivers/hwmon/hwmon.c | 2 +- drivers/media/pci/mgb4/mgb4_core.c | 4 +- drivers/mux/core.c | 2 +- drivers/net/bonding/bond_debugfs.c | 9 +- drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c | 19 +- .../ethernet/marvell/octeontx2/af/rvu_debugfs.c | 76 ++-- drivers/net/ethernet/marvell/skge.c | 5 +- drivers/net/ethernet/marvell/sky2.c | 5 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +- drivers/net/netdevsim/hwstats.c | 29 +- drivers/net/wireless/ath/carl9170/debug.c | 28 +- drivers/net/wireless/broadcom/b43/debugfs.c | 27 +- drivers/net/wireless/broadcom/b43legacy/debugfs.c | 26 +- drivers/nvdimm/bus.c | 2 +- drivers/nvdimm/claim.c | 9 +- drivers/of/unittest-data/tests-platform.dtsi | 5 + drivers/opp/debugfs.c | 10 +- drivers/phy/mediatek/phy-mtk-tphy.c | 40 +- drivers/pwm/core.c | 2 +- drivers/rpmsg/rpmsg_core.c | 4 +- drivers/s390/cio/chp.c | 28 +- drivers/scsi/qla4xxx/ql4_os.c | 3 +- drivers/scsi/scsi_transport_iscsi.c | 10 +- drivers/slimbus/core.c | 17 +- drivers/staging/greybus/camera.c | 17 +- drivers/thunderbolt/retimer.c | 2 +- drivers/thunderbolt/xdomain.c | 2 +- drivers/tty/serial/serial_core.c | 4 +- drivers/usb/host/xhci-debugfs.c | 25 +- drivers/usb/mtu3/mtu3_debugfs.c | 40 +- drivers/usb/typec/class.c | 31 +- drivers/vfio/mdev/mdev_core.c | 4 +- fs/debugfs/file.c | 165 ++++---- fs/debugfs/inode.c | 202 +++++----- fs/debugfs/internal.h | 48 ++- fs/orangefs/orangefs-debugfs.c | 16 +- fs/sysfs/file.c | 2 +- include/kunit/platform_device.h | 1 + include/linux/debugfs.h | 44 ++- include/linux/device.h | 66 +++- include/linux/device/bus.h | 8 +- include/linux/device/class.h | 10 +- include/linux/device/driver.h | 2 +- include/linux/fsl/mc.h | 30 +- include/linux/kobject_ns.h | 2 - include/linux/sysfs.h | 6 +- include/scsi/scsi_transport_iscsi.h | 4 +- kernel/bpf/btf.c | 15 +- kernel/bpf/sysfs_btf.c | 12 +- kernel/kheaders.c | 19 +- kernel/ksysfs.c | 21 +- kernel/module/sysfs.c | 2 +- lib/kobject.c | 24 -- mm/shrinker_debug.c | 16 +- mm/slub.c | 13 +- net/dsa/dsa.c | 2 +- net/hsr/hsr_debugfs.c | 9 +- net/mac80211/debugfs_netdev.c | 11 +- net/wireless/core.c | 5 +- rust/bindings/bindings_helper.h | 4 + rust/helpers/device.c | 10 + rust/helpers/helpers.c | 5 + rust/helpers/io.c | 101 +++++ rust/helpers/pci.c | 18 + rust/helpers/platform.c | 13 + rust/helpers/rcu.c | 13 + rust/kernel/device.rs | 7 + rust/kernel/device_id.rs | 165 ++++++++ rust/kernel/devres.rs | 201 ++++++++++ rust/kernel/driver.rs | 188 +++++++++ rust/kernel/io.rs | 260 ++++++++++++ rust/kernel/lib.rs | 20 + rust/kernel/miscdevice.rs | 104 ++++- rust/kernel/of.rs | 60 +++ rust/kernel/pci.rs | 434 +++++++++++++++++++++ rust/kernel/platform.rs | 200 ++++++++++ rust/kernel/revocable.rs | 219 +++++++++++ rust/kernel/sync.rs | 1 + rust/kernel/sync/rcu.rs | 47 +++ rust/kernel/types.rs | 11 + rust/macros/module.rs | 4 + samples/rust/Kconfig | 31 ++ samples/rust/Makefile | 3 + samples/rust/rust_driver_pci.rs | 110 ++++++ samples/rust/rust_driver_platform.rs | 49 +++ samples/rust/rust_misc_device.rs | 238 +++++++++++ sound/soc/sof/sof-client-ipc-flood-test.c | 39 +- tools/testing/cxl/test/cxl.c | 2 +- 120 files changed, 3256 insertions(+), 995 deletions(-) create mode 100644 rust/helpers/device.c create mode 100644 rust/helpers/io.c create mode 100644 rust/helpers/pci.c create mode 100644 rust/helpers/platform.c create mode 100644 rust/helpers/rcu.c create mode 100644 rust/kernel/device_id.rs create mode 100644 rust/kernel/devres.rs create mode 100644 rust/kernel/driver.rs create mode 100644 rust/kernel/io.rs create mode 100644 rust/kernel/of.rs create mode 100644 rust/kernel/pci.rs create mode 100644 rust/kernel/platform.rs create mode 100644 rust/kernel/revocable.rs create mode 100644 rust/kernel/sync/rcu.rs create mode 100644 samples/rust/rust_driver_pci.rs create mode 100644 samples/rust/rust_driver_platform.rs create mode 100644 samples/rust/rust_misc_device.rs
Greg KH
maintainerQuoted 12 lines · Greg KH
The following changes since commit
5bc55a333a2f7316b58edc7573e8e893f7acb532:Linux 6.13-rc7 (2025-01-12 14:37:56 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.gittags/driver-core-6.14-rc1for you to fetch changes up to
01b3cb620815fc3feb90ee117d9445a5b608a9f7:rust: device: Use
as_char_ptr()to avoid explicit cast (2025-01-16 11:07:27 +0100)
Quoted 8 lines
----------------------------------------------------------------
Driver core and debugfs updatesHere is the big set of driver core and debugfs updates for 6.14-rc1. It's coming late in the merge cycle as there are a number of merge conflicts with your tree now, and I wanted to make sure they were working properly. To resolve them, look in linux-next, and I will send the "fixup" patch as a response to the pull request.
And here's the merge resolution patch that I've used to get a clean build with your tree:
kernel/module/sysfs.c +0 -0
@@@ -196,8 -190,8 +190,8 @@@ static int add_notes_attrs(struct modul nattr->attr.mode =0444 ; nattr->size = info->sechdrs[i].sh_size; nattr->private = (void *)info->sechdrs[i].sh_addr; - nattr->read = sysfs_bin_attr_simple_read; + nattr->read_new = sysfs_bin_attr_simple_read; - ++nattr; + *(gattr++) = nattr++; } ++loaded; }
rust/kernel/lib.rs +0 -0
@@@ -13,16 -13,12 +13,17 @@@#![no_std] #![feature(arbitrary_self_types)] -#![feature(coerce_unsized)] -#![feature(dispatch_from_dyn)] +#![cfg_attr( CONFIG_RUSTC_HAS_COERCE_POINTEE , feature(derive_coerce_pointee))] +#![cfg_attr(not( CONFIG_RUSTC_HAS_COERCE_POINTEE ), feature(coerce_unsized))] +#![cfg_attr(not( CONFIG_RUSTC_HAS_COERCE_POINTEE ), feature(dispatch_from_dyn))] +#![cfg_attr(not( CONFIG_RUSTC_HAS_COERCE_POINTEE ), feature(unsize))] #![feature(inline_const)] #![feature(lint_reasons)] - #![feature(unsize)] +// Stable in Rust 1.83 +#![feature(const_maybe_uninit_as_mut_ptr)] +#![feature(const_mut_refs)] +#![feature(const_ptr_write)] +#![feature(const_refs_to_cell)] // Ensure conditional compilation based on the kernel configuration works; // otherwise we may silently break things like initcall handling. pub mod alloc;#[cfg( CONFIG_BLOCK )] pub mod block; -mod build_assert; +#[doc(hidden)] +pub mod build_assert;pub mod cred;pub mod device; +pub mod device_id; +pub mod devres; +pub mod driver;pub mod error;#[cfg( CONFIG_RUST_FW_LOADER_ABSTRACTIONS )] pub mod firmware;
rust/kernel/miscdevice.rs +0 -0
@@@ -10,11 -10,9 +10,12 @@@use crate ::{ bindings, + device::Device, error::{to_result,Error ,Result ,VTABLE_DEFAULT_ERROR }, + fs::File, + ffi::{c_int, c_long, c_uint, c_ulong}, prelude::*, + seq_file::SeqFile, str::CStr , types::{ForeignOwnable ,Opaque }, }; _cmd: u32, _arg: usize, ) -> Result<isize> { - kernel::build_error!(VTABLE_DEFAULT_ERROR) + build_error!(VTABLE_DEFAULT_ERROR) } + + /// Show info for this fd. + fn show_fdinfo( + _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>, + _m: &SeqFile, + _file: &File, + ) { - kernel::build_error!(VTABLE_DEFAULT_ERROR ) ++ build_error!(VTABLE_DEFAULT_ERROR) + } }const fn create_vtable <T :MiscDevice >() -> &'static bindings::file_operations { Err(err) => return err.to_errno(), }; -// SAFETY: The open call of a file owns the private data. - unsafe { (*file).private_data = ptr.into_foreign() }; + // This overwrites the private data with the value specified by the user, changing the type of +// this file's private data. All future accesses to the private data is performed by other + // fops_* methods in this file, which all correctly cast the private data to the new type. + // + // SAFETY: The open call of a file can access the private data. -unsafe { (*raw_file).private_data = ptr.into_foreign ().cast_mut () }; ++ unsafe { (*raw_file).private_data = ptr.into_foreign() };0 }// SAFETY: Ioctl calls can borrow the private data of the file. let device =unsafe { <T ::Ptr as ForeignOwnable >::borrow (private) }; - match T::ioctl(device, cmd, arg) { + // SAFETY: + // * The file is valid for the duration of this call. + // * There is no active fdget_pos region on the file on this thread. + let file = unsafe { File::from_raw_file(file) }; + - match T::ioctl(device, file, cmd, arg as usize) { ++ match T::ioctl(device, file, cmd, arg) { Ok(ret) => ret as c_long, Err(err) => err.to_errno() as c_long, } // SAFETY: Ioctl calls can borrow the private data of the file. let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) }; - match T::compat_ioctl(device, cmd, arg) { + // SAFETY: + // * The file is valid for the duration of this call. + // * There is no active fdget_pos region on the file on this thread. + let file = unsafe { File::from_raw_file(file) }; + - match T::compat_ioctl(device, file, cmd, arg as usize) { ++ match T::compat_ioctl(device, file, cmd, arg) { Ok(ret) => ret as c_long, Err(err) => err.to_errno() as c_long, }
drivers/i2c/i2c-core-base.c +1 -1
@@ -1310,7 +1310,7 @@ new_device_store(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_WO (new_device); -static int __i2c_find_user_addr (struct device *dev,void *addrp) +static int __i2c_find_user_addr (struct device *dev,const void *addrp) {struct i2c_client *client =i2c_verify_client (dev);unsigned short addr = *(unsigned short *)addrp;
drivers/leds/leds-turris-omnia.c +1 -1
@@ -438,7 +438,7 @@ static int omnia_mcu_get_features(const struct i2c_client *mcu_client)return reply; } -static int omnia_match_mcu_client (struct device *dev,void *data) +static int omnia_match_mcu_client (struct device *dev,const void *data) {struct i2c_client *client;
The pull request you sent on Tue, 28 Jan 2025 19:57:21 +0100:
The pull request you sent on Tue, 28 Jan 2025 19:57:21 +0100:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.gittags/driver-core-6.14-rc1
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/2ab002c755bfa88777e3f2db884d531f3010736c
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html