Skip to content

Commit 20b3c56

Browse files
hegdevasantgregkh
authored andcommitted
iommu/amd: Fix clone_alias() to use the original device's devid
[ Upstream commit faad224 ] Currently clone_alias() assumes first argument (pdev) is always the original device pointer. This function is called by pci_for_each_dma_alias() which based on topology decides to send original or alias device details in first argument. This meant that the source devid used to look up and copy the DTE may be incorrect, leading to wrong or stale DTE entries being propagated to alias device. Fix this by passing the original pdev as the opaque data argument to both the direct clone_alias() call and pci_for_each_dma_alias(). Inside clone_alias(), retrieve the original device from data and compute devid from it. Fixes: 3332364 ("iommu/amd: Support multiple PCI DMA aliases in device table") Signed-off-by: Vasant Hegde <vasant.hegde@amd.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 715d7b1 commit 20b3c56

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,12 @@ struct iommu_dev_data *search_dev_data(struct amd_iommu *iommu, u16 devid)
381381
return NULL;
382382
}
383383

384-
static int clone_alias(struct pci_dev *pdev, u16 alias, void *data)
384+
static int clone_alias(struct pci_dev *pdev_origin, u16 alias, void *data)
385385
{
386386
struct dev_table_entry new;
387387
struct amd_iommu *iommu;
388388
struct iommu_dev_data *dev_data, *alias_data;
389+
struct pci_dev *pdev = data;
389390
u16 devid = pci_dev_id(pdev);
390391
int ret = 0;
391392

@@ -432,9 +433,9 @@ static void clone_aliases(struct amd_iommu *iommu, struct device *dev)
432433
* part of the PCI DMA aliases if it's bus differs
433434
* from the original device.
434435
*/
435-
clone_alias(pdev, iommu->pci_seg->alias_table[pci_dev_id(pdev)], NULL);
436+
clone_alias(pdev, iommu->pci_seg->alias_table[pci_dev_id(pdev)], pdev);
436437

437-
pci_for_each_dma_alias(pdev, clone_alias, NULL);
438+
pci_for_each_dma_alias(pdev, clone_alias, pdev);
438439
}
439440

440441
static void setup_aliases(struct amd_iommu *iommu, struct device *dev)

0 commit comments

Comments
 (0)