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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 A0328ECD9A6 for ; Thu, 5 Feb 2026 21:21:10 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4f6VWm3j38z2xKx; Fri, 06 Feb 2026 08:21:08 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2a01:e0a:1040:9780:49:5ff:fe41:d261" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1770326468; cv=none; b=XtO9Q/CuMD14OXRZ9INc8OughoAh+XWbq4hEBPAvOn0fIQLrWyx9/lqDW1ASNRwzXBk79Zk/GgNIred8F7kWR94fy101SYGM6Y9sldA7FknmmsnitlE8/xXaHTIudI6HOsY0R6kYtBvJITuzk/kzA+LsS1sMmnlKtFbkJAuaqki6WwBQ/VYlLyv3jjzSQMBXMVDPQgGtr3TU+0AGTx/tHPdMOFO0YQrRu/hr6DeKbbkNXJeaNDjrsPiLNnPJlUa+3iPXIeamNpKVwbhdOO/nDWX5BRjLCaCgxBzM+9+vD2C7d9N6d/dic7behiOov1/rxGdrj7D3Jqzdpo9L4cdAFw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1770326468; c=relaxed/relaxed; bh=+maSr6t9X0huLqfMIpthVCeAr6qnqyICEdUEnSrtpM0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EeTDZCvfJrWMND+EJnTF6TihJnmxt3USiI0rqohjQ/lu+pfulAGDCXUVgSUyyxqgogbHLZ4R9Q4+3y/L3u0TVnUvOblMENNQMQmB/PGJBCTwiKFBg2w2yPUBir0FQSXIn+29Vbp16pFLe/vVYz2/j7UdDgdtOeam5OOUbny/gCK8ClXbvlxzOFuyomA8XM+4lojrigQJlts88uWC7sbDOOsvyf4DD1u+nKmbz10YzuGLyE2PBDQV5P2YkxuaMNcsxoX++8RJIc4Lb36qDoAqWefRRpFRT5q3aXKm2h8wIQl/36/+SHHWEkeJxNxNtSZkXRzfWPpEFo+4pH2fF0VqXA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linkmauve.fr; spf=pass (client-ip=2a01:e0a:1040:9780:49:5ff:fe41:d261; helo=luna.linkmauve.fr; envelope-from=linkmauve@linkmauve.fr; receiver=lists.ozlabs.org) smtp.mailfrom=linkmauve.fr Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linkmauve.fr Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linkmauve.fr (client-ip=2a01:e0a:1040:9780:49:5ff:fe41:d261; helo=luna.linkmauve.fr; envelope-from=linkmauve@linkmauve.fr; receiver=lists.ozlabs.org) X-Greylist: delayed 152134 seconds by postgrey-1.37 at boromir; Fri, 06 Feb 2026 08:21:06 AEDT Received: from luna.linkmauve.fr (unknown [IPv6:2a01:e0a:1040:9780:49:5ff:fe41:d261]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4f6VWk50PNz2xJ5 for ; Fri, 06 Feb 2026 08:21:06 +1100 (AEDT) Received: by luna.linkmauve.fr (Postfix, from userid 1000) id 5C640F439CC; Thu, 05 Feb 2026 22:20:56 +0100 (CET) Date: Thu, 5 Feb 2026 22:20:56 +0100 From: Link Mauve To: Danilo Krummrich Cc: Daniel Almeida , Gary Guo , Link Mauve , rust-for-linux@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Srinivas Kandagatla , Miguel Ojeda , Boqun Feng , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Ard Biesheuvel , "Martin K. Petersen" , Eric Biggers , Greg Kroah-Hartman , Lyude Paul , Asahi Lina , Viresh Kumar , Lorenzo Stoakes , Tamir Duberstein , FUJITA Tomonori , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, officialTechflashYT@gmail.com, Ash Logan , Roberto Van Eeden , Jonathan =?iso-8859-1?Q?Neusch=E4fer?= Subject: Re: [PATCH v2 1/4] rust: io: Add big-endian read and write functions Message-ID: References: <20260204040505.8447-1-linkmauve@linkmauve.fr> <20260204040505.8447-2-linkmauve@linkmauve.fr> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Jabber-ID: linkmauve@linkmauve.fr On Thu, Feb 05, 2026 at 08:05:08PM +0100, Danilo Krummrich wrote: > On Thu Feb 5, 2026 at 6:28 PM CET, Daniel Almeida wrote: > >> On 5 Feb 2026, at 12:16, Gary Guo wrote: > >> I think we should have everything default to little endian, and have wrapper > >> types that do big endian which require expicit construction, similar to > >> RelaxedMmio in Alex's series. > > > > Ah yes, the RelaxedMmio pattern is definitely a good one. I agree that we > > should head in this direction. > > I strongly disagree. > > This is a great pattern for relaxed ordering because: > > (1) We need both strict and relaxed ordering. > > (2) Relaxed ordering is rare, hence it doesn't hurt to write e.g. > > io.relaxed().write() > > (3) If you by accident just write > > io.write() > > i.e. forget to call relaxed() it s not a bug, nothing bad happens. > > Whereas for endianness it is a bad pattern because: > > (1) Devices are either little-endian or big-endian. Hence, having to write > > io.big_endian().write() > > is excessive, we always want big-endian for a big-endian device. > > (2) It is error prone, if you forget to call big_endian() first, it is a bug. > > (3) It is unergonomic in combination with relaxed ordering. > > io.big_endian().relaxed().write() > > (Does the other way around work as well? :) > > It makes much more sense to define once when we request the I/O memory whether > the device is litte-endian or big-endian. > > This could be done with different request functions, a const generic or a > function argument, but it should be done at request time. Could this ever be done in the device tree? I understand this would mean having to change all drivers and all device trees that do big endian, but it seems to be the natural location for this information. I have no idea how to structure that though. -- Link Mauve