Rust for Linux List
 help / color / mirror / Atom feed
From: "Danilo Krummrich" <dakr@kernel.org>
To: "Onur Özkan" <work@onurozkan.dev>
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: Fri, 22 May 2026 15:15:48 +0200	[thread overview]
Message-ID: <DIP8F1CLYQ27.11XC6BW3Y3WGP@kernel.org> (raw)
In-Reply-To: <20260510082211.207450-1-work@onurozkan.dev>

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.

  parent reply	other threads:[~2026-05-22 13:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-10  8:21 [PATCH v1] rust: workqueue: add cancel_sync support 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 [this message]
2026-05-23  6:52   ` Onur Özkan

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=DIP8F1CLYQ27.11XC6BW3Y3WGP@kernel.org \
    --to=dakr@kernel.org \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@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 \
    --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