From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0E4B31AF18; Fri, 17 Oct 2025 10:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760698601; cv=none; b=RsmR4QgxPXCVcxNZnild+Ah8i0gIj/IcIVxCT5qUJlItlQF3yb1BEIVAZWQpkvAeQ+tWG3SK0p3fIJEZ0l4td6L8dXAapI+7GYYOcAa5u/d13CMpYjkkguw9dxdtjq+WsXy55Mvyc2djWJmteGRJ0p9VDq27m6wMfi+Rs559qN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760698601; c=relaxed/simple; bh=tyA/LHJlFit5K6PqK6XOjstXqHYpybUs0kAPdQMiMhA=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:To:From:Subject: References:In-Reply-To; b=iCvZhqzv2EgtDKsBSVExnSDQ27yF4z8Q2wUP38QFDcGtftNt2qg+IC+liCrwHQwg5qt6n4mGdIiMBknbhqyrZy5giuJwZbwxE7ztyY38f6FuiMFR6uiTdj7S1XB+dohGxga9VbZXyQyCC/TrGI8iWSOCiN7X/5e8xQfvRB8Bo30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VTPJ8dU6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VTPJ8dU6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 041D3C4CEE7; Fri, 17 Oct 2025 10:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760698600; bh=tyA/LHJlFit5K6PqK6XOjstXqHYpybUs0kAPdQMiMhA=; h=Date:Cc:To:From:Subject:References:In-Reply-To:From; b=VTPJ8dU6WcbYUPcgmJO4eOEz9CbPEBuxfrH3aIvi9nacKFwUZPFn8/nvXF2yDNdSC Vl7KULH8FxwarRMsXDzCnOamNPN+D70vPR9ttRAwha2OFr4SGEIiDpYpg+85o+fT/l gXfUNo1lcdXq3zEqHMTmN4uATBQWI+Eo00ePLUBtuTtHoObxaEhqj8/4qsdA/AYazp ZzHDpdNLsYPQa7KSDhC7fYvU1WA0E/+AWNazWf3zCPJjNGIn24qu85AJy1M5ZARGzf D3v0sPgfD6OBqEn6R2y88qMgTcw2bxFCAFS9lUyviKm43m5MCX7VZF4aaDGqQe9bqK Gjf/wdlj9ECLg== Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 17 Oct 2025 12:56:34 +0200 Message-Id: Cc: , , , , , , , , , , , , , , , , , , , , , , , , To: "Zhi Wang" From: "Danilo Krummrich" Subject: Re: [PATCH v2 1/5] rust/io: factor common I/O helpers into Io trait and specialize Mmio References: <20251016210250.15932-1-zhiw@nvidia.com> <20251016210250.15932-2-zhiw@nvidia.com> In-Reply-To: <20251016210250.15932-2-zhiw@nvidia.com> On Thu Oct 16, 2025 at 11:02 PM CEST, Zhi Wang wrote: > diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core= /regs/macros.rs > index 8058e1696df9..c2a6547d58cd 100644 > --- a/drivers/gpu/nova-core/regs/macros.rs > +++ b/drivers/gpu/nova-core/regs/macros.rs > @@ -609,7 +609,7 @@ impl $name { > /// Read the register from its address in `io`. > #[inline(always)] > pub(crate) fn read(io: &T) -> Self whe= re > - T: ::core::ops::Deref>= , > + T: ::core::ops::Deref>, This should be T: ::core::ops::Deref, I: ::kernel::io::Io, instead, otherwise register!() only works for MMIO, but it should work for = any I/O backend. > +impl Io for Mmio { > + /// Returns the base address of this mapping. > + #[inline] > + fn addr(&self) -> usize { > + self.0.addr() > + } > + > + /// Returns the maximum size of this mapping. > + #[inline] > + fn maxsize(&self) -> usize { > + self.0.maxsize() > + } > +} The I/O trait should contain the corresponding read/write accessors, otherw= ise we can't easily wire up the register!() macro with arbitrary I/O backends. I think more specific things, such as relaxed operations can remain MMIO specific, but all the {try_}{read,write}{8,16,32,64} accessors should be pa= rt of the I/O trait.