linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guo Chao <yan@linux.vnet.ibm.com>
To: linux-pci@vger.kernel.org
Cc: Guo Chao <yan@linux.vnet.ibm.com>
Subject: [PATCH] PCI: Reset failed bridge resources in PCI realloc
Date: Wed, 30 Jul 2014 16:00:07 +0800	[thread overview]
Message-ID: <1406707207-13152-1-git-send-email-yan@linux.vnet.ibm.com> (raw)

We observed a problem on at least two POWER machines with PCIe
devices with very large SR-IOV BARs. The total size is larger than
host bridge MMIO window. We expect normal BARs of this device get address
successfuly, and SR-IOV BARs deserted. However, this only happens if PCI
realloc is disabled (pci=realloc=off or not config at all). Otherwise we
fail to assign both BARs.

Here is what happened when realloc is enabled:
	* SR-IOV resources will NOT be considered as optional until the last
	  round of realloc. Both normal BARs and SR-IOV BARs of this device
	  will be sized and recorded in upstream bridge as initial size.
	* Realloc never works because this bridge is too big, at end of
	  each round, the bridge is restored to the value before
	  assigning, i.e. it keeps its size.
	* At last round, we finally consider SR-IOV resources optional
	  and size them seperately. We should get a small bridge this
	  time.
	* However, in pbus_size_mem() we call calculate_memsize() to
	  calculate the final size. calculate_memsize() never shrinks
	  window, i.e. if old size is larger than newly sized result,
	  old size will be honored. Unfortunately, the old size at this
	  time is the sum of both normal BARs and SR-IOV BARs when doing
	  realloc.
	* The bridge window failed to get address just like previous rounds.

Without PCI realloc, SR-IOV resources are considered as optional
from the beginning and sized seperately. The old size would be 0. We get
a small bridge window and assinged successfully. Everything work as
expected.

I actually don't quite understand what realloc does. Apparently this is
not the right fix ...

Cc: Yinghai Lu <yinghai@kernel.org> 
Signed-off-by: Guo Chao <yan@linux.vnet.ibm.com>
---
 drivers/pci/setup-bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index a5a63ec..39837d7 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1623,7 +1623,7 @@ again:
 		res->end = fail_res->end;
 		res->flags = fail_res->flags;
 		if (fail_res->dev->subordinate)
-			res->flags = 0;
+			res->flags = res->start = res->end = 0;
 	}
 	free_list(&fail_head);
 
-- 
1.9.1


             reply	other threads:[~2014-07-30  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30  8:00 Guo Chao [this message]
2014-07-30 19:59 ` [PATCH] PCI: Reset failed bridge resources in PCI realloc Yinghai Lu
2014-07-31  8:48   ` Guo Chao
2014-09-04  4:23   ` 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=1406707207-13152-1-git-send-email-yan@linux.vnet.ibm.com \
    --to=yan@linux.vnet.ibm.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).