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 3C3BA6A8D2 for ; Mon, 16 Feb 2026 10:35:51 +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=1771238153; cv=none; b=ZCxSJaE8XTaYCW0+XMBPX1il7KtWPkoVAnoTqxqaztjcfzBIOqeGhTDbhCTPB8h1jygXRuEgy7w0ZRpxTDD2eqv9sCQnvSi+ndUzyeAoIhxx2KC7LluflXv461zL4RR5/oIE0zpo2dzEdwlR2APRAgK1ZwZJRqIoGb+KRg3dOhc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771238153; c=relaxed/simple; bh=cYY+UcoPJtcwpUYE/xB9l0lk416abMLoNHFFwBOD08Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Kt7ryzb/CZBo+dMxQnq32q4Wg0cRsX42cfKW39hKHbqtbxbSZYoYb18DrqrtRfmMptNZPO6GcO9EFDl/bjMkavH3TI2z0GlrT/IOSAdlxobugzbzgcZSoa93Vg3Wo/xpDGmpacf/BoQucQe9bwAHa3hr6zBQRVei1PfD6Mx5zpU= 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=h6VB56f0; 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="h6VB56f0" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4836c819456so37590185e9.3 for ; Mon, 16 Feb 2026 02:35:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771238149; x=1771842949; 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=il3up+c5fnRwBnfs7hyIeXZdI4lnvbRcc9BTTBqVr7Y=; b=h6VB56f023WtqKxt24T/kauiN+Db/QeJe435Y64u3HQirdlzYr7W22t1vKg0Z54+Pn MnXv8dGm+BwrxWnN8GfIBl7JRjgKOq2+da5FVqvsFcQc3B7oKCTP82dPwY5OXbZ7i+ds PeUKi58ZqlEIYp36mO1jQQVcnsApXuLU24V76hnesIm9jw93UPjn4MQgD7fd/Jl+bTiK cTPBf5WEie9t0hMaoNocmppSVNLXjrVUpvGWowL1HFqq9FbER4nRLBQ7MfL1pPGDU/yk 2GN00ulIt3gikZvsVdvNulj5+kM4j2HAqWHBtKL5M0NGpTPCqnk6ujCgrr5IManWBVz9 iZPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771238149; x=1771842949; 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=il3up+c5fnRwBnfs7hyIeXZdI4lnvbRcc9BTTBqVr7Y=; b=aUQfs9CvyFlc8yPNWtNqHzdGIxVEq+bIYGhrdaQWbhlBcIZUfQlDMXlkW/rjhHESsA CfGr8UWwMB0RDHV2itbMac24syyiTC6gST9sZxAQsNtAFXyQpEwT8AWSVpMFvb6h+2dl i5tDrV8+rXtIZQhUY3cMDm2ib+bNoytfLgtls7pET+YX5VzbXQFKynODhbp/z9BxDEqd InMxpkjiVostoUfhW2w/fETwWuwHlHXBq+/CC4+C9Vptwuz1WduFTMnoyd71AUMIqBY7 q7PoM3eg1pHKGXFbpy9mf8QcM8+r8/MKRWMYvXd2fF2e5Es7yCEMRrEkJKyoUucQx4kd ZRnQ== X-Forwarded-Encrypted: i=1; AJvYcCXi9lcfBjf3Ex/xzq+jFUzM+cFXWMnXvn4cglTHrgMYz0auET5zbnMxY0hAH5QmGiwjCGgKUSELzIcdG9g=@vger.kernel.org X-Gm-Message-State: AOJu0YxPJxtdB1ZaKTsRw6gL0l9ojXupbKk5UG3fMeuIaQv+LIudJPJc tPUcUIM9nyWnG/NxwQRDETpRcpkmFybPm0yhAmoI3bX7yPQCr9wWezgTuRQ7QnrCQHExteN/IAE KOe3LYKu2M9N1rcfFeg== X-Received: from wmhi21.prod.google.com ([2002:a05:600c:14d5:b0:483:6e28:c182]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:c0ca:b0:483:78c5:d743 with SMTP id 5b1f17b1804b1-48378c5d9fcmr106715565e9.28.1771238149251; Mon, 16 Feb 2026 02:35:49 -0800 (PST) Date: Mon, 16 Feb 2026 10:35:48 +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 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? Alice