From patchwork Thu May 30 05:45:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hao, Xudong" X-Patchwork-Id: 2633731 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 59EC2DF2A1 for ; Thu, 30 May 2013 05:46:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967493Ab3E3FqC (ORCPT ); Thu, 30 May 2013 01:46:02 -0400 Received: from mga02.intel.com ([134.134.136.20]:55420 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967488Ab3E3FqB (ORCPT ); Thu, 30 May 2013 01:46:01 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 29 May 2013 22:45:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,768,1363158000"; d="scan'208";a="321746786" Received: from xhao-dev.sh.intel.com (HELO localhost.localdomain) ([10.239.48.48]) by orsmga001.jf.intel.com with ESMTP; 29 May 2013 22:45:50 -0700 From: Xudong Hao To: bhelgaas@google.com Cc: yinghai@kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Xudong Hao Subject: [PATCH] PCI: set correct value for iov device before device Date: Thu, 30 May 2013 13:45:34 +0800 Message-Id: <1369892734-26244-1-git-send-email-xudong.hao@intel.com> X-Mailer: git-send-email 1.5.5 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Since device registering is put into pci_device_add(), it must set value of Virtual Function device's member before the pci_dev is put to device tree. Or some relevant subsystem of driver model such as xen will report a incorrect IOV device to Xen hypervior. Signed-off-by: Xudong Hao --- drivers/pci/iov.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index c93071d..43d3de9 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -110,12 +110,12 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) if (reset) __pci_reset_function(virtfn); - pci_device_add(virtfn, virtfn->bus); - mutex_unlock(&iov->dev->sriov->lock); - virtfn->physfn = pci_dev_get(dev); virtfn->is_virtfn = 1; + pci_device_add(virtfn, virtfn->bus); + mutex_unlock(&iov->dev->sriov->lock); + rc = pci_bus_add_device(virtfn); sprintf(buf, "virtfn%u", id); rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);