pci_dev_reset_iommu_prepare(9)
okay bestie, you're looking at pci_dev_reset_iommu_prepare(9) from the Kernel API Manual, and it's giving "pause the IOMMU so this PCI device can reset safely" realness. lowkey crucial. π¦
β¨ NAME β¨
pci_dev_reset_iommu_prepare β Block IOMMU to prepare for a PCI device reset. periodt.
π SYNOPSIS π
int pci_dev_reset_iommu_prepare (struct pci_dev *pdev );
π ARGUMENTS π
pdevβ the PCI device that is going to enter a reset routine. that's the one we're prepping for, bestie π
π₯ DESCRIPTION π₯
okay so the PCIe r6.0, sec 10.3.1 IMPLEMENTATION NOTE recommends to disable and block ATS before initiating a reset. yes, the actual spec note. and what that means is: during the reset routine, a PCIe device wants to block any IOMMU activity β both translation and ATS invalidation. both. not a vibe check, a full block. π
This function attaches the device's RID/PASID(s) to the group->blocking_domain, incrementing the group->recovery_cnt, so the IOMMU driver can pause any IOMMU activity while leaving the group->domain pointer intact. the domain pointer stays untouched, the blocking domain gets the RID/PASID(s), and recovery_cnt goes up. later, when the reset is finished, pci_dev_reset_iommu_done can restore everything. iconic teamwork, honestly. π«Ά
The caller must use pci_dev_reset_iommu_prepare with pci_dev_reset_iommu_done before/after the core-level reset routine, to decrement the recovery_cnt. like, they're a matched set β don't use one without the other and then act surprised. π
These two functions are designed to be used by PCI reset functions that would not invoke any racy iommu_release_device, since the PCI sysfs node gets removed before it notifies with a BUS_NOTIFY_REMOVED_DEVICE. when using them in other case, callers must ensure there will be no racy iommu_release_device call β which otherwise would UAF the dev->iommu_group pointer. no cap, that's a use-after-free and it is NOT the move. π
β οΈ real talk: using these outside the designed path means you must ensure there is no racyiommu_release_devicecall. if there is, it would UAF thedev->iommu_grouppointer. not cute, not slay, do not do it. π¨
β RETURN β
0 on success, or a negative error code if the preparation failed. that's the whole return vibe. β¨
π SEE ALSO π
Kernel file ./drivers/iommu/iommu.c β yes, that exact file β plus all these function besties, in the original order:
iommu_device_register(9)iommu_insert_resv_region(9)iommu_group_alloc(9)iommu_group_get_iommudata(9)iommu_group_set_iommudata(9)iommu_group_set_name(9)iommu_group_add_device(9)iommu_group_remove_device(9)iommu_group_mutex_assert(9)iommu_group_for_each_dev(9)iommu_group_get(9)iommu_group_ref_get(9)iommu_group_put(9)iommu_group_id(9)device_iommu_capable(9)iommu_group_has_isolated_msi(9)iommu_set_fault_handler(9)iommu_paging_domain_alloc_flags(9)iommu_attach_device(9)iommu_get_domain_for_dev(9)iommu_driver_get_domain_for_dev(9)iommu_attach_group(9)iommu_unmap(9)iommu_unmap_fast(9)report_iommu_fault(9)iommu_get_resv_regions(9)iommu_put_resv_regions(9)iommu_setup_default_domain(9)iommu_device_use_default_domain(9)iommu_device_unuse_default_domain(9)iommu_group_claim_dma_owner(9)iommu_device_claim_dma_owner(9)iommu_group_release_dma_owner(9)iommu_device_release_dma_owner(9)iommu_group_dma_owner_claimed(9)iommu_replace_device_pasid(9)iommu_attach_handle_get(9)iommu_attach_group_handle(9)iommu_detach_group_handle(9)iommu_replace_group_handle(9)pci_dev_reset_iommu_done(9)iommu_dma_prepare_msi(9)
mwah π this page is from source ./drivers/iommu, in the Kernel API Manual, dated October 2026 β pci_dev_reset_iommu_prepare(9), out. slay bestie, go prep that reset. π
π¦ 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