Re: [PATCH v5 2/9] gpu: nova-core: gsp: add mechanism to wait for space on command queue

From: Alexandre Courbot

Date: Fri Mar 06 2026 - 00:22:08 EST


On Thu Mar 5, 2026 at 8:16 PM JST, Danilo Krummrich wrote:
> On Thu Mar 5, 2026 at 8:37 AM CET, Eliot Courtney wrote:
>> On Wed Mar 4, 2026 at 8:39 PM JST, Danilo Krummrich wrote:
>>> On Wed Mar 4, 2026 at 2:42 AM CET, Eliot Courtney wrote:
>>>> + fn allocate_command(&mut self, size: usize, timeout: Delta) -> Result<GspCommand<'_>> {
>>>> + read_poll_timeout(
>>>> + || Ok(self.driver_write_area_size()),
>>>> + |available_bytes| *available_bytes >= size_of::<GspMsgElement>() + size,
>>>> + Delta::ZERO,
>>>
>>> Isn't this either creating unneccessary thrashing of the memory controller or
>>> unnecessary contention at the cache-coherency level?
>>>
>>> I think we should probably add at least a small delay of something around 1us.
>>
>> This is what nouveau does (specifically `usleep_range(1, 2)`). OTOH,
>> openrm just does a busy wait, which is what I replicated here for now.
>> GSP command queue not having space IIUC is meant to be very exceptional.
>> I am not sure which is best, maybe Alex has an opinion, but also happy
>> to change it because that reasoning makes sense to me and I don't know
>> enough about the distribution of how often it would actually need
>> to wait to know if 0 delay is justified.
>
> Well, what this code says is "let's hammer the cache / memory controller as fast
> as we can for up to one second".
>
> This really should come with some justification why it is actually needed for
> proper operation of the driver.

A 1us delay sounds very reasonable. I can add it when applying if there
is no feedback justifying a respin.