From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: drm: dispatch work items to the private data Date: Wed, 25 Mar 2026 07:11:04 +1000 Message-ID: In-Reply-To: <20260323-aref-workitem-v3-2-f59729b812aa@collabora.com> References: <20260323-aref-workitem-v3-0-f59729b812aa@collabora.com> <20260323-aref-workitem-v3-2-f59729b812aa@collabora.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Patch Review This patch implements `WorkItem` and `HasWork` for `Device` to forward t= o `T::Data`. **The `HasWork` implementation:** ```rust unsafe impl HasWork, ID> for Device where T: drm::Driver, T::Data: HasWork, ID>, { unsafe fn raw_get_work(ptr: *mut Self) -> *mut Work, ID> { let data_ptr =3D unsafe { &raw mut (*ptr).data }; unsafe { T::Data::raw_get_work(data_ptr) } } ``` There's a subtle type issue worth noting: `T::Data::raw_get_work(data_ptr)`= =E2=80=94 the bound is `T::Data: HasWork, ID>`, so `raw_get_work= ` expects `*mut T::Data` (since `HasWork::raw_get_work` takes `*mut Self` w= here `Self =3D T::Data`). The `data_ptr` is `*mut T::Data` from `&raw mut (= *ptr).data`, so this is correct. The `work_container_of` does: ```rust unsafe fn work_container_of(ptr: *mut Work, ID>) -> *mut Self { let data_ptr =3D unsafe { T::Data::work_container_of(ptr) }; unsafe { crate::container_of!(data_ptr, Self, data) } } ``` This correctly goes from `Work` =E2=86=92 `T::Data` =E2=86=92 `Device` v= ia `container_of`. Since `Device` is `#[repr(C)]` with `data` as the sec= ond field, the `container_of` is valid. **The `WorkItem` implementation:** ```rust impl WorkItem for Device where T: drm::Driver, T::Data: WorkItem>>, T::Data: HasWork, ID>, { type Pointer =3D ARef>; fn run(ptr: ARef>) { T::Data::run(ptr); } } ``` This requires `T::Data: WorkItem>>`. This is= the key constraint =E2=80=94 the driver's data type must declare its work = item pointer as `ARef>`, not `ARef`. This makes sense gi= ven the orphan rule motivation and is clearly documented in the commit mess= age. Looks correct. --- Generated by Claude Code Patch Reviewer