-
-
Notifications
You must be signed in to change notification settings - Fork 250
Move creating gpu blobs to m1n1. #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Move creating gpu blobs to m1n1. #466
Conversation
339d779 to
e90dd1d
Compare
|
I vaguely remember that bsd has some issues(?) with building rust code. we should check if this would create additional pain for them and then potentially allow building without rust (which means no gpu support then ofc). |
|
looks like this also breaks the CI because https://src.fedoraproject.org/rpms/m1n1/raw/main/f/m1n1-rust-deps.patch doesn't apply anymore. no idea where that file comes from though or why we need it. |
|
It's here: https://src.fedoraproject.org/rpms/m1n1/blob/rawhide/f/m1n1-rust-deps.patch . We need it because in Fedora we build against the system packages, not the vendored ones. |
|
let's not break m1n1 stage2 builds for all openbsd users. so we either need to convert this all to C (ugh...) or allow builds without rust and gpu support and make sure we don't shot ourselves in the foot with that |
svenpeter42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lina's sign-off is missing, my other comment is optional and can be ignored. I also didn't really review the rust code because it's been copied from the kernel and we know that it works
4e61475 to
bd07db6
Compare
It is not a 1 to 1 copy, but i have a special kernel build that compares the kernel blob with m1n1 one, and those matched on t6000 |
|
Let's see if jannau wants to review all this magic since he's more familiar with both rust and the gpu driver but I'm fine with merging it |
jannau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review of the C code
src/kboot_gpu.c
Outdated
| int32_t rust_gpu_initdata_size(uint32_t compat_maj, uint32_t compat_min, size_t *data_a, | ||
| size_t *data_b, size_t *globals); | ||
|
|
||
| int32_t rust_fill_gpu_initdata(size_t perf_state_table_count, size_t perf_state_count, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use a struct for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, i just find structs to be a bit inconvenient to keep in sync with rust/c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but keeping 22 function arguments in sync is convenient? I find the the function argument variant harder to validate and would assume it's more likely to attract bugs. We could use bindgen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, they are both terrible tbh. i'll look into bindgen
src/kboot_gpu.c
Outdated
| size_t n_perf_states_afr, const struct aux_perf_state *pstates_afr, | ||
| uint32_t is_j180, uint32_t base_pstate, uint64_t uat_ttb_base, | ||
| uint32_t num_cores, uint32_t compat_maj, uint32_t compat_min, | ||
| uint32_t gpu_rev_id, void *data_a, void *data_b, void *globals); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd feel more comfortable if we pass the size data_a, data_b and globals as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caller is supposed to allocate exactly as much as rust_gpu_initdata_size asked for, so not sure what value that adds?
3d6d5de to
b131656
Compare
881a53b to
55c9824
Compare
c2ae886 to
e0ccac2
Compare
jannau's going to take care of this one since he actually knows both the gpu driver and rust
Booting with Linux 6.17-rc1 device trees fails due to missing "operating-points-v2" properties. Check for the downstream only "apple,agx-t*" compatible strings and disable the gpu node if those are not found. This serves as temporary fix until AsahiLinux#466 is merged. Signed-off-by: Janne Grunau <j@jannau.net>
Booting with Linux 6.17-rc1 device trees fails due to missing "operating-points-v2" properties. Check for the downstream only "apple,agx-t*" compatible strings and disable the gpu node if those are not found. This serves as temporary fix until #466 is merged. Signed-off-by: Janne Grunau <j@jannau.net>
aeb9983 to
46e70a4
Compare
Booting with Linux 6.17-rc1 device trees fails due to missing "operating-points-v2" properties. Check for the downstream only "apple,agx-t*" compatible strings and disable the gpu node if those are not found. This serves as temporary fix until AsahiLinux#466 is merged. Signed-off-by: Janne Grunau <j@jannau.net>
jannau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With fixes from https://github.com/jannau/m1n1/commits/bootloader-cal-blobs/ GPU initdata matches on j274, j375c, j375d, j473, j474s, j493 and j180d. I've pushed verification changes to asahi-wip. Missing devices to verify are M1 Pro/Max laptops and M2 Max (laptop and studio).
The branch contains fixes for some of the review comments and depends on #499. Feel free to cherry-pick and squash.
Besides the review comments I'd like to have the code in kboot_gpu.c split into 3 parts:
- common
- downstream compatibles
- upstream compatibles
but that can happen after this PR is merged
46e70a4 to
495680b
Compare
|
m1 pro is verified on my side |
495680b to
2eaed13
Compare
from_path_trace inserts an extra root node, which when roundripped via C resutls in a None entry, but breaks using it directly from rust. Replace it with a None Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Instead of doing gpu initialization partially in m1n1 and partially in kernel, build all the blobs in m1n1 and put them in the device tree to be picked up by the kernel. Most of the code here is copied and pasted kernel code, with some fixups Signed-off-by: Asahi Lina <lina@asahilina.net> Co-authored-by: Sasha Finkelstein <fnkl.kernel@gmail.com> Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
The reserved-memory nodes have a page size aligned size. Signed-off-by: Janne Grunau <j@jannau.net>
This mirrors the DT in the downstream AsahiLinux kernel. j274 misses the "gpu-perf-base-pstate" property in the ADT. j474s uses 1 which is unusual for non-battery powered devices. Using the same values as the downstream DT simplifies comparing Linux and m1n1 initialized GPU initdata. Signed-off-by: Janne Grunau <j@jannau.net>
Based on the downstream Linux DT. Values are in the ADT so they could be read from there but that would be a larger refactoring. Signed-off-by: Janne Grunau <j@jannau.net>
2eaed13 to
c8ae45f
Compare
Instead of doing gpu initialization partially in m1n1 and partially in kernel, build all the blobs in m1n1 and put them in the device tree to be picked up by the kernel. Most of the code here is copied and pasted kernel code, with some fixups