Skip to content

Commit 0cd4017

Browse files
Ley Foon TanDinh Nguyen
authored andcommitted
arch/nios2: Port nios2 kernel to v3.13
- add asm/preempt.h and posix_types.h to Kbuild - remove kernel/time/Kconfig from Kconfig - handle pgtable_page_ctor() fail - remove PREEMPT_ACTIVE and use generic - remove duplicated arch/nios2/include/uapi/asm/setup.h - convert to use new early_init_dt_scan function - convert to use new of_flat_dt_get_machine function - use boot_command_line instead of private cmd_line - use unflatten_and_copy_device_tree - use early_init_dt_scan - remove unnecessary prom.c includes Signed-off-by: Ley Foon Tan <[email protected]>
1 parent 7997628 commit 0cd4017

File tree

11 files changed

+14
-197
lines changed

11 files changed

+14
-197
lines changed

arch/nios2/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ source "kernel/Kconfig.freezer"
6060

6161
source "kernel/Kconfig.hz"
6262

63-
source "kernel/time/Kconfig"
64-
6563
source "mm/Kconfig"
6664

6765
config FORCE_MAX_ZONEORDER

arch/nios2/include/asm/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ generic-y += module.h
3434
generic-y += msgbuf.h
3535
generic-y += param.h
3636
generic-y += percpu.h
37+
generic-y += posix_types.h
38+
generic-y += preempt.h
3739
generic-y += resource.h
3840
generic-y += scatterlist.h
3941
generic-y += sections.h

arch/nios2/include/asm/pgalloc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm,
5959

6060
pte = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
6161
if (pte) {
62+
if (!pgtable_page_ctor(pte)) {
63+
__free_page(pte);
64+
return NULL;
65+
}
6266
clear_highpage(pte);
63-
pgtable_page_ctor(pte);
6467
}
6568
return pte;
6669
}

arch/nios2/include/asm/prom.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,4 @@ extern int __dtb_start;
2323

2424
extern unsigned long early_altera_uart_or_juart_console(void);
2525

26-
extern void device_tree_init(void);
27-
2826
#endif /* _ASM_NIOS2_PROM_H */

arch/nios2/include/asm/setup.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#ifndef __ASSEMBLY__
2525
# ifdef __KERNEL__
2626

27-
extern char cmd_line[COMMAND_LINE_SIZE];
28-
2927
extern char exception_handler_hook[];
3028
extern char fast_handler[];
3129
extern char fast_handler_end[];

arch/nios2/include/asm/thread_info.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ static inline struct thread_info *current_thread_info(void)
8888
}
8989
#endif /* !__ASSEMBLY__ */
9090

91-
#define PREEMPT_ACTIVE 0x10000000
92-
9391
/*
9492
* thread information flags
9593
* - these are process state flags that various assembly files may need to

arch/nios2/include/uapi/asm/posix_types.h

Lines changed: 0 additions & 58 deletions
This file was deleted.

arch/nios2/include/uapi/asm/setup.h

Lines changed: 0 additions & 41 deletions
This file was deleted.

arch/nios2/kernel/prom.c

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,14 @@
2424
*/
2525

2626
#include <linux/init.h>
27-
#include <linux/export.h>
28-
#include <linux/errno.h>
2927
#include <linux/types.h>
3028
#include <linux/bootmem.h>
31-
#include <linux/initrd.h>
32-
#include <linux/debugfs.h>
3329
#include <linux/of.h>
3430
#include <linux/of_fdt.h>
35-
#include <linux/of_irq.h>
36-
#include <linux/of_platform.h>
3731
#include <linux/io.h>
3832

39-
#include <asm/page.h>
4033
#include <asm/prom.h>
4134
#include <asm/sections.h>
42-
#include <asm/setup.h>
4335

4436
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
4537
{
@@ -57,15 +49,6 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
5749
return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS));
5850
}
5951

60-
#ifdef CONFIG_BLK_DEV_INITRD
61-
void __init early_init_dt_setup_initrd_arch(u64 start, u64 end)
62-
{
63-
initrd_start = (unsigned long)__va(start);
64-
initrd_end = (unsigned long)__va(end);
65-
initrd_below_start_ok = 1;
66-
}
67-
#endif
68-
6952
void __init early_init_devtree(void *params)
7053
{
7154
if (params && be32_to_cpup((__be32 *)params) == OF_DT_HEADER)
@@ -80,59 +63,7 @@ void __init early_init_devtree(void *params)
8063
else
8164
return;
8265

83-
/* Retrieve various informations from the /chosen node of the
84-
* device-tree, including the platform type, initrd location and
85-
* size, and more ...
86-
*/
87-
of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
88-
89-
/* Scan memory nodes */
90-
of_scan_flat_dt(early_init_dt_scan_root, NULL);
91-
of_scan_flat_dt(early_init_dt_scan_memory, NULL);
92-
}
93-
94-
void __init device_tree_init(void)
95-
{
96-
unsigned long base, size;
97-
void *fdt_copy;
98-
99-
if (!initial_boot_params)
100-
return;
101-
102-
base = virt_to_phys((void *)initial_boot_params);
103-
size = be32_to_cpu(initial_boot_params->totalsize);
104-
105-
/*
106-
* If the supplied DTB is located in the kernel, it is
107-
* in __init memory and will eventually be destroyed
108-
* ('Freeing unused kernel memory: ...').
109-
*
110-
* If the DTB is located in the available system RAM
111-
* (between memory_start and memory_end), it will also
112-
* eventually be destroyed if that memory is allocated by
113-
* applications. The DTB might get placed there by a boot-
114-
* loader from not directly addressable memory such as a
115-
* SPI EEPROM sector.
116-
*
117-
* Usually, the DT will already have served its
118-
* purpose when the kernel starts. However, if drivers are
119-
* loaded as modules, they must still be able to access the
120-
* DTB entries after the kernel has started.
121-
*
122-
* Therefore, in these 2 cases, the DTB is moved to a new
123-
* bootmem-allocator allocated area. It has the added
124-
* benefit of reducing memory fragmentation.
125-
*/
126-
127-
if ((base >= __pa(_text)) && (base < memory_end)) {
128-
reserve_bootmem(base, size, BOOTMEM_DEFAULT);
129-
fdt_copy = alloc_bootmem(size);
130-
memcpy(fdt_copy, initial_boot_params, size);
131-
initial_boot_params = fdt_copy;
132-
free_bootmem(base, size);
133-
}
134-
135-
unflatten_device_tree();
66+
early_init_dt_scan(initial_boot_params);
13667
}
13768

13869
#ifdef CONFIG_EARLY_PRINTK

arch/nios2/kernel/setup.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ EXPORT_SYMBOL(memory_end);
3535

3636
unsigned long memory_size;
3737

38-
char cmd_line[COMMAND_LINE_SIZE] = { 0, };
39-
4038
/* r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11*/
4139
/* r12 r13 r14 r15 or2 ra fp sp gp es ste ea*/
4240
static struct pt_regs fake_regs = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -131,10 +129,10 @@ asmlinkage void __init nios2_boot_init(unsigned r4, unsigned r5, unsigned r6,
131129

132130
#ifndef CONFIG_CMDLINE_FORCE
133131
if (cmdline_passed[0])
134-
strncpy(cmd_line, cmdline_passed, COMMAND_LINE_SIZE);
132+
strncpy(boot_command_line, cmdline_passed, COMMAND_LINE_SIZE);
135133
#ifdef CONFIG_CMDLINE_IGNORE_DTB
136134
else
137-
strncpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
135+
strncpy(boot_command_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
138136
#endif
139137
#endif
140138
}
@@ -159,10 +157,7 @@ void __init setup_arch(char **cmdline_p)
159157
init_task.thread.kregs = &fake_regs;
160158

161159
/* Keep a copy of command line */
162-
*cmdline_p = &cmd_line[0];
163-
164-
memcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
165-
boot_command_line[COMMAND_LINE_SIZE-1] = 0;
160+
*cmdline_p = boot_command_line;
166161

167162
/*
168163
* give all the memory to the bootmap allocator, tell it to put the
@@ -202,7 +197,7 @@ void __init setup_arch(char **cmdline_p)
202197
}
203198
#endif /* CONFIG_BLK_DEV_INITRD */
204199

205-
device_tree_init();
200+
unflatten_and_copy_device_tree();
206201

207202
setup_cpuinfo();
208203

0 commit comments

Comments
 (0)