From patchwork Tue May 14 02:28:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinghai Lu X-Patchwork-Id: 2562521 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 96568DFE75 for ; Tue, 14 May 2013 02:30:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756341Ab3ENC3b (ORCPT ); Mon, 13 May 2013 22:29:31 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:19624 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755993Ab3ENC33 (ORCPT ); Mon, 13 May 2013 22:29:29 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r4E2SsEw011393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 14 May 2013 02:28:55 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4E2SrpI026312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 14 May 2013 02:28:53 GMT Received: from abhmt109.oracle.com (abhmt109.oracle.com [141.146.116.61]) by userz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r4E2SqLV003709; Tue, 14 May 2013 02:28:52 GMT Received: from linux-siqj.site (/75.36.254.174) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 13 May 2013 19:28:52 -0700 From: Yinghai Lu To: Bjorn Helgaas Cc: Gu Zheng , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Yinghai Lu , David Woodhouse , 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 Message-Id: <1368498506-25857-8-git-send-email-yinghai@kernel.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1368498506-25857-1-git-send-email-yinghai@kernel.org> References: <1368498506-25857-1-git-send-email-yinghai@kernel.org> X-Source-IP: ucsinet21.oracle.com [156.151.31.93] Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.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: [] 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] [] iommu_bus_notifier+0x3e/0xd0 [ 122.374645] [] notifier_call_chain+0x6e/0xb0 [ 122.381277] [] __blocking_notifier_call_chain+0x5e/0x90 [ 122.388963] [] blocking_notifier_call_chain+0x16/0x20 [ 122.396471] [] 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 Cc: David Woodhouse Cc: iommu@lists.linux-foundation.org --- drivers/iommu/intel-iommu.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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,