From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CAE930E0CC for ; Tue, 10 Feb 2026 14:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770732676; cv=none; b=U0znVsTzIiFSVBzTTOILEUMJsXcpW3x1nOD/SUYHODrcG/hy9jCdG2JF+S45MsPAl6ZPlKrTKuM3+c+z+C8qxoMEJUhCRCJEbcDpTvPc2xVVjmfrLsiwJt6b1qUtHVve32pYBLtNcGjnU4UvIOrYEJ6CR1vTerHVRh7FAF+SkWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770732676; c=relaxed/simple; bh=qYC95AIHzGKa9UHbhK4gdEItdEhA/WrbJAvnt1ujDXM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=THGnci3+1MhuMA0NtLZRbsd8FdEw6rrbC2c/Uue5lZIvfMExx1YfCsPXzgxZeXYoJN8iFBJJyYvvLhDFjFIf14AYN7qgN0fXAuiNliVMvuwJeZ4YP0NH3LMeox4K7iJihb7T42rxjmUNz+ZTlbzeRuPOp/XvlUQ661tmHRIpZRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2ksu+LtG; arc=none smtp.client-ip=209.85.218.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2ksu+LtG" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-b8861544696so679896766b.3 for ; Tue, 10 Feb 2026 06:11:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770732674; x=1771337474; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wpyZuzgNw/WGJaYO0aTw62Jp3X9Gu5cXyXe5IaYxcjU=; b=2ksu+LtGL24jabf4jISRI4ekREKT5Bsya3JAlDdJ5lUb+Okymk4s6PpQSHPrGlw6H/ voL7V81qsgtLTdPT9f/82nGqozmcx4kfCSPX2zaUgAQ6kVMZBKzHpOtcgAMX+CQkoxJ/ nSrA/HwEfKJVSAw8SwFkdyKS98RsP8k+Cxu7UmvxF/OiLpeqg035paqXn28A1y88KazG E2lAY4/omCfDmBj6jnJ1ISuQdQNMqwxglLhtOXxk0K50LYD3yfKSXlS21zKOueVSjCqe B8aPaAul4OD0qFxHtr1ymJf1goZ9QY+lGBhyp7CuBAIsLJ7xzlWClLpHckF056wiRwZP YH5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770732674; x=1771337474; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wpyZuzgNw/WGJaYO0aTw62Jp3X9Gu5cXyXe5IaYxcjU=; b=BC6cm2i3F0ytAfLcSnix5vWasvQbYMvS+txq9rmh65nODzWJBfzjDLypPgPhxWYEq9 3EsVQWHU2e7syV9d2+LGIFkB6gJeZrvrzenuR+mHxvWSXN+M+7p7Iy+7Z9IkC00ZVf2S DrznEUBpYs/ANZhdF9AhJpJL3Qdes1Mz3cx72mTOXuwv5oK5AqHiXRshtENSU5pdnLgX ZxjSuRlXSQ3hJTVzpqX/9g1rmVg3CQe7c6OkKh9j/mT6v5kaVNM4kWNejpZbjq8/jMqu vwFffDQlKBKpUliuFk+LlzDjmvlZ0F5AX8gFQuDlAYVQSAdo6DkngHD62/yapqj1+T42 jhZw== X-Forwarded-Encrypted: i=1; AJvYcCUcHC/XKraXtSjqFcRcCljiZ2fDHD3t6xHqdCbJG4METY3EkDeANymoYxZX4iEB/flkZ4rhw177ZKMDAjw=@vger.kernel.org X-Gm-Message-State: AOJu0Ywy9SB+Wk6FghUgKf/1+AQBTPjrwHtBPsmRw9TzM0mpMbn+KMDU PhDB8nIQdLp5sylIrafEqWaE0ooWw7YTQKJmWf8DOBI26izjYmuvcMiYqvynax1lCdxV1NS4lTR S5C3qlwPqxTk3lDAuXA== X-Received: from ejca6.prod.google.com ([2002:a17:906:3686:b0:b8e:7d43:b280]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a17:906:f58b:b0:b86:f194:9eec with SMTP id a640c23a62f3a-b8edf1ea493mr956084166b.18.1770732673626; Tue, 10 Feb 2026 06:11:13 -0800 (PST) Date: Tue, 10 Feb 2026 14:11:12 +0000 In-Reply-To: <20260210145156.108ab292@fedora> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260209155843.725dcfe1@fedora> <20260210101525.7fb85f25@fedora> <20260210134913.33cb674f@fedora> <20260210145156.108ab292@fedora> Message-ID: Subject: Re: [RFC PATCH 2/4] rust: sync: Add dma_fence abstractions From: Alice Ryhl To: Boris Brezillon Cc: "Christian =?utf-8?B?S8O2bmln?=" , Philipp Stanner , phasta@kernel.org, Danilo Krummrich , David Airlie , Simona Vetter , Gary Guo , Benno Lossin , Daniel Almeida , Joel Fernandes , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Tue, Feb 10, 2026 at 02:51:56PM +0100, Boris Brezillon wrote: > On Tue, 10 Feb 2026 13:26:48 +0000 > Alice Ryhl wrote: > > > On Tue, Feb 10, 2026 at 01:49:13PM +0100, Boris Brezillon wrote: > > > On Tue, 10 Feb 2026 10:15:04 +0000 > > > Alice Ryhl wrote: > > > > > > > /// The owner of this value must ensure that this fence is signalled. > > > > struct MustBeSignalled<'fence> { ... } > > > > /// Proof value indicating that the fence has either already been > > > > /// signalled, or it will be. The lifetime ensures that you cannot mix > > > > /// up the proof value. > > > > struct WillBeSignalled<'fence> { ... } > > > > > > Sorry, I have more questions, unfortunately. Seems that > > > {Must,Will}BeSignalled are targeting specific fences (at least that's > > > what the doc and 'fence lifetime says), but in practice, the WorkItem > > > backing the scheduler can queue 0-N jobs (0 if no jobs have their deps > > > met, and N > 1 if more than one job is ready). Similarly, an IRQ > > > handler can signal 0-N fences (can be that the IRQ has nothing to do we > > > job completion, or, it can be that multiple jobs have completed). How > > > is this MustBeSignalled object going to be instantiated in practice if > > > it's done before the DmaFenceWorkItem::run() function is called? > > > > The {Must,Will}BeSignalled closure pair needs to wrap the piece of code > > that ensures a specific fence is signalled. If you have code that > > manages a collection of fences and invokes code for specific fences > > depending on outside conditions, then that's a different matter. > > > > After all, transfer_to_wq() has two components: > > 1. Logic to ensure any spawned workqueue job eventually gets to run. > > 2. Once the individual job runs, logic specific to the one fence ensures > > that this one fence gets signalled. > > Okay, that's a change compared to how things are modeled in C (and in > JobQueue) at the moment: the WorkItem is not embedded in a specific > job, it's something that's attached to the JobQueue. The idea being > that the WorkItem represents a task to be done on the queue itself > (check if the first element in the queue is ready for execution), not on > a particular job. Now, we could change that and have a per-job WorkItem, > but ultimately, we'll have to make sure jobs are dequeued in order > (deps on JobN can be met before deps on Job0, but we still want JobN to > be submitted after Job0), and we'd pay the WorkItem overhead once per > Job instead of once per JobQueue. Probably not the end of the world, > but it's worth considering, still. It sounds like the fix here is to have transfer_to_job_queue() instead of trying to do it at the workqueue level. > > And {Must,Will}BeSignalled exists to help model part (2.). But what you > > described with the IRQ callback falls into (1.) instead, which is > > outside the scope of {Must,Will}BeSignalled (or at least requires more > > complex APIs). > > For IRQ callbacks, it's not just about making sure they run, but also > making sure nothing in there can lead to deadlocks, which is basically > #2, except it's not scoped to a particular fence. It's just a "fences > can be signaled from there" marker. We could restrict it to "fences of > this particular implementation can be signaled from there" but not > "this particular fence instance will be signaled next, if any", because > that we don't know until we've walked some HW state to figure out which > job is complete and thus which fence we need to signal (the interrupt > we get is most likely multiplexing completion on multiple GPU contexts, > so before we can even get to our per-context in-flight-jobs FIFO, we > need to demux this thing). All I can say is that this is a different use-case for the C api dma_fence_begin_signalling(). This different usage also seems useful, but it would be one that does not involve {Must,Will}BeSignalled arguments at all. After all, dma_fence_begin_signalling() only requires those arguments if you want to convert a PrivateFence into a PublishedFence. (I guess a better name is PublishableFence.) If you're not trying to prove that a specific fence will be signalled, then you don't need the {Must,Will}BeSignalled arguments. Alice