On Fri Feb 27, 2026 at 8:28 PM JST, Alexandre Courbot wrote:
>> + /// Sends `command` to the GSP.
>> + ///
>> + /// The command may be split into multiple messages if it is large.
>> + ///
>> + /// # Errors
>> + ///
>> + /// - `ETIMEDOUT` if space does not become available within the timeout.
>> + /// - `EIO` if the variable payload requested by the command has not
>> been entirely
>> + /// written to by its [`CommandToGsp::init_variable_payload`] method.
>> + ///
>> + /// Error codes returned by the command initializers are propagated
>> as-is.
>> + pub(crate) fn send_command<M>(&mut self, bar: &Bar0, command: M) ->
>> Result
>> + where
>> + M: CommandToGsp,
>> + Error: From<M::InitError>,
>> + {
>> + let mut state = SplitState::new(&command)?;
>> +
>> + self.send_single_command(bar, state.command(command))?;
>
> As we discussed offline these two lines were bothering me a bit, because
> we pass `command` twice and there is a possibility (although purely
> hypothetical) of API misuse. I think I found a way around it: we turn
> `SplitState` into an enum with a `Single` variant, that contains the
> original command, and a `Split` one, which contains the truncated
> initial command and its continuation records.
>
> This simple change cascades into more simplifications in the new types
> introduced by this patch: `SplitCommand` is not an enum anymore, but the
> original command with a shorter payload. And the continuation records
> are their own self-contained type. This is achieved by allocating two
> `KVVec`s when we split, and taking advantage of the `SBuffer` we
> conveniently have at hand to fill them both.
>
> I have pushed a branch with this idea implemented on top of yours in [1]
> - please check it, but I think it brings a nice (if small) incremental
> improvement. It removes the API misuse potential, makes every type
> purely single-purpose, and doesn't need `PhantomData` or lifetimes,
> making it simpler overall IMHO.
>
> [1] https://github.com/Gnurou/linux/tree/review/continuations
Thank you for looking into this and I agree this new design is better.
We pay an extra allocation but it's rare that that path will be hit, so
I agree it's worth it.
Added and thanks for your work on improving this API.
>> +
>> +/// The `ContinuationRecord` command.
>> +pub(crate) struct ContinuationRecord<'a> {
>
> These new types are to be used by the command queue, and we don't want
> to use them elsewhere, so `pub(super)` seems more appropriate to me.
>
> And actually, since they are more command queue infrastructure than pure
> "commands" that fulfill a given purpose, I'd suggest moving them into
> their own sub-module of `gsp` (named `continuation` or `split` maybe?).
> That way they don't get in the way of readers who just want to learn
> about GSP commands.
Done.