|
|
Subscribe / Log in / New account

rust: pci: add config space read/write support, take 1

From:  Zhi Wang <zhiw-AT-nvidia.com>
To:  <rust-for-linux-AT-vger.kernel.org>
Subject:  [PATCH v2 0/5] rust: pci: add config space read/write support, take 1
Date:  Thu, 16 Oct 2025 21:02:45 +0000
Message-ID:  <20251016210250.15932-1-zhiw@nvidia.com>
Cc:  <dakr-AT-kernel.org>, <bhelgaas-AT-google.com>, <kwilczynski-AT-kernel.org>, <ojeda-AT-kernel.org>, <alex.gaynor-AT-gmail.com>, <boqun.feng-AT-gmail.com>, <gary-AT-garyguo.net>, <bjorn3_gh-AT-protonmail.com>, <lossin-AT-kernel.org>, <a.hindborg-AT-kernel.org>, <aliceryhl-AT-google.com>, <tmgross-AT-umich.edu>, <linux-pci-AT-vger.kernel.org>, <linux-kernel-AT-vger.kernel.org>, <cjia-AT-nvidia.com>, <smitra-AT-nvidia.com>, <ankita-AT-nvidia.com>, <aniketa-AT-nvidia.com>, <kwankhede-AT-nvidia.com>, <targupta-AT-nvidia.com>, <zhiw-AT-nvidia.com>, <zhiwang-AT-kernel.org>, <acourbot-AT-nvidia.com>, <joelagnelf-AT-nvidia.com>, <jhubbard-AT-nvidia.com>, <markus.probst-AT-posteo.de>
Archive-link:  Article

In the NVIDIA vGPU RFC [1], the PCI configuration space access is
required in nova-core for preparing gspVFInfo when vGPU support is
enabled. This series is the following up of the discussion with Danilo
for how to introduce support of PCI configuration space access in Rust
PCI abstrations. Bascially, we are thinking of introducing another
backend for PCI configuration space access similar with Kernel::Io.

This ideas of this series are:

- Factor out a common trait 'Io' for other accessors to share the
  same compiling/runtime check like before.

- Factor the MMIO read/write macros from the define_read! and
  define_write! macros. Thus, define_{read, write}! can be used in other
  backend.

- Add a helper to query configuration space size. This is mostly for
  runtime check.

- Implement the PCI configuration space access backend in PCI
  abstractions.

v2:

- Factor out common trait as 'Io' and keep the rest routines in original
  'Io' as 'Mmio'. (Danilo)

- Rename 'IoRaw' to 'MmioRaw'. Update the bus MMIO implemention to use
  'MmioRaw'.

- Intorduce pci::Device<Bound>::config_space(). (Danilo)

- Implement both infallible and fallible read/write routines, the device
  driver devicdes which version should be used.

Moving forward:

- Define and use register! macros.
- Introduce { cap, ecap } search and read.

RFC v1:
https://lore.kernel.org/all/20251010080330.183559-1-zhiw@...

[1] https://lore.kernel.org/all/20250903221111.3866249-1-zhiw...

Zhi Wang (5):
  rust/io: factor common I/O helpers into Io trait and specialize
    Mmio<SIZE>
  rust: io: factor out MMIO read/write macros
  rust: pci: add a helper to query configuration space size
  rust: pci: add config space read/write support
  nova-core: test configuration routine.

 drivers/gpu/nova-core/driver.rs      |   4 +
 drivers/gpu/nova-core/regs/macros.rs |  36 +++---
 rust/kernel/io.rs                    | 161 +++++++++++++++++----------
 rust/kernel/io/mem.rs                |  16 +--
 rust/kernel/pci.rs                   |  79 ++++++++++++-
 5 files changed, 206 insertions(+), 90 deletions(-)

-- 
2.47.3




Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds