Skip to content

Commit db4cd14

Browse files
committed
Merge branch 'bits/190-rust' into asahi-wip
2 parents 97c445d + 9739db6 commit db4cd14

Some content is hidden

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

62 files changed

+5450
-197
lines changed

MAINTAINERS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3997,7 +3997,7 @@ F: drivers/input/touchscreen/atmel_mxt_ts.c
39973997
ATOMIC INFRASTRUCTURE
39983998
M: Will Deacon <will@kernel.org>
39993999
M: Peter Zijlstra <peterz@infradead.org>
4000-
R: Boqun Feng <boqun.feng@gmail.com>
4000+
M: Boqun Feng <boqun.feng@gmail.com>
40014001
R: Mark Rutland <mark.rutland@arm.com>
40024002
L: linux-kernel@vger.kernel.org
40034003
S: Maintained
@@ -4006,6 +4006,8 @@ F: arch/*/include/asm/atomic*.h
40064006
F: include/*/atomic*.h
40074007
F: include/linux/refcount.h
40084008
F: scripts/atomic/
4009+
F: rust/kernel/sync/atomic.rs
4010+
F: rust/kernel/sync/atomic/
40094011

40104012
ATTO EXPRESSSAS SAS/SATA RAID SCSI DRIVER
40114013
M: Bradley Grove <linuxdrivers@attotech.com>
@@ -17137,6 +17139,8 @@ F: include/linux/module*.h
1713717139
F: kernel/module/
1713817140
F: lib/test_kmod.c
1713917141
F: lib/tests/module/
17142+
F: rust/kernel/module_param.rs
17143+
F: rust/macros/module.rs
1714017144
F: scripts/module*
1714117145
F: tools/testing/selftests/kmod/
1714217146
F: tools/testing/selftests/module/

drivers/soc/apple/Kconfig

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

7272
Say 'y' here if you have an Apple SoC.
7373

74+
config RUST_APPLE_RTKIT
75+
bool
76+
depends on RUST
77+
depends on APPLE_RTKIT
78+
7479
endmenu
7580

7681
endif

include/linux/xarray.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ void *__xa_erase(struct xarray *, unsigned long index);
563563
void *__xa_store(struct xarray *, unsigned long index, void *entry, gfp_t);
564564
void *__xa_cmpxchg(struct xarray *, unsigned long index, void *old,
565565
void *entry, gfp_t);
566+
void *__xa_cmpxchg_raw(struct xarray *, unsigned long index, void *old,
567+
void *entry, gfp_t);
566568
int __must_check __xa_insert(struct xarray *, unsigned long index,
567569
void *entry, gfp_t);
568570
int __must_check __xa_alloc(struct xarray *, u32 *id, void *entry,

lib/xarray.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,9 +1738,6 @@ void *xa_store(struct xarray *xa, unsigned long index, void *entry, gfp_t gfp)
17381738
}
17391739
EXPORT_SYMBOL(xa_store);
17401740

1741-
static inline void *__xa_cmpxchg_raw(struct xarray *xa, unsigned long index,
1742-
void *old, void *entry, gfp_t gfp);
1743-
17441741
/**
17451742
* __xa_cmpxchg() - Conditionally replace an entry in the XArray.
17461743
* @xa: XArray.
@@ -1767,7 +1764,29 @@ void *__xa_cmpxchg(struct xarray *xa, unsigned long index,
17671764
}
17681765
EXPORT_SYMBOL(__xa_cmpxchg);
17691766

1770-
static inline void *__xa_cmpxchg_raw(struct xarray *xa, unsigned long index,
1767+
/**
1768+
* __xa_cmpxchg_raw() - Conditionally replace an entry in the XArray.
1769+
* @xa: XArray.
1770+
* @index: Index into array.
1771+
* @old: Old value to test against.
1772+
* @entry: New value to place in array.
1773+
* @gfp: Memory allocation flags.
1774+
*
1775+
* You must already be holding the xa_lock when calling this function.
1776+
* It will drop the lock if needed to allocate memory, and then reacquire
1777+
* it afterwards.
1778+
*
1779+
* If the entry at @index is the same as @old, replace it with @entry.
1780+
* If the return value is equal to @old, then the exchange was successful.
1781+
*
1782+
* This function is the same as __xa_cmpxchg() except that it does not coerce
1783+
* XA_ZERO_ENTRY to NULL on egress.
1784+
*
1785+
* Context: Any context. Expects xa_lock to be held on entry. May
1786+
* release and reacquire xa_lock if @gfp flags permit.
1787+
* Return: The old value at this index or xa_err() if an error happened.
1788+
*/
1789+
void *__xa_cmpxchg_raw(struct xarray *xa, unsigned long index,
17711790
void *old, void *entry, gfp_t gfp)
17721791
{
17731792
XA_STATE(xas, xa, index);
@@ -1787,6 +1806,7 @@ static inline void *__xa_cmpxchg_raw(struct xarray *xa, unsigned long index,
17871806

17881807
return xas_result(&xas, curr);
17891808
}
1809+
EXPORT_SYMBOL(__xa_cmpxchg_raw);
17901810

17911811
/**
17921812
* __xa_insert() - Store this entry in the XArray if no entry is present.

rust/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,17 +544,19 @@ $(obj)/ffi.o: private skip_gendwarfksyms = 1
544544
$(obj)/ffi.o: $(src)/ffi.rs $(obj)/compiler_builtins.o FORCE
545545
+$(call if_changed_rule,rustc_library)
546546

547-
$(obj)/bindings.o: private rustc_target_flags = --extern ffi
547+
$(obj)/bindings.o: private rustc_target_flags = --extern ffi --extern pin_init
548548
$(obj)/bindings.o: $(src)/bindings/lib.rs \
549549
$(obj)/ffi.o \
550+
$(obj)/pin_init.o \
550551
$(obj)/bindings/bindings_generated.rs \
551552
$(obj)/bindings/bindings_helpers_generated.rs FORCE
552553
+$(call if_changed_rule,rustc_library)
553554

554-
$(obj)/uapi.o: private rustc_target_flags = --extern ffi
555+
$(obj)/uapi.o: private rustc_target_flags = --extern ffi --extern pin_init
555556
$(obj)/uapi.o: private skip_gendwarfksyms = 1
556557
$(obj)/uapi.o: $(src)/uapi/lib.rs \
557558
$(obj)/ffi.o \
559+
$(obj)/pin_init.o \
558560
$(obj)/uapi/uapi_generated.rs FORCE
559561
+$(call if_changed_rule,rustc_library)
560562

rust/bindgen_parameters

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@
3434
# We use const helpers to aid bindgen, to avoid conflicts when constants are
3535
# recognized, block generation of the non-helper constants.
3636
--blocklist-item ARCH_SLAB_MINALIGN
37+
38+
# Structs should implement Zeroable when all of their fields do.
39+
--with-derive-custom-struct .*=MaybeZeroable
40+
--with-derive-custom-union .*=MaybeZeroable

rust/bindings/bindings_helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@
5858
#include <linux/jump_label.h>
5959
#include <linux/mdio.h>
6060
#include <linux/miscdevice.h>
61+
#include <linux/of.h>
62+
#include <linux/of_address.h>
6163
#include <linux/of_device.h>
64+
#include <linux/of_reserved_mem.h>
6265
#include <linux/pci.h>
6366
#include <linux/phy.h>
6467
#include <linux/pid_namespace.h>
@@ -71,6 +74,7 @@
7174
#include <linux/sched.h>
7275
#include <linux/security.h>
7376
#include <linux/slab.h>
77+
#include <linux/soc/apple/rtkit.h>
7478
#include <linux/tracepoint.h>
7579
#include <linux/wait.h>
7680
#include <linux/workqueue.h>

rust/bindings/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@
3131
#[allow(clippy::undocumented_unsafe_blocks)]
3232
#[cfg_attr(CONFIG_RUSTC_HAS_UNNECESSARY_TRANSMUTES, allow(unnecessary_transmutes))]
3333
mod bindings_raw {
34+
use pin_init::{MaybeZeroable, Zeroable};
35+
3436
// Manual definition for blocklisted types.
3537
type __kernel_size_t = usize;
3638
type __kernel_ssize_t = isize;
3739
type __kernel_ptrdiff_t = isize;
3840

41+
// `bindgen` doesn't automatically do this, see
42+
// <https://github.com/rust-lang/rust-bindgen/issues/3196>
43+
//
44+
// SAFETY: `__BindgenBitfieldUnit<Storage>` is a newtype around `Storage`.
45+
unsafe impl<Storage> Zeroable for __BindgenBitfieldUnit<Storage> where Storage: Zeroable {}
46+
3947
// Use glob import here to expose all helpers.
4048
// Symbols defined within the module will take precedence to the glob import.
4149
pub use super::bindings_helper::*;

0 commit comments

Comments
 (0)