Re: [PATCH v5 6/9] rust: pci: add typed SR-IOV PF registration data
From: Bjorn Helgaas
Date: Wed Nov 04 2026 - 18:07:00 EST
On Fri, Oct 30, 2026 at 10:12:24AM -0700, Simon Song wrote:
> From: Zhi Wang <zhiw@xxxxxxxxxx>
>
> Rust PF and VF drivers bind to separate PCI devices and may reside
> in different modules. A VF driver that calls PF operations needs
> typed access to the data exposed by the PF driver. This data must
> remain valid until VF driver removal completes.
>
> Add VfRegistration to register a pinned object in the PF's private
> data. VF drivers can borrow it after checking the requested Rust
> type, using a higher-ranked closure or a covariant lifetime encoding.
>
> Capture the core callback context in the initializer. Reject active
> VFs and an occupied registration slot before initializing the payload,
> then recheck the slot before publication in case the payload initializer
> created another registration. Publish only after all fallible work.
>
> During registration teardown, disable SR-IOV and wait for VF remove
> callbacks to finish before clearing the pointer and dropping the object.
>
> Co-developed-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> Signed-off-by: Zhi Wang <zhiw@xxxxxxxxxx>
> Signed-off-by: Simon Song <xinmengs@xxxxxxxxxx>
Acked-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> # include/linux/pci.h
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d31a8d107b1..9b6ae544469 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -551,6 +551,13 @@ struct pci_dev {
> u16 ats_cap; /* ATS Capability offset */
> u8 ats_stu; /* ATS Smallest Translation Unit */
> #endif
> +#if defined(CONFIG_PCI_IOV) && defined(CONFIG_RUST)
> + /*
> + * Private data owned by the PF's Rust driver, readable by VF drivers
> + * through the PCI VF registration data Rust abstraction.
> + */
> + void *vf_registration_data_rust;
I assume use of vf_registration_data_rust is meant to stay
encapsulated in rust/kernel/pci.rc and rust/kernel/pci/.