The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Christian König" <christian.koenig@amd.com>
Cc: phasta@kernel.org, "Sumit Semwal" <sumit.semwal@linaro.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: DamFence: Remove warning about unsignaled drop
Date: Fri, 20 Nov 2026 12:44:31 +0100	[thread overview]
Message-ID: <DN00GAPAAQTY.1T9M9U7UAFYC0@kernel.org> (raw)
In-Reply-To: <c18fc55a-717f-42a0-b37f-4ed81efd29d1@amd.com>

On Fri Nov 20, 2026 at 10:15 AM CET, Christian König wrote:
> On 11/19/26 16:34, Danilo Krummrich wrote:
>> On Thu Nov 19, 2026 at 11:47 AM CET, Christian König wrote:
>>> A dma_fence should *NEVER* signal because you waited for something. Instead
>>> the dma_fence is what is waited on.
>> 
>> In the end, despite doing it on behalf of the hardware, the driver is the
>> producer of the fence. And there are cases where it can't wait on its own fence,
>> because no one is going to signal it other than the driver itself.
>> 
>> Assume you have an execution context that is torn down, and also assume the
>> hardware supports preemption. Then some of the jobs in the queue might still
>> signal, but some jobs are not processed anymore and hence are not signaled.
>> 
>> For those jobs that did not execute anymore, the fence still has to be signaled.
>> So the driver has to signal them after it waited on the preemption and execution
>> context teardown is complete and no more operations are in flight.
>
> Oh well that comment made me smile because it confirmed what I wrote :)

No, it just seems that way because you ignore everything I write and instead
repeat "wait for the DMA fence".

Again, how can a driver wait for its own fence to be signaled (e.g. through an
interrupt) when the hardware (or firmware) queue is dead?

> How do you wait for the "preemption and execution context teardown is complete
> and no more operations are in flight" ?

I think the generic answer is exactly the same way as if an individual job
completes, the driver signals the fence for otherwise.

> That waiting for DMA context teardown must be done through a dma-fence. That
> is the whole concept of dma-fences in the first place.

Again, how can this be done if the hardware or firmware queue is dead?

> I wish I could enforce that in C somehow but we missed that opportunity when
> we originally designed the dma-fence and now it is to late because of the
> fallout and complexity required for such a change.
>
> See the discussion here as well https://lists.freedesktop.org/archives/dri-devel/2025-August/520640.html

You ask about whether dma_fence_work_commit_imm() in i915 should exist in the
first place. I can't find any subsequent discussion and the function exists in
i915 till today. What did you intend me to extract from this?

> I think we are at the point where I need to make clear that practices like
> signaling fences from a destructor or other IOCTL initiated teardown is a NAK
> from my side as DMA-buf maintainer.
>
> When you want to push forward with this anyway I think we need to raise this
> with Dave/Linus to get an answer if such an approach is ok or not.

There's many indicators in this discussion that show me that you probably don't
understand Rust enough, or didn't engage with the arguments enough to make such
a call (mixing up Rust destructors and IOCTL context above is one of them).

At this point, none of this needs an authoritative answer.

That said, maybe it helps to find some similar examples in C. I tried to find
amdgpu ones. Xe code is probably a better fit as it has firmware queues as well,
but let's try this first.

amdgpu signales fences in a way that is a destructor too.

[1] was introduced in commit 97ff19462539 ("drm/amdgpu: Implement a new
userqueue fence driver"), explicitly suggested and reviewed by yourself.

(To me it seems that this signaling loop is unnecessary though, so maybe fair
enough.)

Another example is amdgpu_fence_driver_force_completion() [2], which is called
in many places. One of them has the following callchain:

	amdgpu_pci_remove()
	  drm_dev_unplug()
	  amdgpu_driver_unload_kms()
	    amdgpu_device_fini_hw()
	      amdgpu_fence_driver_hw_fini()
	        amdgpu_fence_driver_force_completion()
	          amdgpu_fence_process()
	            dma_fence_signal()
	

The comment in [3] explicitly says "You can't wait for HW to signal if it's
gone", which is exactly my point.

The same is true for when a firmware ring is gone (or dead) and the firmware
guarantees that there are no more outstanding transfers.

And then there's of course the case where jobs didn't hit a hardware or firmware
queue in the first palce, e.g. in drm_sched_entity_kill().

All of those examples are all destructors.

[1] https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c#L183
[2] https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c#L668
[3] https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c#L543
[4] https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/scheduler/sched_entity.c#L305

>> The same is true for job fences that are in a software queue and never hit the
>> queue of the hardware execution context.

  reply	other threads:[~2026-11-20 11:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 10:10 [PATCH] rust: DamFence: Remove warning about unsignaled drop Philipp Stanner
2026-11-12 10:29 ` Christian König
2026-11-17  8:24   ` Philipp Stanner
2026-11-17  9:51     ` Christian König
2026-11-17 10:54       ` Philipp Stanner
2026-11-17 13:40         ` Christian König
2026-11-17 13:50           ` Danilo Krummrich
2026-11-17 14:50             ` Christian König
2026-11-17 16:26               ` Gary Guo
2026-11-17 16:36               ` Danilo Krummrich
2026-11-19  9:32                 ` Christian König
2026-11-19  9:58                   ` Philipp Stanner
2026-11-19 10:47                     ` Christian König
2026-11-19 14:55                       ` Philipp Stanner
2026-11-19 15:34                       ` Danilo Krummrich
2026-11-20  9:15                         ` Christian König
2026-11-20 11:44                           ` Danilo Krummrich [this message]
2026-11-19 12:35                   ` Danilo Krummrich
2026-11-17 14:06       ` Danilo Krummrich

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=DN00GAPAAQTY.1T9M9U7UAFYC0@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel.almeida@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=phasta@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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