LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH -mm] MMCONFIG: Reject a broken MCFG tables on Asus etc
@ 2007-01-13 21:27 OGAWA Hirofumi
  2007-01-16 19:19 ` Olivier Galibert
  0 siblings, 1 reply; 3+ messages in thread
From: OGAWA Hirofumi @ 2007-01-13 21:27 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Arjan van de Ven, Andi Kleen, linux-kernel

This rejects a broken MCFG tables on Asus etc.
Arjan and Andi suggest this.

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 arch/i386/pci/mmconfig-shared.c |   24 ++++++++++++++++++-
 arch/i386/pci/mmconfig.c        |    9 -------
 arch/x86_64/pci/mmconfig.c      |   50 +++++++++++-----------------------------
 3 files changed, 37 insertions(+), 46 deletions(-)

diff -puN arch/i386/pci/mmconfig-shared.c~pci-mmconfig-reject-mcfg_broken arch/i386/pci/mmconfig-shared.c
--- linux-2.6/arch/i386/pci/mmconfig-shared.c~pci-mmconfig-reject-mcfg_broken	2007-01-12 23:15:58.000000000 +0900
+++ linux-2.6-hirofumi/arch/i386/pci/mmconfig-shared.c	2007-01-12 23:15:58.000000000 +0900
@@ -207,6 +207,26 @@ static void __init pci_mmcfg_insert_reso
 	}
 }
 
+static void __init pci_mmcfg_reject_broken(void)
+{
+	struct acpi_table_mcfg_config *cfg = &pci_mmcfg_config[0];
+
+	/*
+	 * Handle more broken MCFG tables on Asus etc.
+	 * They only contain a single entry for bus 0-0.
+	 */
+	if (pci_mmcfg_config_num == 1 &&
+	    cfg->pci_segment_group_number == 0 &&
+	    (cfg->start_bus_number | cfg->end_bus_number) == 0) {
+		kfree(pci_mmcfg_config);
+		pci_mmcfg_config = NULL;
+		pci_mmcfg_config_num = 0;
+
+		printk(KERN_ERR "PCI: start and end of bus number is 0. "
+		       "Rejected as broken MCFG.");
+	}
+}
+
 void __init pci_mmcfg_init(int type)
 {
 	int known_bridge = 0;
@@ -217,8 +237,10 @@ void __init pci_mmcfg_init(int type)
 	if (type == 1 && pci_mmcfg_check_hostbridge())
 		known_bridge = 1;
 
-	if (!known_bridge)
+	if (!known_bridge) {
 		acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
+		pci_mmcfg_reject_broken();
+	}
 
 	if ((pci_mmcfg_config_num == 0) ||
 	    (pci_mmcfg_config == NULL) ||
diff -puN arch/i386/pci/mmconfig.c~pci-mmconfig-reject-mcfg_broken arch/i386/pci/mmconfig.c
--- linux-2.6/arch/i386/pci/mmconfig.c~pci-mmconfig-reject-mcfg_broken	2007-01-12 23:15:58.000000000 +0900
+++ linux-2.6-hirofumi/arch/i386/pci/mmconfig.c	2007-01-12 23:15:58.000000000 +0900
@@ -42,15 +42,6 @@ static u32 get_base_addr(unsigned int se
 			return cfg->base_address;
 	}
 
-	/* Handle more broken MCFG tables on Asus etc.
-	   They only contain a single entry for bus 0-0. Assume
- 	   this applies to all busses. */
-	cfg = &pci_mmcfg_config[0];
-	if (pci_mmcfg_config_num == 1 &&
-		cfg->pci_segment_group_number == 0 &&
-		(cfg->start_bus_number | cfg->end_bus_number) == 0)
-		return cfg->base_address;
-
 	/* Fall back to type 0 */
 	return 0;
 }
diff -puN arch/x86_64/pci/mmconfig.c~pci-mmconfig-reject-mcfg_broken arch/x86_64/pci/mmconfig.c
--- linux-2.6/arch/x86_64/pci/mmconfig.c~pci-mmconfig-reject-mcfg_broken	2007-01-12 23:15:58.000000000 +0900
+++ linux-2.6-hirofumi/arch/x86_64/pci/mmconfig.c	2007-01-12 23:20:25.000000000 +0900
@@ -20,39 +20,6 @@ struct mmcfg_virt {
 };
 static struct mmcfg_virt *pci_mmcfg_virt;
 
-static inline int mcfg_broken(void)
-{
-	struct acpi_table_mcfg_config *cfg = &pci_mmcfg_config[0];
-
-	/* Handle more broken MCFG tables on Asus etc.
-	   They only contain a single entry for bus 0-0. Assume
- 	   this applies to all busses. */
-	if (pci_mmcfg_config_num == 1 &&
-	    cfg->pci_segment_group_number == 0 &&
-	    (cfg->start_bus_number | cfg->end_bus_number) == 0)
-		return 1;
-	return 0;
-}
-
-static void __iomem *mcfg_ioremap(struct acpi_table_mcfg_config *cfg)
-{
-	void __iomem *addr;
-	u32 size;
-
-	if (mcfg_broken())
-		size = 256 << 20;
-	else
-		size = (cfg->end_bus_number + 1) << 20;
-
-	addr = ioremap_nocache(cfg->base_address, size);
-	if (addr) {
-		printk(KERN_INFO "PCI: Using MMCONFIG at %x - %x\n",
-		       cfg->base_address,
-		       cfg->base_address + size - 1);
-	}
-	return addr;
-}
-
 static char __iomem *get_virt(unsigned int seg, unsigned bus)
 {
 	struct acpi_table_mcfg_config *cfg;
@@ -66,9 +33,6 @@ static char __iomem *get_virt(unsigned i
 			return pci_mmcfg_virt[cfg_num].virt;
 	}
 
-	if (mcfg_broken())
-		return pci_mmcfg_virt[0].virt;
-
 	/* Fall back to type 0 */
 	return NULL;
 }
@@ -154,6 +118,20 @@ int __init pci_mmcfg_arch_reachable(unsi
 	return pci_dev_base(seg, bus, devfn) != NULL;
 }
 
+static void __iomem * __init mcfg_ioremap(struct acpi_table_mcfg_config *cfg)
+{
+	void __iomem *addr;
+	u32 size;
+
+	size = (cfg->end_bus_number + 1) << 20;
+	addr = ioremap_nocache(cfg->base_address, size);
+	if (addr) {
+		printk(KERN_INFO "PCI: Using MMCONFIG at %x - %x\n",
+		       cfg->base_address, cfg->base_address + size - 1);
+	}
+	return addr;
+}
+
 int __init pci_mmcfg_arch_init(void)
 {
 	int i;
_

-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -mm] MMCONFIG: Reject a broken MCFG tables on Asus etc
  2007-01-13 21:27 [PATCH -mm] MMCONFIG: Reject a broken MCFG tables on Asus etc OGAWA Hirofumi
@ 2007-01-16 19:19 ` Olivier Galibert
  2007-01-16 19:42   ` OGAWA Hirofumi
  0 siblings, 1 reply; 3+ messages in thread
From: Olivier Galibert @ 2007-01-16 19:19 UTC (permalink / raw)
  To: OGAWA Hirofumi; +Cc: Andrew Morton, Arjan van de Ven, Andi Kleen, linux-kernel

On Sun, Jan 14, 2007 at 06:27:18AM +0900, OGAWA Hirofumi wrote:
> This rejects a broken MCFG tables on Asus etc.
> Arjan and Andi suggest this.

And I agree completely with the principle.  If you don't know the
chipset on a first-name basis, trash the MCFG unless it's squeaky
clean (or you don't have a choice).


> +static void __init pci_mmcfg_reject_broken(void)
> +{
> +	struct acpi_table_mcfg_config *cfg = &pci_mmcfg_config[0];
> +
> +	/*
> +	 * Handle more broken MCFG tables on Asus etc.
> +	 * They only contain a single entry for bus 0-0.
> +	 */
> +	if (pci_mmcfg_config_num == 1 &&
> +	    cfg->pci_segment_group_number == 0 &&
> +	    (cfg->start_bus_number | cfg->end_bus_number) == 0) {
> +		kfree(pci_mmcfg_config);
> +		pci_mmcfg_config = NULL;
> +		pci_mmcfg_config_num = 0;
> +
> +		printk(KERN_ERR "PCI: start and end of bus number is 0. "
> +		       "Rejected as broken MCFG.");
> +	}
> +}
> +

If you're going to do a MCFG validation function, and I don't have a
problem with that, you should put the e820 test in it too.

  OG.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -mm] MMCONFIG: Reject a broken MCFG tables on Asus etc
  2007-01-16 19:19 ` Olivier Galibert
@ 2007-01-16 19:42   ` OGAWA Hirofumi
  0 siblings, 0 replies; 3+ messages in thread
From: OGAWA Hirofumi @ 2007-01-16 19:42 UTC (permalink / raw)
  To: Olivier Galibert
  Cc: Andrew Morton, Arjan van de Ven, Andi Kleen, linux-kernel

Olivier Galibert <galibert@pobox.com> writes:

> If you're going to do a MCFG validation function, and I don't have a
> problem with that, you should put the e820 test in it too.

Sounds good, thanks. I'll do later.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-16 19:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-13 21:27 [PATCH -mm] MMCONFIG: Reject a broken MCFG tables on Asus etc OGAWA Hirofumi
2007-01-16 19:19 ` Olivier Galibert
2007-01-16 19:42   ` OGAWA Hirofumi

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).