From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: rust: add Work::disable_sync
Date: Sat, 14 Mar 2026 07:15:46 +1000 [thread overview]
Message-ID: <review-patch2-20260313091646.16938-3-work@onurozkan.dev> (raw)
In-Reply-To: <20260313091646.16938-3-work@onurozkan.dev>
Patch Review
**Minor concern: should this really be `unsafe`?**
```rust
+ pub unsafe fn disable_sync(&self) {
+ let ptr: *const Self = self;
+ // SAFETY: `self` points to a valid initialized work.
+ let raw_work = unsafe { Self::raw_get(ptr) };
+ // SAFETY: `raw_work` is a valid embedded `work_struct`.
+ unsafe { bindings::disable_work_sync(raw_work) };
+ }
```
The safety doc says:
```rust
+ /// # Safety
+ ///
+ /// Must be called from a sleepable context if the work was last queued on a non-BH
+ /// workqueue.
```
This is reasonable — `disable_work_sync()` can sleep, so calling it from atomic context would be a bug. However, this pattern ("must be called from sleepable context") is very common in kernel APIs and many Rust wrappers handle it differently (e.g., via type-level guarantees or just making it safe with a documented precondition, since calling from atomic context is already UB-adjacent behavior the kernel catches with `might_sleep()` debugging). Consider whether making this `unsafe` is the right abstraction level — the Rust workqueue `Queue` type's methods like `enqueue` are safe despite having their own context requirements.
Also, the `# Safety` section is documenting a caller requirement but this is a method on `&self` — the naming convention in kernel Rust is typically to use `# Safety` for `unsafe` preconditions, which this does, but you might also want a `# Panics` or general doc section clarifying when it's valid to call. Minor style nit.
**Missing C helper**: The patch adds a Rust wrapper for `disable_work_sync` but doesn't add a corresponding C helper in `rust/helpers/workqueue.c`. Looking at the binding, `bindings::disable_work_sync` would need to resolve to the C function. Since `disable_work_sync()` in `include/linux/workqueue.h` is a regular (non-inline, non-macro) extern function, this should work via direct bindgen without a helper. This is fine.
---
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-03-13 21:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-13 9:16 [PATCH v1 RESEND 0/4] drm/tyr: implement GPU reset API Onur Özkan
2026-03-13 9:16 ` [PATCH v1 RESEND 1/4] drm/tyr: clear reset IRQ before soft reset Onur Özkan
2026-03-13 21:15 ` Claude review: " Claude Code Review Bot
2026-03-13 9:16 ` [PATCH v1 RESEND 2/4] rust: add Work::disable_sync Onur Özkan
2026-03-13 12:00 ` Alice Ryhl
2026-03-13 21:15 ` Claude Code Review Bot [this message]
2026-03-13 9:16 ` [PATCH v1 RESEND 3/4] rust: add ordered workqueue wrapper Onur Özkan
2026-03-13 21:15 ` Claude review: " Claude Code Review Bot
2026-03-13 9:16 ` [PATCH v1 RESEND 4/4] drm/tyr: add GPU reset handling Onur Özkan
2026-03-13 14:56 ` Daniel Almeida
2026-03-13 21:15 ` Claude review: " Claude Code Review Bot
2026-03-13 9:52 ` [PATCH v1 RESEND 0/4] drm/tyr: implement GPU reset API Alice Ryhl
2026-03-13 11:12 ` Onur Özkan
2026-03-13 11:26 ` Alice Ryhl
2026-03-13 21:15 ` Claude review: " Claude Code Review Bot
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=review-patch2-20260313091646.16938-3-work@onurozkan.dev \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.com \
/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