All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai Lu <yhlu.kernel@gmail.com>
To: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	jbarnes@virtuousgeek.org,
	Jack Howarth <howarth@bromo.msbb.uc.edu>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] x86,pci: detect end_bus_number according to acpi/e820 reserved
Date: Fri, 18 Jul 2008 13:22:36 -0700	[thread overview]
Message-ID: <200807181322.37500.yhlu.kernel@gmail.com> (raw)
In-Reply-To: <200807180941.09779.yhlu.kernel@gmail.com>


for MacBookPro2

change the mconf bus range from [0,0xff] to to [0, 0x3f]
to match range [0xf0000000, 0xf4000000) in e820 tables.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

---
 arch/x86/pci/mmconfig-shared.c |   64 ++++++++++++++++++++++++++++++-----------
 1 file changed, 47 insertions(+), 17 deletions(-)

Index: linux-2.6/arch/x86/pci/mmconfig-shared.c
===================================================================
--- linux-2.6.orig/arch/x86/pci/mmconfig-shared.c
+++ linux-2.6/arch/x86/pci/mmconfig-shared.c
@@ -293,7 +293,7 @@ static acpi_status __init find_mboard_re
 	return AE_OK;
 }
 
-static int __init is_acpi_reserved(unsigned long start, unsigned long end)
+static int __init is_acpi_reserved(u64 start, u64 end, unsigned not_used)
 {
 	struct resource mcfg_res;
 
@@ -310,6 +310,41 @@ static int __init is_acpi_reserved(unsig
 	return mcfg_res.flags;
 }
 
+typedef int (*check_reserved_t)(u64 start, u64 end, unsigned type);
+
+static int __init is_mmconf_reserved(check_reserved_t is_reserved,
+		u64 addr, u64 size, int i,
+	        typeof(pci_mmcfg_config[0]) *cfg, int with_e820)
+{
+	u64 old_size = size;
+	int valid = 0;
+
+	while (!is_reserved(addr, addr + size - 1, E820_RESERVED)) {
+		size >>= 1;
+		if (size < (16UL<<20))
+			break;
+	}
+
+	if (size >= (16UL<<20) || size == old_size) {
+		printk(KERN_NOTICE
+		       "PCI: MCFG area at %Lx reserved in %s\n",
+			addr, with_e820?"E820":"ACPI motherboard resources");
+		valid = 1;
+
+		if (old_size != size) {
+			/* update end_bus_number */
+			cfg->end_bus_number = cfg->start_bus_number + ((size>>20) - 1);
+			printk(KERN_NOTICE "PCI: updated MCFG configuration %d: base %lx "
+			       "segment %hu buses %u - %u\n",
+			       i, (unsigned long)cfg->address, cfg->pci_segment,
+			       (unsigned int)cfg->start_bus_number,
+			       (unsigned int)cfg->end_bus_number);
+		}
+	}
+
+	return valid;
+}
+
 static void __init pci_mmcfg_reject_broken(int early)
 {
 	typeof(pci_mmcfg_config[0]) *cfg;
@@ -324,21 +359,21 @@ static void __init pci_mmcfg_reject_brok
 
 	for (i = 0; i < pci_mmcfg_config_num; i++) {
 		int valid = 0;
-		u32 size = (cfg->end_bus_number + 1) << 20;
+		u64 addr, size;
+
 		cfg = &pci_mmcfg_config[i];
+		addr = cfg->start_bus_number;
+		addr <<= 20;
+		size = cfg->end_bus_number + 1 - cfg->start_bus_number;
+		size <<= 20;
 		printk(KERN_NOTICE "PCI: MCFG configuration %d: base %lx "
 		       "segment %hu buses %u - %u\n",
 		       i, (unsigned long)cfg->address, cfg->pci_segment,
 		       (unsigned int)cfg->start_bus_number,
 		       (unsigned int)cfg->end_bus_number);
 
-		if (!early &&
-		    is_acpi_reserved(cfg->address, cfg->address + size - 1)) {
-			printk(KERN_NOTICE "PCI: MCFG area at %Lx reserved "
-			       "in ACPI motherboard resources\n",
-			       cfg->address);
-			valid = 1;
-		}
+		if (!early)
+			valid = is_mmconf_reserved(is_acpi_reserved, addr, size, i, cfg, 0);
 
 		if (valid)
 			continue;
@@ -347,16 +382,11 @@ static void __init pci_mmcfg_reject_brok
 			printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %Lx is not"
 			       " reserved in ACPI motherboard resources\n",
 			       cfg->address);
+
 		/* Don't try to do this check unless configuration
 		   type 1 is available. how about type 2 ?*/
-		if (raw_pci_ops && e820_all_mapped(cfg->address,
-						  cfg->address + size - 1,
-						  E820_RESERVED)) {
-			printk(KERN_NOTICE
-			       "PCI: MCFG area at %Lx reserved in E820\n",
-			       cfg->address);
-			valid = 1;
-		}
+		if (raw_pci_ops)
+			valid = is_mmconf_reserved(e820_all_mapped, addr, size, i, cfg, 1);
 
 		if (!valid)
 			goto reject;

  parent reply	other threads:[~2008-07-18 20:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-18 16:41 [PATCH] x86,pci: dmi check for mackpro 2.2 mmconf Yinghai Lu
2008-07-18 16:50 ` Jack Howarth
2008-07-18 17:44 ` H. Peter Anvin
2008-07-18 17:47   ` Yinghai Lu
2008-07-18 17:49     ` H. Peter Anvin
2008-07-18 17:54       ` Yinghai Lu
2008-07-18 20:19         ` Ingo Molnar
2008-07-18 20:21           ` Yinghai Lu
2008-07-18 20:21 ` Ingo Molnar
2008-07-18 20:26   ` Yinghai Lu
2008-07-19  0:58     ` Jack Howarth
2008-07-19  1:22       ` Yinghai Lu
2008-07-19  3:28         ` Jack Howarth
2008-07-19  3:43           ` Justin Mattock
2008-07-19  4:45           ` Yinghai Lu
2008-07-19  5:12             ` Jack Howarth
2008-07-19  5:28               ` Yinghai Lu
2008-07-19 17:26                 ` Jesse Barnes
2008-07-19 18:19                   ` Jack Howarth
2008-07-19 18:40                   ` Jack Howarth
2008-07-19 19:04                     ` Jesse Barnes
2008-07-19 19:14                       ` Jack Howarth
2008-07-21  6:49                         ` Shaohua Li
2008-07-22 21:15                           ` Jesse Barnes
2008-07-18 20:22 ` Yinghai Lu [this message]
2008-07-18 20:48   ` [PATCH] x86,pci: detect end_bus_number according to acpi/e820 reserved Ingo Molnar
2008-07-18 21:48   ` Jack Howarth
2008-07-18 22:27     ` Yinghai Lu
2008-07-18 22:42       ` Jesse Barnes
2008-07-20  6:48         ` Ingo Molnar
2008-07-19  9:16   ` [PATCH] x86,pci: detect end_bus_number according to acpi/e820 reserved - fix Yinghai Lu
2008-07-20  6:44     ` Ingo Molnar

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=200807181322.37500.yhlu.kernel@gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=howarth@bromo.msbb.uc.edu \
    --cc=hpa@zytor.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.