Skip to content

Commit c1bf94e

Browse files
committed
iommu/amd: Cache pdev pointer to root-bridge
At some point pci_get_bus_and_slot started to enable interrupts. Since this function is used in the amd_iommu_resume path it will enable interrupts on resume which causes a warning. The fix will use a cached pointer to the root-bridge to re-enable the IOMMU in case the BIOS is broken. Cc: [email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent f8f5701 commit c1bf94e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/iommu/amd_iommu_init.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,9 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
10291029
if (!iommu->dev)
10301030
return 1;
10311031

1032+
iommu->root_pdev = pci_get_bus_and_slot(iommu->dev->bus->number,
1033+
PCI_DEVFN(0, 0));
1034+
10321035
iommu->cap_ptr = h->cap_ptr;
10331036
iommu->pci_seg = h->pci_seg;
10341037
iommu->mmio_phys = h->mmio_phys;
@@ -1323,20 +1326,16 @@ static void iommu_apply_resume_quirks(struct amd_iommu *iommu)
13231326
{
13241327
int i, j;
13251328
u32 ioc_feature_control;
1326-
struct pci_dev *pdev = NULL;
1329+
struct pci_dev *pdev = iommu->root_pdev;
13271330

13281331
/* RD890 BIOSes may not have completely reconfigured the iommu */
1329-
if (!is_rd890_iommu(iommu->dev))
1332+
if (!is_rd890_iommu(iommu->dev) || !pdev)
13301333
return;
13311334

13321335
/*
13331336
* First, we need to ensure that the iommu is enabled. This is
13341337
* controlled by a register in the northbridge
13351338
*/
1336-
pdev = pci_get_bus_and_slot(iommu->dev->bus->number, PCI_DEVFN(0, 0));
1337-
1338-
if (!pdev)
1339-
return;
13401339

13411340
/* Select Northbridge indirect register 0x75 and enable writing */
13421341
pci_write_config_dword(pdev, 0x60, 0x75 | (1 << 7));
@@ -1346,8 +1345,6 @@ static void iommu_apply_resume_quirks(struct amd_iommu *iommu)
13461345
if (!(ioc_feature_control & 0x1))
13471346
pci_write_config_dword(pdev, 0x64, ioc_feature_control | 1);
13481347

1349-
pci_dev_put(pdev);
1350-
13511348
/* Restore the iommu BAR */
13521349
pci_write_config_dword(iommu->dev, iommu->cap_ptr + 4,
13531350
iommu->stored_addr_lo);

drivers/iommu/amd_iommu_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ struct amd_iommu {
481481
/* Pointer to PCI device of this IOMMU */
482482
struct pci_dev *dev;
483483

484+
/* Cache pdev to root device for resume quirks */
485+
struct pci_dev *root_pdev;
486+
484487
/* physical address of MMIO space */
485488
u64 mmio_phys;
486489
/* virtual address of MMIO space */

0 commit comments

Comments
 (0)