[PATCH v2 0/8] gpu: nova-core: add NVKV codec
Eliot Courtney <[email protected]>
| Newsgroups | dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <[email protected]> |
This series adds support for the NVKV wire format for communicating with GSP. Essentially, the format encodes a sequence of calls to some function f(key, index, value), where value is a [u8], u32, u64, [u32], or a [u64]. The key is a u16 and the index is a 12 bit integer. The interpretation of these function calls is per GMCAPI (RPC interface used in firmwares later than r570). Generally speaking, the function calls will map to some struct - for example, f(GPU_NAME_STRING_KEY, 0, b"some gpu") naturally maps to storing a &str with the GPU name. This series adds a general encoder and decoder that works with the base formats used ([u8], u32, u64, [u32], or a [u64]) for encode and a general `Schema` trait for decode. This could be used directly, but since most messages are struct-like, it's more ergonomic to use some typed helpers for this declarative use case. So this series adds two simple macros for encode and decode of structs, plus some general types and implementations that help with using these. Future patches will wire this up through the command queue. This is based on drm-rust-next. --- Changes in v2: - Tweak Schema trait to avoid materializing copies on the stack - Move ArrayVec to alloc module (+add potentially useful methods) (Danilo) - Add Vec::try_push_init (Danilo) - Add sum error type for try_push_init, PushInitError - Use Danilo's EncodedStream abstraction - Add some stack space asserts (Danilo) - needs to skip on clippy tho - Using zerocopy e.g. ref_from_prefix_with_elems requires updated zerocopy to avoid linking error, so added those as prereqs. - Link to v1: https://patch.msgid.link/[email protected] --- Eliot Courtney (8): rust: alloc: add Vec::try_push_init rust: alloc: add Vec::push_init rust: alloc: add ArrayVec gpu: nova-core: add NVKV encoder gpu: nova-core: add NVKV decoder gpu: nova-core: add NVKV typed encoding gpu: nova-core: add NVKV typed decoding gpu: nova-core: add NVKV GSP_INIT schemas drivers/gpu/nova-core/gsp.rs | 1 + drivers/gpu/nova-core/gsp/fw/commands.rs | 350 +++++++++++++++ drivers/gpu/nova-core/gsp/nvkv.rs | 197 ++++++++ drivers/gpu/nova-core/gsp/nvkv/decode.rs | 741 +++++++++++++++++++++++++++++++ drivers/gpu/nova-core/gsp/nvkv/encode.rs | 388 ++++++++++++++++ rust/kernel/alloc.rs | 3 + rust/kernel/alloc/arrayvec.rs | 347 +++++++++++++++ rust/kernel/alloc/kvec.rs | 73 ++- rust/kernel/alloc/kvec/errors.rs | 30 ++ 9 files changed, 2128 insertions(+), 2 deletions(-) --- base-commit: 4c9ba407018e8deb06dbc643112bac8f40404f95 change-id: 20260812-b4-nvkv-131af5c2661c prerequisite-message-id: [email protected] prerequisite-patch-id: 1387aaf8fd9dbfaf04e6e8d52c3b39fbd9ff9432 prerequisite-message-id: [email protected] prerequisite-patch-id: 75036fb19a16a9c89bcba34e233a4b6de4ae421e Best regards, -- Eliot Courtney <[email protected]>