All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiang Liu <liuj97@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
	Yinghai Lu <yinghai@kernel.org>,
	Xudong Hao <xudong.hao@intel.com>
Cc: Yijing Wang <wangyijing@huawei.com>,
	linux-pci@vger.kernel.org, Jiang Liu <jiang.liu@huawei.com>
Subject: [PATCH 1/3] PCI: set correct value for iov device before device
Date: Fri, 31 May 2013 12:21:29 +0800	[thread overview]
Message-ID: <1369974092-11450-1-git-send-email-jiang.liu@huawei.com> (raw)

From: Xudong Hao <xudong.hao@intel.com>

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 <xudong.hao@intel.com>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: <stable@vger.kernel.org> # 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);
-- 
1.8.1.2


             reply	other threads:[~2013-05-31  4:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31  4:21 Jiang Liu [this message]
2013-05-31  4:21 ` [PATCH 2/3] PCI, ACPI: Don't glue ACPI dev with pci VFs Jiang Liu
2013-05-31 21:40   ` Bjorn Helgaas
2013-06-04 21:48     ` Bjorn Helgaas
2013-06-04 21:57       ` Yinghai Lu
2013-06-04 22:00         ` Bjorn Helgaas
2013-06-04 22:08           ` Yinghai Lu
2013-06-04 22:44   ` Rafael J. Wysocki
2013-06-04 22:49     ` Rafael J. Wysocki
2013-06-04 22:57       ` Yinghai Lu
2013-06-04 23:51         ` Rafael J. Wysocki
2013-06-05 15:55           ` Yinghai Lu
2013-06-05 16:21             ` Bjorn Helgaas
2013-05-31  4:21 ` [PATCH 3/3] PCI: Hide remove and rescan sysfs interfaces for SR-IOV virtual functions Jiang Liu
2013-06-05 18:32   ` Bjorn Helgaas
2013-06-05 18:31 ` [PATCH 1/3] PCI: set correct value for iov device before device Bjorn Helgaas

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=1369974092-11450-1-git-send-email-jiang.liu@huawei.com \
    --to=liuj97@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=jiang.liu@huawei.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=wangyijing@huawei.com \
    --cc=xudong.hao@intel.com \
    --cc=yinghai@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.