On Mon Nov 30, 2026 at 2:19 PM GMT, Janne Grunau wrote: > On Mon, Nov 30, 2026 at 01:32:18PM +0100, Alice Ryhl wrote: >> On Mon, Nov 30, 2026 at 12:48 PM Miguel Ojeda >> <[email protected]> wrote: >> > >> > On Mon, Nov 30, 2026 at 11:18 AM Alice Ryhl <[email protected]> wrote: >> > > >> > > While teaching the Rust for Linux course, >> > >> > Without context, people will not know what course it means. Maybe add >> > the company name? >> >> Yeah I worded this "my" elsewhere but forgot to do so here. >> >> > > integer, so it's not clear what values about i32::MAX would mean. >> > >> > "above" >> > >> > > This means that there are two ways of returning a >> > > negative value to userspace (either Err(err) or Ok(-x)), and that >> > > userspace cannot distinguish whether the driver did one or the other. >> > >> > Yeah, I am not thrilled about having two ways that look different but >> > do the same. >> >> Well, I don't think the current behavior that has errornous behavior >> is great either. Perhaps we can just return Result<()>, but I am not >> sure if any DRM drivers actually need non-zero return value. > > drm_ioctl() is annotated to return "Zero on success, negative error code > on failure." [1] so it should be safe to switch to Result<()>. > I verified that it's true for the asahi downstream driver. A quick > verification of panthor's (and nouveau's?) ioctl wouldn't hurt but I'd > be surprised if those return values other than 0 on success. > So it should be safe to return Result<()> at least for now but I > wouldn't expect this to change. > The drm_ioctl implementation had since forever (the git root commit in > 2005) a debug log statement on non-zero ioctl return values.
I asked a clanker to search for the codebase (and I verified), and there're a few ioctls that return non-zero on success: - DRM_IOCTL_I915_PERF_OPEN -- returning a file descriptor - DRM_IOCTL_I915_PERF_ADD_CONFIG -- returning a OA config ID - DRM_IOCTL_XE_OBSERVATION -- returning FD or OA config ID - DRM_IOCTL_MSM_PERFCNTR_CONFIG -- returning a FD All of them are driver-specific ioctls and according to the clanker none of the core ioctls return non-zero on success (unverified). I think we can define a trait for allowed return values perhaps? Initially just implement it for () which converts to 0, and we can add more when it's needed in the future. Best, Gary > > Janne > > Link: > https://www.kernel.org/doc/html/v4.11/gpu/drm-internals.html#c.drm_ioctl [1]
