[linux-yocto] [PATCH 11/26] arm: Allow >=4GB RAM to be configured

Bruce Ashfield bruce.ashfield at windriver.com
Thu Mar 20 09:03:02 PDT 2014


On 14-03-20 05:48 AM, Anders Berg wrote:
> On Thu, Mar 20, 2014 at 04:47:27AM -0400, Bruce Ashfield wrote:
>> On 14-03-18 03:49 AM, Charlie Paul wrote:
>>> From: Anders Berg <anders.berg at lsi.com>
>>>
>>> Use phys_addr_t to hold the RAM bank sizes to avoid truncation to 32-bits.
>>
>> Since these are arch common files, is this an issue for all boards ? If so,
>> is this patch going upstream ?
>>
> This is fixed upstream in this commit (since v3.6):
>
> a5d5f7d ARM: 7465/1: Handle >4GB memory sizes in device tree and mem=size at start option
>
> In retrospect, maybe it should have been a backport of this commit.

That makes it much easier for me to merge and maintain. A mainline mapping
of the commit gives a good division of the changes, and when I merge
LTSI, -stable updates, or even update kernels, I know exactly what to
keep, drop or be aware of.

Can we morph this commit into the mainline one ?

Bruce

>
> /Anders
>
>
>> Bruce
>>
>>>
>>> Signed-off-by: Anders Berg <anders.berg at lsi.com>
>>> ---
>>>   arch/arm/include/asm/setup.h |   10 +++---
>>>   arch/arm/kernel/setup.c      |   70 +++++++++++++++++++++---------------------
>>>   2 files changed, 40 insertions(+), 40 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
>>> index 23ebc0c..4d65c38 100644
>>> --- a/arch/arm/include/asm/setup.h
>>> +++ b/arch/arm/include/asm/setup.h
>>> @@ -173,14 +173,14 @@ struct tagtable {
>>>   	int (*parse)(const struct tag *);
>>>   };
>>>
>>> -#define tag_member_present(tag,member)				\
>>> +#define tag_member_present(tag, member)				\
>>>   	((unsigned long)(&((struct tag *)0L)->member + 1)	\
>>>   		<= (tag)->hdr.size * 4)
>>>
>>>   #define tag_next(t)	((struct tag *)((__u32 *)(t) + (t)->hdr.size))
>>>   #define tag_size(type)	((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
>>>
>>> -#define for_each_tag(t,base)		\
>>> +#define for_each_tag(t, base)		\
>>>   	for (t = base; t->hdr.size; t = tag_next(t))
>>>
>>>   #ifdef __KERNEL__
>>> @@ -196,7 +196,7 @@ static const struct tagtable __tagtable_##fn __tag = { tag, fn }
>>>
>>>   struct membank {
>>>   	phys_addr_t start;
>>> -	unsigned long size;
>>> +	phys_addr_t size;
>>>   	unsigned int highmem;
>>>   };
>>>
>>> @@ -207,7 +207,7 @@ struct meminfo {
>>>
>>>   extern struct meminfo meminfo;
>>>
>>> -#define for_each_bank(iter,mi)				\
>>> +#define for_each_bank(iter, mi)				\
>>>   	for (iter = 0; iter < (mi)->nr_banks; iter++)
>>>
>>>   #define bank_pfn_start(bank)	__phys_to_pfn((bank)->start)
>>> @@ -217,7 +217,7 @@ extern struct meminfo meminfo;
>>>   #define bank_phys_end(bank)	((bank)->start + (bank)->size)
>>>   #define bank_phys_size(bank)	(bank)->size
>>>
>>> -extern int arm_add_memory(phys_addr_t start, unsigned long size);
>>> +extern int arm_add_memory(phys_addr_t start, phys_addr_t size);
>>>   extern void early_print(const char *str, ...);
>>>   extern void dump_machine_table(void);
>>>
>>> diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
>>> index 467155b..ad28e29 100644
>>> --- a/arch/arm/kernel/setup.c
>>> +++ b/arch/arm/kernel/setup.c
>>> @@ -328,7 +328,7 @@ static void __init cacheid_init(void)
>>>   		cacheid = CACHEID_VIVT;
>>>   	}
>>>
>>> -	printk("CPU: %s data cache, %s instruction cache\n",
>>> +	printk(KERN_INFO "CPU: %s data cache, %s instruction cache\n",
>>>   		cache_is_vivt() ? "VIVT" :
>>>   		cache_is_vipt_aliasing() ? "VIPT aliasing" :
>>>   		cache_is_vipt_nonaliasing() ? "PIPT / VIPT nonaliasing" : "unknown",
>>> @@ -358,7 +358,7 @@ void __init early_print(const char *str, ...)
>>>   #ifdef CONFIG_DEBUG_LL
>>>   	printascii(buf);
>>>   #endif
>>> -	printk("%s", buf);
>>> +	printk(KERN_INFO "%s", buf);
>>>   }
>>>
>>>   static void __init feat_v6_fixup(void)
>>> @@ -419,13 +419,13 @@ void cpu_init(void)
>>>   	"msr	cpsr_c, %7"
>>>   	    :
>>>   	    : "r" (stk),
>>> -	      PLC (PSR_F_BIT | PSR_I_BIT | IRQ_MODE),
>>> +	      PLC(PSR_F_BIT | PSR_I_BIT | IRQ_MODE),
>>>   	      "I" (offsetof(struct stack, irq[0])),
>>> -	      PLC (PSR_F_BIT | PSR_I_BIT | ABT_MODE),
>>> +	      PLC(PSR_F_BIT | PSR_I_BIT | ABT_MODE),
>>>   	      "I" (offsetof(struct stack, abt[0])),
>>> -	      PLC (PSR_F_BIT | PSR_I_BIT | UND_MODE),
>>> +	      PLC(PSR_F_BIT | PSR_I_BIT | UND_MODE),
>>>   	      "I" (offsetof(struct stack, und[0])),
>>> -	      PLC (PSR_F_BIT | PSR_I_BIT | SVC_MODE)
>>> +	      PLC(PSR_F_BIT | PSR_I_BIT | SVC_MODE)
>>>   	    : "r14");
>>>   }
>>>
>>> @@ -454,9 +454,10 @@ static void __init setup_processor(void)
>>>   	 */
>>>   	list = lookup_processor_type(read_cpuid_id());
>>>   	if (!list) {
>>> -		printk("CPU configuration botched (ID %08x), unable "
>>> -		       "to continue.\n", read_cpuid_id());
>>> -		while (1);
>>> +		printk(KERN_INFO "CPU configuration botched (ID %08x), unable to continue.\n",
>>> +				read_cpuid_id());
>>> +		while (1)
>>> +			;
>>>   	}
>>>
>>>   	cpu_name = list->cpu_name;
>>> @@ -475,7 +476,7 @@ static void __init setup_processor(void)
>>>   	cpu_cache = *list->cache;
>>>   #endif
>>>
>>> -	printk("CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
>>> +	printk(KERN_INFO "CPU: %s [%08x] revision %d (ARMv%s), cr=%08lx\n",
>>>   	       cpu_name, read_cpuid_id(), read_cpuid_id() & 15,
>>>   	       proc_arch[cpu_architecture()], cr_alignment);
>>>
>>> @@ -508,13 +509,13 @@ void __init dump_machine_table(void)
>>>   		/* can't use cpu_relax() here as it may require MMU setup */;
>>>   }
>>>
>>> -int __init arm_add_memory(phys_addr_t start, unsigned long size)
>>> +int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
>>>   {
>>>   	struct membank *bank = &meminfo.bank[meminfo.nr_banks];
>>>
>>>   	if (meminfo.nr_banks >= NR_BANKS) {
>>> -		printk(KERN_CRIT "NR_BANKS too low, "
>>> -			"ignoring memory at 0x%08llx\n", (long long)start);
>>> +		printk(KERN_CRIT "NR_BANKS too low, ignoring memory at 0x%08llx\n",
>>> +				(long long)start);
>>>   		return -EINVAL;
>>>   	}
>>>
>>> @@ -527,8 +528,8 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
>>>
>>>   #ifndef CONFIG_LPAE
>>>   	if (bank->start + size < bank->start) {
>>> -		printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
>>> -			"32-bit physical address space\n", (long long)start);
>>> +		printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in 32-bit physical address space\n",
>>> +				(long long)start);
>>>   		/*
>>>   		 * To ensure bank->start + bank->size is representable in
>>>   		 * 32 bits, we use ULONG_MAX as the upper limit rather than 4GB.
>>> @@ -538,7 +539,7 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
>>>   	}
>>>   #endif
>>>
>>> -	bank->size = size & PAGE_MASK;
>>> +	bank->size = size & ~(phys_addr_t)(PAGE_SIZE-1);
>>>
>>>   	/*
>>>   	 * Check whether this memory region has non-zero size or
>>> @@ -557,8 +558,8 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
>>>    */
>>>   static int __init early_mem(char *p)
>>>   {
>>> -	static int usermem __initdata = 0;
>>> -	unsigned long size;
>>> +	static int usermem __initdata;
>>> +	phys_addr_t size;
>>>   	phys_addr_t start;
>>>   	char *endp;
>>>
>>> @@ -674,12 +675,12 @@ __tagtable(ATAG_MEM, parse_tag_mem32);
>>>
>>>   #if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
>>>   struct screen_info screen_info = {
>>> - .orig_video_lines	= 30,
>>> - .orig_video_cols	= 80,
>>> - .orig_video_mode	= 0,
>>> - .orig_video_ega_bx	= 0,
>>> - .orig_video_isVGA	= 1,
>>> - .orig_video_points	= 8
>>> +		.orig_video_lines	= 30,
>>> +		.orig_video_cols	= 80,
>>> +		.orig_video_mode	= 0,
>>> +		.orig_video_ega_bx	= 0,
>>> +		.orig_video_isVGA	= 1,
>>> +		.orig_video_points	= 8
>>>   };
>>>
>>>   static int __init parse_tag_videotext(const struct tag *tag)
>>> @@ -839,16 +840,15 @@ static void __init reserve_crashkernel(void)
>>>
>>>   	ret = reserve_bootmem(crash_base, crash_size, BOOTMEM_EXCLUSIVE);
>>>   	if (ret < 0) {
>>> -		printk(KERN_WARNING "crashkernel reservation failed - "
>>> -		       "memory is in use (0x%lx)\n", (unsigned long)crash_base);
>>> +		printk(KERN_WARNING "crashkernel reservation failed - memory is in use (0x%lx)\n",
>>> +				(unsigned long)crash_base);
>>>   		return;
>>>   	}
>>>
>>> -	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
>>> -	       "for crashkernel (System RAM: %ldMB)\n",
>>> -	       (unsigned long)(crash_size >> 20),
>>> -	       (unsigned long)(crash_base >> 20),
>>> -	       (unsigned long)(total_mem >> 20));
>>> +	printk(KERN_INFO "Reserving %ldMB of memory at %ldMB for crashkernel (System RAM: %ldMB)\n",
>>> +			(unsigned long)(crash_size >> 20),
>>> +			(unsigned long)(crash_base >> 20),
>>> +			(unsigned long)(total_mem >> 20));
>>>
>>>   	crashk_res.start = crash_base;
>>>   	crashk_res.end = crash_base + crash_size - 1;
>>> @@ -878,14 +878,13 @@ static struct machine_desc * __init setup_machine_tags(unsigned int nr)
>>>   	 */
>>>   	for_each_machine_desc(p)
>>>   		if (nr == p->nr) {
>>> -			printk("Machine: %s\n", p->name);
>>> +			printk(KERN_INFO "Machine: %s\n", p->name);
>>>   			mdesc = p;
>>>   			break;
>>>   		}
>>>
>>>   	if (!mdesc) {
>>> -		early_print("\nError: unrecognized/unsupported machine ID"
>>> -			" (r1 = 0x%08x).\n\n", nr);
>>> +		early_print("\nError: unrecognized/unsupported machine ID (r1 = 0x%08x).\n\n", nr);
>>>   		dump_machine_table(); /* does not return */
>>>   	}
>>>
>>> @@ -964,7 +963,8 @@ void __init setup_arch(char **cmdline_p)
>>>
>>>   	parse_early_param();
>>>
>>> -	sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
>>> +	sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]),
>>> +			meminfo_cmp, NULL);
>>>   	sanity_check_meminfo();
>>>   	arm_memblock_init(&meminfo, mdesc);
>>>
>>>
>>
>>



More information about the linux-yocto mailing list