From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 42635267714 for ; Sat, 21 Feb 2026 08:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771663393; cv=none; b=n1z6pDUO2LZK/1BhphdcVvk8FlK7IFOIaKqchgxxo8LjLzyBpAO8LwgBeJUe6HVziqeCg/6A5qPiPIJ9tPjj85DogSghodN4U3GB0O3W0+w9bdAk8t7MCFr9IziG1K1dgVc5K01urFsB/T9qJdpOM8c6YcIkyy7HMn/BfPoketo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771663393; c=relaxed/simple; bh=GatSdbu3Cxzh1BhHt9Nrd2UzxFhJ/XWk1amcznPRydo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=L/fVjsPGzaR8TziWG/LOjbJOrzMGE9wpU02CqXDfLzwb4+WbH1kwGuI7jgbyjm8BOSiZSLahSUEOPZLl4IDfylW3Bwv2KuQ6hQo3mQ3EZ4MtY+biEBC+c/5pmYGMJM88PuEymtufz1vtLqQbpiUAylciFk6ZmSbNHGHfCu/j7UM= 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=W4zIkTuS; arc=none smtp.client-ip=209.85.128.74 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="W4zIkTuS" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4837b9913c9so31915555e9.0 for ; Sat, 21 Feb 2026 00:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771663388; x=1772268188; 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=TI1u65dUKTPlQPt6U/0xJyIkF4F/BeJUkS8IGT0Cslk=; b=W4zIkTuS5l8kAfY9XMr/TWE7NbjiodpWP6EhhrviYjtO3QoBxtuu1TGJiAkbxPBGj6 hSxfJrTwBa5QO8PGytMXimSmpzcFSdMdIYaO+uf5ahwdAbt5Dx4VCfzbn3zB/kXKKzlo vLIMPJ15IifkbA1r1s5JFDguVUrryISDYzd5Kmv1nX3HmA+067Srf3rMVgPv38FVy0Ox CkDoPiefO5QWXt8Dv1oAcNQOVB5c0Tpj8U9EoWm4RCzkdpzAtQVo+G8l90rojIkRy2OD aTrkMZGacUzGulfsgHAVvgpvN0Zm7+ebvkgq84xE3SeKIEW57uMUwVwSD9DkYq+0fkWA XZCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771663388; x=1772268188; 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=TI1u65dUKTPlQPt6U/0xJyIkF4F/BeJUkS8IGT0Cslk=; b=Zebf+RNr7cQ4sVVVpQZRVmmDDX+lQRdCOGw5ij3jgJF2oNSDNXWly64dsaVU0LshKc lCUeZZJZpTwhIdhairGuYMrkOfkJp0LZm/z+j4J+eOLxi610aLp798uP3/EVWS3OMlug vF+ePKMGzHXGKOVcTGa6YhkgtzdlPFiBRTIrt429wf3Kam4cTcUEOGKX3v4b+XD1KG7p +GZDXWfut7oDGjVRORH+dHyp1Nni4NZk9TqKNUjP0msIa3nZXlAx8/Mmx0hOk8Dt1xPh s3r4AuTjaWDLxfKBx9E0b4ZiDManwIOtQRHCP/0Sf2KEmpwXFq3ExUU2jBzXCRUWyqgI XuNw== X-Forwarded-Encrypted: i=1; AJvYcCVRUgs9qw66WOyBH4scHfBG/0TNvBLhFe5CQrKugODymJXKIpc6er7AphS5mJ9Of95NH/MAtp7SdYTx1FQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9ECNMl0ywv1iMgy6edRQgs/KyJ/VVwJrhu6adTWpGN5ZPLnGm BDKFj0VUTwLk6FJMwAa7nHeODERIWMC06Xx6yeNwpG2RrFEnc0/siw007eoqI+rdjyVQu6OajXB fv+pod6sqG8io53OQlw== X-Received: from wmbdo20.prod.google.com ([2002:a05:600c:6814:b0:480:6c79:b533]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:46c9:b0:483:a21:774c with SMTP id 5b1f17b1804b1-483a95eab7cmr37449865e9.25.1771663388514; Sat, 21 Feb 2026 00:43:08 -0800 (PST) Date: Sat, 21 Feb 2026 08:43:07 +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 11:45:25PM +0900, Alexandre Courbot wrote: > On Fri Feb 20, 2026 at 5:18 PM JST, Alice Ryhl wrote: > > 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"? > > Well it's a specification of how to access an I/O area... kind of. > > "Location" sounds good too, and abbreviates nicely to "Loc", let me see > how that looks in practice. Ok, I like location too. Alice