aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/mm/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/mm/init.c')
-rw-r--r--arch/sh/mm/init.c74
1 files changed, 60 insertions, 14 deletions
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index b75a7acd62fb..2a53943924b2 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -23,7 +23,19 @@
23 23
24DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 24DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
25pgd_t swapper_pg_dir[PTRS_PER_PGD]; 25pgd_t swapper_pg_dir[PTRS_PER_PGD];
26unsigned long cached_to_uncached = 0; 26
27#ifdef CONFIG_SUPERH32
28/*
29 * Handle trivial transitions between cached and uncached
30 * segments, making use of the 1:1 mapping relationship in
31 * 512MB lowmem.
32 *
33 * This is the offset of the uncached section from its cached alias.
34 * Default value only valid in 29 bit mode, in 32bit mode will be
35 * overridden in pmb_init.
36 */
37unsigned long cached_to_uncached = P2SEG - P1SEG;
38#endif
27 39
28#ifdef CONFIG_MMU 40#ifdef CONFIG_MMU
29static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) 41static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
@@ -58,9 +70,7 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
58 } 70 }
59 71
60 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, prot)); 72 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, prot));
61 73 flush_tlb_one(get_asid(), addr);
62 if (cached_to_uncached)
63 flush_tlb_one(get_asid(), addr);
64} 74}
65 75
66/* 76/*
@@ -113,7 +123,6 @@ void __init page_table_range_init(unsigned long start, unsigned long end,
113 if (!pmd_present(*pmd)) { 123 if (!pmd_present(*pmd)) {
114 pte_t *pte_table; 124 pte_t *pte_table;
115 pte_table = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE); 125 pte_table = (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
116 memset(pte_table, 0, PAGE_SIZE);
117 pmd_populate_kernel(&init_mm, pmd, pte_table); 126 pmd_populate_kernel(&init_mm, pmd, pte_table);
118 } 127 }
119 128
@@ -165,15 +174,6 @@ void __init paging_init(void)
165#ifdef CONFIG_SUPERH32 174#ifdef CONFIG_SUPERH32
166 /* Set up the uncached fixmap */ 175 /* Set up the uncached fixmap */
167 set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); 176 set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start));
168
169#ifdef CONFIG_29BIT
170 /*
171 * Handle trivial transitions between cached and uncached
172 * segments, making use of the 1:1 mapping relationship in
173 * 512MB lowmem.
174 */
175 cached_to_uncached = P2SEG - P1SEG;
176#endif
177#endif 177#endif
178} 178}
179 179
@@ -265,6 +265,35 @@ void free_initrd_mem(unsigned long start, unsigned long end)
265} 265}
266#endif 266#endif
267 267
268#if THREAD_SHIFT < PAGE_SHIFT
269static struct kmem_cache *thread_info_cache;
270
271struct thread_info *alloc_thread_info(struct task_struct *tsk)
272{
273 struct thread_info *ti;
274
275 ti = kmem_cache_alloc(thread_info_cache, GFP_KERNEL);
276 if (unlikely(ti == NULL))
277 return NULL;
278#ifdef CONFIG_DEBUG_STACK_USAGE
279 memset(ti, 0, THREAD_SIZE);
280#endif
281 return ti;
282}
283
284void free_thread_info(struct thread_info *ti)
285{
286 kmem_cache_free(thread_info_cache, ti);
287}
288
289void thread_info_cache_init(void)
290{
291 thread_info_cache = kmem_cache_create("thread_info", THREAD_SIZE,
292 THREAD_SIZE, 0, NULL);
293 BUG_ON(thread_info_cache == NULL);
294}
295#endif /* THREAD_SHIFT < PAGE_SHIFT */
296
268#ifdef CONFIG_MEMORY_HOTPLUG 297#ifdef CONFIG_MEMORY_HOTPLUG
269int arch_add_memory(int nid, u64 start, u64 size) 298int arch_add_memory(int nid, u64 start, u64 size)
270{ 299{
@@ -292,4 +321,21 @@ int memory_add_physaddr_to_nid(u64 addr)
292} 321}
293EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); 322EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
294#endif 323#endif
324
325#ifdef CONFIG_MEMORY_HOTREMOVE
326int remove_memory(u64 start, u64 size)
327{
328 unsigned long start_pfn = start >> PAGE_SHIFT;
329 unsigned long end_pfn = start_pfn + (size >> PAGE_SHIFT);
330 int ret;
331
332 ret = offline_pages(start_pfn, end_pfn, 120 * HZ);
333 if (unlikely(ret))
334 printk("%s: Failed, offline_pages() == %d\n", __func__, ret);
335
336 return ret;
337}
338EXPORT_SYMBOL_GPL(remove_memory);
295#endif 339#endif
340
341#endif /* CONFIG_MEMORY_HOTPLUG */