Skip to content

Commit 30eebb5

Browse files
committed
Merge branch 'next' of git://git.monstr.eu/linux-2.6-microblaze
Pull arch/microblaze fixes from Michal Simek * 'next' of git://git.monstr.eu/linux-2.6-microblaze: microblaze: Handle TLB skip size dynamically microblaze: Introduce TLB skip size microblaze: Improve TLB calculation for small systems microblaze: Extend space for compiled-in FDT to 32kB microblaze: Clear all MSR flags on the first kernel instruction microblaze: Use node name instead of compatible string microblaze: Fix mapin_ram function microblaze: Highmem support microblaze: Use active regions microblaze: Show more detailed information about memory microblaze: Introduce fixmap microblaze: mm: Fix lowmem max memory size limits microblaze: mm: Use ZONE_DMA instead of ZONE_NORMAL microblaze: trivial: Fix typo fault in timer.c microblaze: Use vsprintf extention %pf with builtin_return_address microblaze: Add PVR version string for MB 8.20.b and 8.30.a microblaze: Fix makefile to work with latest toolchain microblaze: Fix typo in early_printk.c
2 parents 9e4db1c + e02db0a commit 30eebb5

23 files changed

Lines changed: 710 additions & 95 deletions

‎arch/microblaze/Kconfig‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
config MICROBLAZE
22
def_bool y
33
select HAVE_MEMBLOCK
4+
select HAVE_MEMBLOCK_NODE_MAP
45
select HAVE_FUNCTION_TRACER
56
select HAVE_FUNCTION_TRACE_MCOUNT_TEST
67
select HAVE_FUNCTION_GRAPH_TRACER
@@ -28,6 +29,12 @@ config SWAP
2829
config RWSEM_GENERIC_SPINLOCK
2930
def_bool y
3031

32+
config ZONE_DMA
33+
def_bool y
34+
35+
config ARCH_POPULATES_NODE_MAP
36+
def_bool y
37+
3138
config RWSEM_XCHGADD_ALGORITHM
3239
bool
3340

@@ -153,20 +160,18 @@ config XILINX_UNCACHED_SHADOW
153160
The feature requires the design to define the RAM memory controller
154161
window to be twice as large as the actual physical memory.
155162

156-
config HIGHMEM_START_BOOL
157-
bool "Set high memory pool address"
158-
depends on ADVANCED_OPTIONS && HIGHMEM
163+
config HIGHMEM
164+
bool "High memory support"
165+
depends on MMU
159166
help
160-
This option allows you to set the base address of the kernel virtual
161-
area used to map high memory pages. This can be useful in
162-
optimizing the layout of kernel virtual memory.
167+
The address space of Microblaze processors is only 4 Gigabytes large
168+
and it has to accommodate user address space, kernel address
169+
space as well as some memory mapped IO. That means that, if you
170+
have a large amount of physical memory and/or IO, not all of the
171+
memory can be "permanently mapped" by the kernel. The physical
172+
memory that is not permanently mapped is called "high memory".
163173

164-
Say N here unless you know what you are doing.
165-
166-
config HIGHMEM_START
167-
hex "Virtual start address of high memory pool" if HIGHMEM_START_BOOL
168-
depends on MMU
169-
default "0xfe000000"
174+
If unsure, say n.
170175

171176
config LOWMEM_SIZE_BOOL
172177
bool "Set maximum low memory"
@@ -255,6 +260,10 @@ config MICROBLAZE_32K_PAGES
255260

256261
endchoice
257262

263+
config KERNEL_PAD
264+
hex "Kernel PAD for unpacking" if ADVANCED_OPTIONS
265+
default "0x80000" if MMU
266+
258267
endmenu
259268

260269
source "mm/Kconfig"

‎arch/microblaze/boot/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-y += linked_dtb.o
88

99
targets := linux.bin linux.bin.gz simpleImage.%
1010

11-
OBJCOPYFLAGS := -O binary
11+
OBJCOPYFLAGS := -R .note -R .comment -R .note.gnu.build-id -O binary
1212

1313
# Ensure system.dtb exists
1414
$(obj)/linked_dtb.o: $(obj)/system.dtb
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* fixmap.h: compile-time virtual memory allocation
3+
*
4+
* This file is subject to the terms and conditions of the GNU General Public
5+
* License. See the file "COPYING" in the main directory of this archive
6+
* for more details.
7+
*
8+
* Copyright (C) 1998 Ingo Molnar
9+
*
10+
* Copyright 2008 Freescale Semiconductor Inc.
11+
* Port to powerpc added by Kumar Gala
12+
*
13+
* Copyright 2011 Michal Simek <monstr@monstr.eu>
14+
* Copyright 2011 PetaLogix Qld Pty Ltd
15+
* Port to Microblaze
16+
*/
17+
18+
#ifndef _ASM_FIXMAP_H
19+
#define _ASM_FIXMAP_H
20+
21+
#ifndef __ASSEMBLY__
22+
#include <linux/kernel.h>
23+
#include <asm/page.h>
24+
#ifdef CONFIG_HIGHMEM
25+
#include <linux/threads.h>
26+
#include <asm/kmap_types.h>
27+
#endif
28+
29+
#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE))
30+
31+
/*
32+
* Here we define all the compile-time 'special' virtual
33+
* addresses. The point is to have a constant address at
34+
* compile time, but to set the physical address only
35+
* in the boot process. We allocate these special addresses
36+
* from the end of virtual memory (0xfffff000) backwards.
37+
* Also this lets us do fail-safe vmalloc(), we
38+
* can guarantee that these special addresses and
39+
* vmalloc()-ed addresses never overlap.
40+
*
41+
* these 'compile-time allocated' memory buffers are
42+
* fixed-size 4k pages. (or larger if used with an increment
43+
* highger than 1) use fixmap_set(idx,phys) to associate
44+
* physical memory with fixmap indices.
45+
*
46+
* TLB entries of such buffers will not be flushed across
47+
* task switches.
48+
*/
49+
enum fixed_addresses {
50+
FIX_HOLE,
51+
#ifdef CONFIG_HIGHMEM
52+
FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
53+
FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * num_possible_cpus()) - 1,
54+
#endif
55+
__end_of_fixed_addresses
56+
};
57+
58+
extern void __set_fixmap(enum fixed_addresses idx,
59+
phys_addr_t phys, pgprot_t flags);
60+
61+
#define set_fixmap(idx, phys) \
62+
__set_fixmap(idx, phys, PAGE_KERNEL)
63+
/*
64+
* Some hardware wants to get fixmapped without caching.
65+
*/
66+
#define set_fixmap_nocache(idx, phys) \
67+
__set_fixmap(idx, phys, PAGE_KERNEL_CI)
68+
69+
#define clear_fixmap(idx) \
70+
__set_fixmap(idx, 0, __pgprot(0))
71+
72+
#define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
73+
#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
74+
75+
#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
76+
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
77+
78+
extern void __this_fixmap_does_not_exist(void);
79+
80+
/*
81+
* 'index to address' translation. If anyone tries to use the idx
82+
* directly without tranlation, we catch the bug with a NULL-deference
83+
* kernel oops. Illegal ranges of incoming indices are caught too.
84+
*/
85+
static __always_inline unsigned long fix_to_virt(const unsigned int idx)
86+
{
87+
/*
88+
* this branch gets completely eliminated after inlining,
89+
* except when someone tries to use fixaddr indices in an
90+
* illegal way. (such as mixing up address types or using
91+
* out-of-range indices).
92+
*
93+
* If it doesn't get removed, the linker will complain
94+
* loudly with a reasonably clear error message..
95+
*/
96+
if (idx >= __end_of_fixed_addresses)
97+
__this_fixmap_does_not_exist();
98+
99+
return __fix_to_virt(idx);
100+
}
101+
102+
static inline unsigned long virt_to_fix(const unsigned long vaddr)
103+
{
104+
BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
105+
return __virt_to_fix(vaddr);
106+
}
107+
108+
#endif /* !__ASSEMBLY__ */
109+
#endif
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* highmem.h: virtual kernel memory mappings for high memory
3+
*
4+
* Used in CONFIG_HIGHMEM systems for memory pages which
5+
* are not addressable by direct kernel virtual addresses.
6+
*
7+
* Copyright (C) 1999 Gerhard Wichert, Siemens AG
8+
* Gerhard.Wichert@pdb.siemens.de
9+
*
10+
*
11+
* Redesigned the x86 32-bit VM architecture to deal with
12+
* up to 16 Terabyte physical memory. With current x86 CPUs
13+
* we now support up to 64 Gigabytes physical RAM.
14+
*
15+
* Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
16+
*/
17+
#ifndef _ASM_HIGHMEM_H
18+
#define _ASM_HIGHMEM_H
19+
20+
#ifdef __KERNEL__
21+
22+
#include <linux/init.h>
23+
#include <linux/interrupt.h>
24+
#include <linux/uaccess.h>
25+
#include <asm/fixmap.h>
26+
27+
extern pte_t *kmap_pte;
28+
extern pgprot_t kmap_prot;
29+
extern pte_t *pkmap_page_table;
30+
31+
/*
32+
* Right now we initialize only a single pte table. It can be extended
33+
* easily, subsequent pte tables have to be allocated in one physical
34+
* chunk of RAM.
35+
*/
36+
/*
37+
* We use one full pte table with 4K pages. And with 16K/64K/256K pages pte
38+
* table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP
39+
* and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP
40+
* in case of 16K/64K/256K page sizes.
41+
*/
42+
43+
#define PKMAP_ORDER PTE_SHIFT
44+
#define LAST_PKMAP (1 << PKMAP_ORDER)
45+
46+
#define PKMAP_BASE ((FIXADDR_START - PAGE_SIZE * (LAST_PKMAP + 1)) \
47+
& PMD_MASK)
48+
49+
#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
50+
#define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT)
51+
#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
52+
53+
extern void *kmap_high(struct page *page);
54+
extern void kunmap_high(struct page *page);
55+
extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
56+
extern void __kunmap_atomic(void *kvaddr);
57+
58+
static inline void *kmap(struct page *page)
59+
{
60+
might_sleep();
61+
if (!PageHighMem(page))
62+
return page_address(page);
63+
return kmap_high(page);
64+
}
65+
66+
static inline void kunmap(struct page *page)
67+
{
68+
BUG_ON(in_interrupt());
69+
if (!PageHighMem(page))
70+
return;
71+
kunmap_high(page);
72+
}
73+
74+
static inline void *__kmap_atomic(struct page *page)
75+
{
76+
return kmap_atomic_prot(page, kmap_prot);
77+
}
78+
79+
static inline struct page *kmap_atomic_to_page(void *ptr)
80+
{
81+
unsigned long idx, vaddr = (unsigned long) ptr;
82+
pte_t *pte;
83+
84+
if (vaddr < FIXADDR_START)
85+
return virt_to_page(ptr);
86+
87+
idx = virt_to_fix(vaddr);
88+
pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
89+
return pte_page(*pte);
90+
}
91+
92+
#define flush_cache_kmaps() { flush_icache(); flush_dcache(); }
93+
94+
#endif /* __KERNEL__ */
95+
96+
#endif /* _ASM_HIGHMEM_H */

‎arch/microblaze/include/asm/mmu.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ typedef struct _SEGREG {
5656

5757
extern void _tlbie(unsigned long va); /* invalidate a TLB entry */
5858
extern void _tlbia(void); /* invalidate all TLB entries */
59+
60+
/*
61+
* tlb_skip size stores actual number skipped TLBs from TLB0 - every directy TLB
62+
* mapping has to increase tlb_skip size.
63+
*/
64+
extern u32 tlb_skip;
5965
# endif /* __ASSEMBLY__ */
6066

6167
/*
@@ -69,6 +75,12 @@ extern void _tlbia(void); /* invalidate all TLB entries */
6975

7076
# define MICROBLAZE_TLB_SIZE 64
7177

78+
/* For cases when you want to skip some TLB entries */
79+
# define MICROBLAZE_TLB_SKIP 0
80+
81+
/* Use the last TLB for temporary access to LMB */
82+
# define MICROBLAZE_LMB_TLB_ID 63
83+
7284
/*
7385
* TLB entries are defined by a "high" tag portion and a "low" data
7486
* portion. The data portion is 32-bits.

‎arch/microblaze/include/asm/page.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ extern unsigned long min_low_pfn;
135135
extern unsigned long max_pfn;
136136

137137
extern unsigned long memory_start;
138-
extern unsigned long memory_end;
139138
extern unsigned long memory_size;
139+
extern unsigned long lowmem_size;
140140

141141
extern int page_is_ram(unsigned long pfn);
142142

‎arch/microblaze/include/asm/pgtable.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
9494
/* Start and end of the vmalloc area. */
9595
/* Make sure to map the vmalloc area above the pinned kernel memory area
9696
of 32Mb. */
97-
#define VMALLOC_START (CONFIG_KERNEL_START + \
98-
max(32 * 1024 * 1024UL, memory_size))
97+
#define VMALLOC_START (CONFIG_KERNEL_START + CONFIG_LOWMEM_SIZE)
9998
#define VMALLOC_END ioremap_bot
10099

101100
#endif /* __ASSEMBLY__ */

‎arch/microblaze/include/asm/setup.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ extern void of_platform_reset_gpio_probe(void);
3939
void time_init(void);
4040
void init_IRQ(void);
4141
void machine_early_init(const char *cmdline, unsigned int ram,
42-
unsigned int fdt, unsigned int msr);
42+
unsigned int fdt, unsigned int msr, unsigned int tlb0,
43+
unsigned int tlb1);
4344

4445
void machine_restart(char *cmd);
4546
void machine_shutdown(void);

‎arch/microblaze/include/asm/system.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ void default_idle(void);
8383
void free_init_pages(char *what, unsigned long begin, unsigned long end);
8484
void free_initmem(void);
8585
extern char *klimit;
86+
extern unsigned long kernel_tlb;
8687
extern void ret_from_fork(void);
8788

8889
extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);

‎arch/microblaze/include/asm/uaccess.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ extern unsigned long search_exception_table(unsigned long);
8080
static inline int ___range_ok(unsigned long addr, unsigned long size)
8181
{
8282
return ((addr < memory_start) ||
83-
((addr + size) > memory_end));
83+
((addr + size - 1) > (memory_start + memory_size - 1)));
8484
}
8585

8686
#define __range_ok(addr, size) \

0 commit comments

Comments
 (0)