linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Yang <weiyang@linux.vnet.ibm.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, Wei Yang <weiyang@linux.vnet.ibm.com>
Subject: [PATCH v2] PCI: Don't update VF's BAR
Date: Wed, 29 Jul 2015 16:52:58 +0800	[thread overview]
Message-ID: <1438159978-32285-1-git-send-email-weiyang@linux.vnet.ibm.com> (raw)
In-Reply-To: <20150714221511.GM24416@google.com>

VF BARs are RO zero, so updating VF BARs will not take any effect.
See the SR-IOV spec r1.1, sec 3.4.1.11.

Also this patch adds a warning in pci_update_resource() in case someone
really tries to update it.

Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>
---
 drivers/pci/pci.c       |    7 +++++++
 drivers/pci/setup-res.c |    5 +++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 0008c95..93c0d24 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -483,6 +483,13 @@ static void pci_restore_bars(struct pci_dev *dev)
 {
 	int i;
 
+        /* 
+	 * Per SRIOV SPEC 3.4.1.11, VF BARs are RO zero.
+	 * If this is a VF, just return.
+	 */
+	if (dev->is_virtfn)
+		return;
+
 	for (i = 0; i < PCI_BRIDGE_RESOURCES; i++)
 		pci_update_resource(dev, i);
 }
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 232f925..ebe57db 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -36,6 +36,11 @@ void pci_update_resource(struct pci_dev *dev, int resno)
 	enum pci_bar_type type;
 	struct resource *res = dev->resource + resno;
 
+	if (dev->is_virtfn) {
+		dev_warn(&dev->dev, "Trying to update VF BAR\n");
+		return;
+	}
+
 	/*
 	 * Ignore resources for unimplemented BARs and unused resource slots
 	 * for 64 bit BARs.
-- 
1.7.9.5


  parent reply	other threads:[~2015-07-29  8:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30  7:37 [PATCH] PCI: Don't update VF's BAR Wei Yang
2015-07-14 22:15 ` Bjorn Helgaas
2015-07-15  1:38   ` Wei Yang
2015-07-29  8:52   ` Wei Yang [this message]
2015-08-27 17:27     ` [PATCH v2] " Bjorn Helgaas
2015-08-28  3:51       ` Richard Yang

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=1438159978-32285-1-git-send-email-weiyang@linux.vnet.ibm.com \
    --to=weiyang@linux.vnet.ibm.com \
    --cc=bhelgaas@google.com \
    --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).