pci_iov_get_pf_drvdata(9)
β¨ pci_iov_get_pf_drvdata(9) β¨
okay so bestie, welcome to the Kernel API Manual β this one's a little function with big "don't talk to me until the PF driver says it's cool" energy π
π NAME π
pci_iov_get_pf_drvdata β literally just returns the drvdata of a PF π«Ά
πΈ SYNOPSIS πΈ
void * pci_iov_get_pf_drvdata (struct pci_dev *dev , struct pci_driver *pf_driver );
π ARGUMENTS π
devβ the VFpci_dev(yes, the VF, not the PF, stay with me here)pf_driverβ the device driver that's required to own the PF. like, mandatory. no substitutes π₯
π¦ DESCRIPTION π¦
So here's the vibe check: you must call this from a context that guarantees a VF driver is attached. Periodt. Because the value you get back goes β¨invalidβ¨ the second the VF driver finishes its remove callback. So don't be out here holding onto it like it's gonna last π
The locking? Handled by the driver core, no cap. A VF driver cannot be probed until pci_enable_sriov is called, and pci_disable_sriov doesn't return until all the VF drivers have finished their remove. Iconic behaviour honestly π
Also, huge one: the PF driver must call pci_disable_sriov before it starts destroying the drvdata. Like, before. Not during, not after. Before. π
β οΈ lowkey important: return value = invalid after the VF driver's remove callback completes. don't say I didn't warn you π
π SEE ALSO π
Kernel file ./drivers/pci/iov.c, plus the whole friend group:
pci_iov_init(9)pci_iov_release(9)pci_iov_remove(9)pci_iov_update_resource(9)pci_sriov_resource_alignment(9)pci_restore_iov_state(9)pci_vf_drivers_autoprobe(9)pci_iov_bus_range(9)pci_enable_sriov(9)pci_disable_sriov(9)pci_num_vf(9)pci_vfs_assigned(9)pci_sriov_set_totalvfs(9)pci_sriov_get_totalvfs(9)pci_sriov_configure_simple(9)pci_iov_vf_bar_set_size(9)pci_iov_vf_bar_get_sizes(9)
and that's the whole page, bestie π this lil gem lives over in ./drivers/pci and it's stamped October 2026 β iykyk, go forth and get that PF drvdata responsibly ππ§
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms