Re: [PATCH v5 6/9] rust: pci: add typed SR-IOV PF registration data

From: Alexandre Courbot

Date: Mon Nov 09 2026 - 07:06:32 EST


On Sat Oct 31, 2026 at 2:12 AM JST, 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>

Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>