Umio-Yasuno / libdrm-amdgpu-sys-rs

libdrm_amdgpu bindings for Rust, and some methods ported from Mesa3D
MIT License
9 stars 1 forks source link

vbios related function safety #6

Closed ilya-zlobintsev closed 4 months ago

ilya-zlobintsev commented 4 months ago

I'm thinking of adding VBIOS dumping functionality to LACT (like shown in the vbios_dump example), and I've noticed that most functions for VBIOS functionality are marked as unsafe. Is this simply because of FFI, or are there more considerations about using them (like hardware quirks)? They are the only functions marked as unsafe on DeviceHandle.

Umio-Yasuno commented 4 months ago

I remember this because vbios related functions were not implemented in libdrm_amdgpu and drmCommandWrite had to be used.
Therefore, those functions lacked safety or functionality, and they were actually broken.

https://github.com/Umio-Yasuno/libdrm-amdgpu-sys-rs/commit/f8d9860bd8990c7ad283640645a030742461489f

ilya-zlobintsev commented 4 months ago

Are they fine to use now? The vbios image it produces on my system (Vega 56) seems to be valid (amdvbflash can at least read info from it). It's a lot smaller than the image i originally flashed on the GPU - 60kb vs 256kb - but it seems like the original has a lot of padding with empty data to get it to an exact 256kb size.

Umio-Yasuno commented 4 months ago

The latest version outputs the same image as /sys/kernel/debug/dri/<num>/amdgpu_vbios.
However, if you want to take a reliable approach, I recommend reading /sys/kernel/debug/dri/<num>/amdgpu_vbios.

ilya-zlobintsev commented 4 months ago

OK, I'll use that instead. Thanks