From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Zhi Wang" <zhiw@nvidia.com>
Cc: <rust-for-linux@vger.kernel.org>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <dakr@kernel.org>,
<aliceryhl@google.com>, <bhelgaas@google.com>,
<kwilczynski@kernel.org>, <ojeda@kernel.org>,
<alex.gaynor@gmail.com>, <boqun.feng@gmail.com>,
<gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
<lossin@kernel.org>, <a.hindborg@kernel.org>, <tmgross@umich.edu>,
<markus.probst@posteo.de>, <helgaas@kernel.org>,
<cjia@nvidia.com>, <smitra@nvidia.com>, <ankita@nvidia.com>,
<aniketa@nvidia.com>, <kwankhede@nvidia.com>,
<targupta@nvidia.com>, <joelagnelf@nvidia.com>,
<jhubbard@nvidia.com>, <zhiwang@kernel.org>,
<daniel.almeida@collabora.com>
Subject: Re: [PATCH v12 5/5] sample: rust: pci: add tests for config space routines
Date: Mon, 26 Jan 2026 19:35:17 +0900 [thread overview]
Message-ID: <DFYGCYCIM8SY.IUGLO22VO3UO@nvidia.com> (raw)
In-Reply-To: <20260126090531.6ef5986e@inno-ryzen>
On Mon Jan 26, 2026 at 6:05 PM JST, Zhi Wang wrote:
> On Mon, 26 Jan 2026 14:08:30 +0900
> "Alexandre Courbot" <acourbot@nvidia.com> wrote:
>
>> On Thu Jan 22, 2026 at 1:31 PM JST, Alexandre Courbot wrote:
>> > On Thu Jan 22, 2026 at 5:22 AM JST, Zhi Wang wrote:
>> >> Add tests exercising the PCI configuration space helpers.
>> >>
>> >> Suggested-by: Danilo Krummrich <dakr@kernel.org>
>> >> Signed-off-by: Zhi Wang <zhiw@nvidia.com>
>> >> ---
>> >> samples/rust/rust_driver_pci.rs | 28 ++++++++++++++++++++++++++++
>> >> 1 file changed, 28 insertions(+)
>> >>
>> >> diff --git a/samples/rust/rust_driver_pci.rs
>> >> b/samples/rust/rust_driver_pci.rs index 38c949efce38..1bc5bd1a8df5
>> >> 100644 --- a/samples/rust/rust_driver_pci.rs
>> >> +++ b/samples/rust/rust_driver_pci.rs
>> >> @@ -5,6 +5,7 @@
>> >> //! To make this driver probe, QEMU must be run with `-device
>> >> pci-testdev`.
>> >> use kernel::{
>> >> + device::Bound,
>> >> device::Core,
>> >> devres::Devres,
>> >> io::Io,
>> >> @@ -65,6 +66,32 @@ fn testdev(index: &TestIndex, bar: &Bar0) ->
>> >> Result<u32> {
>> >> Ok(bar.read32(Regs::COUNT))
>> >> }
>> >> +
>> >> + fn config_space(pdev: &pci::Device<Bound>) -> Result {
>> >> + let config = pdev.config_space()?;
>> >> +
>> >> + // TODO: use the register!() macro for defining PCI
>> >> configuration space registers once it
>> >
>> > I'll rebase the `register!` series on top of this and try to address
>> > this item.
>>
>> Actually... is this expected to work?
>>
>> > + dev_info!(
>> > + pdev.as_ref(),
>> > + "pci-testdev config space read8 rev ID: {:x}\n",
>> > + config.read8(0x8)
>> > + );
>>
>> We are performing I/O on `config`, but since this is a sample device
>> with no hardware backing, what is providing the data for the
>> registers?
>>
>
> We are running the sample driver in the virtual machine. QEMU provides
> a emulated PCI test device (-device pci-testdev) for this purpose. E.g.
> with the following command line, I am able to run and test this in the
> virtual machine.
>
> qemu-system-x86_64 \
> -enable-kvm \
> -cpu host \
> -m 8192 \
> -smp 24 \
> -drive file=/home/inno/vm/xubuntu.img,if=virtio \
> -netdev user,id=net0 \
> -device virtio-net-pci,netdev=net0 \
> -device usb-tablet \
> -device pci-testdev \
> -usb
Ah, that makes sense! Thanks for the explanation.
next prev parent reply other threads:[~2026-01-26 10:35 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 20:22 [PATCH v12 0/5] rust: pci: add config space read/write support Zhi Wang
2026-01-21 20:22 ` [PATCH v12 1/5] rust: devres: style for imports Zhi Wang
2026-01-22 4:25 ` Alexandre Courbot
2026-01-21 20:22 ` [PATCH v12 2/5] rust: io: separate generic I/O helpers from MMIO implementation Zhi Wang
2026-01-22 4:28 ` Alexandre Courbot
2026-01-22 11:52 ` Gary Guo
2026-01-22 12:52 ` Danilo Krummrich
2026-01-23 9:13 ` Alice Ryhl
2026-01-21 20:22 ` [PATCH v12 3/5] rust: io: factor out MMIO read/write macros Zhi Wang
2026-01-22 4:30 ` Alexandre Courbot
2026-01-22 11:54 ` Gary Guo
2026-01-21 20:22 ` [PATCH v12 4/5] rust: pci: add config space read/write support Zhi Wang
2026-01-22 4:25 ` Alexandre Courbot
2026-01-22 11:59 ` Gary Guo
2026-01-22 12:40 ` Danilo Krummrich
2026-01-22 12:52 ` Zhi Wang
2026-01-22 14:26 ` Gary Guo
2026-01-21 20:22 ` [PATCH v12 5/5] sample: rust: pci: add tests for config space routines Zhi Wang
2026-01-22 4:31 ` Alexandre Courbot
2026-01-26 5:08 ` Alexandre Courbot
2026-01-26 9:05 ` Zhi Wang
2026-01-26 10:21 ` Zhi Wang
2026-01-26 10:35 ` Alexandre Courbot [this message]
2026-01-22 12:00 ` Gary Guo
2026-01-24 0:12 ` [PATCH v12 0/5] rust: pci: add config space read/write support Danilo Krummrich
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=DFYGCYCIM8SY.IUGLO22VO3UO@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=aniketa@nvidia.com \
--cc=ankita@nvidia.com \
--cc=bhelgaas@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=cjia@nvidia.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=gary@garyguo.net \
--cc=helgaas@kernel.org \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=kwankhede@nvidia.com \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=smitra@nvidia.com \
--cc=targupta@nvidia.com \
--cc=tmgross@umich.edu \
--cc=zhiw@nvidia.com \
--cc=zhiwang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.