From: "Onur Özkan" <work@onurozkan.dev>
To: Danilo Krummrich <dakr@kernel.org>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net,
bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
peterz@infradead.org, fujita.tomonori@gmail.com,
tamird@kernel.org
Subject: Re: [PATCH v1] rust: workqueue: add cancel_sync support
Date: Sat, 23 May 2026 09:52:12 +0300 [thread overview]
Message-ID: <20260523065215.23709-1-work@onurozkan.dev> (raw)
In-Reply-To: <DIP8F1CLYQ27.11XC6BW3Y3WGP@kernel.org>
On Fri, 22 May 2026 15:15:48 +0200
Danilo Krummrich <dakr@kernel.org> wrote:
> On Sun May 10, 2026 at 10:21 AM CEST, Onur Özkan wrote:
> > Drivers can use this during teardown to cancel pending work and wait for
> > running work to finish before dropping related resources.
>
> If you need this for driver teardown and the work uses device resources, you
> should rather create a new type of work that internally synchronizes with driver
> unbind.
>
> This also allows you to provide a &Device<Bound> within the work function itself
> directly.
>
> Instead you now have to fall back to unsafe code in your work callback
> implementation making it a driver responsibility to call cancel_sync() at the
> correct point of time:
>
> // SAFETY: `Controller` is part of driver-private data and only exists
> // while the platform device is bound.
> let pdev = unsafe { self.pdev.as_ref().as_bound() };
>
> I already mentioned this a couple of times in the past that we want "managed"
> work for drivers for this exact reason.
>
> More in general, please don't use Device::as_bound() from driver code; if it is
> needed it implies a design issue or that we're missing a proper solution.
That makes sense a lot of sense. I will try to figure out a design for this.
- Onur
prev parent reply other threads:[~2026-05-23 6:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 8:21 Onur Özkan
2026-05-10 13:43 ` Alice Ryhl
2026-05-10 15:53 ` Onur Özkan
2026-05-13 7:33 ` Alice Ryhl
2026-05-22 11:39 ` Onur Özkan
2026-05-22 13:15 ` Danilo Krummrich
2026-05-23 6:52 ` Onur Özkan [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=20260523065215.23709-1-work@onurozkan.dev \
--to=work@onurozkan.dev \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
/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®