aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71-e3000/0093-check-pci-dev-before-getting-pci-alias.patch
blob: 9890a61c43106e4f5d1eeddfb02cf198e16d8e70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 1bca08eb860a16e2679655918bd36f21fa213422 Mon Sep 17 00:00:00 2001
From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Date: Thu, 26 Apr 2018 23:31:29 -0500
Subject: [PATCH 93/95] check pci dev before getting pci alias

Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
---
 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