Commit graph

770 commits

Author SHA1 Message Date
Asahi Lina
0a05a0171e proxy: Add smp_is_alive() thunk
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-03-28 19:06:20 +09:00
Eileen Yoon
4a679b12bd tunables_static: improve sequence iter
Signed-off-by: Eileen Yoon <eyn@gmx.com>
2023-03-28 17:19:45 +09:00
Eileen Yoon
2abf3af38e tunables_static: add t8103 ane tunables
Signed-off-by: Eileen Yoon <eyn@gmx.com>
2023-03-28 17:19:45 +09:00
Eileen Yoon
cf09e4ff56 tunables_static: abstraction to reuse entries
Signed-off-by: Eileen Yoon <eyn@gmx.com>
2023-03-28 17:19:45 +09:00
Hector Martin
a633b90634 kboot: Remove leftover IPD lookup dead code
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-03-19 20:30:01 +09:00
Hector Martin
a024101b75 kboot: Pass keyboard layout ID & country code in HID device
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-03-19 18:14:44 +09:00
Janne Grunau
c6c426581b pcie: Add link speed override for SD card reader
The SD card reader on Macbook Pro 14"/16" and Mac Studio uses yet
another property to override the port's "maximum-link-speed" property.
Add parsing for "expected-link-speed" and always look in the port's
first child for these properties.
Increases the link speed to PCIe 2.0 which is required for the full
bandwidth of SDXC UHS-II.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-03-12 00:32:10 +09:00
Asahi Lina
5d5fa70efa firmware: Add 13.1/13.2 to version list
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-03-06 15:15:17 +09:00
Janne Grunau
583f290b2b Add a space between '//' and '#' to satisfy clang-format 15
Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:51:08 +09:00
Janne Grunau
c8c0bd5dc5 display: Check if FB IOVA is available on dart-disp0
Fixes a copy and paste error in 1b5dee2496 checking dart-dcp twice.

Fixes: 1b5dee2496 ("display: Map the framebuffer if it is not mapped")
Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
4e7398e3a8 display: Start scanning for fb IOVA at vm-base
Required for M2 devices as the M2 Mac mini.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
bff8aa647c dcp: Offset temporary IOVA space from vm-base
Required on M2 devices.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
7e33a578d8 rtkit: Extend IOVA to 36-bit
Required for DCP on M2.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
f68a842ab7 rtkit: Apply "asc-dram-mask" consistently
Required for DCP on M2 which requires 36-bit IOVA space.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
6466f8dec8 dcp: Parse dart SID for DCP
Required for M2 which for which the dice showed "5".

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
8af2489d84 dart: Increase IO address space to 36-bit
This address space a single TTBR can hold with a 16k page size. Required
for DCP on M2.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
93abc760b2 dart: Add checks to dart_translate_internal()
Previous assumptions are not longer true with dart8110 on M2.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
c3c29bbd92 dart: Allow SIDs != 0 in dart_setup_pt_region()
Required for dart-dcp on M2 and M2 Pro/Max.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Janne Grunau
72cdec0e31 dart: Use "vm-base" as start when installing L2 tables
Additional L2 tables for dart-dcp/disp0 need to be from carveout memory
so they can kept after m1n1 exist. iboot has "pt-region-X" and "l2-tt-X"
in the ADT. For DCP on M2 we have to start installing them at "vm-base"
which is 0x8_0000_0000.
This probably causes problems on M2 Pro which uses 1 << 40 as vm-base
for dart-dcp0.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-02-02 09:50:33 +09:00
Sasha Finkelstein
d110da1e75 copy the touchscreen calibration
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
2023-01-28 21:58:44 +09:00
Sven Peter
90d0cd6b89 kboot: Copy ACIO tunables and DROM data
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2023-01-28 10:56:03 +09:00
Mark Kettenis
951afdd033 kboot: Add new U-Boot driver model 'phase-tags'
U-Boot is moving to a new set of tags to indicate devices that
should be bound/probed in early bootstrap phases.  Add 'bootph-all'
tags from the new bindings such that probing the serial port
early on in U-Boot continues to work and doesn't hang the system.

Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
2023-01-22 23:54:00 +09:00
Janne Grunau
a56e3fbc78 kboot: dcp: Add "memory-region-names" properties
Signed-off-by: Janne Grunau <j@jannau.net>
2023-01-22 23:47:40 +09:00
Janne Grunau
fe38315f1c kboot: reserve framebuffer from "/vram"
Fixes dcp if m1n1 reallocated the framebuffer due to large boot display
resolution. In that case we update "/vram" but leave the carveout
unmodified.

Use "framebuffer" as compatible string as proposed in
https://lore.kernel.org/dri-devel/20221117184039.2291937-4-thierry.reding@gmail.com/

Signed-off-by: Janne Grunau <j@jannau.net>
2023-01-22 23:47:40 +09:00
Janne Grunau
d73f53d9a0 kboot: dcp: Use "apple,asc-mem" as compatible strings for reserved memory
This is in preparation for the next commit to use "framebuffer" as
compatible string for the boot framebuffer. This is in line with a
proposed change for boot framebuffer handling on Nvidia Tegra SoCs.
It will allow removing simpledrm via
drm_aperture_remove_conflicting_framebuffers().

Signed-off-by: Janne Grunau <j@jannau.net>
2023-01-22 23:47:40 +09:00
Janne Grunau
9ca6016a4e kboot: dcp: Use "apple,asc-mem" as compatible strings for reserved memory
This is in preparation for the next commit to use "framebuffer" as
compatible string for the boot framebuffer. This is in line with a
proposed change for boot framebuffer handling on Nvidia Tegra SoCs.
It will allow removing simpledrm via
drm_aperture_remove_conflicting_framebuffers().

Signed-off-by: Janne Grunau <j@jannau.net>
2023-01-22 23:47:40 +09:00
Janne Grunau
4ed1a9c862 kboot: move dt_carveout_reserved_regions() after refactoring
Signed-off-by: Janne Grunau <j@jannau.net>
2023-01-22 23:47:40 +09:00
Janne Grunau
2667b10054 kboot: refactor dt_carveout_reserved_regions()
The main part of function will be used to add a reserved memory region
for the framebuffer from "/vram" instead of the carveout.

Signed-off-by: Janne Grunau <j@jannau.net>
2023-01-22 23:47:40 +09:00
Asahi Lina
3d28ac4d6f tools/chainload.py: Properly sleep DCP when chainloading macOS
Signed-off-by: Asahi Lina <lina@asahilina.net>
2023-01-20 18:18:13 +09:00
Martin Povišer
7db691737e kboot: Transfer virtio nodes from ADT to FDT
Signed-off-by: Martin Povišer <povik@cutebit.org>
2023-01-13 17:25:25 +09:00
Martin Povišer
6661ab14d0 hv: Add 9P virtio peripheral
Add some minimal implementation of virtio peripherals. At the level
of on-target hypervisor code we implement the MMIO layout and
maintain virtqueues. Once a buffer is available, we break into the
host proxyclient to deal with it.

Specific device-classes of the virtio spec ought to be implemented in
the proxyclient. Here the one device implemented is 9P transport,
exporting the m1n1 source directory.

Signed-off-by: Martin Povišer <povik@cutebit.org>
2023-01-13 17:25:25 +09:00
Hector Martin
fb36e30236 firmware: Add support for 12.3.1 firmware.
This includes mapping it to 12.3.0 for compat in both DCP and GPU.

Added for machines with replaced logic boards that trigger the 12.3
bootloop issue.

Also fix the 12.5/12.6 version arrays which were wrong.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-12-08 23:04:01 +09:00
Janne Grunau
426604926d kboot/dcpext: Fix mapping of dcp_txt on t8112 / M2
dcp_txt is mapped on dart-dcp and dart-dcpext so check if its reserved
memory node already exist before adding it.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-12-04 22:04:40 +09:00
Janne Grunau
159c553c6a kboot: Call dt_set_dcp_firmware() from dt_carveout_reserved_regions()
This avoids having duplicate calls for dcpext* on each mayor SoC
variant. Fixes setting firmware versions for dcpext on t8103 and t8112.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-12-04 22:04:40 +09:00
Hector Martin
2abf2b1693 kboot: Forward DCP firmware versions into the DT
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-12-04 16:06:27 +09:00
Hector Martin
e1b2c45f34 kboot_gpu: Set firmware versions from ADT
The kernel side doesn't check this yet, we'll let Lina take care of
that.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-12-04 16:06:27 +09:00
Hector Martin
c8d95baca0 kboot: Forward iBoot, firmware and m1n1 versions into the DT
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-12-04 16:06:27 +09:00
Hector Martin
c19303dc87 firmware: New module to detect firmware version
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-12-04 16:06:27 +09:00
Asahi Lina
db93de58b8 kboot_gpu: Add proper max-power and leakage calculations for t8112
This uses a similar algorithm to t600x, but with different constants and
exponents. The current limit also engages here, so add it, and add the
t600x one too (even though it is never hit).

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
d20d89b704 tunables_static: Add t8112 GPU tunables
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
f9862415b1 tunables_static: Add t600x GPU tunables
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
e6ffbb018b kboot_gpu: Add proper max-power and leakage calculations for t600x/t8103
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
057151cb21 math: Add expf() implementation from musl
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
444c3c854b kboot_gpu: Dummy t8112 power calculation
This is wrong but it will do for now

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
3278d75453 kboot_gpu: Add preliminary T600x support
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:17:10 +09:00
Asahi Lina
4a6a4c0376 kboot: Add initial GPU property forwarding
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-12-04 13:15:55 +09:00
Janne Grunau
0aafd74b69 kboot: Transfer display memory carveouts for M2
Signed-off-by: Janne Grunau <j@jannau.net>
2022-11-29 01:33:30 +09:00
Janne Grunau
a954eb47f9 dart: Support locking dart-t8110
Signed-off-by: Janne Grunau <j@jannau.net>
2022-11-29 01:33:30 +09:00
Janne Grunau
ba1dfab4d2 kboot: Enable dart-disp0 as part of the display setup
Devicetrees with dart-disp0 will have it disabled to avoid breaking
scanout off the boot framebuffer when booting via m1n1 version which
does not lock dart-disp0.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-11-15 17:52:16 +09:00
Janne Grunau
0bb521c2c3 kboot: Save notch height in dcp node
DCP will use this information to provide "notch-less" display modes.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-26 01:22:00 +09:00
Janne Grunau
53e6254497 kboot: Skip over missing dcp aliases
Prevents failing on non-existant carveout regions from the M1 Ultra on
M1 Pro/Max.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-26 01:22:00 +09:00
Hector Martin
aa0a3e6fcf kboot: Don't fail if there are fewer than 6 DCPEXTs on t600x
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-10-25 00:23:42 +09:00
Janne Grunau
ca68e1a9d2 kboot: Transfer dcpext* iommu mappings to device tree
Only dcpext* has memory mapped iboot.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Janne Grunau
21dc622735 kboot: Transfer display related memory carveouts to device tree
DCP and disp0 need their bootloader iommu mappings maintained until
an OS driver can take over. DCP's mappings have to be kept
indefinitively since it's unknown if or how it can be restarted.

Bindings based on
https://lore.kernel.org/asahi/20220923123557.866972-1-thierry.reding@gmail.com

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Janne Grunau
7ae0aac831 kboot: lock dart-disp0 to prevent accidental resets
This prevents older systems from resetting dart-disp0 on init when they
encounter device trees with DCP/disp nodes.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Janne Grunau
e5db7233a9 dart: add dart_init_fdt()
Used to intialize by FDT phandle.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Janne Grunau
d27ca705c1 devicetree: Add dt utils for "ranges" based address translation
Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Janne Grunau
f1664ccef4 dart: Add DART_PTR_ERR to indicate failures for IOVA returning functions
0 is a valid and used device virtual address. Daart functions returning
device address can not use 0 to indicate errors.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-10-23 17:21:26 +09:00
Hector Martin
2e1ed1d457 nvme: Increase enable timeout to 5s, do a clean shutdown on fail
It seems unclean startup sometimes takes longer. On top of that, if we
don't do a clean shutdown in the error path, the next startup will
continue failing (we know hard-disable triggers races and crashes the
ASC).

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-10-17 22:14:21 +09:00
Asahi Lina
67901fa1bb main: Move tunables_apply_static() here
m1n1 python scripts probably want this too, let's just do it
unconditionally.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-10-17 22:14:21 +09:00
Asahi Lina
d6d72b6398 hv_exc: Pass through TLBI OS instructions
Gues VM TLBI OS instructions don't work. Trap them and pass them through
as the host.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-10-17 22:14:21 +09:00
Asahi Lina
d8c2d68ebf exception: Fix FAR decoding in GL2
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-10-17 22:14:21 +09:00
Asahi Lina
52e72c62b8 hv: Fix bugs in split r/w emulation
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-10-17 22:14:21 +09:00
Asahi Lina
4274c9d74a hv: Log memory attribute & sharability info in mmiotrace
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-10-17 22:14:21 +09:00
Janne Grunau
81acfe96d8 kboot: Adapt multi-die handling to linux submitted DT
"simple-bus" restricts the node names to predefined list. "soc" looks
like the most appropiate name considering the dies are M1 Max SoCs.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-09-28 01:23:28 +09:00
Asahi Lina
fe0d3e8e34 tunables_static: New module to set up static tunables
This is for things that xnu hard-codes. This first one for AGX is
required to make coprocessor TLB coherency work properly...

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-09-27 06:04:41 +09:00
Asahi Lina
a15eb0919d hv_vm: Support LDAR/STLR instructions
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-09-27 06:04:41 +09:00
Asahi Lina
da9ceddeac memory: Map lowmem using 16K pages only
Turns out CTRR does not like working with huge pages, and just throws up
its hands in the air with an L2 address size fault if a huge page
overlaps the CTRR region.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-09-27 06:02:28 +09:00
Asahi Lina
6feceef2b0 hv_vm: Retry mapped page faults
This is usually a race that happens when the Python side has just
removed a hook, but there was already a CPU core faulting on an access.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-09-27 06:02:28 +09:00
Hector Martin
c0b1dbea20 kboot: Fix chosen arg setting with >1 var
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-09-18 20:17:51 +09:00
James Calligeros
ca47121561 kboot: inject Apple serial number into the FDT
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2022-08-30 22:32:03 +09:00
Janne Grunau
0f0ddf3397 hv_exc: Add s3_7_c15_c3_1 sysreg passthroughs for t8112/macos 12.4
Boot panics due to what appears a timeout without ignoring this sys_reg
in m1n1.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-08-30 22:30:22 +09:00
Hector Martin
4c672c00b6 iodev, uartproxy: Fix write interleaving causing corruption
This should fix the issue where console writes from another CPU in the
middle of events/etc corrupt data

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-08-29 17:02:40 +09:00
Hector Martin
170cca1482 mcc: Also unmap memory aliases
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-08-29 17:02:40 +09:00
Hector Martin
8fa5659bab kboot: Squelch die-count warning
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-08-29 17:02:40 +09:00
Hector Martin
8f945fcdfe exception: Clean up FIQ state on secondary startup
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-08-29 17:02:40 +09:00
Asahi Lina
ad29c08ab8 exception: Clear L2C error flags on exception
Some of these errors are apparently sticky / write-1-to-clear, and if we
don't do this, then the SError behaves as level-triggered and just continues
to fire.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-18 18:33:32 +09:00
Asahi Lina
89a482fcab memory: Do not invalidate Normal-NC mappings
We probably don't need it, and the hypervisor doesn't like it.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-17 17:17:22 +09:00
Asahi Lina
6f6073a531 exception: Fix a lot of brokenness when exceptions are taken in GLx
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-17 15:00:00 +09:00
Asahi Lina
e1b12a6983 usb_dwc3: Make it 3 times faster
We can use buffers that are more than one packet in size!

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-17 15:00:00 +09:00
Asahi Lina
15d04b3778 proxy: Expose hv_write_hcr()
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-17 14:02:55 +09:00
Asahi Lina
b6d2cc127c hv_exc: Add support for resetting stolen time delta
This is useful to re-sync AGX, since it shares the same timebase as the
CPU.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-17 14:01:49 +09:00
Asahi Lina
e3d5f70244 afk: Correctly ack unknown messages during init
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-08-05 15:26:05 +09:00
Hector Martin
0c04783a86 main: Check for SIP disable for proxy backdoor mode
Seems -v stopped being filtered (or never was?). Explicitly check boot
policy, so we don't depend on boot-args filtering directly (which can
change). -v still makes things verbose unconditionally, but the proxy
backdoor now requires that plus full SIP disable (sip0=127).

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-30 11:18:23 +09:00
Hector Martin
f61e5d4958 cpu_regs: Add more chicken bit names
These are from a public Apple source that shall remain unidentified
(because it's utterly silly that they keep trying to hide these).

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-17 03:17:13 +09:00
Hector Martin
ee0667e190 chickens_avalance: Add missing HID11_DISABLE_LD_NT_WIDGET
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-17 01:43:32 +09:00
Hector Martin
ffc38f84ac kboot: Grab kblang-calibration for M2
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-12 13:44:48 +09:00
Hector Martin
9769200f60 nvme: Reset ANS as well as ANS2
M2 machines call it that...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-12 13:08:28 +09:00
Hector Martin
a5a57c230e pmgr: Add pmgr_adt_reset()
This isn't actually useful for NVMe, but let's keep it...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-12 13:04:42 +09:00
Sven Peter
aacbfc04e9 kboot: swap BD address
Unlike the MAC addresses Bluetooth addresses have to be stored
in little-endian byte order (see devicetree/bindings/net/bluetooth.txt)

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-07-11 19:56:42 +09:00
Hector Martin
b1ad2d340f asc: Do not clear ASC run bit while running
Some ASCs will get stuck if we do that. Instead, explicitly clear it
after an RTKit shutdown.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-11 19:02:21 +09:00
Hector Martin
4555cc5148 dapf: Initialize DAPFs from the ADT
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-03 23:27:50 +09:00
Hector Martin
ecfed3e100 pcie: Add t8112 support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-01 23:37:00 +09:00
Hector Martin
bf09fcd286 asc: Add retries and a timeout to asc_send
Fixes: #211
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-07-01 18:03:42 +09:00
Sven Peter
481e4ceefc kboot: use 'local-bd-address' for bluetooth mac address
Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-07-01 17:58:02 +09:00
Sven Peter
2c37105412 kboot: propagate bluetooth calibration blob
Depending on the chip stepping (stored in the OTP) either the blob for
beamforming or the normal calibration blob has to be used.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
2022-07-01 17:58:02 +09:00
Hector Martin
b1f9d72554 hv: Don't touch DCP on laptops
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:47:02 +09:00
Hector Martin
1ac6c7659d smp: Add T8112 support
PMGR cpustart offset moved...

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:47:02 +09:00
Hector Martin
55ca4855a5 cpufreq: Add T8112 clusters
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
b077c08181 dart: Add dart,t8110 support
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
bfd03cf428 mcc: Add t8112 support
This is compatible with t8103.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
ece84e0acb mcc: Make more robust
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
c481c0799b main: Fix version number message
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:24 +09:00
Hector Martin
22adc922f7 chickens: Add T8112 chickens
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
b16a19715a chickens: Split off core sequences into separate files
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
d9c1ef7d49 cpu_regs: Add new defines for T8112 chickens
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
8a607f049f soc: Add T8112 defines
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Hector Martin
c947b600c7 main: Add a BRINGUP define to disable ~everything but UART
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-28 01:41:23 +09:00
Vincent Duvert
66a85593db AFK: limit number of tries in start_interface
Signed-off-by: Vincent Duvert <vincent@duvert.net>
2022-06-21 17:20:54 +09:00
Hector Martin
f3ce8a68d0 smp: Fix pathological thrashing with the hypervisor
Writing to the IPI register causes a trap, which sets the event...
causing every CPU to go into a tight loop of traps contended on the BHL.

We don't need to clear IPIs in WFE mode, so don't do that.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 21:53:42 +09:00
Hector Martin
849729f0c0 memory: Add GRE and nGRE mappings for experiments
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 21:53:06 +09:00
Hector Martin
c95189ba2e memory: Normalize naming of Normal-NC memory attributes
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 16:12:16 +09:00
Hector Martin
ee2949e744 smp: Use stronger barriers around wfe/sev
Not sure if this fixes anything, but it looks more correct.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-19 15:21:59 +09:00
Asahi Lina
ffe2f4104e fb: Support XBGR pixel format for fb_blit()
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-06-19 01:36:41 +09:00
Akihiko Odaki
bcbe26d79b m1n1.hv: Always continue on the stepped thread
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
2022-06-04 20:20:21 +09:00
Asahi Lina
b48e33a333 hv: More instructions
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-06-02 22:50:52 +09:00
Hector Martin
17abe8f94b display: Report time spent modesetting
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 02:03:32 +09:00
Hector Martin
714420a694 display: Put DCP to sleep if display is external
This stops DCP from killing our modeset if the connection cycles.

Also force a (potential) configure cycle if the display is external;
this makes sure updated stage2s will have a chance at fixing issues of
old stage1s. Modesetting is fast when it's the same mode as before.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 01:54:11 +09:00
Hector Martin
9748b5525e dart: Only allocate a max of 2 L2 tables
This is what iBoot normally does, and >2 will panic macOS

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 01:49:59 +09:00
Hector Martin
abd48b0b5c rtkit: Always wake up/boot IOP unconditionally
Get rid of asc_cpu_stop() which was never a thing. The CPU start bit
should always be off in the steady state, it is only used momentarily to
start the CPU.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
7023e247bb rtkit: Align naming with Linux version
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
06ec66e2a9 proxy: Export pmgr_reset()
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
0472bc05cd proxy: Export display functions
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Hector Martin
09013da441 display: Don't crash if shutdown is called twice
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-06-01 00:57:17 +09:00
Akihiko Odaki
8163883252 utils: Use exclusive load to wake up from WFE
Commit 9c795fbdbf introduced the pair of
WFE and SEV for spinlock, but it caused delays of tens of seconds. A
possible explanation for the delay is lack of data synchronization
barrier between the store instruction and SEV instruction.
Arm Architecture Reference Manual for A-profile architecture (issue H.a)
says:
> Arm recommends that software includes a Data Synchronization Barrier
> (DSB) instruction before any SEV instruction. The DSB instruction
> ensures that no instructions, including any SEV instructions, that
> appear in program order after the DSB instruction, can execute until
> the DSB instruction has completed.

However, inserting a DSB instruction still didn't resolve the delay.

The exclusive load is an alternative to the SEV instruction. The manual
says:
> ...However, in Armv8, when the global monitor for a PE changes from
> Exclusive Access state to Open Access state, an event is generated.

> This is equivalent to issuing an SEVL instruction on the PE for which
> the monitor state has changed. It removes the need for spinlock code
> to include an SEV instruction after clearing a spinlock.

As an additional benefit, the exclusive load is local to the PE and
eliminates spurious events for other PEs.

Trusted Firmware-A v2.6 also employs the same algorithm.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
2022-05-31 21:49:37 +09:00
Janne Grunau
8147c2d374 display: Add 'retina' flag to display_parse_mode
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
7f4347ebe8 display: Reallocate framebuffer if required for wanted display mode
If an explicitly specified display mode exceeds the allocated
framebuffer allocate a new one from the top of RAM.

Note: macOS panics immediately with a realloced framebuffer.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
1ea31ae996 dart: Add setup of pre-allocated L2 tables for dcp/disp0
DART nodes for dcp and disp0 have pre-allocated L1 and L2 tables which
are annotated in the ADT. The pre-allocated memory is specified in
"pt-region-${DEVICE}". The first page is used as L1 table and the
following pages are used as L2 tables. The number of valid L2 tables is
specified in "l2-tt-${DEVICE}". The first entry identifies the region
and the second entry is the number of valid L2 tables.

iboot (macOS 12.3) inits just 2 L2 tables. Larger framebuffers require
more. By using the pre-allocated page tables we do not have worry about
keeping the memory mapped after m1n1 executes the next target.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
079659dfea display: Move dcp iboot swap into its own function
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
d08793a456 dcp: Free iovad_dcp including dart L2 tables on shutdown
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
9356e60803 dcp: Limit dcp iovad to 256M
Does not make a difference but avoids effort on shutdown.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
645152e849 dart: Make dart translation error logs more informative
Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
c577e94d75 display: limit timing modes by framebuffer size
The reserved framebuffer on the Mac Studio is 0x854000 bytes. This is
too small for 1920x1200 with 4 byte per pixel. Setting 1920x1200 as
mode crashes dcp but not the actual display controller. The display
remains working and even comes back after display hotplug/power cycle.

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 23:01:01 +09:00
Janne Grunau
65199c63da kboot: support multi die machines in dt_disable_missing_devs
The device tree for multi die SoCs as the M1 Ultra has its devices
under "/soc/dieX" instead of directly under "/soc".

Signed-off-by: Janne Grunau <j@jannau.net>
2022-05-30 22:56:12 +09:00
Hector Martin
8eeb7966aa hv: Refactor CPU switch logic, make hv.cpu() not exit shell
Get rid of the hv_rearm() thing (which was always a bit dodgy) and
instead properly make sure that all CPUs rendezvous when needed and
switch the active proxy thread without ever exiting exception context.

The Python side can now switch proxy context (by waiting directly for
a proxy boot) without having to exit out of the hypervisor callback,
so cpu() now works as a normal Python method.

Add a cpus() iterator so you can do things like:

>>> for i in cpus(): bt()

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 22:33:44 +09:00
Hector Martin
01a1a0f597 hv: Make time stealing run-time configurable
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 19:37:23 +09:00
Hector Martin
908f263f22 proxy: Fix warning in P_MCC_GET_CARVEOUTS
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 19:29:51 +09:00
Hector Martin
9c795fbdbf utils: Use WFE/SEV in spinlock
This should reduce memory traffic spam and power usage from lock
contention when threads are blocked on a spinlock.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-30 19:22:55 +09:00
Hector Martin
ad659daa6d payload: Fix spurious variable detection on EOF
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-05-23 20:40:07 +09:00
Asahi Lina
25d33aa4c7 hv_vm: Implement more opcodes
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Asahi Lina
5b534cbf31 hv_vm: Add more SIMD ops to emulation
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Asahi Lina
c746549c2e hv: Map RAM via tracer infra, handle carveouts in Python
Previously RAM was mapped ad-hoc, but this can end up interacting
poorly with the tracer infrastructure which we are now using for RAM
too. Move to mapping guest RAM via the tracer infra, and also unmap the
TZ carveouts in the Python side so it knows about them.

This is a HV ABI break.

Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Asahi Lina
b88785fa58 hv_vm: Add 32-bit LDP emulation
Signed-off-by: Asahi Lina <lina@asahilina.net>
2022-05-21 03:54:12 +09:00
Hector Martin
52bb64b86c hv_exc: Do not forget to arm tick in fast path
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-20 00:38:22 +09:00
Hector Martin
e750dfcca1 hv_exc: Improve multi-core scalability
The HV tick polling now only runs on CPU#0. All CPUs have the 1000Hz
HV tick, but secondaries only use it to poll the FIQ state and that path
does not take the BHL if no other FIQ was pending.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-20 00:20:58 +09:00
Hector Martin
3020e26e00 dart: Announce real-time DARTs
Mostly just for reference.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-19 23:42:22 +09:00
Hector Martin
fabe27e3f1 memory: Remap some carveouts as uncached
This fixes display DART real-time cache hits causing AMCC exceptions.

The relevant carve-outs have flags 0x60004016; 0x60004002 is used for
DCP which is non-realtime, so I'm guessing the '16' means we should map
it uncached.

Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-19 23:41:17 +09:00
Janne Grunau
6df73d80ee cpufreq: Add support for t6002
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:39:52 +09:00
Janne Grunau
4aa4ff98b6 smp: Start CPU cores on the second t6002 die
Signed-off-by: Janne Grunau <j@jannau.net>
2022-04-19 21:39:52 +09:00
Hector Martin
8df40df17e nvme: Support nvme on die 1 for t6002
Signed-off-by: Hector Martin <marcan@marcan.st>
2022-04-19 21:39:52 +09:00