mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Almeida <daniel.almeida@collabora.com>
To: Philipp Stanner <phasta@kernel.org>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.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>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Boris Brezillon" <boris.brezillon@collabora.com>,
	John.harrison@igalia.com, da.gomez@kernel.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org
Subject: Re: [RFC PATCH v5 0/6] rust: Add drm::JobQueue
Date: Sat, 10 Oct 2026 21:22:07 -0300	[thread overview]
Message-ID: <F09C7397-AF97-4947-89D5-759498BCF7B0@collabora.com> (raw)
In-Reply-To: <20261009191124.1022902-2-phasta@kernel.org>

Hi Philipp,

> On 9 Oct 2026, at 16:11, Philipp Stanner <phasta@kernel.org> wrote:
> 
> Changes in v5:
>  - Add back the Revocable<JobQueueInner…> from my earliest RFCs. Reason
>    is still the same: JQ dropping while dependency fences signal could
>    deadlock. Similarly, this solves a dependency kicking of the work
>    item again while drop() is running.

Can you expand a bit on this? IIUC the problem is introduced by trying to take
the jq lock on signal? If so, this could be avoided by queuing the worker from
that path instead?

>  - Do not call run_job() with a lock held, since run_job() might sleep.
>    AFAICS, this also makes the proposed XArray solution impossible and
>    demands that we use a list.

Can you expand on this a bit?

>  - Re-add the earlier credit-count-system, so that run_job() is
>    infallible. Simplifies the design quite a bit. (Danilo)

What is AGX’s position on this? IIRC, this credit system could not represent
their submission model exactly, like it can for others.


>  - Drop jobs in a deferred manner through the work item so that job
>    payload data can do atomic-hostile stuff.
>  - Because of the point above, I suggest that we stop dropping a
>    DriverFence on signal (Danilo's and my idea). It has no real
>    advantage, and getting rid of it allows for better controlling what
>    drops when through JobQueue. For fence it's only relevant that there
>    is an RCU grace period, thus:
>  - Replace DriverFence::drop()'s call_rcu() with synchronize_rcu(). We
>    would, therefore, demand that everyone who's got a problem with the
>    delay drops via work item.

I will get back to you.

> 
> This can still not be tested as I'm blocked by pin-init vs self-ref.
> Just FYI.
> 
> I would appreciate confirmation of these following thoughts on locking
> design:
> 
> 1.
> I believe that callers of jq.new_job() and jq.submit_job() do not need
> an outer serialization mutex. Reason is that JQ serializes with its
> internal lock. Sequence numbers cannot take over older seqnos because it
> is submit_job() who sets the seqno.

I guess this makes sense, so long as submit_job() doesn’t take &mut self?

Also, submit_job() assigning seqnos is not compatible with the XArray IIRC.
Fine if going with lists, I suppose.


> 
> 2.
> I, furthermore, believe that a driver will not need to hold a
> driver-lock while calling jq.complete_jobs_up_to_seqno().

In tyr, we hold _no_ locks. The driver signals the fences, and this will
enqueue the worker thread.

> 
> IOW, I am suggesting that a driver can always safely use JQ without an
> outer lock, and actually *should* do so to avoid potential locking
> issues.
> 
> Reason:
> 
> let driver_stuff = foo.lock();
> let current_gpu_seqno = driver_stuff.get_seqno();
> drop(driver_stuff);
> jq.complete_jobs_up_to_seqno(current_gpu_seqno);
> 
> Thus, I believe that it is OK for me to take the JQ lock in
> jq.complete_jobs_up_to_seqno().
> 
> Please correct me if I'm missing something.
> 
> Should I be wrong and a lock inversion could occur, then we could
> hypothetically add a fence Signaler object, with which we could signal
> fences with a different lock. Similar to how drm_sched does it with the
> hardware_fence.
> 
> 
> Regards
> P.
> 
> 

I will have a more thorough look this week :)

— Daniel



      parent reply	other threads:[~2026-10-11  0:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-09 19:11 Philipp Stanner
2026-10-09 19:11 ` [RFC PATCH v5 1/6] rust: DmaFence: remove static lifetime Philipp Stanner
2026-10-09 19:11 ` [RFC PATCH v5 2/6] rust: DmaFence: Implement Deref for FenceContext Philipp Stanner
2026-10-09 19:11 ` [RFC PATCH v5 3/6] rust: DmaFence: Don't drop on signal Philipp Stanner
2026-10-09 19:11 ` [RFC PATCH v5 4/6] rust: DmaFence: [RFC] Add Signaler Philipp Stanner
2026-10-09 19:11 ` [RFC PATCH v5 5/6] rust: DmaFence: Replace call_rcu() with synchronize_rcu() Philipp Stanner
2026-10-09 19:11 ` [RFC PATCH v5 6/6] rust: drm: Add JobQueue Philipp Stanner
2026-10-11  0:22 ` Daniel Almeida [this message]

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=F09C7397-AF97-4947-89D5-759498BCF7B0@collabora.com \
    --to=daniel.almeida@collabora.com \
    --cc=John.harrison@igalia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=christian.koenig@amd.com \
    --cc=da.gomez@kernel.org \
    --cc=dakr@kernel.org \
    --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=simona@ffwll.ch \
    --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

all inboxes | Powered by JetHome®