linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Yinghai Lu <yinghai@kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	iommu@lists.linux-foundation.org
Subject: [PATCH 7/7] PCI: use pf as dma_dev for vf that does not have func0 sibling
Date: Mon, 13 May 2013 19:28:26 -0700	[thread overview]
Message-ID: <1368498506-25857-8-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1368498506-25857-1-git-send-email-yinghai@kernel.org>

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@kernel.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: iommu@lists.linux-foundation.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,

      parent reply	other threads:[~2013-05-14  2:28 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14  2:28 [PATCH 0/7] PCI: fix pci dev add and remove sequence Yinghai Lu
2013-05-14  2:28 ` [PATCH 1/7] PCI: move back pci_proc_attach_devices calling Yinghai Lu
2013-05-14  2:28 ` [PATCH 2/7] PCI: move resources and bus_list releasing to pci_release_dev Yinghai Lu
2013-05-14  3:20   ` Yijing Wang
2013-05-14  3:56     ` Yinghai Lu
2013-05-14  6:02       ` Yijing Wang
2013-05-14  2:28 ` [PATCH 3/7] PCI: Detach driver in pci_stop_device Yinghai Lu
2013-05-14  2:28 ` [PATCH 4/7] PCI: Fix racing for pci device removing via sysfs Yinghai Lu
2013-05-16  7:52   ` Gu Zheng
2013-05-14  2:28 ` [PATCH 5/7] PCI, ACPI: Don't glue ACPI dev with pci VFs Yinghai Lu
2013-05-14  2:28 ` [PATCH 6/7] PCI: Make sure VF's driver get attached after PF's Yinghai Lu
2013-05-14  8:58   ` Yan Burman
2013-05-14 15:43     ` Yinghai Lu
2013-05-16  4:00       ` Or Gerlitz
2013-05-16  4:39         ` Yinghai Lu
2013-05-16  4:56           ` Or Gerlitz
2013-05-16 17:53             ` Tejun Heo
2013-05-16 18:36               ` Yinghai Lu
2013-05-20 12:23                 ` Or Gerlitz
2013-05-14  9:46   ` Perla, Sathya
2013-05-14 15:19     ` Yinghai Lu
2013-05-14 16:00   ` Alexander Duyck
2013-05-14 18:44     ` Yinghai Lu
2013-05-14 19:45       ` Alexander Duyck
2013-05-14 19:59         ` Yinghai Lu
2013-05-14 21:39           ` Alexander Duyck
2013-05-21 21:30             ` Don Dutile
2013-05-21 21:31               ` Don Dutile
2013-05-21 21:58                 ` Alexander Duyck
2013-05-21 22:09                   ` Don Dutile
2013-05-21 22:12                     ` Alexander Duyck
2013-05-21 21:49               ` Michael S. Tsirkin
2013-05-21 22:01                 ` Alexander Duyck
2013-05-21 22:11                   ` Michael S. Tsirkin
2013-05-21 22:30                     ` Alexander Duyck
2013-05-22 20:16                       ` Or Gerlitz
2013-05-22 21:40                         ` Don Dutile
2013-05-23  6:43                           ` Or Gerlitz
2013-05-22 23:45                         ` Ben Hutchings
2013-05-23  6:32                           ` Or Gerlitz
2013-05-16  6:39   ` Michael S. Tsirkin
2013-05-14  2:28 ` Yinghai Lu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368498506-25857-8-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=dwmw2@infradead.org \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).