Skip to content

Commit 100f739

Browse files
committed
Merge commit 'bits/190-rust' into asahi-wip
2 parents c527b07 + b7bb0e0 commit 100f739

90 files changed

Lines changed: 7390 additions & 319 deletions

Some content is hidden

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

.clippy.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22

3+
msrv = "1.78.0"
4+
35
check-private-items = true
46

57
disallowed-macros = [

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*.dtb.S
2323
*.dtbo.S
2424
*.dwo
25+
*.dylib
2526
*.elf
2627
*.gcno
2728
*.gcda

Documentation/kbuild/kbuild.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ HOSTRUSTFLAGS
9191
-------------
9292
Additional flags to be passed to $(HOSTRUSTC) when building host programs.
9393

94+
PROCMACROLDFLAGS
95+
----------------
96+
Flags to be passed when linking Rust proc macros. Since proc macros are loaded
97+
by rustc at build time, they must be linked in a way that is compatible with
98+
the rustc toolchain being used.
99+
100+
For instance, it can be useful when rustc uses a different C library than
101+
the one the user wants to use for host programs.
102+
103+
If unset, it defaults to the flags passed when linking host programs.
104+
94105
HOSTLDFLAGS
95106
-----------
96107
Additional flags to be passed when linking host programs.

MAINTAINERS

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6833,6 +6833,18 @@ F: include/linux/dma-mapping.h
68336833
F: include/linux/swiotlb.h
68346834
F: kernel/dma/
68356835

6836+
DMA MAPPING HELPERS DEVICE DRIVER API [RUST]
6837+
M: Abdiel Janulgue <abdiel.janulgue@gmail.com>
6838+
M: Danilo Krummrich <dakr@kernel.org>
6839+
R: Daniel Almeida <daniel.almeida@collabora.com>
6840+
R: Robin Murphy <robin.murphy@arm.com>
6841+
R: Andreas Hindborg <a.hindborg@kernel.org>
6842+
L: rust-for-linux@vger.kernel.org
6843+
S: Supported
6844+
W: https://rust-for-linux.com
6845+
T: git https://github.com/Rust-for-Linux/linux.git rust-next
6846+
F: rust/kernel/dma.rs
6847+
68366848
DMA-BUF HEAPS FRAMEWORK
68376849
M: Sumit Semwal <sumit.semwal@linaro.org>
68386850
R: Benjamin Gaignard <benjamin.gaignard@collabora.com>
@@ -7044,6 +7056,10 @@ F: include/linux/kobj*
70447056
F: include/linux/property.h
70457057
F: lib/kobj*
70467058
F: rust/kernel/device.rs
7059+
F: rust/kernel/device_id.rs
7060+
F: rust/kernel/devres.rs
7061+
F: rust/kernel/driver.rs
7062+
F: rust/kernel/platform.rs
70477063

70487064
DRIVERS FOR OMAP ADAPTIVE VOLTAGE SCALING (AVS)
70497065
M: Nishanth Menon <nm@ti.com>
@@ -15859,6 +15875,8 @@ F: include/linux/kmod.h
1585915875
F: include/linux/module*.h
1586015876
F: kernel/module/
1586115877
F: lib/test_kmod.c
15878+
F: rust/kernel/module_param.rs
15879+
F: rust/macros/module.rs
1586215880
F: scripts/module*
1586315881
F: tools/testing/selftests/kmod/
1586415882

@@ -17511,6 +17529,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
1751117529
F: Documentation/ABI/testing/sysfs-firmware-ofw
1751217530
F: drivers/of/
1751317531
F: include/linux/of*.h
17532+
F: rust/kernel/of.rs
1751417533
F: scripts/dtc/
1751517534
F: tools/testing/selftests/dt/
1751617535
K: of_overlay_notifier_
@@ -18111,6 +18130,7 @@ F: include/asm-generic/pci*
1811118130
F: include/linux/of_pci.h
1811218131
F: include/linux/pci*
1811318132
F: include/uapi/linux/pci*
18133+
F: rust/kernel/pci.rs
1811418134

1811518135
PCIE BANDWIDTH CONTROLLER
1811618136
M: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
@@ -19698,6 +19718,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
1969819718
F: Documentation/RCU/
1969919719
F: include/linux/rcu*
1970019720
F: kernel/rcu/
19721+
F: rust/kernel/sync/rcu.rs
1970119722
X: Documentation/RCU/torture.rst
1970219723
X: include/linux/srcu*.h
1970319724
X: kernel/rcu/srcu*.c

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \
497497
-Zallow-features= $(HOSTRUSTFLAGS)
498498
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
499499
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
500+
KBUILD_PROCMACROLDFLAGS := $(or $(PROCMACROLDFLAGS),$(KBUILD_HOSTLDFLAGS))
500501

501502
# Make variables (CC, etc...)
502503
CPP = $(CC) -E
@@ -621,7 +622,7 @@ export HOSTRUSTC KBUILD_HOSTRUSTFLAGS
621622
export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
622623
export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
623624
export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
624-
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
625+
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS KBUILD_PROCMACROLDFLAGS LDFLAGS_MODULE
625626
export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
626627

627628
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@@ -1571,7 +1572,7 @@ MRPROPER_FILES += include/config include/generated \
15711572
certs/x509.genkey \
15721573
vmlinux-gdb.py \
15731574
rpmbuild \
1574-
rust/libmacros.so
1575+
rust/libmacros.so rust/libmacros.dylib
15751576

15761577
# clean - Delete most, but leave enough to build external modules
15771578
#

drivers/base/devres.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,25 +750,38 @@ int __devm_add_action(struct device *dev, void (*action)(void *), void *data, co
750750
EXPORT_SYMBOL_GPL(__devm_add_action);
751751

752752
/**
753-
* devm_remove_action() - removes previously added custom action
753+
* devm_remove_action_nowarn() - removes previously added custom action
754754
* @dev: Device that owns the action
755755
* @action: Function implementing the action
756756
* @data: Pointer to data passed to @action implementation
757757
*
758758
* Removes instance of @action previously added by devm_add_action().
759759
* Both action and data should match one of the existing entries.
760+
*
761+
* In contrast to devm_remove_action(), this function does not WARN() if no
762+
* entry could have been found.
763+
*
764+
* This should only be used if the action is contained in an object with
765+
* independent lifetime management, e.g. the Devres rust abstraction.
766+
*
767+
* Causing the warning from regular driver code most likely indicates an abuse
768+
* of the devres API.
769+
*
770+
* Returns: 0 on success, -ENOENT if no entry could have been found.
760771
*/
761-
void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
772+
int devm_remove_action_nowarn(struct device *dev,
773+
void (*action)(void *),
774+
void *data)
762775
{
763776
struct action_devres devres = {
764777
.data = data,
765778
.action = action,
766779
};
767780

768-
WARN_ON(devres_destroy(dev, devm_action_release, devm_action_match,
769-
&devres));
781+
return devres_destroy(dev, devm_action_release, devm_action_match,
782+
&devres);
770783
}
771-
EXPORT_SYMBOL_GPL(devm_remove_action);
784+
EXPORT_SYMBOL_GPL(devm_remove_action_nowarn);
772785

773786
/**
774787
* devm_release_action() - release previously added custom action

drivers/soc/apple/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ config APPLE_SART
7474

7575
Say 'y' here if you have an Apple SoC.
7676

77+
config RUST_APPLE_RTKIT
78+
bool
79+
depends on RUST
80+
depends on APPLE_RTKIT
81+
7782
endmenu
7883

7984
endif

include/linux/device.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,23 @@ void __iomem *devm_of_iomap(struct device *dev,
399399
#endif
400400

401401
/* allows to add/remove a custom action to devres stack */
402-
void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
402+
int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
403+
404+
/**
405+
* devm_remove_action() - removes previously added custom action
406+
* @dev: Device that owns the action
407+
* @action: Function implementing the action
408+
* @data: Pointer to data passed to @action implementation
409+
*
410+
* Removes instance of @action previously added by devm_add_action().
411+
* Both action and data should match one of the existing entries.
412+
*/
413+
static inline
414+
void devm_remove_action(struct device *dev, void (*action)(void *), void *data)
415+
{
416+
WARN_ON(devm_remove_action_nowarn(dev, action, data));
417+
}
418+
403419
void devm_release_action(struct device *dev, void (*action)(void *), void *data);
404420

405421
int __devm_add_action(struct device *dev, void (*action)(void *), void *data, const char *name);

init/Kconfig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ config CC_HAS_COUNTED_BY
129129
# https://github.com/llvm/llvm-project/pull/112636
130130
depends on !(CC_IS_CLANG && CLANG_VERSION < 190103)
131131

132+
config RUSTC_HAS_COERCE_POINTEE
133+
def_bool RUSTC_VERSION >= 108400
134+
132135
config PAHOLE_VERSION
133136
int
134137
default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
@@ -1989,8 +1992,10 @@ config BINDGEN_VERSION_TEXT
19891992
string
19901993
depends on RUST
19911994
# The dummy parameter `workaround-for-0.69.0` is required to support 0.69.0
1992-
# (https://github.com/rust-lang/rust-bindgen/pull/2678). It can be removed when
1993-
# the minimum version is upgraded past that (0.69.1 already fixed the issue).
1995+
# (https://github.com/rust-lang/rust-bindgen/pull/2678) and 0.71.0
1996+
# (https://github.com/rust-lang/rust-bindgen/pull/3040). It can be removed
1997+
# when the minimum version is upgraded past the latter (0.69.1 and 0.71.1
1998+
# both fixed the issue).
19941999
default "$(shell,$(BINDGEN) --version workaround-for-0.69.0 2>/dev/null)"
19952000

19962001
#

lib/Kconfig.debug

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,6 +3253,14 @@ config RUST_KERNEL_DOCTESTS
32533253

32543254
If unsure, say N.
32553255

3256+
config RUST_EXTRA_LOCKDEP
3257+
bool "Extra lockdep checking"
3258+
depends on RUST && PROVE_LOCKING
3259+
help
3260+
Enabled additional lockdep integration with certain Rust types.
3261+
3262+
If unsure, say N.
3263+
32563264
endmenu # "Rust"
32573265

32583266
endmenu # Kernel hacking

0 commit comments

Comments
 (0)