From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9D702C5DF66 for ; Mon, 17 Aug 2026 14:08:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1257910E7F4; Mon, 17 Aug 2026 14:08:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Jtv/Vobn"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0622B10E7F4; Mon, 17 Aug 2026 14:08:17 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 756B042E61; Mon, 17 Aug 2026 14:08:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 264B91F00A3D; Mon, 17 Aug 2026 14:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786975696; bh=xxy0gHLKhdxtuUAFYQ8rWUWihf1KnUG6LllOzkRyE90=; h=Date:Cc:To:From:Subject:References:In-Reply-To; b=Jtv/Vobnmlg6DM04eaz2kLJKTht4m5jYkvnTMmQB+vxstfx4e1GVnc0h6yNLA3BKa s4JGuQrDe8RlhzVvoNU5J7pqSwVDMrOowrZHRp5YCh+07v4QnMW+vczzROYAXLS9mQ 5Eca6vSJ244zkNpfgGJKiUWRm1xC0mJmXDDmMoAhSBMcp/Yn0O24JSlMDY9NxVvCRY hW0Rn/iXpQKWJFrFWcmt/N6kDpcDYln5ZB03/t/OnSxaKMzbk3oorl1gA13vm5/qGm qoj4q5EX+ggSCBPU4PK/xrd1RE8vR2vAoWaO0yTe4q5xfNdt9/z+UyNyWK/SMk+0UD vaFH80nhpFfqA== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 17 Aug 2026 16:08:09 +0200 Message-Id: Cc: "Eliot Courtney" , "Yury Norov" , "Alice Ryhl" , "Burak Emir" , "Yury Norov" , "Miguel Ojeda" , "Boqun Feng" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Daniel Almeida" , "Tamir Duberstein" , "Alexandre Courbot" , =?utf-8?q?Onur_=C3=96zkan?= , "David Airlie" , "Simona Vetter" , "Greg Kroah-Hartman" , "John Hubbard" , "Alistair Popple" , "Timur Tabi" , "Zhi Wang" , , , , , "dri-devel" To: "Gary Guo" From: "Danilo Krummrich" Subject: Re: [PATCH v5 5/5] gpu: nova-core: add ChannelIdPool References: <20260812-chid-v5-0-6c767770b3f4@nvidia.com> <20260812-chid-v5-5-6c767770b3f4@nvidia.com> In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon Aug 17, 2026 at 3:02 PM CEST, Gary Guo wrote: > Now, with `NonZero` or `Bounded`, we are doing none of that. The only thi= ng here > is that there is a range restriction. Other than the value restriction > themselves, they carry no other semantic meanings. How you interpret thes= e types > still fully depend on the API that accepts them. Therefore, it is very co= mmon > that you'd be using these with literals, and it becomes an ergnomic pain. I agree that NonZero and Bounded are on the weaker end of the argument. But there's still the flexibility argument. The API itself, i.e. alloc_area(), does not need to bother with how the val= ue is checked. I.e. is it a runtime check, compile or build time check, or is it = even unchecked (or panicking) because we can derive the invariant from another t= ype. > Personally I value ergnomics higher than possibility of misuse if latter = can > be easily mitigated otherwise (in this case, by WARN_ON or just support > zero-sized alloc). Both is not a mitigation IMO. WARN_ON() is does not prevent misuse of the API in the first place and in c= ase the value comes from userspace even introduces a vulnerability. Making zero a valid argument simply ignores the problem or just moves it elsewhere, e.g. where the caller has to validate the returned type instead,= i.e. the ChannelIdArea. IOW, we'd remove the invariant ChannelIdArea carries.