Skip to content

Commit 443653f

Browse files
committed
Merge branch 'bits/190-rust' into asahi-wip
2 parents 50e5f24 + 8508060 commit 443653f

100 files changed

Lines changed: 7653 additions & 344 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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6833,6 +6833,19 @@ 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 alloc-next
6846+
F: rust/kernel/dma.rs
6847+
F: samples/rust/rust_dma.rs
6848+
68366849
DMA-BUF HEAPS FRAMEWORK
68376850
M: Sumit Semwal <sumit.semwal@linaro.org>
68386851
R: Benjamin Gaignard <benjamin.gaignard@collabora.com>
@@ -7044,6 +7057,10 @@ F: include/linux/kobj*
70447057
F: include/linux/property.h
70457058
F: lib/kobj*
70467059
F: rust/kernel/device.rs
7060+
F: rust/kernel/device_id.rs
7061+
F: rust/kernel/devres.rs
7062+
F: rust/kernel/driver.rs
7063+
F: rust/kernel/platform.rs
70477064

70487065
DRIVERS FOR OMAP ADAPTIVE VOLTAGE SCALING (AVS)
70497066
M: Nishanth Menon <nm@ti.com>
@@ -15859,6 +15876,8 @@ F: include/linux/kmod.h
1585915876
F: include/linux/module*.h
1586015877
F: kernel/module/
1586115878
F: lib/test_kmod.c
15879+
F: rust/kernel/module_param.rs
15880+
F: rust/macros/module.rs
1586215881
F: scripts/module*
1586315882
F: tools/testing/selftests/kmod/
1586415883

@@ -17511,6 +17530,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git
1751117530
F: Documentation/ABI/testing/sysfs-firmware-ofw
1751217531
F: drivers/of/
1751317532
F: include/linux/of*.h
17533+
F: rust/kernel/of.rs
1751417534
F: scripts/dtc/
1751517535
F: tools/testing/selftests/dt/
1751617536
K: of_overlay_notifier_
@@ -18111,6 +18131,7 @@ F: include/asm-generic/pci*
1811118131
F: include/linux/of_pci.h
1811218132
F: include/linux/pci*
1811318133
F: include/uapi/linux/pci*
18134+
F: rust/kernel/pci.rs
1811418135

1811518136
PCIE BANDWIDTH CONTROLLER
1811618137
M: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
@@ -19698,6 +19719,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git dev
1969819719
F: Documentation/RCU/
1969919720
F: include/linux/rcu*
1970019721
F: kernel/rcu/
19722+
F: rust/kernel/sync/rcu.rs
1970119723
X: Documentation/RCU/torture.rst
1970219724
X: include/linux/srcu*.h
1970319725
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/block/rnull.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use kernel::{
2727
module! {
2828
type: NullBlkModule,
2929
name: "rnull_mod",
30-
author: "Andreas Hindborg",
30+
authors: ["Andreas Hindborg"],
3131
description: "Rust implementation of the C null block driver",
3232
license: "GPL v2",
3333
}

drivers/gpu/drm/drm_panic.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,6 @@ static void drm_panic_qr_exit(void)
699699
stream.workspace = NULL;
700700
}
701701

702-
extern size_t drm_panic_qr_max_data_size(u8 version, size_t url_len);
703-
704-
extern u8 drm_panic_qr_generate(const char *url, u8 *data, size_t data_len, size_t data_size,
705-
u8 *tmp, size_t tmp_size);
706-
707702
static int drm_panic_get_qr_code_url(u8 **qr_image)
708703
{
709704
struct kmsg_dump_iter iter;

drivers/gpu/drm/drm_panic_qr.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//! * <https://github.com/bjguillot/qr>
2828
2929
use core::cmp;
30-
use kernel::str::CStr;
30+
use kernel::{prelude::*, str::CStr};
3131

3232
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
3333
struct Version(usize);
@@ -929,7 +929,7 @@ impl QrImage<'_> {
929929
/// * `tmp` must be valid for reading and writing for `tmp_size` bytes.
930930
///
931931
/// They must remain valid for the duration of the function call.
932-
#[no_mangle]
932+
#[export]
933933
pub unsafe extern "C" fn drm_panic_qr_generate(
934934
url: *const kernel::ffi::c_char,
935935
data: *mut u8,
@@ -980,8 +980,13 @@ pub unsafe extern "C" fn drm_panic_qr_generate(
980980
/// * If `url_len` > 0, remove the 2 segments header/length and also count the
981981
/// conversion to numeric segments.
982982
/// * If `url_len` = 0, only removes 3 bytes for 1 binary segment.
983-
#[no_mangle]
984-
pub extern "C" fn drm_panic_qr_max_data_size(version: u8, url_len: usize) -> usize {
983+
///
984+
/// # Safety
985+
///
986+
/// Always safe to call.
987+
// Required to be unsafe due to the `#[export]` annotation.
988+
#[export]
989+
pub unsafe extern "C" fn drm_panic_qr_max_data_size(version: u8, url_len: usize) -> usize {
985990
#[expect(clippy::manual_range_contains)]
986991
if version < 1 || version > 40 {
987992
return 0;

drivers/net/phy/ax88796b_rust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ kernel::module_phy_driver! {
1919
DeviceId::new_with_driver::<PhyAX88796B>()
2020
],
2121
name: "rust_asix_phy",
22-
author: "FUJITA Tomonori <fujita.tomonori@gmail.com>",
22+
authors: ["FUJITA Tomonori <fujita.tomonori@gmail.com>"],
2323
description: "Rust Asix PHYs driver",
2424
license: "GPL",
2525
}

0 commit comments

Comments
 (0)