[PATCH 6/9] gpu: nova-core: generalize `flush_into_kvec` to `flush_into_vec`

From: Eliot Courtney

Date: Fri Feb 27 2026 - 07:37:26 EST


Add general `flush_into_vec` function. Add `flush_into_kvvec`
convenience wrapper alongside the existing `flush_into_kvec` function.
This is generally useful but immediately used for e.g. holding RM
control payloads, which can be large (~>=20 KiB).

Signed-off-by: Eliot Courtney <ecourtney@xxxxxxxxxx>
---
drivers/gpu/nova-core/sbuffer.rs | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/nova-core/sbuffer.rs b/drivers/gpu/nova-core/sbuffer.rs
index 3a41d224c77a..38f8a8426521 100644
--- a/drivers/gpu/nova-core/sbuffer.rs
+++ b/drivers/gpu/nova-core/sbuffer.rs
@@ -2,7 +2,13 @@

use core::ops::Deref;

-use kernel::prelude::*;
+use kernel::{
+ alloc::{
+ Allocator,
+ KVec, //
+ },
+ prelude::*, //
+};

/// A buffer abstraction for discontiguous byte slices.
///
@@ -162,11 +168,14 @@ pub(crate) fn read_exact(&mut self, mut dst: &mut [u8]) -> Result {
Ok(())
}

- /// Read all the remaining data into a [`KVec`].
+ /// Read all the remaining data into a [`Vec`] with the given allocator.
///
/// `self` will be empty after this operation.
- pub(crate) fn flush_into_kvec(&mut self, flags: kernel::alloc::Flags) -> Result<KVec<u8>> {
- let mut buf = KVec::<u8>::new();
+ pub(crate) fn flush_into_vec<A: Allocator>(
+ &mut self,
+ flags: kernel::alloc::Flags,
+ ) -> Result<Vec<u8, A>> {
+ let mut buf = Vec::<u8, A>::new();

if let Some(slice) = core::mem::take(&mut self.cur_slice) {
buf.extend_from_slice(slice, flags)?;
@@ -177,6 +186,20 @@ pub(crate) fn flush_into_kvec(&mut self, flags: kernel::alloc::Flags) -> Result<

Ok(buf)
}
+
+ /// Read all the remaining data into a [`KVec`].
+ ///
+ /// `self` will be empty after this operation.
+ pub(crate) fn flush_into_kvec(&mut self, flags: kernel::alloc::Flags) -> Result<KVec<u8>> {
+ self.flush_into_vec(flags)
+ }
+
+ /// Read all the remaining data into a [`KVVec`].
+ ///
+ /// `self` will be empty after this operation.
+ pub(crate) fn flush_into_kvvec(&mut self, flags: kernel::alloc::Flags) -> Result<KVVec<u8>> {
+ self.flush_into_vec(flags)
+ }
}

/// Provides a way to get mutable slices of data to write into.

--
2.53.0