public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yinghai@kernel.org>
To: Jesse Barnes <jbarnes@virtuousgeek.org>,
	Ingo Molnar <mingo@elte.hu>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
	Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
	Alex Chiang <achiang@hp.com>,
	Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	Yinghai Lu <yinghai@kernel.org>
Subject: [PATCH 01/14] pci: separate pci_setup_bridge to small functions
Date: Tue, 22 Dec 2009 15:02:21 -0800	[thread overview]
Message-ID: <1261522954-12591-2-git-send-email-yinghai@kernel.org> (raw)
In-Reply-To: <1261522954-12591-1-git-send-email-yinghai@kernel.org>

prepare to use those small functions according to resource type later

-v2: remove pref_mem64 typo, it should be removed

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 drivers/pci/setup-bus.c |   66 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index c48cd37..1bd41ac 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -134,18 +134,12 @@ EXPORT_SYMBOL(pci_setup_cardbus);
    config space writes, so it's quite possible that an I/O window of
    the bridge will have some undesirable address (e.g. 0) after the
    first write. Ditto 64-bit prefetchable MMIO.  */
-static void pci_setup_bridge(struct pci_bus *bus)
+static void pci_setup_bridge_io(struct pci_bus *bus)
 {
 	struct pci_dev *bridge = bus->self;
 	struct resource *res;
 	struct pci_bus_region region;
-	u32 l, bu, lu, io_upper16;
-
-	if (pci_is_enabled(bridge))
-		return;
-
-	dev_info(&bridge->dev, "PCI bridge to [bus %02x-%02x]\n",
-		 bus->secondary, bus->subordinate);
+	u32 l, io_upper16;
 
 	/* Set up the top and bottom of the PCI I/O segment for this bus. */
 	res = bus->resource[0];
@@ -158,8 +152,7 @@ static void pci_setup_bridge(struct pci_bus *bus)
 		/* Set up upper 16 bits of I/O base/limit. */
 		io_upper16 = (region.end & 0xffff0000) | (region.start >> 16);
 		dev_info(&bridge->dev, "  bridge window %pR\n", res);
-	}
-	else {
+	} else {
 		/* Clear upper 16 bits of I/O base/limit. */
 		io_upper16 = 0;
 		l = 0x00f0;
@@ -171,21 +164,35 @@ static void pci_setup_bridge(struct pci_bus *bus)
 	pci_write_config_dword(bridge, PCI_IO_BASE, l);
 	/* Update upper 16 bits of I/O base/limit. */
 	pci_write_config_dword(bridge, PCI_IO_BASE_UPPER16, io_upper16);
+}
+
+static void pci_setup_bridge_mmio(struct pci_bus *bus)
+{
+	struct pci_dev *bridge = bus->self;
+	struct resource *res;
+	struct pci_bus_region region;
+	u32 l;
 
-	/* Set up the top and bottom of the PCI Memory segment
-	   for this bus. */
+	/* Set up the top and bottom of the PCI Memory segment for this bus. */
 	res = bus->resource[1];
 	pcibios_resource_to_bus(bridge, &region, res);
 	if (res->flags & IORESOURCE_MEM) {
 		l = (region.start >> 16) & 0xfff0;
 		l |= region.end & 0xfff00000;
 		dev_info(&bridge->dev, "  bridge window %pR\n", res);
-	}
-	else {
+	} else {
 		l = 0x0000fff0;
 		dev_info(&bridge->dev, "  bridge window [mem disabled]\n");
 	}
 	pci_write_config_dword(bridge, PCI_MEMORY_BASE, l);
+}
+
+static void pci_setup_bridge_mmio_pref(struct pci_bus *bus)
+{
+	struct pci_dev *bridge = bus->self;
+	struct resource *res;
+	struct pci_bus_region region;
+	u32 l, bu, lu;
 
 	/* Clear out the upper 32 bits of PREF limit.
 	   If PCI_PREF_BASE_UPPER32 was non-zero, this temporarily
@@ -204,8 +211,7 @@ static void pci_setup_bridge(struct pci_bus *bus)
 			lu = upper_32_bits(region.end);
 		}
 		dev_info(&bridge->dev, "  bridge window %pR\n", res);
-	}
-	else {
+	} else {
 		l = 0x0000fff0;
 		dev_info(&bridge->dev, "  bridge window [mem pref disabled]\n");
 	}
@@ -214,10 +220,38 @@ static void pci_setup_bridge(struct pci_bus *bus)
 	/* Set the upper 32 bits of PREF base & limit. */
 	pci_write_config_dword(bridge, PCI_PREF_BASE_UPPER32, bu);
 	pci_write_config_dword(bridge, PCI_PREF_LIMIT_UPPER32, lu);
+}
+
+static void __pci_setup_bridge(struct pci_bus *bus, unsigned long type)
+{
+	struct pci_dev *bridge = bus->self;
+
+	if (pci_is_enabled(bridge))
+		return;
+
+	dev_info(&bridge->dev, "PCI bridge to [bus %02x-%02x]\n",
+		 bus->secondary, bus->subordinate);
+
+	if (type & IORESOURCE_IO)
+		pci_setup_bridge_io(bus);
+
+	if (type & IORESOURCE_MEM)
+		pci_setup_bridge_mmio(bus);
+
+	if (type & IORESOURCE_PREFETCH)
+		pci_setup_bridge_mmio_pref(bus);
 
 	pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bus->bridge_ctl);
 }
 
+static void pci_setup_bridge(struct pci_bus *bus)
+{
+	unsigned long type = IORESOURCE_IO | IORESOURCE_MEM |
+				  IORESOURCE_PREFETCH;
+
+	__pci_setup_bridge(bus, type);
+}
+
 /* Check whether the bridge supports optional I/O and
    prefetchable memory ranges. If not, the respective
    base/limit registers must be read-only and read as 0. */
-- 
1.6.0.2


  reply	other threads:[~2009-12-22 23:06 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-22 23:02 [PATCH 00/14] pci: update pci bridge resources Yinghai Lu
2009-12-22 23:02 ` Yinghai Lu [this message]
2010-01-15 18:54   ` [PATCH 01/14] pci: separate pci_setup_bridge to small functions Jesse Barnes
2009-12-22 23:02 ` [PATCH 02/14] resource: add release_child_resources Yinghai Lu
2010-01-15 18:54   ` Jesse Barnes
2009-12-22 23:02 ` [PATCH 03/14] pci: add pci_bridge_release_unused_res and pci_bus_release_unused_bridge_res Yinghai Lu
2010-01-15 18:53   ` Jesse Barnes
2010-01-16  0:20     ` Yinghai Lu
2009-12-22 23:02 ` [PATCH 04/14] pci: don't dump it when bus resource flags is not used Yinghai Lu
2010-01-15 18:54   ` Jesse Barnes
2009-12-22 23:02 ` [PATCH 05/14] pci: add failed_list to record failed one for pci_bus_assign_resources Yinghai Lu
2010-01-15 18:56   ` Jesse Barnes
2010-01-15 21:13     ` Yinghai Lu
2010-01-15 21:41   ` Bjorn Helgaas
2009-12-22 23:02 ` [PATCH 06/14] pci: reject mmio range start from 0 on pci_bridge read Yinghai Lu
2010-01-15 19:19   ` Jesse Barnes
2010-01-15 21:15     ` Yinghai Lu
2009-12-22 23:02 ` [PATCH 07/14] pci: don't shrink bridge resources Yinghai Lu
2010-01-15 19:04   ` Jesse Barnes
2010-01-15 21:09     ` Yinghai Lu
2010-01-15 21:31       ` Jesse Barnes
2010-01-16  0:32         ` Yinghai Lu
2009-12-22 23:02 ` [PATCH 08/14] pci: update bridge res to get more big range in pci assign unssign Yinghai Lu
2010-01-15 19:12   ` Jesse Barnes
2010-01-15 21:12     ` Yinghai Lu
2010-01-15 21:34       ` Bjorn Helgaas
2010-01-15 21:34       ` Jesse Barnes
2009-12-22 23:02 ` [PATCH 09/14] pci: introduce pci_assign_unassigned_bridge_resources Yinghai Lu
2010-01-13  0:50   ` Kenji Kaneshige
2010-01-13  1:58     ` Yinghai Lu
2010-01-13  7:31       ` Kenji Kaneshige
2010-01-13  7:52         ` Yinghai Lu
2009-12-22 23:02 ` [PATCH 10/14] pci: pciehp clean flow in pciehp_configure_device Yinghai Lu
2010-01-15 19:14   ` Jesse Barnes
2010-01-15 21:14     ` Yinghai Lu
2009-12-22 23:02 ` [PATCH 11/14] pci: pciehp second try to get big range for pcie devices Yinghai Lu
2009-12-22 23:02 ` [PATCH 12/14] pci: pci_bridge_release_res Yinghai Lu
2009-12-22 23:02 ` [PATCH 13/14] pciehp: add support for bridge resource reallocation Yinghai Lu
2009-12-22 23:02 ` [PATCH 14/14] pci: set PCI_PREF_RANGE_TYPE_64 in pci_bridge_check_ranges Yinghai Lu
2010-01-08 21:33 ` [PATCH 00/14] pci: update pci bridge resources Patrick Keller
2010-01-11 21:57 ` Patrick Keller
2010-01-12 18:18   ` Jesse Barnes

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=1261522954-12591-2-git-send-email-yinghai@kernel.org \
    --to=yinghai@kernel.org \
    --cc=achiang@hp.com \
    --cc=bjorn.helgaas@hp.com \
    --cc=ink@jurassic.park.msu.ru \
    --cc=jbarnes@virtuousgeek.org \
    --cc=kaneshige.kenji@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@linux-foundation.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