Commit graph

2142 commits

Author SHA1 Message Date
Janne Grunau
2b92f4b1c3 hv/dcp: Add OOB ASYNC call context
Only observed with dcp/dptx in linux after initialisation and reset in
m1n1. On the initial startup dcp sends two D576 (hotPlug_notify_gated)
presumendly due to state confusion due to  the multiple dptx
connections.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Janne Grunau
5006e083c7 display: Use dcpext0 for HDMI out on t8112/t6020/t6021
dcpext0 behaves like dcp on M1* devices and can sleep after display
init. This has the advantage of not breaking macOS when starting with an
initialized display.
dcpext* are according to Apple's tech specs slightly more powerful than
dcp. They are advertised as 6K at 60Hz while dcp seems to be limited to
5K at 60Hz.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Janne Grunau
5245fc6a58 dcp: Pass the die number for dptx' connectTo method
Apperently just informative as display init on M2 Ultra in m1n1 worked
as expected despite passing '0' as die number.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Janne Grunau
ba69847862 display: Add NO_DISPLAY build config to skip display init
Required for stage 1 loader to allow chainloaded display/dcp experiments
to start with the state left by iboot.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Janne Grunau
30485ead25 build: Increase stack usage warning to 2048
Same value as the arm64 kernel build uses.
Avoids following warning:

 | src/tinf/tinflate.c: In function ‘tinf_uncompress’:
 | src/tinf/tinflate.c:559:5: warning: stack usage is 1712 bytes [-Wstack-usage=]
 |   559 | int tinf_uncompress(void *dest, unsigned int *destLen,

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-27 13:33:08 +09:00
Daniel Berlin
b48c6d2ea4 Add ipython shell to proxyclient
Same functionality as the readline shell, but based on
ipython so that it has nicer help/autocomplete/etc

Signed-off-by: Daniel Berlin <dberlin@dberlin.org>
2023-11-27 13:30:27 +09:00
Janne Grunau
232836bd64 kboot_gpu: Declare GPU firmware 13.6.2 as 13.5 compatible
Tested on t6001-j314c.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-15 12:13:00 +09:00
Janne Grunau
65185bd306 kboot: Declare DCP firmware 13.6.2 as 13.5 compatible
Tested on t6001-j314c.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-15 12:13:00 +09:00
Janne Grunau
0a8aa3da87 isp: Declare 13.6.2 firmware as 13.5 compatible on t600x/t602x
Tested on t6001-j314c.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-15 12:13:00 +09:00
Janne Grunau
630c62785a firmware: Add 13.6.2 and 14.1.1 firmware versions
Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-15 12:13:00 +09:00
Daniel Berlin
a925356096 Add initial M3 values for CPU_START_OFF
I only can easily find the T6031/T6034/T8122 values.
If there is a T6030, the value is not in the same place I found these.

Signed-off-by: Daniel Berlin <dberlin@dberlin.org>
2023-11-14 19:01:30 +09:00
Alyssa Ross
93cce40476 m1n1.adt: introduce yet another DAPFT8110 variant
When I tried to use the proxyclient shell, I got:
"Exception parsing /device-tree/arm-io/dart-dcp.dapf-instance-0 value […]"

I laid out the hex dump in a text editor, and added line breaks every
56 bytes (the former size of DAPFT8110B):

0000703b020000000080713b0200000020000000000000000000000000000000000000000000000000000000000000000003010000000000
40723b020000000080723b020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000
003b020000007f73073b02000000200000000000000000000000000000000000000000000000000000000000000000030100000000000028
3d020000000040283d020000002000000000000000000000000000000000000000000000000000000000000000000301000000000080003d
020000000380003d020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000e03f02
000000ffffef3f0200000020000000000000000000000000000000000000000000000000000000000000000003010000000000c0403e0200
0000ffff403e020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000433e020000
00ff3f433e020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000783d02000000
03417a3d0200000020000000000000000000000000000000000000000000000000000000000000000003010000000000003c3b0200000000
003e3b020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000403c02000000ffff
473c020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000103c020000004f0c10
3c020000002000000000000000000000000000000000000000000000000000000000000000000301000000000000703d020000000341723d
02000000200000000000000000000000000000000000000000000000000000000000000000030100000000

Looking at the patterns shared by all struct instances
(r0h = 3, r0l = 1, for example), each row appeared to be shifted one
byte to the left compared to its predecessor.  This suggests that
DAPFT8110B has only three extra bytes of padding compared to
DAPFT8110.

So, here I introduce DAPFT8110C, a new variant, one byte shorter than
DAPFT8110B.  Unlike DAPFT8110, there's no flag to differentiate
between these two variants, so we just have to guess based on what
divisor makes whole structs.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2023-11-14 18:59:27 +09:00
Alyssa Ross
8bdfdb7ce8 Fix build with -DDEBUG
If DEBUG is not defined, the compiler doesn't look at the arguments to
dprintf().  This has led to dprintf() bitrotting over time, referring
to variables that no longer exist, or by the wrong type, etc.

Here, I've tried to fix all the dprintf() calls to the best of my
ability, by comparing them to nearby calls that do compile, and
looking through the git history to understand the original intent.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2023-11-14 18:58:16 +09:00
Janne Grunau
f297951783 kboot: dcp: Enable dcpext on t600x/t8103 as well
Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
e72e84f669 clk: Add missing '\n' in printf message
Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
48c5ca8eca firmware: Reformat firmware version info table
Disable clanmg-format for it and transform it into a readable form by
padding columns with spaces.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
e4ea2d5319 kboot: dcp: Use OS firmware 13.5 as compat version
The dptxport endpoint changed API between 13.3 and 13.5. Nobody is
supposed to run 13.3 OS firmware at this point so do not claim to be
compatible. The DCP linux driver is fixed since a couple of weeks to
accept 13.5 as compat version.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
4ce65e1c08 kboot: dcpext: Enable dcpext* on t600x only with firmware 13.5
Only the HDMI port on 14 and 16 inch Macbook Pros needs dcpext and the
dptxport endpoint implemention in the DCP driver supports only the 13.5
firmware. Postpone this for after the fedora release.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
c9ae791b79 kboot: dcpext: t8112/t602x: Use dt_reserve_asc_firmware() for dcpext*
Avoids manually matching pre-mapped memory against "carveout-memory-map"
and maintaining a list of hopefully static carveoout regions.
Leave t8103 and t600x alone for now. Porting dcp over to this a littles
harder since that needs additional handling for regions mapped to
"dart-disp0?".

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
9a3a1271a5 kboot: Align segment sizes to 16k in dt_reserve_asc_firmware()
The segment for the dcp firmware text is inexplicably only aligned to 4k.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
69e3610737 display: Optionally use dcpext0/1 on t6020 and t6021
Allows emulating a t6022 system with fused off dcp0/dcp1 display
controllers.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Janne Grunau
8c99a189e0 dptx: Add the number of dptxport services
Avoids waiting 500 ms for the second dptxport service on t6020 and
possibly t6021.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-11-14 18:57:15 +09:00
Hector Martin
787eb8c220 display: More Sonoma workarounds
Power up display early (fixes HPD sometimes) and delay at least one
frame after swapping before quiescing DCP, otherwise the swap somehow
doesn't complete.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 19:19:10 +09:00
Hector Martin
5cecf53144 everything: Use calloc instead of malloc almost everywhere
This fixes at least one and likely more than one bug where we forgot to
zero-init.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
321a80c928 afk: Increase timeout from 500 loops to 500ms (time-based)
This should hopefully solve the reliability issues here.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
40a9444484 display,fb: Clear framebuffer early in the Sonoma stage2 fixup path
stage1 ends up with an ugly Asahi 100% logo on top of a 200% Apple logo.
Let's just clear it so it looks nicer.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:33 +09:00
Hector Martin
6af39a9b40 display: Try to modeset twice
This works around issues switching to 120Hz mode on systems affected by
the Sonoma situation, and in general it's probably a good idea anyway.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:27 +09:00
Hector Martin
c887c3cb54 display: Work around macOS Sonoma firmware bugs
It appears that when macOS is set to non-ProMotion mode, DCP firmware
<14.0 booted from DCP firmware 14.0+ needs a delay before modesetting to
complete the modeset properly.

The cases here are:
- Older m1n1 stage1 will, as far as it's concerned, initialize the
  display properly, but it won't work. It also misses the retina flag,
  since this codepath was intended for external displays. Use the
  missing retina flag as a signal to trigger reconfig.
- If installed as stage1, we reconfigure the display as usual, now with
  the extra delay. We also set the Retina flag now.

The persistence mechanism for the ProMotion flag is unknown. It doesn't
seem to be nvram. It also doesn't matter if we successfully modeset to
120Hz mode and then reboot, it breaks again, so it's not about the
"current" mode sticking.

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-11-02 18:12:26 +09:00
Tobias Heider
33a7e35d81 bash is not available everywhere. Use #!/usr/bin/env sh instead
which should work on most posix platforms. Fixes OpenBSD.

Signed-off-by: Tobias Heider <me@tobhe.de>
2023-11-02 15:54:34 +09:00
Alyssa Ross
0d5454e235 m1n1.shell: carry on if saving history fails
This shouldn't crash the shell — it's enough to warn about it and
carry on.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2023-11-02 15:54:23 +09:00
Janne Grunau
9a277fadc9 dcp/afk: Retry harder to init afk endpoints/services
Extend start_interface() with the number of expected services so it can
stop when all services are initialized.

Fixes failed display init on some devices in stage 1 due to a too slow
IOP which does not manage to send service announce messages in 20
mailbox / ringbuffer query operations.

Proper fix for this is to let the endpoint implementations drive the
initialization via afk_epic_work() until the expected services are
found.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-13 16:33:09 +09:00
Janne Grunau
1ea734296a dcp: Fix shutdown sequence on dptx errors
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-13 16:33:09 +09:00
Hector Martin
680f1c9bd9 run_guest_kernel: s/python/python3/
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-12 02:47:07 +09:00
Hector Martin
6de69564bd cpufreq: Fix t6022 clusters
We were only initializing the first die...

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-08 19:14:33 +09:00
Asahi Lina
12ba00d98b m1n1.trace.dart: Add basic IOVA tracer
In the spirit of what we have for AGX, but simpler.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-08 16:12:59 +09:00
Asahi Lina
23d4f99bb4 m1n1.trace.isp: t8112 etc changes
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-08 16:12:59 +09:00
Asahi Lina
250f96bb15 hv_vm: Implement scalar LDNP instructions
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-08 16:12:59 +09:00
James Calligeros
c3820a5016 smc: fix smc_init() definition
clang 17 now enforces strict prototyping. add void to the parameters
to fix building with clang going forward.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2023-10-08 16:09:18 +09:00
Janne Grunau
50ac69eaa5 dcp: Wait 25ms after enabling dcp/dptx-phy power-domains
Fixes display initialization from stage 1 m1n1. 20ms looked reliable on
j473 but let's add 25% safety margin. Someone with more motivation (and
HW serial) to do repeated `kmutil configure-boot ...` can try to
minimize this and test on t602x.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-07 21:56:19 +09:00
Janne Grunau
0097d51149 afk/dptx: Convert noisy/misleading printf to dprintf
Signed-off-by: Janne Grunau <j@jannau.net>
2023-10-07 21:56:19 +09:00
Hector Martin
595ecb423a m1n1.adt: Fix the weird DAPF variant parsing
Looks like there is a flag bit for this...

Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 16:05:53 +09:00
Asahi Lina
7e3e9ac301 isp, kboot: Misc changes for t8112
Probably doesn't do anything...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
5e2e537506 m1n1.adt: Add DAPF decoding
There's a weird thing with DCP DAPF entries being larger... but we don't
use them anyway?

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
e1bb8e85a6 m1n1.adt: Fix dashes in __delattr__
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
d07ea82821 kboot: Add firmware versions to ISP node
Might be useful...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
182fddd31e kboot: Fix ISP remap on t8103/t8112
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
0e471529cc m1n1.trace.isp: Hexdump to HV log
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
204f6b8189 m1n1.fw.isp: Fix message validity check
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Asahi Lina
6aca0608d8 isp: Handle high mapped VAs for t602x
This is similar to some of the other hardware we've seen on this SoC...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-10-05 14:21:13 +09:00
Hector Martin
0b7708f98e kboot: Try isp/isp0 for reserving firmware
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-10-05 14:21:13 +09:00