From: Dan Carpenter <dan.carpenter@linaro.org>
To: "SHANMUGAM, SRINIVASAN" <SRINIVASAN.SHANMUGAM@amd.com>
Cc: "amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Kuehling, Felix" <Felix.Kuehling@amd.com>,
"Deucher, Alexander" <Alexander.Deucher@amd.com>,
"Koenig, Christian" <Christian.Koenig@amd.com>,
"Lazar, Lijo" <Lijo.Lazar@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Make emit_vm_flush() check explicit in amdgpu_vm_flush()
Date: Mon, 16 Mar 2026 13:49:35 +0300 [thread overview]
Message-ID: <abfgP8zS5RDTEBcy@stanley.mountain> (raw)
In-Reply-To: <IA0PR12MB8208E15658F04F7E3A6A345B9040A@IA0PR12MB8208.namprd12.prod.outlook.com>
On Mon, Mar 16, 2026 at 07:04:46AM +0000, SHANMUGAM, SRINIVASAN wrote:
> > > Fixes the below:
> > > drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:826 amdgpu_vm_flush() error: we
> > > previously assumed 'ring->funcs->emit_vm_flush' could be null (see
> > > line 788)
> > >
> >
> > I think the code logic is correct and the check is implicit in vm_flush_needed. We
> > don't need to write code to eliminate 'false warnings'. Moreover, it is inappropriate to
> > use a Fixes tag for this.
>
>
> My initial thought was that the earlier gating of vm_flush_needed on
> ring->funcs->emit_vm_flush would make the later call safe, but Smatch
> still reports the following warning:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:826 amdgpu_vm_flush()
> error: we previously assumed 'ring->funcs->emit_vm_flush' could be null
>
> Dan, could you please confirm whether this is expected to be a false
> positive from Smatch due to the vm_flush_needed boolean, or if there
> is a recommended pattern to help Smatch track this relationship?
I really would just encourage everyone to get used to ignoring old
warnings. If we fix all the real bugs then the old warnings are all
false positives.
It's this assignment which trips Smatch up:
vm_flush_needed &= !!ring->funcs->emit_vm_flush &&
job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET;
If we wrote it like:
if (!ring->funcs->emit_vm_flush || job->vm_pd_addr == AMDGPU_BO_INVALID_OFFSET)
vm_flush_needed = false;
Then Smatch would parse it correctly. Or if we wrote it like this:
vm_flush_needed = vm_flush_needed &&
(ring->funcs->emit_vm_flush &&
job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET);
In that case, Smatch sees the && and says this is a condition assignment
and re-writes it behind the scenes as:
if (vm_flush_needed && (ring->funcs->emit_vm_flush &&
job->vm_pd_addr != AMDGPU_BO_INVALID_OFFSET))
vm_flush_needed = true;
else
vm_flush_needed = false;
which is also parsed correctly.
So the difference here is that the &= type assignment is not handled. The
simplest thing would be to make &= a special case. This wouldn't really
help in many cases but handling |= would help since having a string of
"ret |= frob();" assignments is quite common.
regards,
dan carpenter
next prev parent reply other threads:[~2026-03-16 13:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-15 6:55 [PATCH] drm/amdgpu: Make emit_vm_flush() check explicit in amdgpu_vm_flush() Srinivasan Shanmugam
2026-03-16 6:48 ` Lazar, Lijo
2026-03-16 7:04 ` SHANMUGAM, SRINIVASAN
2026-03-16 8:26 ` Christian König
2026-03-16 10:49 ` Dan Carpenter [this message]
2026-03-16 8:17 ` Christian König
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=abfgP8zS5RDTEBcy@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=Alexander.Deucher@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Lijo.Lazar@amd.com \
--cc=SRINIVASAN.SHANMUGAM@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox