mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 2/2] PCI: Skip IORESOURCE_IO size and allocation for root bus without ioport range
Date: Mon,  6 May 2013 16:15:30 -0700	[thread overview]
Message-ID: <1367882130-19452-2-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1367882130-19452-1-git-send-email-yinghai@kernel.org>

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 will try must then try to extend must with optional.
That will fail as mmio-non-pref and mmio-pref for bridge will
be next to each other. So we have no chance to extend mmio-non-pref.

We should not fall into retry in this case, as root bus does
not io port range.

We check if the root bus has ioport range, and set bus_res_type_mask,
and pass it to __bus_size_bridges and skip io port resources.

For the retry failing, we could allocate mmio-non-pref bottom-up
and mmio-pref will be top-down, but that could not be material for v3.10.

Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/setup-bus.c |   39 +++++++++++++++++++++++++++++++--------
 1 file changed, 31 insertions(+), 8 deletions(-)

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
@@ -1045,7 +1045,8 @@ handle_done:
 }
 
 static void __ref __pci_bus_size_bridges(struct pci_bus *bus,
-			struct list_head *realloc_head)
+			struct list_head *realloc_head,
+			unsigned long res_type_mask)
 {
 	struct pci_dev *dev;
 	unsigned long mask, prefmask;
@@ -1063,7 +1064,7 @@ static void __ref __pci_bus_size_bridges
 
 		case PCI_CLASS_BRIDGE_PCI:
 		default:
-			__pci_bus_size_bridges(b, realloc_head);
+			__pci_bus_size_bridges(b, realloc_head, res_type_mask);
 			break;
 		}
 	}
@@ -1087,8 +1088,9 @@ static void __ref __pci_bus_size_bridges
 		 * Follow thru
 		 */
 	default:
-		pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
-			     additional_io_size, realloc_head);
+		if (res_type_mask & IORESOURCE_IO)
+			pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
+				     additional_io_size, realloc_head);
 		/* If the bridge supports prefetchable range, size it
 		   separately. If it doesn't, or its prefetchable window
 		   has already been allocated by arch code, try
@@ -1111,7 +1113,10 @@ static void __ref __pci_bus_size_bridges
 
 void __ref pci_bus_size_bridges(struct pci_bus *bus)
 {
-	__pci_bus_size_bridges(bus, NULL);
+	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
+				  IORESOURCE_PREFETCH;
+
+	__pci_bus_size_bridges(bus, NULL, type_mask);
 }
 EXPORT_SYMBOL(pci_bus_size_bridges);
 
@@ -1376,6 +1381,21 @@ static enum enable_type __init pci_reall
 	return enable_local;
 }
 
+static unsigned int __init pci_bus_res_type_mask(struct pci_bus *bus)
+{
+	int i;
+	struct resource *r;
+	unsigned long mask = 0;
+	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
+				  IORESOURCE_PREFETCH;
+
+	pci_bus_for_each_resource(bus, r, i)
+		if (r)
+			mask |= r->flags & type_mask;
+
+	return mask;
+}
+
 /*
  * first try will not touch pci bridge res
  * second  and later try will clear small leaf bridge res
@@ -1395,6 +1415,7 @@ pci_assign_unassigned_root_bus_resources
 				  IORESOURCE_PREFETCH;
 	int pci_try_num = 1;
 	enum enable_type enable_local;
+	unsigned long bus_res_type_mask = pci_bus_res_type_mask(bus);
 
 	/* don't realloc if asked to do so */
 	enable_local = pci_realloc_detect(bus, pci_realloc_enable);
@@ -1416,7 +1437,7 @@ again:
 		add_list = &realloc_head;
 	/* Depth first, calculate sizes and alignments of all
 	   subordinate buses. */
-	__pci_bus_size_bridges(bus, add_list);
+	__pci_bus_size_bridges(bus, add_list, bus_res_type_mask);
 
 	/* Depth last, allocate resources and update the hardware. */
 	__pci_bus_assign_resources(bus, add_list, &fail_head);
@@ -1496,9 +1517,10 @@ void pci_assign_unassigned_bridge_resour
 	int retval;
 	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
 				  IORESOURCE_PREFETCH;
+	unsigned long bus_res_type_mask = pci_bus_res_type_mask(bridge->bus);
 
 again:
-	__pci_bus_size_bridges(parent, &add_list);
+	__pci_bus_size_bridges(parent, &add_list, bus_res_type_mask);
 	__pci_bridge_assign_resources(bridge, &add_list, &fail_head);
 	BUG_ON(!list_empty(&add_list));
 	tried_times++;
@@ -1554,6 +1576,7 @@ void pci_assign_unassigned_bus_resources
 	struct pci_dev *dev;
 	LIST_HEAD(add_list); /* list of resources that
 					want additional resources */
+	unsigned long bus_res_type_mask = pci_bus_res_type_mask(bus);
 
 	down_read(&pci_bus_sem);
 	list_for_each_entry(dev, &bus->devices, bus_list)
@@ -1561,7 +1584,7 @@ void pci_assign_unassigned_bus_resources
 		    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
 			if (dev->subordinate)
 				__pci_bus_size_bridges(dev->subordinate,
-							 &add_list);
+						 &add_list, bus_res_type_mask);
 	up_read(&pci_bus_sem);
 	__pci_bus_assign_resources(bus, &add_list, NULL);
 	BUG_ON(!list_empty(&add_list));

  reply	other threads:[~2013-05-06 23:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1367837311.15842.31.camel@pasglop>
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   ` Yinghai Lu [this message]
2013-05-07  0:50   ` 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

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=1367882130-19452-2-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

Powered by JetHome