Re: [PATCH rc v7 4/6] iommu: Fix nested pci_dev_reset_iommu_prepare/done()
From: Baolu Lu
Date: Fri Apr 24 2026 - 02:15:04 EST
On 4/19/26 07:41, Nicolin Chen wrote:
Shuai found that cxl_reset_bus_function() calls pci_reset_bus_function()
internally while both are calling pci_dev_reset_iommu_prepare/done().
As pci_dev_reset_iommu_prepare() doesn't support re-entry, the inner call
will trigger a WARN_ON and return -EBUSY, resulting in failing the entire
device reset.
On the other hand, removing the outer calls in the PCI callers is unsafe.
As pointed out by Kevin, device-specific quirks like reset_hinic_vf_dev()
execute custom firmware waits after their inner pcie_flr() completes. If
the IOMMU protection relies solely on the inner reset, the IOMMU will be
unblocked prematurely while the device is still resetting.
Instead, fix this by making pci_dev_reset_iommu_prepare/done() reentrant.
Introduce gdev->reset_depth to handle the re-entries on the same device.
Fixes: c279e83953d9 ("iommu: Introduce pci_dev_reset_iommu_prepare/done()")
Cc:stable@xxxxxxxxxxxxxxx
Reported-by: Shuai Xue<xueshuai@xxxxxxxxxxxxxxxxx>
Closes:https://lore.kernel.org/all/absKsk7qQOwzhpzv@Asurada-Nvidia/
Suggested-by: Kevin Tian<kevin.tian@xxxxxxxxx>
Reviewed-by: Shuai Xue<xueshuai@xxxxxxxxxxxxxxxxx>
Reviewed-by: Jason Gunthorpe<jgg@xxxxxxxxxx>
Reviewed-by: Kevin Tian<kevin.tian@xxxxxxxxx>
Signed-off-by: Nicolin Chen<nicolinc@xxxxxxxxxx>
---
drivers/iommu/iommu.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>