Re: [PATCH 7/8] rust: pci: add physfn(), to return PF device for VF device

Danilo Krummrich
2025-11-22T22:43:17Z

On Sun Nov 23, 2025 at 5:16 AM NZDT, Jason Gunthorpe wrote:
> I think to make progress along this line you need to still somehow
> validate that the PF driver is working right, either by checking that
> the driver is bound to a rust driver somehow or using the same
> approach as the core helper.

Do you refer to the

if (pf_dev->driver != pf_driver)

check? If so, that's (in a slightly different form) already part of the generic
Device::drvdata() accessor.

> I'm not sure the idea to force all drivers to do disable sriov is
> going to be easy, and I'd rather see rust bindings progress without
> opening such a topic..

I'm sorry, I should have mentioned what I actually propose:

My idea would be to provide a bool in struct pci_driver, which, if set,
guarantees that all VFs are unbound when the PF is unbound.

With this bool being set, the PCI bus can provide the guarantee that VF bound
implies PF bound; the Rust accessor can then leverage this guarantee.

This can also be leveraged by the C code, where we could have a separate
accessor that checks the bool rather than askes the driver to promise that the
PF is bound, which pci_iov_get_pf_drvdata() does.

(Although I have to admit that without the additional type system capabilities
we have in Rust, it is not that big of an improvement.)