iommu/amd: Support multiple PCI DMA aliases in device table
authorLogan Gunthorpe <logang@deltatee.com>
Tue, 22 Oct 2019 22:01:20 +0000 (16:01 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Feb 2020 09:34:48 +0000 (09:34 +0000)
commit1f03a258f20f1699ede29bb40804074db9398a0d
tree9c6eeb69bea20a56864ed6958ffd7b6609e39cf5
parentd7937ea02315cdd07348e064d71ea73e00b7ed03
iommu/amd: Support multiple PCI DMA aliases in device table

[ Upstream commit 3332364e4ebc0581d133a334645a20fd13b580f1 ]

Non-Transparent Bridge (NTB) devices (among others) may have many DMA
aliases seeing the hardware will send requests with different device ids
depending on their origin across the bridged hardware.

See commit ad281ecf1c7d ("PCI: Add DMA alias quirk for Microsemi
Switchtec NTB") for more information on this.

The AMD IOMMU ignores all the PCI aliases except the last one so DMA
transfers from these aliases will be blocked on AMD hardware with the
IOMMU enabled.

To fix this, ensure the DTEs are cloned for every PCI alias. This is
done by copying the DTE data for each alias as well as the IVRS alias
every time it is changed.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/amd_iommu.c
drivers/iommu/amd_iommu_types.h