iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 7/7] PCI: use pf as dma_dev for vf that does not have func0 sibling
       [not found] ` <1368498506-25857-1-git-send-email-yinghai-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
@ 2013-05-14  2:28   ` Yinghai Lu
  0 siblings, 0 replies; only message in thread
From: Yinghai Lu @ 2013-05-14  2:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-pci-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Yinghai Lu,
	Gu Zheng, David Woodhouse

Fix crash:
[  122.181002] pci 0000:c4:00.4: [10df:e228] type 00 class 0x020000
[  122.188541] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
[  122.197324] IP: [<ffffffff81f58f78>] intel_iommu_add_device+0x108/0x1e0
[  122.204753] PGD 0 
[  122.207019] Oops: 0000 [#1] SMP 
[  122.210655] Modules linked in:
[  122.214084] CPU: 49 PID: 1 Comm: swapper/0 Tainted: G          I  3.9.0-yh-09240-g8a69c01-dirty #1571
...
[  122.365363] Call Trace:
[  122.368112]  [<ffffffff81f4ee2e>] iommu_bus_notifier+0x3e/0xd0
[  122.374645]  [<ffffffff820b702e>] notifier_call_chain+0x6e/0xb0
[  122.381277]  [<ffffffff810b912e>] __blocking_notifier_call_chain+0x5e/0x90
[  122.388963]  [<ffffffff810b9176>] blocking_notifier_call_chain+0x16/0x20
[  122.396471]  [<ffffffff81762fc5>] device_add+0x475/0x6f0

pv is c3:00.0, and vf is from c4:00.4 and there is no c4:00.0,
as we have
     Initial VFs: 64, Total VFs: 64, Number of VFs: 63, Function Dependency Link: 00
     VF offset: 260, stride: 1

Signed-off-by: Yinghai Lu <yinghai-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: David Woodhouse <dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org

---
 drivers/iommu/intel-iommu.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-2.6/drivers/iommu/intel-iommu.c
===================================================================
--- linux-2.6.orig/drivers/iommu/intel-iommu.c
+++ linux-2.6/drivers/iommu/intel-iommu.c
@@ -4185,11 +4185,15 @@ static int intel_iommu_add_device(struct
 	 * required ACS flags, add to the same group as function 0.
 	 */
 	if (dma_pdev->multifunction &&
-	    !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS))
-		swap_pci_ref(&dma_pdev,
-			     pci_get_slot(dma_pdev->bus,
+	    !pci_acs_enabled(dma_pdev, REQ_ACS_FLAGS)) {
+		struct pci_dev *dev_tmp = pci_get_slot(dma_pdev->bus,
 					  PCI_DEVFN(PCI_SLOT(dma_pdev->devfn),
-					  0)));
+					  0));
+
+		if (!dev_tmp && dma_pdev->is_virtfn)
+			dev_tmp = pci_dev_get(dma_pdev->physfn);
+		swap_pci_ref(&dma_pdev, dev_tmp);
+	}
 
 	/*
 	 * Devices on the root bus go through the iommu.  If that's not us,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-05-14  2:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1368498506-25857-1-git-send-email-yinghai@kernel.org>
     [not found] ` <1368498506-25857-1-git-send-email-yinghai-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-05-14  2:28   ` [PATCH 7/7] PCI: use pf as dma_dev for vf that does not have func0 sibling Yinghai Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).