linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ibft, x86: Change reserve_ibft_region() to find_ibft_region()
@ 2010-04-01  2:07 Yinghai Lu
  2010-04-01 20:12 ` Konrad Rzeszutek Wilk
  2010-04-01 21:32 ` [PATCH -v2] " Yinghai Lu
  0 siblings, 2 replies; 8+ messages in thread
From: Yinghai Lu @ 2010-04-01  2:07 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich



So arch code could decide the way to reserve the ibft.

And We should reserve ibft as early as possible, instead of BOOTMEM stage,
in case the table is in RAM range and is not reserved by BIOS.

move that just sfter find_smp_config()

Also when CONFIG_NO_BOOTMEM=y, We will not have reserve_bootmem() anymore

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Peter Jones <pjones@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
CC: Jan Beulich <jbeulich@novell.com>

---
 arch/x86/kernel/setup.c            |   14 ++++++++++++--
 drivers/firmware/iscsi_ibft_find.c |   11 ++++++++---
 include/linux/iscsi_ibft.h         |    8 ++++++--
 3 files changed, 26 insertions(+), 7 deletions(-)

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
@@ -608,6 +608,16 @@ static int __init setup_elfcorehdr(char
 early_param("elfcorehdr", setup_elfcorehdr);
 #endif
 
+static __init void reserve_ibft_region(void)
+{
+	unsigned long addr, size = 0;
+
+	addr = find_ibft_region(&size);
+
+	if (size)
+		reserve_early_overlap_ok(addr, addr + size, "ifbt");
+}
+
 #ifdef CONFIG_X86_RESERVE_LOW_64K
 static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
 {
@@ -910,6 +920,8 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	find_smp_config();
 
+	reserve_ibft_region();
+
 	reserve_trampoline_memory();
 
 #ifdef CONFIG_ACPI_SLEEP
@@ -977,8 +989,6 @@ void __init setup_arch(char **cmdline_p)
 
 	dma32_reserve_bootmem();
 
-	reserve_ibft_region();
-
 #ifdef CONFIG_KVM_CLOCK
 	kvmclock_init();
 #endif
Index: linux-2.6/drivers/firmware/iscsi_ibft_find.c
===================================================================
--- linux-2.6.orig/drivers/firmware/iscsi_ibft_find.c
+++ linux-2.6/drivers/firmware/iscsi_ibft_find.c
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(ibft_addr);
  * Routine used to find the iSCSI Boot Format Table. The logical
  * kernel address is set in the ibft_addr global variable.
  */
-void __init reserve_ibft_region(void)
+unsigned long __init find_ibft_region(unsigned long *sizep)
 {
 	unsigned long pos;
 	unsigned int len = 0;
@@ -78,6 +78,11 @@ void __init reserve_ibft_region(void)
 			}
 		}
 	}
-	if (ibft_addr)
-		reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT);
+	if (ibft_addr) {
+		*sizep = PAGE_ALIGN(len);
+		return pos;
+	}
+
+	*sizep = 0;
+	return 0;
 }
Index: linux-2.6/include/linux/iscsi_ibft.h
===================================================================
--- linux-2.6.orig/include/linux/iscsi_ibft.h
+++ linux-2.6/include/linux/iscsi_ibft.h
@@ -42,9 +42,13 @@ extern struct ibft_table_header *ibft_ad
  * mapped address is set in the ibft_addr variable.
  */
 #ifdef CONFIG_ISCSI_IBFT_FIND
-extern void __init reserve_ibft_region(void);
+unsigned long find_ibft_region(unsigned long *sizep);
 #else
-static inline void reserve_ibft_region(void) { }
+static inline unsigned long find_ibft_region(unsigned long *sizep)
+{
+	*sizep = 0;
+	return 0;
+}
 #endif
 
 #endif /* ISCSI_IBFT_H */

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

* Re: [PATCH] ibft, x86: Change reserve_ibft_region() to find_ibft_region()
  2010-04-01  2:07 [PATCH] ibft, x86: Change reserve_ibft_region() to find_ibft_region() Yinghai Lu
@ 2010-04-01 20:12 ` Konrad Rzeszutek Wilk
  2010-04-01 20:59   ` Yinghai Lu
  2010-04-01 21:32 ` [PATCH -v2] " Yinghai Lu
  1 sibling, 1 reply; 8+ messages in thread
From: Konrad Rzeszutek Wilk @ 2010-04-01 20:12 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich

On Wed, Mar 31, 2010 at 07:07:32PM -0700, Yinghai Lu wrote:
> 
> 
> So arch code could decide the way to reserve the ibft.
> 
> And We should reserve ibft as early as possible, instead of BOOTMEM stage,
> in case the table is in RAM range and is not reserved by BIOS.

What test vehicle did you use to find this bug?


.. snip..
> +	if (size)
> +		reserve_early_overlap_ok(addr, addr + size, "ifbt");
							     ^^^^ - ibft


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

* Re: [PATCH] ibft, x86: Change reserve_ibft_region() to find_ibft_region()
  2010-04-01 20:12 ` Konrad Rzeszutek Wilk
@ 2010-04-01 20:59   ` Yinghai Lu
  0 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2010-04-01 20:59 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk
  Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich

On 04/01/2010 01:12 PM, Konrad Rzeszutek Wilk wrote:
> On Wed, Mar 31, 2010 at 07:07:32PM -0700, Yinghai Lu wrote:
>>
>>
>> So arch code could decide the way to reserve the ibft.
>>
>> And We should reserve ibft as early as possible, instead of BOOTMEM stage,
>> in case the table is in RAM range and is not reserved by BIOS.
> 
> What test vehicle did you use to find this bug?

code review for CONFIG_NO_BOOTMEM

reserve_bootmem() should only be used for converting entries reserved by reserved_early()

so When we are using CONFIG_NO_BOOTMEM, reserve_bootmem() is killed.

> 
> 
> .. snip..
>> +	if (size)
>> +		reserve_early_overlap_ok(addr, addr + size, "ifbt");
> 							     ^^^^ - ibft
thanks, will change it.

Yinghai

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

* [PATCH -v2] ibft, x86: Change reserve_ibft_region() to find_ibft_region()
  2010-04-01  2:07 [PATCH] ibft, x86: Change reserve_ibft_region() to find_ibft_region() Yinghai Lu
  2010-04-01 20:12 ` Konrad Rzeszutek Wilk
@ 2010-04-01 21:32 ` Yinghai Lu
  2010-04-01 21:54   ` Randy Dunlap
  2010-04-01 23:51   ` [tip:x86/urgent] " tip-bot for Yinghai Lu
  1 sibling, 2 replies; 8+ messages in thread
From: Yinghai Lu @ 2010-04-01 21:32 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar, Thomas Gleixner
  Cc: linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich



So arch code could decide the way to reserve the ibft.

And We should reserve ibft as early as possible, instead of BOOTMEM stage,
in case the table is in RAM range and is not reserved by BIOS.

move that just sfter find_smp_config()

Also when CONFIG_NO_BOOTMEM=y, We will not have reserve_bootmem() anymorea

-v2: fix typo about ibft pointed by Konrad Rzeszutek Wilk <konrad@darnok.org>

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Peter Jones <pjones@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
CC: Jan Beulich <jbeulich@novell.com>

---
 arch/x86/kernel/setup.c            |   14 ++++++++++++--
 drivers/firmware/iscsi_ibft_find.c |   11 ++++++++---
 include/linux/iscsi_ibft.h         |    8 ++++++--
 3 files changed, 26 insertions(+), 7 deletions(-)

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
@@ -608,6 +608,16 @@ static int __init setup_elfcorehdr(char
 early_param("elfcorehdr", setup_elfcorehdr);
 #endif
 
+static __init void reserve_ibft_region(void)
+{
+	unsigned long addr, size = 0;
+
+	addr = find_ibft_region(&size);
+
+	if (size)
+		reserve_early_overlap_ok(addr, addr + size, "ibft");
+}
+
 #ifdef CONFIG_X86_RESERVE_LOW_64K
 static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
 {
@@ -910,6 +920,8 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	find_smp_config();
 
+	reserve_ibft_region();
+
 	reserve_trampoline_memory();
 
 #ifdef CONFIG_ACPI_SLEEP
@@ -977,8 +989,6 @@ void __init setup_arch(char **cmdline_p)
 
 	dma32_reserve_bootmem();
 
-	reserve_ibft_region();
-
 #ifdef CONFIG_KVM_CLOCK
 	kvmclock_init();
 #endif
Index: linux-2.6/drivers/firmware/iscsi_ibft_find.c
===================================================================
--- linux-2.6.orig/drivers/firmware/iscsi_ibft_find.c
+++ linux-2.6/drivers/firmware/iscsi_ibft_find.c
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(ibft_addr);
  * Routine used to find the iSCSI Boot Format Table. The logical
  * kernel address is set in the ibft_addr global variable.
  */
-void __init reserve_ibft_region(void)
+unsigned long __init find_ibft_region(unsigned long *sizep)
 {
 	unsigned long pos;
 	unsigned int len = 0;
@@ -78,6 +78,11 @@ void __init reserve_ibft_region(void)
 			}
 		}
 	}
-	if (ibft_addr)
-		reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT);
+	if (ibft_addr) {
+		*sizep = PAGE_ALIGN(len);
+		return pos;
+	}
+
+	*sizep = 0;
+	return 0;
 }
Index: linux-2.6/include/linux/iscsi_ibft.h
===================================================================
--- linux-2.6.orig/include/linux/iscsi_ibft.h
+++ linux-2.6/include/linux/iscsi_ibft.h
@@ -42,9 +42,13 @@ extern struct ibft_table_header *ibft_ad
  * mapped address is set in the ibft_addr variable.
  */
 #ifdef CONFIG_ISCSI_IBFT_FIND
-extern void __init reserve_ibft_region(void);
+unsigned long find_ibft_region(unsigned long *sizep);
 #else
-static inline void reserve_ibft_region(void) { }
+static inline unsigned long find_ibft_region(unsigned long *sizep)
+{
+	*sizep = 0;
+	return 0;
+}
 #endif
 
 #endif /* ISCSI_IBFT_H */

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

* Re: [PATCH -v2] ibft, x86: Change reserve_ibft_region() to find_ibft_region()
  2010-04-01 21:32 ` [PATCH -v2] " Yinghai Lu
@ 2010-04-01 21:54   ` Randy Dunlap
  2010-04-01 22:00     ` Yinghai Lu
  2010-04-01 23:51   ` [tip:x86/urgent] " tip-bot for Yinghai Lu
  1 sibling, 1 reply; 8+ messages in thread
From: Randy Dunlap @ 2010-04-01 21:54 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich

On Thu, 01 Apr 2010 14:32:43 -0700 Yinghai Lu wrote:

> 
> 
> So arch code could decide the way to reserve the ibft.
> 
> And We should reserve ibft as early as possible, instead of BOOTMEM stage,
> in case the table is in RAM range and is not reserved by BIOS.
> 
> move that just sfter find_smp_config()
> 
> Also when CONFIG_NO_BOOTMEM=y, We will not have reserve_bootmem() anymorea
> 
> -v2: fix typo about ibft pointed by Konrad Rzeszutek Wilk <konrad@darnok.org>


> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Pekka Enberg <penberg@cs.helsinki.fi>
> Cc: Peter Jones <pjones@redhat.com>
> Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
> CC: Jan Beulich <jbeulich@novell.com>
> 
> ---
>  arch/x86/kernel/setup.c            |   14 ++++++++++++--
>  drivers/firmware/iscsi_ibft_find.c |   11 ++++++++---
>  include/linux/iscsi_ibft.h         |    8 ++++++--
>  3 files changed, 26 insertions(+), 7 deletions(-)
> 
> 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
> @@ -608,6 +608,16 @@ static int __init setup_elfcorehdr(char
>  early_param("elfcorehdr", setup_elfcorehdr);
>  #endif
>  
> +static __init void reserve_ibft_region(void)
> +{
> +	unsigned long addr, size = 0;
> +
> +	addr = find_ibft_region(&size);
> +
> +	if (size)
> +		reserve_early_overlap_ok(addr, addr + size, "ibft");

	where is the correction?


> +}
> +
>  #ifdef CONFIG_X86_RESERVE_LOW_64K
>  static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
>  {
> @@ -910,6 +920,8 @@ void __init setup_arch(char **cmdline_p)
>  	 */
>  	find_smp_config();
>  
> +	reserve_ibft_region();
> +
>  	reserve_trampoline_memory();
>  
>  #ifdef CONFIG_ACPI_SLEEP
> @@ -977,8 +989,6 @@ void __init setup_arch(char **cmdline_p)
>  
>  	dma32_reserve_bootmem();
>  
> -	reserve_ibft_region();
> -
>  #ifdef CONFIG_KVM_CLOCK
>  	kvmclock_init();
>  #endif
> Index: linux-2.6/drivers/firmware/iscsi_ibft_find.c
> ===================================================================
> --- linux-2.6.orig/drivers/firmware/iscsi_ibft_find.c
> +++ linux-2.6/drivers/firmware/iscsi_ibft_find.c
> @@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(ibft_addr);
>   * Routine used to find the iSCSI Boot Format Table. The logical
>   * kernel address is set in the ibft_addr global variable.
>   */
> -void __init reserve_ibft_region(void)
> +unsigned long __init find_ibft_region(unsigned long *sizep)
>  {
>  	unsigned long pos;
>  	unsigned int len = 0;
> @@ -78,6 +78,11 @@ void __init reserve_ibft_region(void)
>  			}
>  		}
>  	}
> -	if (ibft_addr)
> -		reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT);
> +	if (ibft_addr) {
> +		*sizep = PAGE_ALIGN(len);
> +		return pos;
> +	}
> +
> +	*sizep = 0;
> +	return 0;
>  }
> Index: linux-2.6/include/linux/iscsi_ibft.h
> ===================================================================
> --- linux-2.6.orig/include/linux/iscsi_ibft.h
> +++ linux-2.6/include/linux/iscsi_ibft.h
> @@ -42,9 +42,13 @@ extern struct ibft_table_header *ibft_ad
>   * mapped address is set in the ibft_addr variable.
>   */
>  #ifdef CONFIG_ISCSI_IBFT_FIND
> -extern void __init reserve_ibft_region(void);
> +unsigned long find_ibft_region(unsigned long *sizep);
>  #else
> -static inline void reserve_ibft_region(void) { }
> +static inline unsigned long find_ibft_region(unsigned long *sizep)
> +{
> +	*sizep = 0;
> +	return 0;
> +}
>  #endif
>  
>  #endif /* ISCSI_IBFT_H */
> --


---
~Randy

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

* Re: [PATCH -v2] ibft, x86: Change reserve_ibft_region() to  find_ibft_region()
  2010-04-01 21:54   ` Randy Dunlap
@ 2010-04-01 22:00     ` Yinghai Lu
  2010-04-01 22:03       ` Randy Dunlap
  0 siblings, 1 reply; 8+ messages in thread
From: Yinghai Lu @ 2010-04-01 22:00 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich

On Thu, Apr 1, 2010 at 2:54 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
> On Thu, 01 Apr 2010 14:32:43 -0700 Yinghai Lu wrote:
>
>>
>>
>> So arch code could decide the way to reserve the ibft.
>>
>> And We should reserve ibft as early as possible, instead of BOOTMEM stage,
>> in case the table is in RAM range and is not reserved by BIOS.
>>
>> move that just sfter find_smp_config()
>>
>> Also when CONFIG_NO_BOOTMEM=y, We will not have reserve_bootmem() anymorea
>>
>> -v2: fix typo about ibft pointed by Konrad Rzeszutek Wilk <konrad@darnok.org>
>
>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Pekka Enberg <penberg@cs.helsinki.fi>
>> Cc: Peter Jones <pjones@redhat.com>
>> Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
>> CC: Jan Beulich <jbeulich@novell.com>
>>
>> ---
>>  arch/x86/kernel/setup.c            |   14 ++++++++++++--
>>  drivers/firmware/iscsi_ibft_find.c |   11 ++++++++---
>>  include/linux/iscsi_ibft.h         |    8 ++++++--
>>  3 files changed, 26 insertions(+), 7 deletions(-)
>>
>> 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
>> @@ -608,6 +608,16 @@ static int __init setup_elfcorehdr(char
>>  early_param("elfcorehdr", setup_elfcorehdr);
>>  #endif
>>
>> +static __init void reserve_ibft_region(void)
>> +{
>> +     unsigned long addr, size = 0;
>> +
>> +     addr = find_ibft_region(&size);
>> +
>> +     if (size)
>> +             reserve_early_overlap_ok(addr, addr + size, "ibft");
>
>        where is the correction?

-v1 has

 +     if (size)
 +             reserve_early_overlap_ok(addr, addr + size, "ifbt");

Yinghai

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

* Re: [PATCH -v2] ibft, x86: Change reserve_ibft_region() to  find_ibft_region()
  2010-04-01 22:00     ` Yinghai Lu
@ 2010-04-01 22:03       ` Randy Dunlap
  0 siblings, 0 replies; 8+ messages in thread
From: Randy Dunlap @ 2010-04-01 22:03 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: H. Peter Anvin, Ingo Molnar, Thomas Gleixner,
	linux-kernel@vger.kernel.org, Pekka Enberg, Peter Jones,
	Konrad Rzeszutek Wilk, Jan Beulich

On Thu, 1 Apr 2010 15:00:05 -0700 Yinghai Lu wrote:

> On Thu, Apr 1, 2010 at 2:54 PM, Randy Dunlap <randy.dunlap@oracle.com> wrote:
> > On Thu, 01 Apr 2010 14:32:43 -0700 Yinghai Lu wrote:
> >
> >>
> >>
> >> So arch code could decide the way to reserve the ibft.
> >>
> >> And We should reserve ibft as early as possible, instead of BOOTMEM stage,
> >> in case the table is in RAM range and is not reserved by BIOS.
> >>
> >> move that just sfter find_smp_config()
> >>
> >> Also when CONFIG_NO_BOOTMEM=y, We will not have reserve_bootmem() anymorea
> >>
> >> -v2: fix typo about ibft pointed by Konrad Rzeszutek Wilk <konrad@darnok.org>
> >
> >
> >> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> >> Cc: Pekka Enberg <penberg@cs.helsinki.fi>
> >> Cc: Peter Jones <pjones@redhat.com>
> >> Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
> >> CC: Jan Beulich <jbeulich@novell.com>
> >>
> >> ---
> >>  arch/x86/kernel/setup.c            |   14 ++++++++++++--
> >>  drivers/firmware/iscsi_ibft_find.c |   11 ++++++++---
> >>  include/linux/iscsi_ibft.h         |    8 ++++++--
> >>  3 files changed, 26 insertions(+), 7 deletions(-)
> >>
> >> 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
> >> @@ -608,6 +608,16 @@ static int __init setup_elfcorehdr(char
> >>  early_param("elfcorehdr", setup_elfcorehdr);
> >>  #endif
> >>
> >> +static __init void reserve_ibft_region(void)
> >> +{
> >> +     unsigned long addr, size = 0;
> >> +
> >> +     addr = find_ibft_region(&size);
> >> +
> >> +     if (size)
> >> +             reserve_early_overlap_ok(addr, addr + size, "ibft");
> >
> >        where is the correction?
> 
> -v1 has
> 
>  +     if (size)
>  +             reserve_early_overlap_ok(addr, addr + size, "ifbt");

Thanks.  My eyes are blurry.  ;)

---
~Randy

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

* [tip:x86/urgent] ibft, x86: Change reserve_ibft_region() to find_ibft_region()
  2010-04-01 21:32 ` [PATCH -v2] " Yinghai Lu
  2010-04-01 21:54   ` Randy Dunlap
@ 2010-04-01 23:51   ` tip-bot for Yinghai Lu
  1 sibling, 0 replies; 8+ messages in thread
From: tip-bot for Yinghai Lu @ 2010-04-01 23:51 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: konrad, pjones, linux-kernel, hpa, mingo, yinghai, penberg,
	jbeulich, tglx

Commit-ID:  042be38e6106ed70b42d096ab4a1ed4187e510e6
Gitweb:     http://git.kernel.org/tip/042be38e6106ed70b42d096ab4a1ed4187e510e6
Author:     Yinghai Lu <yinghai@kernel.org>
AuthorDate: Thu, 1 Apr 2010 14:32:43 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Thu, 1 Apr 2010 16:12:48 -0700

ibft, x86: Change reserve_ibft_region() to find_ibft_region()

This allows arch code could decide the way to reserve the ibft.

And we should reserve ibft as early as possible, instead of BOOTMEM
stage, in case the table is in RAM range and is not reserved by BIOS
(this will often be the case.)

Move to just after find_smp_config().

Also when CONFIG_NO_BOOTMEM=y, We will not have reserve_bootmem() anymore.

-v2: fix typo about ibft pointed by Konrad Rzeszutek Wilk <konrad@darnok.org>

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <4BB510FB.80601@kernel.org>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: Peter Jones <pjones@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad@kernel.org>
CC: Jan Beulich <jbeulich@novell.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/kernel/setup.c            |   14 ++++++++++++--
 drivers/firmware/iscsi_ibft_find.c |   11 ++++++++---
 include/linux/iscsi_ibft.h         |    8 ++++++--
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d76e185..580e6b3 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -608,6 +608,16 @@ static int __init setup_elfcorehdr(char *arg)
 early_param("elfcorehdr", setup_elfcorehdr);
 #endif
 
+static __init void reserve_ibft_region(void)
+{
+	unsigned long addr, size = 0;
+
+	addr = find_ibft_region(&size);
+
+	if (size)
+		reserve_early_overlap_ok(addr, addr + size, "ibft");
+}
+
 #ifdef CONFIG_X86_RESERVE_LOW_64K
 static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
 {
@@ -910,6 +920,8 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	find_smp_config();
 
+	reserve_ibft_region();
+
 	reserve_trampoline_memory();
 
 #ifdef CONFIG_ACPI_SLEEP
@@ -977,8 +989,6 @@ void __init setup_arch(char **cmdline_p)
 
 	dma32_reserve_bootmem();
 
-	reserve_ibft_region();
-
 #ifdef CONFIG_KVM_CLOCK
 	kvmclock_init();
 #endif
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c
index dfb15c0..8f5d9e2 100644
--- a/drivers/firmware/iscsi_ibft_find.c
+++ b/drivers/firmware/iscsi_ibft_find.c
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(ibft_addr);
  * Routine used to find the iSCSI Boot Format Table. The logical
  * kernel address is set in the ibft_addr global variable.
  */
-void __init reserve_ibft_region(void)
+unsigned long __init find_ibft_region(unsigned long *sizep)
 {
 	unsigned long pos;
 	unsigned int len = 0;
@@ -78,6 +78,11 @@ void __init reserve_ibft_region(void)
 			}
 		}
 	}
-	if (ibft_addr)
-		reserve_bootmem(pos, PAGE_ALIGN(len), BOOTMEM_DEFAULT);
+	if (ibft_addr) {
+		*sizep = PAGE_ALIGN(len);
+		return pos;
+	}
+
+	*sizep = 0;
+	return 0;
 }
diff --git a/include/linux/iscsi_ibft.h b/include/linux/iscsi_ibft.h
index 6092487..d2e4042 100644
--- a/include/linux/iscsi_ibft.h
+++ b/include/linux/iscsi_ibft.h
@@ -42,9 +42,13 @@ extern struct ibft_table_header *ibft_addr;
  * mapped address is set in the ibft_addr variable.
  */
 #ifdef CONFIG_ISCSI_IBFT_FIND
-extern void __init reserve_ibft_region(void);
+unsigned long find_ibft_region(unsigned long *sizep);
 #else
-static inline void reserve_ibft_region(void) { }
+static inline unsigned long find_ibft_region(unsigned long *sizep)
+{
+	*sizep = 0;
+	return 0;
+}
 #endif
 
 #endif /* ISCSI_IBFT_H */

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

end of thread, other threads:[~2010-04-01 23:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-01  2:07 [PATCH] ibft, x86: Change reserve_ibft_region() to find_ibft_region() Yinghai Lu
2010-04-01 20:12 ` Konrad Rzeszutek Wilk
2010-04-01 20:59   ` Yinghai Lu
2010-04-01 21:32 ` [PATCH -v2] " Yinghai Lu
2010-04-01 21:54   ` Randy Dunlap
2010-04-01 22:00     ` Yinghai Lu
2010-04-01 22:03       ` Randy Dunlap
2010-04-01 23:51   ` [tip:x86/urgent] " tip-bot for Yinghai Lu

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