Thread (37 messages) flat view 37 messages, 4 authors, 8d ago

Re: [PATCH v2 5/8] gpu: nova-core: add NVKV decoder

From: "Alexandre Courbot" <acourbot@nvidia.com>
Date: 2026-09-10 07:47:59
Also in: dri-devel, lkml, rust-for-linux

On Thu Aug 27, 2026 at 11:12 PM JST, Eliot Courtney wrote:
<...>
+    /// Decodes every pair into `schema` and returns the result of [`Schema::finish`].
+    pub(crate) fn decode<'s, S: Schema>(
+        &self,
+        schema: &'s mut S,
+    ) -> Result<impl Init<S::Target, Error> + 's> {
+        let mut cursor = Cursor::new(self.data);
+        while !cursor.is_empty() {
+            let op: Op = cursor.take_u64()?.into();
+
+            let key = op.key().into();
+            let index = op.index();
+            let op_value: u32 = op.value().into();
+            match op.opcode()? {
+                Opcode::Imm32 => {
+                    self.visit(schema, key, index, DecoderValue::Scalar32(op_value))?;
+                }
+                Opcode::Seq32 => {
+                    let values = cursor.take_u32s(num::u32_as_usize(op_value))?;
+                    for (i, &value) in values.iter().enumerate() {
+                        let key = Self::seq_key(key, i)?;
+                        self.visit(schema, key, index, DecoderValue::Scalar32(value))?;
+                    }
+                }
+                Opcode::Seq64 => {
+                    let values = cursor.take_u64s(num::u32_as_usize(op_value))?;
+                    for (i, &value) in values.iter().enumerate() {
+                        let key = Self::seq_key(key, i)?;
+                        self.visit(schema, key, index, DecoderValue::Scalar64(value))?;
+                    }
+                }
Another thing that could be worth clarifying: are `Seq32`/`Seq64` with a
count of `0` valid? Right now they won't trigger a visit or an error,
i.e. they will be silently ignored. Whereas arrays of size 0 do trigger
a visit (which sounds logical). I'm not saying this is a problem, just
wondering if the behavior is consistent with what NVKV specifies in such
cases.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help