From: Yinghai Lu <yinghai@kernel.org>
To: Bjorn Helgaas <bhelgaas@google.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH v3] PCI: Don't let mmio fallback to must-only, if ioport fails with must+optional
Date: Fri, 24 May 2013 16:31:23 -0700 [thread overview]
Message-ID: <1369438283-6208-1-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <CAErSpo6pT2iTMx6U50AeScCjmPu53MOj6-TCnATRj_+EUNz46w@mail.gmail.com>
BenH reported that there is some assign unassigned resource problem
in powerpc.
It turns out after
| commit 0c5be0cb0edfe3b5c4b62eac68aa2aa15ec681af
| Date: Thu Feb 23 19:23:29 2012 -0800
|
| PCI: Retry on IORESOURCE_IO type allocations
even the root bus does not have io port range, it will keep retrying
to realloc with mmio.
Current retry logic is : try with must+optional at first, and if
it fails with any ioport or mmio, it will try must then try to extend
must with optional. The reassign will put extended mmio or pref mmio
in the middle of parent resource range.
That will prevent other sibling resources to get must-have resources
or get extended properly.
We can check fail type to see if can we need fall back to must-have
only, that will keep not needed release resource to be must+optional.
Separate three resource type checking if we need to release
assigned resource after requested + add_size try.
1. if there is io port assign fail, will release assigned io port.
2. if there is pref mmio assign fail, release assigned pref mmio.
if assigned pref mmio's parent is non-pref mmio and there
is non-pref mmio assign fail, will release that assigned pref mmio.
3. if there is non-pref mmio assign fail or pref mmio assigned fail,
will release assigned non-pref mmio.
This will be become more often when we have x86 8 sockets or 32 sockets
system, and those system will have one root bus per socket.
They will have some root buses do not have ioport range.
-v2: need to remove assigned entries from optional list too.
-v3: not just checking ioport related, requested by Bjorn.
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/setup-bus.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
Index: linux-2.6/drivers/pci/setup-bus.c
===================================================================
--- linux-2.6.orig/drivers/pci/setup-bus.c
+++ linux-2.6/drivers/pci/setup-bus.c
@@ -300,6 +300,48 @@ static void assign_requested_resources_s
}
}
+static unsigned long pci_fail_res_type_mask(struct list_head *fail_head)
+{
+ struct pci_dev_resource *fail_res;
+ unsigned long mask = 0;
+
+ /* check failed type */
+ list_for_each_entry(fail_res, fail_head, list)
+ mask |= fail_res->flags;
+
+ /*
+ * one pref failed resource will set IORESOURCE_MEM,
+ * as we can allocate pref in non-pref range.
+ * Will release all asssigned non-pref sibling resources
+ * according to that bit.
+ */
+ return mask & (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH);
+}
+
+static bool pci_need_to_release(unsigned long mask, struct resource *res)
+{
+ if (res->flags & IORESOURCE_IO)
+ return !!(mask & IORESOURCE_IO);
+
+ /* check pref at first */
+ if (res->flags & IORESOURCE_PREFETCH) {
+ if (mask & IORESOURCE_PREFETCH)
+ return true;
+ /* count pref if its parent is non-pref */
+ else if ((mask & IORESOURCE_MEM) &&
+ !(res->parent->flags & IORESOURCE_PREFETCH))
+ return true;
+ else
+ return false;
+ }
+
+ if (res->flags & IORESOURCE_MEM)
+ return !!(mask & IORESOURCE_MEM);
+
+ /* should not get here */
+ return false;
+}
+
static void __assign_resources_sorted(struct list_head *head,
struct list_head *realloc_head,
struct list_head *fail_head)
@@ -312,11 +354,24 @@ static void __assign_resources_sorted(st
* if could do that, could get out early.
* if could not do that, we still try to assign requested at first,
* then try to reassign add_size for some resources.
+ *
+ * Separate three resource type checking if we need to release
+ * assigned resource after requested + add_size try.
+ * 1. if there is io port assign fail, will release assigned
+ * io port.
+ * 2. if there is pref mmio assign fail, release assigned
+ * pref mmio.
+ * if assigned pref mmio's parent is non-pref mmio and there
+ * is non-pref mmio assign fail, will release that assigned
+ * pref mmio.
+ * 3. if there is non-pref mmio assign fail or pref mmio
+ * assigned fail, will release assigned non-pref mmio.
*/
LIST_HEAD(save_head);
LIST_HEAD(local_fail_head);
struct pci_dev_resource *save_res;
- struct pci_dev_resource *dev_res;
+ struct pci_dev_resource *dev_res, *tmp_res;
+ unsigned long fail_type;
/* Check if optional add_size is there */
if (!realloc_head || list_empty(realloc_head))
@@ -348,6 +403,19 @@ static void __assign_resources_sorted(st
return;
}
+ /* check failed type */
+ fail_type = pci_fail_res_type_mask(&local_fail_head);
+ /* remove not need to be released assigned res from head list etc */
+ list_for_each_entry_safe(dev_res, tmp_res, head, list)
+ if (dev_res->res->parent &&
+ !pci_need_to_release(fail_type, dev_res->res)) {
+ /* remove it from realloc_head list */
+ remove_from_list(realloc_head, dev_res->res);
+ remove_from_list(&save_head, dev_res->res);
+ list_del(&dev_res->list);
+ kfree(dev_res);
+ }
+
free_list(&local_fail_head);
/* Release assigned resource */
list_for_each_entry(dev_res, head, list)
next prev parent reply other threads:[~2013-05-24 23:31 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-05 0:10 Resource assignment oddities Benjamin Herrenschmidt
2013-05-05 0:15 ` Benjamin Herrenschmidt
2013-05-05 5:18 ` Yinghai Lu
2013-05-05 5:34 ` Benjamin Herrenschmidt
2013-05-05 7:09 ` Yinghai Lu
2013-05-05 7:52 ` Benjamin Herrenschmidt
[not found] ` <51871088.4594420a.0ccc.7300SMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-06 3:04 ` Yinghai Lu
[not found] ` <20130506103159.GA16927@shangw.(null)>
2013-05-06 10:48 ` Benjamin Herrenschmidt
2013-05-06 19:56 ` Yinghai Lu
[not found] ` <5188b791.a110420a.0bea.077eSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-07 22:21 ` Yinghai Lu
[not found] ` <5189c22b.45f7440a.0a88.6b75SMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-08 3:42 ` Yinghai Lu
2013-05-17 5:36 ` Benjamin Herrenschmidt
2013-05-21 17:28 ` Bjorn Helgaas
2013-05-21 17:39 ` Yinghai Lu
2013-05-21 22:01 ` Benjamin Herrenschmidt
2013-05-06 23:15 ` [PATCH 1/2] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-05-06 23:15 ` [PATCH 2/2] PCI: Skip IORESOURCE_IO size and allocation for root bus without ioport range Yinghai Lu
2013-05-07 0:50 ` [PATCH 1/2] PCI: Split pci_assign_unassigned_resources to per root bus Benjamin Herrenschmidt
[not found] ` <51885a04.c181440a.37c9.ffffa88eSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-07 7:34 ` Yinghai Lu
2013-05-21 20:41 ` Bjorn Helgaas
2013-05-07 22:17 ` [PATCH v3 0/5] PCI: Skip resource allocation for root bus without conresponding type resource Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 1/5] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 2/5] PCI: Skip IORESOURCE_IO allocation for root bus without ioport range Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 3/5] PCI: Skip IORESOURCE_MMIO allocation for root bus without MMIO range Yinghai Lu
2013-05-07 22:28 ` Benjamin Herrenschmidt
2013-05-07 22:44 ` Yinghai Lu
2013-05-08 1:16 ` Benjamin Herrenschmidt
2013-05-08 3:57 ` Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 4/5] PCI: Enable pci bridge when it is needed Yinghai Lu
2013-05-07 22:17 ` [PATCH v3 5/5] PCI: Retry assign unassigned resources for hotadd root bus Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 0/8] PCI: Skip resource allocation for root bus without conresponding type resource Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 1/8] PCI: Don't use temp bus for pci_bus_release_bridge_resources Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 2/8] PCI: Use pci_walk_bus to detect unassigned resources Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 3/8] PCI: Introduce enable_local to prepare per root bus handling Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 4/8] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 5/8] PCI: Skip IORESOURCE_IO allocation for root bus without ioport range Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 6/8] PCI: Skip IORESOURCE_MMIO allocation for root bus without MMIO range Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 7/8] PCI: Enable pci bridge when it is needed Yinghai Lu
2013-05-22 6:38 ` [PATCH v4 8/8] PCI: Retry assign unassigned resources for hotadd root bus Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 0/7] PCI: Change assign unassigned resources per root bus bassis Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 2/7] PCI: Don't use temp bus for pci_bus_release_bridge_resources Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 3/7] PCI: Use pci_walk_bus to detect unassigned resources Yinghai Lu
2013-06-25 21:15 ` Bjorn Helgaas
2013-06-25 21:38 ` Benjamin Herrenschmidt
2013-06-25 21:46 ` Bjorn Helgaas
2013-06-26 8:07 ` Yinghai Lu
2013-06-26 7:38 ` Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 4/7] PCI: Introduce enable_local to prepare per root bus handling Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 5/7] PCI: Split pci_assign_unassigned_resources to per root bus Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 6/7] PCI: Enable pci bridge when it is needed Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 7/7] PCI: Retry assign unassigned resources for hotadd root bus Yinghai Lu
2013-06-01 6:03 ` [PATCH v5 1/7] PCI: Don't let mmio fallback to must-only, if ioport fails with must+optional Yinghai Lu
2013-06-22 3:00 ` [PATCH v5 0/7] PCI: Change assign unassigned resources per root bus bassis Yinghai Lu
[not found] ` <518786a7.64bbec0a.58a0.1f6bSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-22 14:54 ` Resource assignment oddities Bjorn Helgaas
2013-05-22 16:59 ` Yinghai Lu
2013-05-22 17:21 ` Bjorn Helgaas
2013-05-22 20:44 ` Benjamin Herrenschmidt
2013-05-22 21:01 ` Yinghai Lu
2013-05-22 20:43 ` Benjamin Herrenschmidt
2013-05-22 21:00 ` Yinghai Lu
2013-05-22 21:13 ` Benjamin Herrenschmidt
2013-05-22 20:50 ` Yinghai Lu
[not found] ` <519dcfbe.89e9420a.4934.488bSMTPIN_ADDED_BROKEN@mx.google.com>
2013-05-23 17:08 ` Yinghai Lu
2013-05-23 17:12 ` Bjorn Helgaas
2013-05-23 17:17 ` Yinghai Lu
2013-05-23 19:47 ` Bjorn Helgaas
2013-05-23 21:00 ` Yinghai Lu
2013-05-23 21:23 ` Benjamin Herrenschmidt
2013-05-23 22:16 ` Yinghai Lu
2013-05-24 15:59 ` Bjorn Helgaas
2013-05-24 16:33 ` Benjamin Herrenschmidt
2013-05-24 16:34 ` Yinghai Lu
2013-05-23 17:11 ` [PATCH] PCI: Don't let mmio fallback to must-only, if ioport fails with must+optional Yinghai Lu
2013-05-24 17:25 ` Bjorn Helgaas
2013-05-24 23:31 ` Yinghai Lu [this message]
2013-05-24 23:34 ` Yinghai Lu
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=1369438283-6208-1-git-send-email-yinghai@kernel.org \
--to=yinghai@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=shangw@linux.vnet.ibm.com \
/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).