From a78cf1d41c3a7078af39e96c9033c5900dd77513 Mon Sep 17 00:00:00 2001 From: Suravee Suthikulpanit Date: Thu, 26 Apr 2018 23:31:29 -0500 Subject: [PATCH 4096/4131] check pci dev before getting pci alias Signed-off-by: Sudheesh Mavila --- drivers/iommu/amd_iommu.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 10190e3..33dd869 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -254,7 +254,9 @@ static u16 get_alias(struct device *dev) /* The callers make sure that get_device_id() does not fail here */ devid = get_device_id(dev); ivrs_alias = amd_iommu_alias_table[devid]; - pci_for_each_dma_alias(pdev, __last_alias, &pci_alias); + if (dev_is_pci(dev)) { + pci_for_each_dma_alias(pdev, __last_alias, &pci_alias); + } if (ivrs_alias == pci_alias) return ivrs_alias; @@ -280,18 +282,20 @@ static u16 get_alias(struct device *dev) return pci_alias; } - pr_info("AMD-Vi: Using IVRS reported alias %02x:%02x.%d " - "for device %s[%04x:%04x], kernel reported alias " - "%02x:%02x.%d\n", PCI_BUS_NUM(ivrs_alias), PCI_SLOT(ivrs_alias), - PCI_FUNC(ivrs_alias), dev_name(dev), pdev->vendor, pdev->device, - PCI_BUS_NUM(pci_alias), PCI_SLOT(pci_alias), - PCI_FUNC(pci_alias)); + if (dev_is_pci(dev)) { + pr_info("AMD-Vi: Using IVRS reported alias %02x:%02x.%d " + "for device %s[%04x:%04x], kernel reported alias " + "%02x:%02x.%d\n", PCI_BUS_NUM(ivrs_alias), PCI_SLOT(ivrs_alias), + PCI_FUNC(ivrs_alias), dev_name(dev), pdev->vendor, pdev->device, + PCI_BUS_NUM(pci_alias), PCI_SLOT(pci_alias), + PCI_FUNC(pci_alias)); + } /* * If we don't have a PCI DMA alias and the IVRS alias is on the same * bus, then the IVRS table may know about a quirk that we don't. */ - if (pci_alias == devid && + if (dev_is_pci(dev) && pci_alias == devid && PCI_BUS_NUM(ivrs_alias) == pdev->bus->number) { pci_add_dma_alias(pdev, ivrs_alias & 0xff); pr_info("AMD-Vi: Added PCI DMA alias %02x.%d for %s\n", -- 2.7.4