From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.155 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796038998; b=XPvfiwNNU4jLcKA329a4AwhMbLbpFVbDWxa9Z1w/ZyNHHqdNAwb2F2cVuZFCMwd3rtdr 4+GS9nNBRziteW7iXQvwpCG7KqWIj2mrMIrFc8KD+zlRIzlp/8XsvFS8waYwB08wUH5Mg HUKJwLoavC3mtPeycLCuZIE0db8GBUWQogDLu8Us7pm2V+gssAedyI4GoWExmt7RMoc8h woSBsVZ3PXoDNpUApf7ExU2JZSSFlj5jA7FmjtwenumbmC3lwPwxXOUTNfnwwZphah0fj fuTbPcq6isuTzY39tkwnBRHe3+9zYGyxjTo1SEY9stsbEf1zoEDOVtBHU79DDQCDDvg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796038998; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=M2zBNGFzV6efolhQaBOJuOdJsq5jt+kB41pQ/FZ79+4=; b=KWc49CBgfIcvcL/6HOYnZw+FFhju/2G+FW/9OJE9acF4zssk62jn0PlsUOZ2fuixn/RH d4vKHCyLW6FT49jbiPJaSJCnS6wT/O5UMePYA6d9YkSccGoElMDOVNmKmyzwhawnzyBD0 VtxM1hahw50Eq2HDIOgeCJjSk+66H/JngYsys2T30CTg5ZMPoy8kpuuKgdJD/Q18dLTnz JNTdqyqdWW8Rq41KLJWSOX5bQx98Jw3Nu28z04+i4REtvW3kKdbfru3qvVDNEDFx6RQXO SIsLicHKh92/jyNxf3tHJQnDbjJDWnaYUvfBoXy9vzHp6lpo66Kf5QuAezUQ7m4pwQQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=jannau.net; spf=pass smtp.mailfrom=jannau.net; dkim=pass header.d=jannau.net header.i=@jannau.net header.a=rsa-sha256 header.s=fm2 header.b=qrxTbMzz; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=lnmgE3QI; arc=none smtp.remote-ip=103.168.172.155 Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BEF2606A325 for ; Mon, 30 Nov 2026 11:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9BEF2606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jannau.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jannau.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=jannau.net header.i=@jannau.net header.a=rsa-sha256 header.s=fm2 header.b=qrxTbMzz; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=lnmgE3QI Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8230B1402D6A for ; Mon, 30 Nov 2026 06:43:16 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Mon, 30 Nov 2026 06:43:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jannau.net; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1796038996; x=1796125396; bh=M2zBNGFzV6 efolhQaBOJuOdJsq5jt+kB41pQ/FZ79+4=; b=qrxTbMzzh3qkZiKSvmNUjd+jNe z2JJ0mtwbpv+w9/n9MXEh7N3vmmV8jj8snI5WloGesFgvJbhd5ognFFS67BXGyNd 6SryZXQvS7SNcXC5plKzI6AmQjKESEGKJya5L+v8tywkaQw9+PsV+M2OdznoBoOR PPqFzaMf677qyvpGNHkQUo/eV3IXBGOQ6g7bmAwFl8Zefo/ceBQWe0aMBVmnwSSw tB293cyJbc0dp69vUSwuB/wsip4lMGksNS8JAyEFjlnUXPlPG4jfD+7Yp9NsbbmU 9H9FECjAvAy/gyskc9WhqIRwDhQk8JJ76tvvX1jrdDVMNE32ier1vedNmUWw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796038996; x=1796125396; bh=M2zBNGFzV6efolhQaBOJuOdJsq5jt+kB41p Q/FZ79+4=; b=lnmgE3QIkkHV4gZQ2N4f6YyWlf17fYd2MgQkMXb8Mbt9/b5K7OR UmWWmZvY4FMuGI6x3vaQ8Jv5rjyWIUPmRG5hJLTpUiTyNr4sc4vd4ckV4Jn7orLc gbL+j/nbzXaItayCm6n8CHyMGPc3HP/G0KabUOxHpYBd3+wRHh3komlSQylGHQBL UVJxAu4aWIaQqq9KB7Sk7/fxZj61WR3+RlpCU4YjgR3NKKKSPfYGpiywELiUeNUH X36S06+MuT/hUjhoEWvF3KFm3TjCYa9E6lWl8Fy+FDQUD3aKlIZsv8ofobwYnQc2 q9SAflw3l7IfrUt3+8ZgNUd9qCVtuTF/JZw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=jannau.net a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796038996; d=jannau.net; mf=PGpAamFubmF1Lm5ldD4=; rt=PG5vdmEtZ3B1QGxpc3RzLmxpbnV4LmRldj4=; s=fm2:rsa-sha256:bTKnaa4W3mX3/+wA8iSCQAx5k7VIEgpv2yq6aiQKeC60w/j f8bJjgBu9DxiroViATXJizaPwuHmB7IVR2WHniWFNAF0I4xqM4EjhvhtDLyzGJfD XVhf6uX9qPANC7bUimSbmaO6Ir1cfgOwOr9qxyBKsGSnPjCWO/O1pgIm2f3AuTKf gSJL0ersNibFH++6RckWltp3ppWNVmq7257JtpFNV6W3/opp25D7Hm4mbClj6ClZ jBYb/uY6tsYlPr0+9nY1/NymV4JH7lNuH7F0cyucaTU1+9d5ycswoNcNKKJCFbje pGFLY1Itt9F8Jsd3xtsDBr9En/z4vZhdkJJdy/w==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:cLdFQTU7VFt4TWebOHq8hNo5kAyYBhLmpfpdsdQzAGg=:J6cPdX+5x9Rn/fzohPRd8dofuHAam1Ijf34e93i38+I=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGGD/IAmoYS9AVYiUP4XxDm3FdNDQ2qODwnu5+rUGe78rnzT8DLagS0oHcT16yyet +xq6BxMcTxvSrgqcZplgVjKEbHlzQEClFwC0kmK5lFCajBO930dJm5eh3yH7gn6DD5tL5c ooSBEQBCFrV/vwJigiWFeacZyfE11jqF9ll9OP/VW59QEbjsi4INO/PJHjVsu2xi2+puh2 lau0uK35kjunOEBKbh40TxIiGF+hTsU7RUsDit3SONBau/Dr/+j7Oy2jIR0ZKFdgRxrul6 BuvcuEJZS1CoagLjx2enlqRoOACUVyFQ/vxLMDe2sKJfGA6BE6HtpC8NM0K/oWCll2I9Qu WELPvhLVBRUrkxPm4sQCGw7rVo9euUtIDICh5ygmimyM+TtmlaZTU//QaivZdAva8L3Tzs bM9rRnozFI2MAhSPNBh/B9CeN6jIfdWmhib0SEJAp8tQa8EzFkOS4UDVqaZ5L3qOUdOYNK lDnYIU8tl1DGBdYvWj5JE2eh0EwFU69sk7YdLdSj+0cZhBMscVzj4dGi7JkKICDZKkm0Kj lkI8JNE5UThg6MWLNhNpwyxJG8NpLQfZWrHlFmU5DuyvdQ3w+nwUCvMWMMeG3+6vgKSx/t BsyFcZJ1MOGzl4Me+0b/SUjm6MzVQfUia0ohJJ/k85hLd8PUMVlxkSltULsA X-ME-Proxy: Feedback-ID: i47b949f6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Nov 2026 06:43:15 -0500 (EST) Date: Mon, 30 Nov 2026 12:43:13 +0100 From: Janne Grunau To: Alice Ryhl Cc: Danilo Krummrich , Daniel Almeida , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?B?QmrDtnJu?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Tamir Duberstein , Alexandre Courbot , Onur =?utf-8?B?w5Z6a2Fu?= , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH 1/2] rust: drm: ioctl: return Result from ioctl handlers Message-ID: <20261130114313.GA41778@robin.jannau.net> References: <20261130-drm-ioctl-return-i32-v1-0-2134e8274300@google.com> <20261130-drm-ioctl-return-i32-v1-1-2134e8274300@google.com> X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261130-drm-ioctl-return-i32-v1-1-2134e8274300@google.com> On Mon, Nov 30, 2026 at 10:17:44AM +0000, Alice Ryhl wrote: > Currently drm ioctl handlers return a Result where errors are > translated to negative numbers and values are converted to a > non-negative i32. The values above i32::MAX are considered erroronous > and mapped to -ERANGE. > > While teaching the Rust for Linux course, we ended up discussing the > above after a student found it confusing and asked about this return > value. Of course, the students knew that the C side returns a signed > integer, so it's not clear what values about i32::MAX would mean. > > Based on this discussion, I'm suggesting here that we change the return > value to Result. 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. I'd argue that userspace is not the main problem but allowing more sutle variants of `Ok(EINVAL.to_errno())` in the driver may hide bugs. I'm not sure what happens if the the ioctl returns a random negative number and not a defined error. If that ends up in userspace's errno it is probably confusing as well. Would be using `Bounded::` as return value an option? Do we even have DRM ioctls that return a different value than `0` on success? If not and we don't foresee ever adding them we could simplify the return value to a plain Result. Janne