Skip to content

Commit ebacefb

Browse files
committed
Merge branch 'bits/190-rust' into asahi-wip
2 parents 6f29c29 + 103083a commit ebacefb

138 files changed

Lines changed: 9193 additions & 678 deletions

File tree

Some content is hidden

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

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Ben Widawsky <bwidawsk@kernel.org> <benjamin.widawsky@intel.com>
135135
Benjamin Poirier <benjamin.poirier@gmail.com> <bpoirier@suse.de>
136136
Benjamin Tissoires <bentiss@kernel.org> <benjamin.tissoires@gmail.com>
137137
Benjamin Tissoires <bentiss@kernel.org> <benjamin.tissoires@redhat.com>
138+
Benno Lossin <lossin@kernel.org> <benno.lossin@proton.me>
138139
Bingwu Zhang <xtex@aosc.io> <xtexchooser@duck.com>
139140
Bingwu Zhang <xtex@aosc.io> <xtex@xtexx.eu.org>
140141
Bjorn Andersson <andersson@kernel.org> <bjorn@kryo.se>

Documentation/gpu/nova/core/todo.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@ Usage:
102102
let boot0 = Boot0::read(&bar);
103103
pr_info!("Revision: {}\n", boot0.revision());
104104
105+
Note: a work-in-progress implementation currently resides in
106+
`drivers/gpu/nova-core/regs/macros.rs` and is used in nova-core. It would be
107+
nice to improve it (possibly using proc macros) and move it to the `kernel`
108+
crate so it can be used by other components as well.
109+
105110
| Complexity: Advanced
111+
| Contact: Alexandre Courbot
106112
107113
Delay / Sleep abstractions
108114
--------------------------
@@ -190,16 +196,6 @@ Rust abstraction for debugfs APIs.
190196
| Reference: Export GSP log buffers
191197
| Complexity: Intermediate
192198
193-
Vec extensions
194-
--------------
195-
196-
Implement ``Vec::truncate`` and ``Vec::resize``.
197-
198-
Currently this is used for some experimental code to parse the vBIOS.
199-
200-
| Reference vBIOS support
201-
| Complexity: Beginner
202-
203199
GPU (general)
204200
=============
205201

Documentation/rust/coding-guidelines.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ written after the documentation, e.g.:
8585
// ...
8686
}
8787
88+
This applies to both public and private items. This increases consistency with
89+
public items, allows changes to visibility with less changes involved and will
90+
allow us to potentially generate the documentation for private items as well.
91+
In other words, if documentation is written for a private item, then ``///``
92+
should still be used. For instance:
93+
94+
.. code-block:: rust
95+
96+
/// My private function.
97+
// TODO: ...
98+
fn f() {}
99+
88100
One special kind of comments are the ``// SAFETY:`` comments. These must appear
89101
before every ``unsafe`` block, and they explain why the code inside the block is
90102
correct/sound, i.e. why it cannot trigger undefined behavior in any case, e.g.:
@@ -191,6 +203,23 @@ or:
191203
/// [`struct mutex`]: srctree/include/linux/mutex.h
192204
193205
206+
C FFI types
207+
-----------
208+
209+
Rust kernel code refers to C types, such as ``int``, using type aliases such as
210+
``c_int``, which are readily available from the ``kernel`` prelude. Please do
211+
not use the aliases from ``core::ffi`` -- they may not map to the correct types.
212+
213+
These aliases should generally be referred directly by their identifier, i.e.
214+
as a single segment path. For instance:
215+
216+
.. code-block:: rust
217+
218+
fn f(p: *const c_char) -> c_int {
219+
// ...
220+
}
221+
222+
194223
Naming
195224
------
196225

Documentation/rust/quick-start.rst

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,53 @@ they should generally work out of the box, e.g.::
9090
Ubuntu
9191
******
9292

93-
Ubuntu LTS and non-LTS (interim) releases provide recent Rust releases and thus
94-
they should generally work out of the box, e.g.::
93+
25.04
94+
~~~~~
95+
96+
The latest Ubuntu releases provide recent Rust releases and thus they should
97+
generally work out of the box, e.g.::
98+
99+
apt install rustc rust-src bindgen rustfmt rust-clippy
100+
101+
In addition, ``RUST_LIB_SRC`` needs to be set, e.g.::
102+
103+
RUST_LIB_SRC=/usr/src/rustc-$(rustc --version | cut -d' ' -f2)/library
104+
105+
For convenience, ``RUST_LIB_SRC`` can be exported to the global environment.
95106

96-
apt install rustc-1.80 rust-1.80-src bindgen-0.65 rustfmt-1.80 rust-1.80-clippy
107+
108+
24.04 LTS and older
109+
~~~~~~~~~~~~~~~~~~~
110+
111+
Though Ubuntu 24.04 LTS and older versions still provide recent Rust
112+
releases, they require some additional configuration to be set, using
113+
the versioned packages, e.g.::
114+
115+
apt install rustc-1.80 rust-1.80-src bindgen-0.65 rustfmt-1.80 \
116+
rust-1.80-clippy
117+
ln -s /usr/lib/rust-1.80/bin/rustfmt /usr/bin/rustfmt-1.80
118+
ln -s /usr/lib/rust-1.80/bin/clippy-driver /usr/bin/clippy-driver-1.80
119+
120+
None of these packages set their tools as defaults; therefore they should be
121+
specified explicitly, e.g.::
122+
123+
make LLVM=1 RUSTC=rustc-1.80 RUSTDOC=rustdoc-1.80 RUSTFMT=rustfmt-1.80 \
124+
CLIPPY_DRIVER=clippy-driver-1.80 BINDGEN=bindgen-0.65
125+
126+
Alternatively, modify the ``PATH`` variable to place the Rust 1.80 binaries
127+
first and set ``bindgen`` as the default, e.g.::
128+
129+
PATH=/usr/lib/rust-1.80/bin:$PATH
130+
update-alternatives --install /usr/bin/bindgen bindgen \
131+
/usr/bin/bindgen-0.65 100
132+
update-alternatives --set bindgen /usr/bin/bindgen-0.65
97133

98134
``RUST_LIB_SRC`` needs to be set when using the versioned packages, e.g.::
99135

100136
RUST_LIB_SRC=/usr/src/rustc-$(rustc-1.80 --version | cut -d' ' -f2)/library
101137

138+
For convenience, ``RUST_LIB_SRC`` can be exported to the global environment.
139+
102140
In addition, ``bindgen-0.65`` is available in newer releases (24.04 LTS and
103141
24.10), but it may not be available in older ones (20.04 LTS and 22.04 LTS),
104142
thus ``bindgen`` may need to be built manually (please see below).

Documentation/rust/testing.rst

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,85 @@ please see:
133133
The ``#[test]`` tests
134134
---------------------
135135

136-
Additionally, there are the ``#[test]`` tests. These can be run using the
137-
``rusttest`` Make target::
136+
Additionally, there are the ``#[test]`` tests. Like for documentation tests,
137+
these are also fairly similar to what you would expect from userspace, and they
138+
are also mapped to KUnit.
139+
140+
These tests are introduced by the ``kunit_tests`` procedural macro, which takes
141+
the name of the test suite as an argument.
142+
143+
For instance, assume we want to test the function ``f`` from the documentation
144+
tests section. We could write, in the same file where we have our function:
145+
146+
.. code-block:: rust
147+
148+
#[kunit_tests(rust_kernel_mymod)]
149+
mod tests {
150+
use super::*;
151+
152+
#[test]
153+
fn test_f() {
154+
assert_eq!(f(10, 20), 30);
155+
}
156+
}
157+
158+
And if we run it, the kernel log would look like::
159+
160+
KTAP version 1
161+
# Subtest: rust_kernel_mymod
162+
# speed: normal
163+
1..1
164+
# test_f.speed: normal
165+
ok 1 test_f
166+
ok 1 rust_kernel_mymod
167+
168+
Like documentation tests, the ``assert!`` and ``assert_eq!`` macros are mapped
169+
back to KUnit and do not panic. Similarly, the
170+
`? <https://doc.rust-lang.org/reference/expressions/operator-expr.html#the-question-mark-operator>`_
171+
operator is supported, i.e. the test functions may return either nothing (i.e.
172+
the unit type ``()``) or ``Result`` (i.e. any ``Result<T, E>``). For instance:
173+
174+
.. code-block:: rust
175+
176+
#[kunit_tests(rust_kernel_mymod)]
177+
mod tests {
178+
use super::*;
179+
180+
#[test]
181+
fn test_g() -> Result {
182+
let x = g()?;
183+
assert_eq!(x, 30);
184+
Ok(())
185+
}
186+
}
187+
188+
If we run the test and the call to ``g`` fails, then the kernel log would show::
189+
190+
KTAP version 1
191+
# Subtest: rust_kernel_mymod
192+
# speed: normal
193+
1..1
194+
# test_g: ASSERTION FAILED at rust/kernel/lib.rs:335
195+
Expected is_test_result_ok(test_g()) to be true, but is false
196+
# test_g.speed: normal
197+
not ok 1 test_g
198+
not ok 1 rust_kernel_mymod
199+
200+
If a ``#[test]`` test could be useful as an example for the user, then please
201+
use a documentation test instead. Even edge cases of an API, e.g. error or
202+
boundary cases, can be interesting to show in examples.
203+
204+
The ``rusttest`` host tests
205+
---------------------------
206+
207+
These are userspace tests that can be built and run in the host (i.e. the one
208+
that performs the kernel build) using the ``rusttest`` Make target::
138209

139210
make LLVM=1 rusttest
140211

141-
This requires the kernel ``.config``. It runs the ``#[test]`` tests on the host
142-
(currently) and thus is fairly limited in what these tests can test.
212+
This requires the kernel ``.config``.
213+
214+
Currently, they are mostly used for testing the ``macros`` crate's examples.
143215

144216
The Kselftests
145217
--------------

MAINTAINERS

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3894,6 +3894,9 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
38943894
F: Documentation/driver-api/auxiliary_bus.rst
38953895
F: drivers/base/auxiliary.c
38963896
F: include/linux/auxiliary_bus.h
3897+
F: rust/helpers/auxiliary.c
3898+
F: rust/kernel/auxiliary.rs
3899+
F: samples/rust/rust_driver_auxiliary.rs
38973900

38983901
AUXILIARY DISPLAY DRIVERS
38993902
M: Andy Shevchenko <andy@kernel.org>
@@ -7263,6 +7266,7 @@ F: include/linux/property.h
72637266
F: include/linux/sysfs.h
72647267
F: lib/kobj*
72657268
F: rust/kernel/device.rs
7269+
F: rust/kernel/device/
72667270
F: rust/kernel/device_id.rs
72677271
F: rust/kernel/devres.rs
72687272
F: rust/kernel/driver.rs
@@ -7615,6 +7619,18 @@ T: git https://gitlab.freedesktop.org/drm/nova.git nova-next
76157619
F: Documentation/gpu/nova/
76167620
F: drivers/gpu/nova-core/
76177621

7622+
DRM DRIVER FOR NVIDIA GPUS [RUST]
7623+
M: Danilo Krummrich <dakr@kernel.org>
7624+
L: nouveau@lists.freedesktop.org
7625+
S: Supported
7626+
Q: https://patchwork.freedesktop.org/project/nouveau/
7627+
B: https://gitlab.freedesktop.org/drm/nova/-/issues
7628+
C: irc://irc.oftc.net/nouveau
7629+
T: git https://gitlab.freedesktop.org/drm/nova.git nova-next
7630+
F: Documentation/gpu/nova/
7631+
F: drivers/gpu/drm/nova/
7632+
F: include/uapi/drm/nova_drm.h
7633+
76187634
DRM DRIVER FOR OLIMEX LCD-OLINUXINO PANELS
76197635
M: Stefan Mavrodiev <stefan@olimex.com>
76207636
S: Maintained
@@ -7822,6 +7838,7 @@ F: Documentation/devicetree/bindings/display/
78227838
F: Documentation/devicetree/bindings/gpu/
78237839
F: Documentation/gpu/
78247840
F: drivers/gpu/
7841+
F: rust/kernel/drm/
78257842
F: include/drm/
78267843
F: include/linux/vga*
78277844
F: include/uapi/drm/
@@ -7838,6 +7855,7 @@ F: Documentation/devicetree/bindings/gpu/
78387855
F: Documentation/gpu/
78397856
F: drivers/gpu/drm/
78407857
F: drivers/gpu/vga/
7858+
F: rust/kernel/drm/
78417859
F: include/drm/drm
78427860
F: include/linux/vga*
78437861
F: include/uapi/drm/
@@ -10623,20 +10641,23 @@ F: kernel/time/timer_list.c
1062310641
F: kernel/time/timer_migration.*
1062410642
F: tools/testing/selftests/timers/
1062510643

10626-
HIGH-RESOLUTION TIMERS [RUST]
10644+
DELAY, SLEEP, TIMEKEEPING, TIMERS [RUST]
1062710645
M: Andreas Hindborg <a.hindborg@kernel.org>
1062810646
R: Boqun Feng <boqun.feng@gmail.com>
10647+
R: FUJITA Tomonori <fujita.tomonori@gmail.com>
1062910648
R: Frederic Weisbecker <frederic@kernel.org>
1063010649
R: Lyude Paul <lyude@redhat.com>
1063110650
R: Thomas Gleixner <tglx@linutronix.de>
1063210651
R: Anna-Maria Behnsen <anna-maria@linutronix.de>
10652+
R: John Stultz <jstultz@google.com>
10653+
R: Stephen Boyd <sboyd@kernel.org>
1063310654
L: rust-for-linux@vger.kernel.org
1063410655
S: Supported
1063510656
W: https://rust-for-linux.com
1063610657
B: https://github.com/Rust-for-Linux/linux/issues
10637-
T: git https://github.com/Rust-for-Linux/linux.git hrtimer-next
10638-
F: rust/kernel/time/hrtimer.rs
10639-
F: rust/kernel/time/hrtimer/
10658+
T: git https://github.com/Rust-for-Linux/linux.git timekeeping-next
10659+
F: rust/kernel/time.rs
10660+
F: rust/kernel/time/
1064010661

1064110662
HIGH-SPEED SCC DRIVER FOR AX.25
1064210663
L: linux-hams@vger.kernel.org
@@ -16545,6 +16566,8 @@ F: include/linux/module*.h
1654516566
F: kernel/module/
1654616567
F: lib/test_kmod.c
1654716568
F: lib/tests/module/
16569+
F: rust/kernel/module_param.rs
16570+
F: rust/macros/module.rs
1654816571
F: scripts/module*
1654916572
F: tools/testing/selftests/kmod/
1655016573
F: tools/testing/selftests/module/
@@ -21343,7 +21366,7 @@ M: Alex Gaynor <alex.gaynor@gmail.com>
2134321366
R: Boqun Feng <boqun.feng@gmail.com>
2134421367
R: Gary Guo <gary@garyguo.net>
2134521368
R: Björn Roy Baron <bjorn3_gh@protonmail.com>
21346-
R: Benno Lossin <benno.lossin@proton.me>
21369+
R: Benno Lossin <lossin@kernel.org>
2134721370
R: Andreas Hindborg <a.hindborg@kernel.org>
2134821371
R: Alice Ryhl <aliceryhl@google.com>
2134921372
R: Trevor Gross <tmgross@umich.edu>
@@ -21373,7 +21396,7 @@ F: rust/kernel/alloc.rs
2137321396
F: rust/kernel/alloc/
2137421397

2137521398
RUST [PIN-INIT]
21376-
M: Benno Lossin <benno.lossin@proton.me>
21399+
M: Benno Lossin <lossin@kernel.org>
2137721400
L: rust-for-linux@vger.kernel.org
2137821401
S: Maintained
2137921402
W: https://rust-for-linux.com/pin-init
@@ -26495,6 +26518,17 @@ F: lib/test_xarray.c
2649526518
F: lib/xarray.c
2649626519
F: tools/testing/radix-tree
2649726520

26521+
XARRAY API [RUST]
26522+
M: Tamir Duberstein <tamird@gmail.com>
26523+
M: Andreas Hindborg <a.hindborg@kernel.org>
26524+
L: rust-for-linux@vger.kernel.org
26525+
S: Supported
26526+
W: https://rust-for-linux.com
26527+
B: https://github.com/Rust-for-Linux/linux/issues
26528+
C: https://rust-for-linux.zulipchat.com
26529+
T: git https://github.com/Rust-for-Linux/linux.git xarray-next
26530+
F: rust/kernel/xarray.rs
26531+
2649826532
XBOX DVD IR REMOTE
2649926533
M: Benjamin Valentin <benpicco@googlemail.com>
2650026534
S: Maintained

drivers/gpu/drm/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ source "drivers/gpu/drm/amd/amdgpu/Kconfig"
343343

344344
source "drivers/gpu/drm/nouveau/Kconfig"
345345

346+
source "drivers/gpu/drm/nova/Kconfig"
347+
346348
source "drivers/gpu/drm/i915/Kconfig"
347349

348350
source "drivers/gpu/drm/xe/Kconfig"

drivers/gpu/drm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/
176176
obj-$(CONFIG_DRM_VGEM) += vgem/
177177
obj-$(CONFIG_DRM_VKMS) += vkms/
178178
obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/
179+
obj-$(CONFIG_DRM_NOVA) += nova/
179180
obj-$(CONFIG_DRM_EXYNOS) +=exynos/
180181
obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/
181182
obj-$(CONFIG_DRM_GMA500) += gma500/

0 commit comments

Comments
 (0)