All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Eliot Courtney" <ecourtney@nvidia.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>
Cc: <nova-gpu@lists.linux.dev>, <dri-devel@lists.freedesktop.org>,
	<linux-kernel@vger.kernel.org>,
	"dri-devel" <dri-devel-bounces@lists.freedesktop.org>
Subject: Re: [PATCH v3 1/2] gpu: nova-core: fix barrier usage in CPU->GSP messaging path
Date: Mon, 31 Aug 2026 18:25:02 +0100	[thread overview]
Message-ID: <DL3AYW5D121E.29D3XI699XMKN@garyguo.net> (raw)
In-Reply-To: <DKXLSOCZBYYX.1OE2DF4LYRMV5@nvidia.com>

On Tue Aug 25, 2026 at 1:38 AM BST, Eliot Courtney wrote:
> On Mon Aug 24, 2026 at 10:07 PM JST, Gary Guo wrote:
>> On Mon Aug 24, 2026 at 2:03 PM BST, Eliot Courtney wrote:
>>> On Mon Aug 24, 2026 at 9:56 PM JST, Gary Guo wrote:
>>>>>> @@ -683,6 +689,9 @@ fn send_single_command<M>(&mut self, bar: Bar0<'_>, command: M) -> Result
>>>>>>              dst.header.length(),
>>>>>>          );
>>>>>>  
>>>>>> +        // ORDERING: STORE->STORE ordering needed to order `cpu_write_ptr` write after data write.
>>>>>> +        dma_mb(Write);
>>>>>> +
>>>>>
>>>>> Is there a reason this can't go into `advance_cpu_write_ptr`?
>>>>
>>>> I think it's more clear to consider `advance_cpu_write_ptr` to just be the
>>>> pointer increment, and the ordering should be visible in code that performs both
>>>> memory ops.
>>>
>>> In the second patch, it looks like you're adding the memory barrier
>>> directly in `advance_cpu_read_ptr`. So we'd have one barrier directly in
>>> the code advancing the pointer and one not, which seems asymmetric. I
>>> think it's less error prone to put the barrier in the function so it
>>> can't be misused (and we already have evidence the barriers are easy to
>>> get wrong, since this code was already broken).
>>
>> In the second one `message.header.length()` is read, so if I move the barrier to
>> before the advance it'll be incorrect.
>>
>> Best,
>> Gary
>
> Yerp I mean move the barrier into `advance_cpu_write_ptr` not move the
> barrier out of `advance_cpu_read_ptr` - I agree that'd be incorrect. On
> clearness, it feels very odd to me to have these two functions
> (advance_cpu_read_ptr, advance_cpu_write_ptr) where one controls the
> memory barrier and one doesn't, purely based off the structure of the
> callers. And I still think it's less error prone (for future changes) to
> do it this way too.

Frankly I don't like the asymmetry that the advancing code does the barrier,
while the pointer reading code doesn't have the barrier. However, if we move the
barrier to the pointer read function, then the `driver_write_area_size` would
gain a unnecessary barrier. (Actually, `driver_read_area` code have a similar
issue, a failed pool would execute an unnecessary barrier).

As an alternative to move the barrier into the advancing code, alternatively we
can pull the `message.header.length()` to a separate line instead.

I think we should either always have barrier inside the pointer read/update
code, or always on the user side. Given the former would mean unnecessary
barriers, I am erring on the latter.

Best,
Gary

  reply	other threads:[~2026-08-31 17:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 17:28 [PATCH v3 0/2] gpu: nova: fix incorrect GSP barrier usage Gary Guo
2026-08-19 17:28 ` [PATCH v3 1/2] gpu: nova-core: fix barrier usage in CPU->GSP messaging path Gary Guo
2026-08-19 17:39   ` sashiko-bot
2026-08-24 12:50   ` Eliot Courtney
2026-08-24 12:56     ` Gary Guo
2026-08-24 13:03       ` Eliot Courtney
2026-08-24 13:07         ` Gary Guo
2026-08-25  0:38           ` Eliot Courtney
2026-08-31 17:25             ` Gary Guo [this message]
2026-08-19 17:28 ` [PATCH v3 2/2] gpu: nova-core: fix barrier usage in GSP->CPU " Gary Guo
2026-08-19 17:39   ` sashiko-bot
2026-08-24 12:51   ` Eliot Courtney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DL3AYW5D121E.29D3XI699XMKN@garyguo.net \
    --to=gary@garyguo.net \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel-bounces@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=simona@ffwll.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.