On Fri, Jan 10, 2020 at 10:21:11AM -0700, Jon Derrick wrote: > The current DMA alias implementation requires the aliased device be on > the same PCI bus as the requester ID. This introduces an arch-specific > mechanism to point to another PCI device when doing mapping and > PCI DMA alias search. > > Signed-off-by: Jon Derrick <jonathan.derrick@xxxxxxxxx> > --- > arch/x86/pci/common.c | 7 +++++++ > drivers/pci/pci.c | 19 ++++++++++++++++++- > drivers/pci/search.c | 7 +++++++ > include/linux/pci.h | 1 + > 4 files changed, 33 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c > index 1e59df0..83334a5 100644 > --- a/arch/x86/pci/common.c > +++ b/arch/x86/pci/common.c > @@ -736,3 +736,10 @@ int pci_ext_cfg_avail(void) > else > return 0; > } > + > +#if IS_ENABLED(CONFIG_VMD) > +struct pci_dev *pci_direct_dma_alias(struct pci_dev *dev) > +{ > + return to_pci_sysdata(dev->bus)->vmd_dev; > +} > +#endif > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c > index ad746d9..1362694 100644 > --- a/drivers/pci/pci.c > +++ b/drivers/pci/pci.c > @@ -6034,7 +6034,9 @@ bool pci_devs_are_dma_aliases(struct pci_dev *dev1, struct pci_dev *dev2) > return (dev1->dma_alias_mask && > test_bit(dev2->devfn, dev1->dma_alias_mask)) || > (dev2->dma_alias_mask && > - test_bit(dev1->devfn, dev2->dma_alias_mask)); > + test_bit(dev1->devfn, dev2->dma_alias_mask)) || > + (pci_direct_dma_alias(dev1) == dev2) || > + (pci_direct_dma_alias(dev2) == dev1); No need for the inner braces here.