From: Dirk Behme <dirk.behme@gmail.com>
To: Marko Turk <mt@markoturk.info>,
dakr@kernel.org, bhelgaas@google.com, kwilczynski@kernel.org,
miguel.ojeda.sandonis@gmail.com, dirk.behme@de.bosch.com,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 2/2] samples: rust: fix endianness issue in rust_driver_pci
Date: Wed, 10 Dec 2025 15:10:12 +0100 [thread overview]
Message-ID: <cac484ba-904b-447d-b802-3e324c843ffe@gmail.com> (raw)
In-Reply-To: <20251210112503.62925-2-mt@markoturk.info>
On 10.12.25 12:25, Marko Turk wrote:
> MMIO backend of PCI Bar always assumes little-endian devices and
> will convert to CPU endianness automatically. Remove the u32::from_le
> conversion which would cause a bug on big-endian machines.
>
> Signed-off-by: Marko Turk <mt@markoturk.info>
> Fixes: 685376d18e9a ("samples: rust: add Rust PCI sample driver")
> ---
> samples/rust/rust_driver_pci.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
> index 5823787bea8e..fa677991a5c4 100644
> --- a/samples/rust/rust_driver_pci.rs
> +++ b/samples/rust/rust_driver_pci.rs
> @@ -48,7 +48,7 @@ fn testdev(index: &TestIndex, bar: &Bar0) -> Result<u32> {
> // Select the test.
> bar.write8(index.0, Regs::TEST);
>
> - let offset = u32::from_le(bar.read32(Regs::OFFSET)) as usize;
> + let offset = bar.read32(Regs::OFFSET) as usize;
Yes, dropping from_le() is what we talked about:
Reviewed-by: Dirk Behme <dirk.behme@de.bosch.com>
Thanks
Dirk
P.S.: I'm not sure if the `Fixes` is required: As far as I understood
there are no big-endian machines supported by Rust, yet. On all other
supported little-endian machines this is a no-op. So I think it is at
least debatable if this is a "bug" which needs back porting.
prev parent reply other threads:[~2025-12-10 14:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-10 11:25 [PATCH 1/2] rust: pci: document Bar's endianness conversion Marko Turk
2025-12-10 11:25 ` [PATCH 2/2] samples: rust: fix endianness issue in rust_driver_pci Marko Turk
2025-12-10 14:10 ` Dirk Behme [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cac484ba-904b-447d-b802-3e324c843ffe@gmail.com \
--to=dirk.behme@gmail.com \
--cc=bhelgaas@google.com \
--cc=dakr@kernel.org \
--cc=dirk.behme@de.bosch.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=mt@markoturk.info \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).