From patchwork Fri May 31 04:21:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 247841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 413832C0299 for ; Fri, 31 May 2013 14:21:54 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750855Ab3EaEVs (ORCPT ); Fri, 31 May 2013 00:21:48 -0400 Received: from mail-pb0-f52.google.com ([209.85.160.52]:43607 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763Ab3EaEVs (ORCPT ); Fri, 31 May 2013 00:21:48 -0400 Received: by mail-pb0-f52.google.com with SMTP id xa12so1520389pbc.25 for ; Thu, 30 May 2013 21:21:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=0on2qsxH/uWqsxURbmxnXu3DvEuYPydtt6s0oHHI0/w=; b=VWi88Iy/3HEYVHFdWLzS+RQGaEJX5IyWhJeQSq0iC5PzdHMRxsKE4ThrvndTut84Zw aprZfyfdrdE+nknT56bEFNRNHhLqV/W9UMMS2OpPrQusRGZvZDhoZaYP6Angtd0f8gYs RDs+IA5lnwe54RZB7W7zfe/cGrq3MSXX1AnbRkAMqqQOwnPyZijHkPCQ1ZVeYyiuHGv8 DetXaA7JJtHWb+nVBmwCOBAg9WS0sWxR9ygdfQmX/dKn4Mb00GIrjRKZ0GROHUt7W7w6 HENl/A3zbMilUj5V9mpAuy1M/YXnGvNwU+tQZSnjeXHJSOEluL+2s5+9voFblA4YlKNA V0Iw== X-Received: by 10.67.4.196 with SMTP id cg4mr11554951pad.117.1369974107972; Thu, 30 May 2013 21:21:47 -0700 (PDT) Received: from localhost.localdomain (p2155-ipngn4501marunouchi.tokyo.ocn.ne.jp. [153.135.240.155]) by mx.google.com with ESMTPSA id b7sm44778215pba.39.2013.05.30.21.21.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 May 2013 21:21:47 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Yinghai Lu , Xudong Hao Cc: Yijing Wang , linux-pci@vger.kernel.org, Jiang Liu Subject: [PATCH 1/3] PCI: set correct value for iov device before device Date: Fri, 31 May 2013 12:21:29 +0800 Message-Id: <1369974092-11450-1-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Xudong Hao Commit 4f535093cf8f6da8 "PCI: Put pci_dev in device tree as early as possible" moves device registering from pci_bus_add_devices() to pci_device_add(). That change causes troubles to PCI virtual functions because device_add(&virtfn->dev) is called before setting virtfn->is_virtfn flag, which then causes Xen to report PCI virtual functions as PCI physical functions. So fix it by setting virtfn->is_virtfn before calling pci_device_add(). [Jiang Liu]: move the setting of virtfn->is_virtfn ahead further for better readability and modify changelog. Signed-off-by: Xudong Hao Signed-off-by: Jiang Liu Cc: # 3.9+ --- Hi Bjorn and Yinghai, How about this? I split out the bugfix patch as separate patch so it could be easily back ported to stable branches. Regards! Gerry --- drivers/pci/iov.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 5fffca9..de8ffac 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -82,6 +82,8 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) pci_read_config_word(dev, iov->pos + PCI_SRIOV_VF_DID, &virtfn->device); pci_setup_device(virtfn); virtfn->dev.parent = dev->dev.parent; + virtfn->physfn = pci_dev_get(dev); + virtfn->is_virtfn = 1; for (i = 0; i < PCI_SRIOV_NUM_BARS; i++) { res = dev->resource + PCI_IOV_RESOURCES + i; @@ -103,9 +105,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset) pci_device_add(virtfn, virtfn->bus); mutex_unlock(&iov->dev->sriov->lock); - virtfn->physfn = pci_dev_get(dev); - virtfn->is_virtfn = 1; - rc = pci_bus_add_device(virtfn); sprintf(buf, "virtfn%u", id); rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);