All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yinghai <yinghai.lu@oracle.com>
To: "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>,
	Andy Isaacson <adi@hexapodia.org>,
	guenter.roeck@ericsson.com,
	Linus Torvalds <torvalds@linux-foundation.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Thomas Renninger <trenn@suse.de>
Subject: [PATCH -v4 1/3] x86: Reserve [0xa0000, 0x100000] in e820 map
Date: Tue, 20 Apr 2010 22:33:50 -0700	[thread overview]
Message-ID: <4BCE8E3E.4030809@oracle.com> (raw)
In-Reply-To: <4BC4F9C2.20503@oracle.com>



Update e820 at first, and later put them resource tree.
Reserved that early, will not be allocated to unassigned PCI BAR

v3: remove probe_roms() that is not needed, because whole range is reserved
	 already

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: Andy Isaacson <adi@hexapodia.org>
Tested-by: Andy Isaacson <adi@hexapodia.org>

---
 arch/x86/include/asm/setup.h    |    3 
 arch/x86/include/asm/x86_init.h |    4 
 arch/x86/kernel/Makefile        |    1 
 arch/x86/kernel/head32.c        |    2 
 arch/x86/kernel/mrst.c          |    2 
 arch/x86/kernel/probe_roms_32.c |  166 ----------------------------------------
 arch/x86/kernel/setup.c         |   25 ------
 arch/x86/kernel/x86_init.c      |    2 
 8 files changed, 8 insertions(+), 197 deletions(-)

Index: linux-2.6/arch/x86/include/asm/setup.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/setup.h
+++ linux-2.6/arch/x86/include/asm/setup.h
@@ -43,8 +43,8 @@ static inline void visws_early_detect(vo
 
 extern unsigned long saved_video_mode;
 
+void trim_bios_range(void);
 extern void reserve_standard_io_resources(void);
-extern void i386_reserve_resources(void);
 extern void setup_default_timer_irq(void);
 
 #ifdef CONFIG_X86_MRST
@@ -96,7 +96,6 @@ void *extend_brk(size_t size, size_t ali
 #ifdef __i386__
 
 void __init i386_start_kernel(void);
-extern void probe_roms(void);
 
 #else
 void __init x86_64_start_kernel(char *real_mode);
Index: linux-2.6/arch/x86/include/asm/x86_init.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/x86_init.h
+++ linux-2.6/arch/x86/include/asm/x86_init.h
@@ -32,14 +32,14 @@ struct x86_init_mpparse {
 
 /**
  * struct x86_init_resources - platform specific resource related ops
- * @probe_roms:			probe BIOS roms
+ * @trim_bios_range:		trim BIOS related range in E820
  * @reserve_resources:		reserve the standard resources for the
  *				platform
  * @memory_setup:		platform specific memory setup
  *
  */
 struct x86_init_resources {
-	void (*probe_roms)(void);
+	void (*trim_bios_range)(void);
 	void (*reserve_resources)(void);
 	char *(*memory_setup)(void);
 };
Index: linux-2.6/arch/x86/kernel/Makefile
===================================================================
--- linux-2.6.orig/arch/x86/kernel/Makefile
+++ linux-2.6/arch/x86/kernel/Makefile
@@ -34,7 +34,6 @@ obj-y			+= traps.o irq.o irq_$(BITS).o d
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
 obj-y			+= setup.o x86_init.o i8259.o irqinit.o
 obj-$(CONFIG_X86_VISWS)	+= visws_quirks.o
-obj-$(CONFIG_X86_32)	+= probe_roms_32.o
 obj-$(CONFIG_X86_32)	+= sys_i386_32.o i386_ksyms_32.o
 obj-$(CONFIG_X86_64)	+= sys_x86_64.o x8664_ksyms_64.o
 obj-$(CONFIG_X86_64)	+= syscall_64.o vsyscall_64.o
Index: linux-2.6/arch/x86/kernel/head32.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/head32.c
+++ linux-2.6/arch/x86/kernel/head32.c
@@ -21,8 +21,6 @@
 static void __init i386_default_early_setup(void)
 {
 	/* Initilize 32bit specific setup functions */
-	x86_init.resources.probe_roms = probe_roms;
-	x86_init.resources.reserve_resources = i386_reserve_resources;
 	x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc;
 
 	reserve_ebda_region();
Index: linux-2.6/arch/x86/kernel/mrst.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/mrst.c
+++ linux-2.6/arch/x86/kernel/mrst.c
@@ -222,7 +222,7 @@ static void __init mrst_setup_boot_clock
  */
 void __init x86_mrst_early_setup(void)
 {
-	x86_init.resources.probe_roms = x86_init_noop;
+	x86_init.resources.trim_bios_range = x86_init_noop;
 	x86_init.resources.reserve_resources = x86_init_noop;
 
 	x86_init.timers.timer_init = mrst_time_init;
Index: linux-2.6/arch/x86/kernel/probe_roms_32.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/probe_roms_32.c
+++ /dev/null
@@ -1,166 +0,0 @@
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/uaccess.h>
-#include <linux/mmzone.h>
-#include <linux/ioport.h>
-#include <linux/seq_file.h>
-#include <linux/console.h>
-#include <linux/init.h>
-#include <linux/edd.h>
-#include <linux/dmi.h>
-#include <linux/pfn.h>
-#include <linux/pci.h>
-#include <asm/pci-direct.h>
-
-
-#include <asm/e820.h>
-#include <asm/mmzone.h>
-#include <asm/setup.h>
-#include <asm/sections.h>
-#include <asm/io.h>
-#include <asm/setup_arch.h>
-
-static struct resource system_rom_resource = {
-	.name	= "System ROM",
-	.start	= 0xf0000,
-	.end	= 0xfffff,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource extension_rom_resource = {
-	.name	= "Extension ROM",
-	.start	= 0xe0000,
-	.end	= 0xeffff,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-static struct resource adapter_rom_resources[] = { {
-	.name 	= "Adapter ROM",
-	.start	= 0xc8000,
-	.end	= 0,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-	.name 	= "Adapter ROM",
-	.start	= 0,
-	.end	= 0,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-	.name 	= "Adapter ROM",
-	.start	= 0,
-	.end	= 0,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-	.name 	= "Adapter ROM",
-	.start	= 0,
-	.end	= 0,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-	.name 	= "Adapter ROM",
-	.start	= 0,
-	.end	= 0,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-}, {
-	.name 	= "Adapter ROM",
-	.start	= 0,
-	.end	= 0,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-} };
-
-static struct resource video_rom_resource = {
-	.name 	= "Video ROM",
-	.start	= 0xc0000,
-	.end	= 0xc7fff,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
-};
-
-#define ROMSIGNATURE 0xaa55
-
-static int __init romsignature(const unsigned char *rom)
-{
-	const unsigned short * const ptr = (const unsigned short *)rom;
-	unsigned short sig;
-
-	return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE;
-}
-
-static int __init romchecksum(const unsigned char *rom, unsigned long length)
-{
-	unsigned char sum, c;
-
-	for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--)
-		sum += c;
-	return !length && !sum;
-}
-
-void __init probe_roms(void)
-{
-	const unsigned char *rom;
-	unsigned long start, length, upper;
-	unsigned char c;
-	int i;
-
-	/* video rom */
-	upper = adapter_rom_resources[0].start;
-	for (start = video_rom_resource.start; start < upper; start += 2048) {
-		rom = isa_bus_to_virt(start);
-		if (!romsignature(rom))
-			continue;
-
-		video_rom_resource.start = start;
-
-		if (probe_kernel_address(rom + 2, c) != 0)
-			continue;
-
-		/* 0 < length <= 0x7f * 512, historically */
-		length = c * 512;
-
-		/* if checksum okay, trust length byte */
-		if (length && romchecksum(rom, length))
-			video_rom_resource.end = start + length - 1;
-
-		request_resource(&iomem_resource, &video_rom_resource);
-		break;
-	}
-
-	start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
-	if (start < upper)
-		start = upper;
-
-	/* system rom */
-	request_resource(&iomem_resource, &system_rom_resource);
-	upper = system_rom_resource.start;
-
-	/* check for extension rom (ignore length byte!) */
-	rom = isa_bus_to_virt(extension_rom_resource.start);
-	if (romsignature(rom)) {
-		length = extension_rom_resource.end - extension_rom_resource.start + 1;
-		if (romchecksum(rom, length)) {
-			request_resource(&iomem_resource, &extension_rom_resource);
-			upper = extension_rom_resource.start;
-		}
-	}
-
-	/* check for adapter roms on 2k boundaries */
-	for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
-		rom = isa_bus_to_virt(start);
-		if (!romsignature(rom))
-			continue;
-
-		if (probe_kernel_address(rom + 2, c) != 0)
-			continue;
-
-		/* 0 < length <= 0x7f * 512, historically */
-		length = c * 512;
-
-		/* but accept any length that fits if checksum okay */
-		if (!length || start + length > upper || !romchecksum(rom, length))
-			continue;
-
-		adapter_rom_resources[i].start = start;
-		adapter_rom_resources[i].end = start + length - 1;
-		request_resource(&iomem_resource, &adapter_rom_resources[i]);
-
-		start = adapter_rom_resources[i++].end & ~2047UL;
-	}
-}
-
Index: linux-2.6/arch/x86/kernel/setup.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup.c
+++ linux-2.6/arch/x86/kernel/setup.c
@@ -680,7 +680,7 @@ static struct dmi_system_id __initdata b
 	{}
 };
 
-static void __init trim_bios_range(void)
+void __init trim_bios_range(void)
 {
 	/*
 	 * A special case is the first 4Kb of memory;
@@ -693,7 +693,7 @@ static void __init trim_bios_range(void)
 	 * area (640->1Mb) as ram even though it is not.
 	 * take them out.
 	 */
-	e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
+	e820_add_region(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RESERVED);
 	sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 }
 
@@ -853,14 +853,12 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	init_hypervisor_platform();
 
-	x86_init.resources.probe_roms();
-
 	/* after parse_early_param, so could debug it */
 	insert_resource(&iomem_resource, &code_resource);
 	insert_resource(&iomem_resource, &data_resource);
 	insert_resource(&iomem_resource, &bss_resource);
 
-	trim_bios_range();
+	x86_init.resources.trim_bios_range();
 #ifdef CONFIG_X86_32
 	if (ppro_with_ram_bug()) {
 		e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
@@ -1052,20 +1050,3 @@ void __init setup_arch(char **cmdline_p)
 
 	mcheck_init();
 }
-
-#ifdef CONFIG_X86_32
-
-static struct resource video_ram_resource = {
-	.name	= "Video RAM area",
-	.start	= 0xa0000,
-	.end	= 0xbffff,
-	.flags	= IORESOURCE_BUSY | IORESOURCE_MEM
-};
-
-void __init i386_reserve_resources(void)
-{
-	request_resource(&iomem_resource, &video_ram_resource);
-	reserve_standard_io_resources();
-}
-
-#endif /* CONFIG_X86_32 */
Index: linux-2.6/arch/x86/kernel/x86_init.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/x86_init.c
+++ linux-2.6/arch/x86/kernel/x86_init.c
@@ -32,7 +32,7 @@ void iommu_shutdown_noop(void) { }
 struct x86_init_ops x86_init __initdata = {
 
 	.resources = {
-		.probe_roms		= x86_init_noop,
+		.trim_bios_range	= trim_bios_range,
 		.reserve_resources	= reserve_standard_io_resources,
 		.memory_setup		= default_machine_specific_memory_setup,
 	},

  reply	other threads:[~2010-04-21  5:37 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 21:06 [PATCH] x86: Reserve legacy VGA MMIO area for x86_64 as well as x86_32 Bjorn Helgaas
2010-04-07 22:45 ` Yinghai
2010-04-07 23:05   ` Bjorn Helgaas
2010-04-07 23:22     ` Yinghai
2010-04-08  3:24       ` Bjorn Helgaas
2010-04-08  4:42         ` H. Peter Anvin
2010-04-08 13:04           ` Bjorn Helgaas
2010-04-09 16:04       ` Bjorn Helgaas
2010-04-09 16:44         ` H. Peter Anvin
2010-04-09 17:22           ` Yinghai
2010-04-09 18:23             ` H. Peter Anvin
2010-04-09 18:55               ` Guenter Roeck
2010-04-09 19:55                 ` Yinghai
2010-04-09 22:21                   ` Andy Isaacson
2010-04-09 22:27                     ` Yinghai Lu
2010-04-09 22:35                       ` Andy Isaacson
2010-04-09 22:44                         ` H. Peter Anvin
2010-04-09 22:54                           ` Yinghai
2010-04-09 23:01                         ` Yinghai
2010-04-10  0:00                           ` Andy Isaacson
2010-04-10  1:10                             ` Yinghai
2010-04-10  1:43                               ` Andy Isaacson
2010-04-10  1:48                                 ` Yinghai
2010-04-10  1:57                                   ` Andy Isaacson
2010-04-10  2:46                                     ` Yinghai
2010-04-12 18:54                                       ` Andy Isaacson
2010-04-12 19:34                                         ` Yinghai
2010-04-12 19:48                                           ` Andy Isaacson
2010-04-12 19:55                                             ` yinghai.lu
2010-04-12 20:02                                           ` Andy Isaacson
2010-04-12 22:32                                             ` [PATCH -v2 1/2] x86: Reserve [0xa0000, 0x100000] in e820 map Yinghai
2010-04-13 21:02                                               ` Bjorn Helgaas
2010-04-13 21:08                                                 ` Yinghai
2010-04-13 21:09                                                 ` H. Peter Anvin
2010-04-13 21:11                                                   ` Yinghai
2010-04-13 21:18                                                     ` H. Peter Anvin
2010-04-13 21:22                                                       ` [PATCH -v3 1/3] " Yinghai
2010-04-23 23:30                                                         ` H. Peter Anvin
2010-04-26 15:35                                                           ` Jesse Barnes
2010-04-13 21:23                                                       ` [PATCH -v3 2/3] x86,pci, acpi: host bridge windows inherit BUSY flag from parent Yinghai
2010-04-13 21:24                                                       ` [PATCH -v3 3/3] pci: don't allocate from a BUSY bus resource Yinghai
2010-04-13 21:42                                                       ` [PATCH -v2 1/2] x86: Reserve [0xa0000, 0x100000] in e820 map Yinghai
2010-04-13 21:58                                                         ` H. Peter Anvin
2010-04-13 22:29                                                           ` Yinghai
2010-04-13 22:39                                                             ` Yinghai
2010-04-13 22:41                                                             ` H. Peter Anvin
2010-04-13 22:58                                                               ` Yinghai
2010-04-13 23:02                                                                 ` H. Peter Anvin
2010-04-13 23:03                                                                   ` Yinghai
2010-04-13 23:07                                                                     ` H. Peter Anvin
2010-04-13 23:09                                                                       ` Yinghai
2010-04-21  5:33                                                                         ` Yinghai [this message]
2010-04-21  5:34                                                                           ` [PATCH 2/3] x86, resource: Add reserve_region_with_split_check_child() Yinghai
2010-04-21  5:35                                                                           ` [PATCH 3/3] x86,pci,acpi: Handle invalid _CRS Yinghai
2010-04-21 15:21                                                                             ` Bjorn Helgaas
2010-04-21 16:45                                                                               ` Yinghai Lu
2010-04-21 16:59                                                                                 ` Bjorn Helgaas
2010-04-21 22:33                                                                                   ` H. Peter Anvin
2010-04-21 23:04                                                                                     ` Bjorn Helgaas
2010-04-21 23:10                                                                                       ` H. Peter Anvin
2010-04-21 23:43                                                                                         ` Yinghai
2010-04-22  0:02                                                                                           ` H. Peter Anvin
2010-04-22  0:06                                                                                             ` Yinghai
2010-04-21 19:31                                                                           ` [PATCH -v4 1/3] x86: Reserve [0xa0000, 0x100000] in e820 map Andy Isaacson
2010-04-23 23:05                                                                             ` [PATCH] x86/PCI: never allocate PCI MMIO resources below BIOS_END Bjorn Helgaas
2010-04-23 23:44                                                                               ` H. Peter Anvin
2010-04-24  0:36                                                                                 ` Yinghai Lu
2010-04-26 12:50                                                                               ` R. Andrew Bailey
2010-04-26 15:40                                                                                 ` Bjorn Helgaas
2010-04-26 18:34                                                                               ` Andy Isaacson
2010-04-26 19:31                                                                                 ` Jesse Barnes
2010-04-26 20:27                                                                                   ` Bjorn Helgaas
2010-04-26 20:37                                                                                     ` Jesse Barnes
2010-04-26 21:07                                                                                       ` Yinghai
2010-04-26 21:19                                                                                         ` H. Peter Anvin
2010-04-26 21:12                                                                                       ` H. Peter Anvin
2010-04-26 21:25                                                                                         ` Jesse Barnes
2010-04-26 21:44                                                                                           ` H. Peter Anvin
2010-04-26 21:53                                                                                             ` Jesse Barnes
2010-04-26 21:59                                                                                           ` Yinghai Lu
2010-04-26 22:04                                                                                             ` [PATCH -v5] reserve a0000 - 0x10000 Yinghai
     [not found]                                                                                             ` <4BD60CD4.9020708@oracle.com>
2010-04-26 22:04                                                                                               ` [PATCH -v5 1/3] x86: Reserve [0xa0000, 0x100000] in e820 map Yinghai
2010-04-26 22:04                                                                                               ` [PATCH -v5 2/3] x86: Remove probe_roms for 32bit Yinghai
2010-04-26 22:04                                                                                               ` [PATCH -v5 3/3] x86, resource: Add reserve_region_with_split_check_child() Yinghai
2010-04-26 21:44                                                                                         ` [PATCH] x86/PCI: never allocate PCI MMIO resources below BIOS_END jacob pan
2010-04-13 23:03                                                                 ` [PATCH -v2 1/2] x86: Reserve [0xa0000, 0x100000] in e820 map H. Peter Anvin
2010-04-14  0:57                                                           ` Yinghai
2010-04-14 16:55                                                             ` Bjorn Helgaas
2010-04-14 17:21                                                               ` Yinghai Lu
2010-04-14 19:25                                                             ` Andy Isaacson
2010-04-14 19:27                                                               ` Yinghai
2010-04-14 19:43                                                                 ` Andy Isaacson
2010-04-14 19:49                                                                   ` Yinghai
2010-04-12 22:33                                             ` [PATCH -v2 2/2] x86,pci, acpi: Inherent BUSY flag when setup_resource for root bus Yinghai
2010-04-12 22:44                                               ` Jesse Barnes
2010-04-13 21:02                                               ` Bjorn Helgaas
2010-04-09 20:11                 ` [PATCH] x86: Reserve legacy VGA MMIO area for x86_64 as well as x86_32 H. Peter Anvin
2010-04-09 20:31                   ` Guenter Roeck
2010-04-09 20:44                     ` H. Peter Anvin
2010-04-09 21:01                       ` Guenter Roeck
2010-04-09 22:42                       ` Alan Cox
2010-04-09 22:42                         ` H. Peter Anvin
2010-04-09 22:54                           ` Alan Cox
2010-04-09 22:55                             ` H. Peter Anvin
2010-04-09 22:51         ` Alan Cox
2010-04-09 22:55           ` H. Peter Anvin
2010-04-07 23:43   ` H. Peter Anvin
2010-04-08  0:19     ` Andy Isaacson
2010-04-08  5:00       ` H. Peter Anvin
2010-04-08 21:40 ` Andy Isaacson

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=4BCE8E3E.4030809@oracle.com \
    --to=yinghai.lu@oracle.com \
    --cc=adi@hexapodia.org \
    --cc=bjorn.helgaas@hp.com \
    --cc=guenter.roeck@ericsson.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=trenn@suse.de \
    --cc=x86@kernel.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 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.