Skip to content

Commit cccfc24

Browse files
committed
Merge branch 'bits/190-rust' into asahi-wip
2 parents f71fbb6 + a8d61fa commit cccfc24

46 files changed

Lines changed: 3653 additions & 103 deletions

Some content is hidden

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

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17432,6 +17432,8 @@ F: include/linux/module*.h
1743217432
F: kernel/module/
1743317433
F: lib/test_kmod.c
1743417434
F: lib/tests/module/
17435+
F: rust/kernel/module_param.rs
17436+
F: rust/macros/module.rs
1743517437
F: scripts/module*
1743617438
F: tools/testing/selftests/kmod/
1743717439
F: tools/testing/selftests/module/

drivers/soc/apple/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ config APPLE_SART
7272

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

75+
config RUST_APPLE_RTKIT
76+
bool
77+
depends on PM
78+
depends on RUST
79+
select APPLE_RTKIT
80+
7581
endmenu
7682

7783
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/bindings/bindings_helper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@
6464
#include <linux/mdio.h>
6565
#include <linux/mm.h>
6666
#include <linux/miscdevice.h>
67+
#include <linux/of.h>
68+
#include <linux/of_address.h>
6769
#include <linux/of_device.h>
70+
#include <linux/of_reserved_mem.h>
6871
#include <linux/pci.h>
6972
#include <linux/phy.h>
7073
#include <linux/pid_namespace.h>
@@ -78,6 +81,7 @@
7881
#include <linux/sched.h>
7982
#include <linux/security.h>
8083
#include <linux/slab.h>
84+
#include <linux/soc/apple/rtkit.h>
8185
#include <linux/task_work.h>
8286
#include <linux/tracepoint.h>
8387
#include <linux/wait.h>

rust/helpers/device.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ void rust_helper_dev_set_drvdata(struct device *dev, void *data)
2525
{
2626
dev_set_drvdata(dev, data);
2727
}
28+
29+
void rust_helper_device_lock(struct device *dev)
30+
{
31+
device_lock(dev);
32+
}
33+
34+
void rust_helper_device_unlock(struct device *dev)
35+
{
36+
device_unlock(dev);
37+
}

rust/helpers/dma-mapping.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/dma-mapping.h>
4+
5+
int rust_helper_dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
6+
{
7+
return dma_mapping_error(dev, dma_addr);
8+
}

rust/helpers/helpers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525
#include "cred.c"
2626
#include "device.c"
2727
#include "dma.c"
28+
#include "dma-mapping.c"
2829
#include "drm.c"
2930
#include "err.c"
3031
#include "irq.c"
3132
#include "fs.c"
3233
#include "io.c"
34+
#include "iosys_map.c"
3335
#include "jump_label.c"
3436
#include "kunit.c"
3537
#include "maple_tree.c"

rust/helpers/io.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ void rust_helper_iounmap(void __iomem *addr)
1818
iounmap(addr);
1919
}
2020

21+
void rust_helper_memcpy_fromio(void *to, const void __iomem *from, long count)
22+
{
23+
memcpy_fromio(to, from, count);
24+
}
25+
26+
void rust_helper_memcpy_toio(void __iomem *to, const void *from, size_t count)
27+
{
28+
memcpy_toio(to, from, count);
29+
}
30+
2131
u8 rust_helper_readb(const void __iomem *addr)
2232
{
2333
return readb(addr);

rust/helpers/iosys_map.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/iosys-map.h>
4+
5+
void rust_helper_iosys_map_memcpy_to(struct iosys_map *dst, size_t dst_offset,
6+
const void *src, size_t len)
7+
{
8+
iosys_map_memcpy_to(dst, dst_offset, src, len);
9+
}
10+
11+
void rust_helper_iosys_map_memcpy_from(void *dst, const struct iosys_map *src,
12+
size_t src_offset, size_t len)
13+
{
14+
iosys_map_memcpy_from(dst, src, src_offset, len);
15+
}
16+
17+
void rust_helper_iosys_map_memset(struct iosys_map *dst, size_t offset,
18+
int value, size_t len)
19+
{
20+
iosys_map_memset(dst, offset, value, len);
21+
}

0 commit comments

Comments
 (0)