Skip to content

rust: samples: fix init argument - #335

Closed
Bruno-Eduardo wants to merge 1040 commits into
AsahiLinux:asahifrom
Bruno-Eduardo:asahi
Closed

Bruno-Eduardo wants to merge 1040 commits into
AsahiLinux:asahifrom
Bruno-Eduardo:asahi

Conversation

@Bruno-Eduardo

Copy link
Copy Markdown

I was trying to compile the rust_minimal for arm64 using asahi rust/kernel and found the following error:

$ make CROSS_COMPILE="aarch64-linux-gnu-" ARCH=arm64 LLVM=1 ./samples/rust/rust_minimal.o
  CALL    scripts/checksyscalls.sh
  RUSTC [M] samples/rust/rust_minimal.o
error[E0050]: method `init` has 1 parameter but the declaration in trait `kernel::Module::init` has 2
  --> /largeFiles/linux_asahi/samples/rust/rust_minimal.rs:20:22
   |
20 |     fn init(_module: &'static ThisModule) -> Result<Self> {
   |                      ^^^^^^^^^^^^^^^^^^^ expected 2 parameters, found 1
   |
   = note: `init` from trait: `fn(&'static kernel::prelude::CStr, &'static kernel::ThisModule) -> core::result::Result<Self, kernel::error::Error>`

error: aborting due to 1 previous error

And an equivalent error for ./samples/rust/rust_print.o

After commit c96b547:
rust: Addname argument to Module::init()
init needs a name argument. Since both rust samples were made
before that, they fail to compile.

After fix:

$ make CROSS_COMPILE="aarch64-linux-gnu-" ARCH=arm64 LLVM=1 ./samples/rust/rust_minimal.o
  CALL    scripts/checksyscalls.sh
  RUSTC [M] samples/rust/rust_minimal.o
$ make CROSS_COMPILE="aarch64-linux-gnu-" ARCH=arm64 LLVM=1 ./samples/rust/rust_print.o
  CALL    scripts/checksyscalls.sh
  RUSTC [M] samples/rust/rust_print.o

jannau and others added 30 commits September 16, 2024 13:46
Prevents KDE for now to set modes not reported by IOMFB. Seen on j493
with the common display resolution of 2560x1600.

Signed-off-by: Janne Grunau <[email protected]>
Apparently what happens here is that the DCP's idea of backlight
brightness is desynced with the real brightness across power cycles.
This means that even if we just force an update after a power cycle, it
doesn't work since it considers it unchanged. To fix this, we need to
both force an update on poweron and also explicitly turn the backlight
off on poweroff, which makes DCP listen to us and actually update the
backlight state properly.

Signed-off-by: Asahi Lina <[email protected]>
…ated

On non mini-LED displays the backlight comes out of power-off (DPMS)
with minimal backlight brightness. This seems to be a DCP firmware
issue. It logs "[BrightnessLCD.cpp:743][AFK]nitsToDBV: iDAC out of
range" to syslog although the brightness in the swap_submit call is
valid.

This fixes the issue only for clients using swap. For other clients an
atomic backlight update has to be scheduled via a work queue.

Signed-off-by: Janne Grunau <[email protected]>
The hardware does not have a vblank IRQ and drm already knows how to
deal with that appropriately, so don't pretend it does.

Fixes Xorg.

Signed-off-by: Asahi Lina <[email protected]>
Selecting the mode with the highest score may result in HDR mode for
some displays. Since HDR is not support on driver side this produces
an unexpected color representation.
Full parsing allows us to reject virtual color modes (should already be
invalid due to missing "Score").
Preparation for color and timing mode tracing.

Signed-off-by: Janne Grunau <[email protected]>
Prevents trace points of unused color modes.

Signed-off-by: Janne Grunau <[email protected]>
Restrict symbol mapping for EOTF, pixel encoding and colorimetry to
tracing due to low confidence that it is correct. Main concern is the
colorimetry mapping.

Signed-off-by: Janne Grunau <[email protected]>
DCP best scored color mode might result in an HDR mode. As long as the
driver (and DRM) is not ready for HDR try to avoid such modes.

Signed-off-by: Janne Grunau <[email protected]>
Probably not important but avoids an unnecessary difference compred to
macOS.

Signed-off-by: Janne Grunau <[email protected]>
Seems to work now with 'surface.colorspace = 12'.

Signed-off-by: Janne Grunau <[email protected]>
Can be used on devices with camera notch to use the full display height
and thus show the notch.

Signed-off-by: Janne Grunau <[email protected]>
This reverts commit d395421.

'w30r' is a wide gammut mode. As long as the display is SDR DCP will end
up displaying picture correctly but on HDR displays like the display in
the Macbook Pro 14"/16" (2021) or external displays with HDR EOTF the
picture has oversaturated / black colors.

The non-wide gammut 10-bit per component pixelformats "l10r" and "R10k"
 are not supported.

Signed-off-by: Janne Grunau <[email protected]>
This works on both 8-bit and 10-bit modes without any weirdness, and
gives us the native colorspace without any conversion. Color correction
should probably be handled in software anyway.

However, we need to use surface 1 (at least on t600x), since 0 seems
stuck in bg-sRGB mode for some reason...

Signed-off-by: Hector Martin <[email protected]>
With "drm/apple: Enable 10-bit mode & set colorspace to native" kernel
log messages are shown in an Apple logo shaped region in the middle of
the display when using BGRA.
The field currently identified as "opaque" is mislabeled and has to be
investigated further.

Signed-off-by: Janne Grunau <[email protected]>
- opaque -> is_premultiplied
- swap_enabled BIT(31) seems to be update background with
  dcp_swap.bg_color
- add unused fields is_tearing_allowed, ycbcr_matrix, protection_opts,
  unk_num, unk_denom

Changes: use is_premultiplied only for XRGB8/XBGR8, Update background
only when necessary.

Signed-off-by: Janne Grunau <[email protected]>
This does not seem to be as racy as drm_aperture_remove_framebuffers()
and seems to reliably takes over simpledrm's device node.

Signed-off-by: Janne Grunau <[email protected]>
This check for the "nomodeset" kernel command line parameter in its
register method.

Signed-off-by: Janne Grunau <[email protected]>
drm's documentaion explicitly tells us not to use devm_kzalloc(). drm
device structures might out live the device when they are in use by
userspace while the device vanishes.
There was a report of a race between DRM device registration (and
removal of the simpledrm device) and GDM startup.

The component based device binding ensures that all necessary devices
are bind in the probe method of the last missing component.

Technically the piodma-mapper should be a component of dcp but since it
is only used for its iommu it can be a component of the display
subsystem.

Signed-off-by: Janne Grunau <[email protected]>
Avoids "[drm] Cannot find any crtc or sizes" during fbdev initialization
if a display is connected.

Signed-off-by: Janne Grunau <[email protected]>
Fixes following warning when systemd-backlight restores the backlight
level on boot before a mode is set:

Call trace:
  drm_atomic_helper_crtc_duplicate_state+0x58/0x74
  drm_atomic_get_crtc_state+0x84/0x120
  dcp_set_brightness+0xd8/0x21c [apple_dcp]
  backlight_device_set_brightness+0x78/0x130
  ...

Signed-off-by: Janne Grunau <[email protected]>
After commit c96b547:
    rust: Add `name` argument to Module::init()
init needs a name argument. Since both rust samples were made
    before that, they fail to compile.

Signed-off-by: Bruno Oliveira <[email protected]>
@furkanmustafa

Copy link
Copy Markdown

Is this related with Asahi kernel? Seems like samples/rust/rust_minimal is an upstream thing, and mostly about Rust. not Asahi.

@jannau

jannau commented Apr 11, 2025

Copy link
Copy Markdown
Member

the offending changes are dropped from the current asahi tree. It was an incompatibility between upstream rust and patches in the asahi tree

@jannau jannau closed this Apr 11, 2025
jannau pushed a commit that referenced this pull request Oct 16, 2025
[ Upstream commit 6fc6167 ]

Current code will validate current plane and previous plane to
confirm they can share a SSPP with multi-rect mode. The SSPP
is already allocated for previous plane, while current plane
is not associated with any SSPP yet. Null pointer is referenced
when validating the SSPP of current plane. Skip SSPP validation
for current plane.

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
Mem abort info:
  ESR = 0x0000000096000004
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x04: level 0 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=0000000888ac3000
[0000000000000020] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1]  SMP
Modules linked in:
CPU: 4 UID: 0 PID: 1891 Comm: modetest Tainted: G S                  6.15.0-rc2-g3ee3f6e1202e #335 PREEMPT
Tainted: [S]=CPU_OUT_OF_SPEC
Hardware name: SM8650 EV1 rev1 4slam 2et (DT)
pstate: 63400009 (nZCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : dpu_plane_is_multirect_capable+0x68/0x90
lr : dpu_assign_plane_resources+0x288/0x410
sp : ffff800093dcb770
x29: ffff800093dcb770 x28: 0000000000002000 x27: ffff000817c6c000
x26: ffff000806b46368 x25: ffff0008013f6080 x24: ffff00080cbf4800
x23: ffff000810842680 x22: ffff0008013f1080 x21: ffff00080cc86080
x20: ffff000806b463b0 x19: ffff00080cbf5a00 x18: 00000000ffffffff
x17: 707a5f657a696c61 x16: 0000000000000003 x15: 0000000000002200
x14: 00000000ffffffff x13: 00aaaaaa00aaaaaa x12: 0000000000000000
x11: ffff000817c6e2b8 x10: 0000000000000000 x9 : ffff80008106a950
x8 : ffff00080cbf48f4 x7 : 0000000000000000 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000438 x3 : 0000000000000438
x2 : ffff800082e245e0 x1 : 0000000000000008 x0 : 0000000000000000
Call trace:
 dpu_plane_is_multirect_capable+0x68/0x90 (P)
 dpu_crtc_atomic_check+0x5bc/0x650
 drm_atomic_helper_check_planes+0x13c/0x220
 drm_atomic_helper_check+0x58/0xb8
 msm_atomic_check+0xd8/0xf0
 drm_atomic_check_only+0x4a8/0x968
 drm_atomic_commit+0x50/0xd8
 drm_atomic_helper_update_plane+0x140/0x188
 __setplane_atomic+0xfc/0x148
 drm_mode_setplane+0x164/0x378
 drm_ioctl_kernel+0xc0/0x140
 drm_ioctl+0x20c/0x500
 __arm64_sys_ioctl+0xbc/0xf8
 invoke_syscall+0x50/0x120
 el0_svc_common.constprop.0+0x48/0xf8
 do_el0_svc+0x28/0x40
 el0_svc+0x30/0xd0
 el0t_64_sync_handler+0x144/0x168
 el0t_64_sync+0x198/0x1a0
Code: b9402021 370fffc1 f9401441 3707ff81 (f94010a1)
---[ end trace 0000000000000000 ]---

Fixes: 3ed12a3 ("drm/msm/dpu: allow sharing SSPP between planes")
Signed-off-by: Jun Nie <[email protected]>
Patchwork: https://patchwork.freedesktop.org/patch/669224/
Link: https://lore.kernel.org/r/20250819-v6-16-rc2-quad-pipe-upstream-v15-1-2c7a85089db8@linaro.org
Signed-off-by: Dmitry Baryshkov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
sofus13 pushed a commit to sofus13/linux that referenced this pull request Jun 5, 2026
Current code will validate current plane and previous plane to
confirm they can share a SSPP with multi-rect mode. The SSPP
is already allocated for previous plane, while current plane
is not associated with any SSPP yet. Null pointer is referenced
when validating the SSPP of current plane. Skip SSPP validation
for current plane.

Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
Mem abort info:
  ESR = 0x0000000096000004
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x04: level 0 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=0000000888ac3000
[0000000000000020] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1]  SMP
Modules linked in:
CPU: 4 UID: 0 PID: 1891 Comm: modetest Tainted: G S                  6.15.0-rc2-g3ee3f6e1202e AsahiLinux#335 PREEMPT
Tainted: [S]=CPU_OUT_OF_SPEC
Hardware name: SM8650 EV1 rev1 4slam 2et (DT)
pstate: 63400009 (nZCv daif +PAN -UAO +TCO +DIT -SSBS BTYPE=--)
pc : dpu_plane_is_multirect_capable+0x68/0x90
lr : dpu_assign_plane_resources+0x288/0x410
sp : ffff800093dcb770
x29: ffff800093dcb770 x28: 0000000000002000 x27: ffff000817c6c000
x26: ffff000806b46368 x25: ffff0008013f6080 x24: ffff00080cbf4800
x23: ffff000810842680 x22: ffff0008013f1080 x21: ffff00080cc86080
x20: ffff000806b463b0 x19: ffff00080cbf5a00 x18: 00000000ffffffff
x17: 707a5f657a696c61 x16: 0000000000000003 x15: 0000000000002200
x14: 00000000ffffffff x13: 00aaaaaa00aaaaaa x12: 0000000000000000
x11: ffff000817c6e2b8 x10: 0000000000000000 x9 : ffff80008106a950
x8 : ffff00080cbf48f4 x7 : 0000000000000000 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000438 x3 : 0000000000000438
x2 : ffff800082e245e0 x1 : 0000000000000008 x0 : 0000000000000000
Call trace:
 dpu_plane_is_multirect_capable+0x68/0x90 (P)
 dpu_crtc_atomic_check+0x5bc/0x650
 drm_atomic_helper_check_planes+0x13c/0x220
 drm_atomic_helper_check+0x58/0xb8
 msm_atomic_check+0xd8/0xf0
 drm_atomic_check_only+0x4a8/0x968
 drm_atomic_commit+0x50/0xd8
 drm_atomic_helper_update_plane+0x140/0x188
 __setplane_atomic+0xfc/0x148
 drm_mode_setplane+0x164/0x378
 drm_ioctl_kernel+0xc0/0x140
 drm_ioctl+0x20c/0x500
 __arm64_sys_ioctl+0xbc/0xf8
 invoke_syscall+0x50/0x120
 el0_svc_common.constprop.0+0x48/0xf8
 do_el0_svc+0x28/0x40
 el0_svc+0x30/0xd0
 el0t_64_sync_handler+0x144/0x168
 el0t_64_sync+0x198/0x1a0
Code: b9402021 370fffc1 f9401441 3707ff81 (f94010a1)
---[ end trace 0000000000000000 ]---

Fixes: 3ed12a3 ("drm/msm/dpu: allow sharing SSPP between planes")
Signed-off-by: Jun Nie <[email protected]>
Patchwork: https://patchwork.freedesktop.org/patch/669224/
Link: https://lore.kernel.org/r/20250819-v6-16-rc2-quad-pipe-upstream-v15-1-2c7a85089db8@linaro.org
Signed-off-by: Dmitry Baryshkov <[email protected]>
joshuaswarren added a commit to joshuaswarren/linux-aurora that referenced this pull request Nov 14, 2026
Killing a process that has two compute submissions queued made the GPU
fault on an unmapped read, then time out and recover (issue AsahiLinux#335, 15 of
15 kills on an M1). Closing the client's file unmapped the VM and freed
its resources while accepted jobs could still read them.

A job now owns the VM resources it uses. Every command keeps a job guard
and the VM binding until the firmware reports it complete, and the guard
counts accepted jobs so the VM drains deferred unmaps and object closes
only when the last one retires. The VM also keeps its fixed kernel
alias (the dummy mapping) for the same period.

Tracking was previously attached only to G15 and later. It is now
attached to every user VM, so G13 and G14 defer file-close cleanup the
same way. unbind_gem_object() queues a closed buffer on every VM of the
file, mapped or not, until that VM next goes idle. Vm::drop() uses one
close path for all backends, and the VM-create failure guard runs for
all of them.

After a firmware crash no confirmed GPU stop exists. fail_all() now
quarantines the VM before the failed fences become visible, then leaves
the failed commands pinned. Their VM resources stay allocated until
reboot. This leaks them on each crash. Freeing them while the GPU might
still be running is the bug being fixed.

Add a selftest that kills a process with compute work queued. On a
16-inch M1 Max, kernel 7.2.11-sigkill-lab-ARCH passed 20 of 20 SIGKILL
runs with zero GPU faults, timeouts or teardown errors. One SIGKILL on
the baseline 7.1.12-2-20261103.2-lab-ARCH logged 17 GPU timeout lines.
The selftest covers queued compute work and process close. It does not
cover render jobs or explicit VM_BIND unbind.

Closes AsahiLinux#335

Signed-off-by: Joshua Warren <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.