From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E704331327A for ; Fri, 20 Feb 2026 08:18:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771575506; cv=none; b=quD73SKUEcozwd8msAfPyvZ9XenG25ZvHW6sIo6rBaP2K29KCNLH/wafSEXI44+n8nZHQvSsMJ+7g7lAmtvVlgFRQKOxc+R9L9zIgw9YEzW4BtzcGPPH09wPDGLzAbNYkKS6l8zC+BirmMvZVXkP07XDKXsonlN/J8Wk2eF3iy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771575506; c=relaxed/simple; bh=01+8JfL5Hs4jbP5GUEH74yNqWgRnrF2S83HDOgriL1o=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dPV/8ayzqmWO6XAKgnUfaLNOqlMjsmswyrNTz7plxq4KTQgRTEWTRvRh4w6gHtiak6u39m1TV9PQ6pMzlKJ+4og7PaJuhLFPu21ORkAEjOQ5ovikpmEET/aRfSGygsn4L5lxbRHMUYuaXyWmev3LuISymS3HpCjw8eoOr9YZ80A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Zzv1V2K8; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Zzv1V2K8" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-4836c819456so12894205e9.3 for ; Fri, 20 Feb 2026 00:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771575502; x=1772180302; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vT1vNk+ignNIrARqY/24E4GTmpP0zmMbEtNGPGXPf3U=; b=Zzv1V2K8z02tm9zdAX5b6dTHPwU3KXJCW5xAA7F+6lUmeNHrIUAmPsaYnoQGuBKK7N PBevSzQOit2ovZDiwLyw9fV+cly0UjFBxcbShvwa58I2nCwwPaKiXrFl9a6hCXke3Tvz o3j2EqjGlcLZoRf5kAzOW8vDumd2l+QaCyQ385b1oJlwAzTiRM1r+RNuFUKgJpJ5lBKb NSUUQu2fPUwseCbYuddDjS+3YjrScWOf9I4FW6He5xZZl1M7gKwjAbaCJ2O+pYxRclR8 4DWV5JxGZkxtbTXklsRLMgyHaDqsKS9p2lvEhdWnVtdMn7/bRW9NGsJ2wbSotXffRoiL G2rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771575502; x=1772180302; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vT1vNk+ignNIrARqY/24E4GTmpP0zmMbEtNGPGXPf3U=; b=nsT1rlnU2gArnLHPSpjBGko3GqfyKgpVVrt6zWDCofCZBmyFvQBdTvKRaWqysPhYxM K5tLc1TMZkv27ihn8FkAsBTcc7/JTb8+2JKjB6Szq9nPEnJ9UO3xROK4KmvJbKt9oM2/ LQKm+FcicI+GuG1aYojrSKRMDMRgrZlu31mau6awcZdHviL0lCdDAyl242qUUsC98Lcp RrncJGBfL++TUZDtzzMF7hBjaBHsVA7LTYu9DBR5WFr6+BhldF6KRJ+EwORhFyJtwGcs mHKBUuLasq1U1BoVlgoORqtDGA4IHUoNDW9kpiRCSnHIN1wz4gZGlET7l2NfDInVBAKp 5oXQ== X-Forwarded-Encrypted: i=1; AJvYcCWQ0ESJQtZGo0P7NcZU3gmv77IPUVDFXFnjlHoX21CwaYBrN8FCuFaHDR7XYf5S6Ar23IRvV8PL7pvPr30=@vger.kernel.org X-Gm-Message-State: AOJu0YxNbg5TRZh15h5c75yKGR1lNsfv5V7zhI84k0AHhP/WNl6DTQwe 0maQYd943jL5J3dDpMtDDHF+dattI0lr+zXZNEfsHsGAHAuFKJg6WI+BD1VweFtrt0byv7X6Ce4 liP24jHhoN1brmxDHHQ== X-Received: from wmjs18.prod.google.com ([2002:a7b:c392:0:b0:482:dff5:2424]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:35c3:b0:477:afc5:fb02 with SMTP id 5b1f17b1804b1-483a55343c9mr16652245e9.21.1771575501977; Fri, 20 Feb 2026 00:18:21 -0800 (PST) Date: Fri, 20 Feb 2026 08:18:21 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260216-register-v6-0-eec9a4de9e9e@nvidia.com> <20260216-register-v6-5-eec9a4de9e9e@nvidia.com> Message-ID: Subject: Re: [PATCH v6 5/9] rust: io: add IoRef and IoWrite types From: Alice Ryhl To: Alexandre Courbot Cc: Danilo Krummrich , Daniel Almeida , Miguel Ojeda , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , Boqun Feng , Yury Norov , John Hubbard , Alistair Popple , Joel Fernandes , Timur Tabi , Edwin Peer , Eliot Courtney , Dirk Behme , Steven Price , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Fri, Feb 20, 2026 at 03:38:46PM +0900, Alexandre Courbot wrote: > On Mon Feb 16, 2026 at 7:52 PM JST, Alexandre Courbot wrote: > > On Mon Feb 16, 2026 at 7:35 PM JST, Alice Ryhl wrote: > >> On Mon, Feb 16, 2026 at 06:36:29PM +0900, Alexandre Courbot wrote: > >>> On Mon Feb 16, 2026 at 6:01 PM JST, Alice Ryhl wrote: > >>> > On Mon, Feb 16, 2026 at 05:04:41PM +0900, Alexandre Courbot wrote: > >>> >> I/O accesses are defined by the following properties: > >>> >> > >>> >> - For reads, a start address, a width, and a type to interpret the read > >>> >> value as, > >>> >> - For writes, the same as above, and a value to write. > >>> >> > >>> >> Introduce the `IoRef` trait, which allows implementing types to specify > >>> >> the address a type expects to be accessed at, as well as the width of > >>> >> the access, and the user-facing type used to perform the access. > >>> >> > >>> >> This allows read operations to be made generic with the `read` method > >>> >> over an `IoRef` argument. > >>> >> > >>> >> Write operations need a value to write on top of the `IoRef`: fulfill > >>> >> that purpose with the `IoWrite`, which is the combination of an `IoRef` > >>> >> and a value of the type it expects. This allows write operations to be > >>> >> made generic with the `write` method over a single `IoWrite` argument. > >>> >> > >>> >> The main purpose of these new entities is to allow register types to be > >>> >> written using these generic `read` and `write` methods of `Io`. > >>> >> > >>> >> Co-developed-by: Gary Guo > >>> >> Signed-off-by: Gary Guo > >>> >> Signed-off-by: Alexandre Courbot > >>> >> --- > >>> >> rust/kernel/io.rs | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > >>> >> 1 file changed, 243 insertions(+) > >>> >> > >>> >> diff --git a/rust/kernel/io.rs b/rust/kernel/io.rs > >>> >> index b150743ffa4f..6da8593f7858 100644 > >>> >> --- a/rust/kernel/io.rs > >>> >> +++ b/rust/kernel/io.rs > >>> >> @@ -173,6 +173,160 @@ pub trait IoCapable { > >>> >> unsafe fn io_write(&self, value: T, address: usize); > >>> >> } > >>> >> > >>> >> +/// Reference to an I/O location, describing the offset, width, and return type of an access. > >>> > > >>> > In the next patch you implement this for usize, but here you say it's a > >>> > reference to an I/O location. I'm pretty sure usize is not a reference > >>> > to an I/O location. > >>> > >>> Methods like `read_u8` use a `usize` to reference the location we want > >>> to read, so aren't they in that context? > >> > >> Oh .. I wouldn't use the word "reference" like that. How about "index" > >> instead? > > > > "index" looks more accurate indeed for something that is not a pointer > > type. > > Actually this creates a bit of confusion in `register.rs`, where we have > arrays of registers, which `RegisterArrayRef` was built using the index > of a particular register within that array. If we rename `IoRef` to > `IoIndex` and transitively `RegisterArrayRef` to `RegisterArrayIndex`, > we now have an index that takes an index... > > Besides `IoRef` is more than just an index - it is also an access width, > and a type to convert that access from/to. Would `IoSpec` and > `specification` be acceptable? Not using "index" make sense to me, but I don't really understand how "spec" fits in either. How about "place" or "location"? Alice