All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
@ 2011-01-12 22:35 Dima Zavin
  2011-01-12 23:11 ` Russell King - ARM Linux
  0 siblings, 1 reply; 8+ messages in thread
From: Dima Zavin @ 2011-01-12 22:35 UTC (permalink / raw)
  To: linux-arm-kernel

Do not use memory bank info to request the "system ram" resources as
they do not track holes created by memblock_remove inside
machine's reserve callback. If the removed memory is passed as
platform_device's ioresource, then drivers that call
request_mem_region would fail due to a conflict with the incorrectly
configured system ram resource.

Instead, iterate through the regions of memblock.memory and add
those as "System RAM" resources.

Signed-off-by: Dima Zavin <dima@android.com>
---
 arch/arm/kernel/setup.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 336f14e..c3aa394 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -520,6 +520,7 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
 static void __init
 request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
 {
+	struct memblock_type *mem = &memblock.memory;
 	struct resource *res;
 	int i;
 
@@ -528,14 +529,11 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
 	kernel_data.start   = virt_to_phys(_sdata);
 	kernel_data.end     = virt_to_phys(_end - 1);
 
-	for (i = 0; i < mi->nr_banks; i++) {
-		if (mi->bank[i].size == 0)
-			continue;
-
+	for (i = 0; i < mem->cnt; i++) {
 		res = alloc_bootmem_low(sizeof(*res));
 		res->name  = "System RAM";
-		res->start = mi->bank[i].start;
-		res->end   = mi->bank[i].start + mi->bank[i].size - 1;
+		res->start = mem->regions[i].base;
+		res->end   = mem->regions[i].base + mem->regions[i].size - 1;
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 
 		request_resource(&iomem_resource, res);
-- 
1.7.3.1

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-12 22:35 [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources Dima Zavin
@ 2011-01-12 23:11 ` Russell King - ARM Linux
  2011-01-12 23:17   ` Dima Zavin
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2011-01-12 23:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 12, 2011 at 02:35:57PM -0800, Dima Zavin wrote:
> Do not use memory bank info to request the "system ram" resources as
> they do not track holes created by memblock_remove inside
> machine's reserve callback. If the removed memory is passed as
> platform_device's ioresource, then drivers that call
> request_mem_region would fail due to a conflict with the incorrectly
> configured system ram resource.
> 
> Instead, iterate through the regions of memblock.memory and add
> those as "System RAM" resources.
> 
> Signed-off-by: Dima Zavin <dima@android.com>
> ---
>  arch/arm/kernel/setup.c |   10 ++++------
>  1 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> index 336f14e..c3aa394 100644
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -520,6 +520,7 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
>  static void __init
>  request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)

Doesn't this means we can get rid of the 'mi' argument?

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-12 23:11 ` Russell King - ARM Linux
@ 2011-01-12 23:17   ` Dima Zavin
  2011-01-12 23:22     ` Dima Zavin
  0 siblings, 1 reply; 8+ messages in thread
From: Dima Zavin @ 2011-01-12 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

yes. I'll respin the patch.

On Wed, Jan 12, 2011 at 3:11 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Wed, Jan 12, 2011 at 02:35:57PM -0800, Dima Zavin wrote:
>> Do not use memory bank info to request the "system ram" resources as
>> they do not track holes created by memblock_remove inside
>> machine's reserve callback. If the removed memory is passed as
>> platform_device's ioresource, then drivers that call
>> request_mem_region would fail due to a conflict with the incorrectly
>> configured system ram resource.
>>
>> Instead, iterate through the regions of memblock.memory and add
>> those as "System RAM" resources.
>>
>> Signed-off-by: Dima Zavin <dima@android.com>
>> ---
>> ?arch/arm/kernel/setup.c | ? 10 ++++------
>> ?1 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
>> index 336f14e..c3aa394 100644
>> --- a/arch/arm/kernel/setup.c
>> +++ b/arch/arm/kernel/setup.c
>> @@ -520,6 +520,7 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
>> ?static void __init
>> ?request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
>
> Doesn't this means we can get rid of the 'mi' argument?
>

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-12 23:17   ` Dima Zavin
@ 2011-01-12 23:22     ` Dima Zavin
  2011-01-12 23:52       ` Russell King - ARM Linux
  0 siblings, 1 reply; 8+ messages in thread
From: Dima Zavin @ 2011-01-12 23:22 UTC (permalink / raw)
  To: linux-arm-kernel

Do not use memory bank info to request the "system ram" resources as
they do not track holes created by memblock_remove inside
machine's reserve callback. If the removed memory is passed as
platform_device's ioresource, then drivers that call
request_mem_region would fail due to a conflict with the incorrectly
configured system ram resource.

Instead, iterate through the regions of memblock.memory and add
those as "System RAM" resources.

Signed-off-by: Dima Zavin <dima@android.com>
---
 arch/arm/kernel/setup.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 336f14e..b291a6b 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -518,8 +518,9 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
 }
 
 static void __init
-request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
+request_standard_resources(struct machine_desc *mdesc)
 {
+	struct memblock_type *mem = &memblock.memory;
 	struct resource *res;
 	int i;
 
@@ -528,14 +529,11 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
 	kernel_data.start   = virt_to_phys(_sdata);
 	kernel_data.end     = virt_to_phys(_end - 1);
 
-	for (i = 0; i < mi->nr_banks; i++) {
-		if (mi->bank[i].size == 0)
-			continue;
-
+	for (i = 0; i < mem->cnt; i++) {
 		res = alloc_bootmem_low(sizeof(*res));
 		res->name  = "System RAM";
-		res->start = mi->bank[i].start;
-		res->end   = mi->bank[i].start + mi->bank[i].size - 1;
+		res->start = mem->regions[i].base;
+		res->end   = mem->regions[i].base + mem->regions[i].size - 1;
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 
 		request_resource(&iomem_resource, res);
@@ -857,7 +855,7 @@ void __init setup_arch(char **cmdline_p)
 	arm_memblock_init(&meminfo, mdesc);
 
 	paging_init(mdesc);
-	request_standard_resources(&meminfo, mdesc);
+	request_standard_resources(mdesc);
 
 #ifdef CONFIG_SMP
 	if (is_smp())
-- 
1.7.3.1

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-12 23:22     ` Dima Zavin
@ 2011-01-12 23:52       ` Russell King - ARM Linux
  2011-01-13  0:08         ` Dima Zavin
  0 siblings, 1 reply; 8+ messages in thread
From: Russell King - ARM Linux @ 2011-01-12 23:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 12, 2011 at 03:22:40PM -0800, Dima Zavin wrote:
> @@ -518,8 +518,9 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
>  }
>  
>  static void __init
> -request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
> +request_standard_resources(struct machine_desc *mdesc)

Almost there.  This line can now be combined with the preceding line
without wrapping over the 80 column limit.

>  {
> +	struct memblock_type *mem = &memblock.memory;
>  	struct resource *res;
>  	int i;
>  
> @@ -528,14 +529,11 @@ request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
>  	kernel_data.start   = virt_to_phys(_sdata);
>  	kernel_data.end     = virt_to_phys(_end - 1);
>  
> -	for (i = 0; i < mi->nr_banks; i++) {
> -		if (mi->bank[i].size == 0)
> -			continue;
> -
> +	for (i = 0; i < mem->cnt; i++) {

Hmm, probably shouldn't rely on that - we should be using the accessors
which memblock people have provided for us.

	for_each_memblock(memory, mem) {

>  		res = alloc_bootmem_low(sizeof(*res));
>  		res->name  = "System RAM";
> -		res->start = mi->bank[i].start;
> -		res->end   = mi->bank[i].start + mi->bank[i].size - 1;
> +		res->start = mem->regions[i].base;
> +		res->end   = mem->regions[i].base + mem->regions[i].size - 1;

		res->start = __pfn_to_phys(memblock_region_memory_base_pfn(mem));
		res->end   = __pfn_to_phys(memblock_region_memory_end_pfn(mem)) - 1;

And I'd say ignore the 80-column limit on that because of the excessively
long memblock function names.

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-12 23:52       ` Russell King - ARM Linux
@ 2011-01-13  0:08         ` Dima Zavin
  2011-01-13  0:10           ` Dima Zavin
  2011-01-14  9:11           ` Russell King - ARM Linux
  0 siblings, 2 replies; 8+ messages in thread
From: Dima Zavin @ 2011-01-13  0:08 UTC (permalink / raw)
  To: linux-arm-kernel

Do not use memory bank info to request the "system ram" resources as
they do not track holes created by memblock_remove inside
machine's reserve callback. If the removed memory is passed as
platform_device's ioresource, then drivers that call
request_mem_region would fail due to a conflict with the incorrectly
configured system ram resource.

Instead, iterate through the regions of memblock.memory and add
those as "System RAM" resources.

Signed-off-by: Dima Zavin <dima@android.com>
---
 arch/arm/kernel/setup.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 336f14e..470efbc 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -517,25 +517,21 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
 #endif
 }
 
-static void __init
-request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
+static void __init request_standard_resources(struct machine_desc *mdesc)
 {
+	struct memblock_region *region;
 	struct resource *res;
-	int i;
 
 	kernel_code.start   = virt_to_phys(_text);
 	kernel_code.end     = virt_to_phys(_etext - 1);
 	kernel_data.start   = virt_to_phys(_sdata);
 	kernel_data.end     = virt_to_phys(_end - 1);
 
-	for (i = 0; i < mi->nr_banks; i++) {
-		if (mi->bank[i].size == 0)
-			continue;
-
+	for_each_memblock(memory, region) {
 		res = alloc_bootmem_low(sizeof(*res));
 		res->name  = "System RAM";
-		res->start = mi->bank[i].start;
-		res->end   = mi->bank[i].start + mi->bank[i].size - 1;
+		res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
+		res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
 		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
 
 		request_resource(&iomem_resource, res);
@@ -857,7 +853,7 @@ void __init setup_arch(char **cmdline_p)
 	arm_memblock_init(&meminfo, mdesc);
 
 	paging_init(mdesc);
-	request_standard_resources(&meminfo, mdesc);
+	request_standard_resources(mdesc);
 
 #ifdef CONFIG_SMP
 	if (is_smp())
-- 
1.7.3.1

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-13  0:08         ` Dima Zavin
@ 2011-01-13  0:10           ` Dima Zavin
  2011-01-14  9:11           ` Russell King - ARM Linux
  1 sibling, 0 replies; 8+ messages in thread
From: Dima Zavin @ 2011-01-13  0:10 UTC (permalink / raw)
  To: linux-arm-kernel

Thanks for the review.

--Dima

On Wed, Jan 12, 2011 at 4:08 PM, Dima Zavin <dima@android.com> wrote:
> Do not use memory bank info to request the "system ram" resources as
> they do not track holes created by memblock_remove inside
> machine's reserve callback. If the removed memory is passed as
> platform_device's ioresource, then drivers that call
> request_mem_region would fail due to a conflict with the incorrectly
> configured system ram resource.
>
> Instead, iterate through the regions of memblock.memory and add
> those as "System RAM" resources.
>
> Signed-off-by: Dima Zavin <dima@android.com>
> ---
> ?arch/arm/kernel/setup.c | ? 16 ++++++----------
> ?1 files changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
> index 336f14e..470efbc 100644
> --- a/arch/arm/kernel/setup.c
> +++ b/arch/arm/kernel/setup.c
> @@ -517,25 +517,21 @@ setup_ramdisk(int doload, int prompt, int image_start, unsigned int rd_sz)
> ?#endif
> ?}
>
> -static void __init
> -request_standard_resources(struct meminfo *mi, struct machine_desc *mdesc)
> +static void __init request_standard_resources(struct machine_desc *mdesc)
> ?{
> + ? ? ? struct memblock_region *region;
> ? ? ? ?struct resource *res;
> - ? ? ? int i;
>
> ? ? ? ?kernel_code.start ? = virt_to_phys(_text);
> ? ? ? ?kernel_code.end ? ? = virt_to_phys(_etext - 1);
> ? ? ? ?kernel_data.start ? = virt_to_phys(_sdata);
> ? ? ? ?kernel_data.end ? ? = virt_to_phys(_end - 1);
>
> - ? ? ? for (i = 0; i < mi->nr_banks; i++) {
> - ? ? ? ? ? ? ? if (mi->bank[i].size == 0)
> - ? ? ? ? ? ? ? ? ? ? ? continue;
> -
> + ? ? ? for_each_memblock(memory, region) {
> ? ? ? ? ? ? ? ?res = alloc_bootmem_low(sizeof(*res));
> ? ? ? ? ? ? ? ?res->name ?= "System RAM";
> - ? ? ? ? ? ? ? res->start = mi->bank[i].start;
> - ? ? ? ? ? ? ? res->end ? = mi->bank[i].start + mi->bank[i].size - 1;
> + ? ? ? ? ? ? ? res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
> + ? ? ? ? ? ? ? res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
> ? ? ? ? ? ? ? ?res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
>
> ? ? ? ? ? ? ? ?request_resource(&iomem_resource, res);
> @@ -857,7 +853,7 @@ void __init setup_arch(char **cmdline_p)
> ? ? ? ?arm_memblock_init(&meminfo, mdesc);
>
> ? ? ? ?paging_init(mdesc);
> - ? ? ? request_standard_resources(&meminfo, mdesc);
> + ? ? ? request_standard_resources(mdesc);
>
> ?#ifdef CONFIG_SMP
> ? ? ? ?if (is_smp())
> --
> 1.7.3.1
>
>

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

* [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources
  2011-01-13  0:08         ` Dima Zavin
  2011-01-13  0:10           ` Dima Zavin
@ 2011-01-14  9:11           ` Russell King - ARM Linux
  1 sibling, 0 replies; 8+ messages in thread
From: Russell King - ARM Linux @ 2011-01-14  9:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 12, 2011 at 04:08:37PM -0800, Dima Zavin wrote:
> Do not use memory bank info to request the "system ram" resources as
> they do not track holes created by memblock_remove inside
> machine's reserve callback. If the removed memory is passed as
> platform_device's ioresource, then drivers that call
> request_mem_region would fail due to a conflict with the incorrectly
> configured system ram resource.

Patch looks fine - please send it to the patch system, thanks.

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

end of thread, other threads:[~2011-01-14  9:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-12 22:35 [PATCH] ARM: use memblock memory regions for "System RAM" I/O resources Dima Zavin
2011-01-12 23:11 ` Russell King - ARM Linux
2011-01-12 23:17   ` Dima Zavin
2011-01-12 23:22     ` Dima Zavin
2011-01-12 23:52       ` Russell King - ARM Linux
2011-01-13  0:08         ` Dima Zavin
2011-01-13  0:10           ` Dima Zavin
2011-01-14  9:11           ` Russell King - ARM Linux

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.