Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: Fold fixed-PMB support into dynamic PMB support

The initialisation process differs for CONFIG_PMB and for
CONFIG_PMB_FIXED. For CONFIG_PMB_FIXED we need to register the PMB
entries that were allocated by the bootloader.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by

Matt Fleming and committed by
Paul Mundt
20b5014b ef269b32

+64 -53
+2
arch/sh/include/asm/mmu.h
··· 15 15 #define PMB_E_MASK 0x0000000f 16 16 #define PMB_E_SHIFT 8 17 17 18 + #define PMB_PFN_MASK 0xff000000 19 + 18 20 #define PMB_SZ_16M 0x00000000 19 21 #define PMB_SZ_64M 0x00000010 20 22 #define PMB_SZ_128M 0x00000080
+1 -1
arch/sh/kernel/setup.c
··· 453 453 454 454 paging_init(); 455 455 456 - #ifdef CONFIG_PMB 456 + #ifdef CONFIG_PMB_ENABLE 457 457 pmb_init(); 458 458 #endif 459 459
+1 -2
arch/sh/mm/Makefile
··· 33 33 endif 34 34 35 35 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 36 - obj-$(CONFIG_PMB) += pmb.o 37 - obj-$(CONFIG_PMB_FIXED) += pmb-fixed.o 36 + obj-$(CONFIG_PMB_ENABLE) += pmb.o 38 37 obj-$(CONFIG_NUMA) += numa.o 39 38 40 39 # Special flags for fault_64.o. This puts restrictions on the number of
-45
arch/sh/mm/pmb-fixed.c
··· 1 - /* 2 - * arch/sh/mm/fixed_pmb.c 3 - * 4 - * Copyright (C) 2009 Renesas Solutions Corp. 5 - * 6 - * This file is subject to the terms and conditions of the GNU General Public 7 - * License. See the file "COPYING" in the main directory of this archive 8 - * for more details. 9 - */ 10 - #include <linux/init.h> 11 - #include <linux/mm.h> 12 - #include <linux/io.h> 13 - #include <asm/mmu.h> 14 - #include <asm/mmu_context.h> 15 - 16 - static int __uses_jump_to_uncached fixed_pmb_init(void) 17 - { 18 - int i; 19 - unsigned long addr, data; 20 - 21 - jump_to_uncached(); 22 - 23 - for (i = 0; i < PMB_ENTRY_MAX; i++) { 24 - addr = PMB_DATA + (i << PMB_E_SHIFT); 25 - data = ctrl_inl(addr); 26 - if (!(data & PMB_V)) 27 - continue; 28 - 29 - if (data & PMB_C) { 30 - #if defined(CONFIG_CACHE_WRITETHROUGH) 31 - data |= PMB_WT; 32 - #elif defined(CONFIG_CACHE_WRITEBACK) 33 - data &= ~PMB_WT; 34 - #else 35 - data &= ~(PMB_C | PMB_WT); 36 - #endif 37 - } 38 - ctrl_outl(data, addr); 39 - } 40 - 41 - back_to_cached(); 42 - 43 - return 0; 44 - } 45 - arch_initcall(fixed_pmb_init);
+60 -5
arch/sh/mm/pmb.c
··· 70 70 } 71 71 72 72 static struct pmb_entry *pmb_alloc(unsigned long vpn, unsigned long ppn, 73 - unsigned long flags) 73 + unsigned long flags, int entry) 74 74 { 75 75 struct pmb_entry *pmbe; 76 76 int pos; 77 77 78 - pos = pmb_alloc_entry(); 79 - if (pos < 0) 80 - return ERR_PTR(pos); 78 + if (entry == PMB_NO_ENTRY) { 79 + pos = pmb_alloc_entry(); 80 + if (pos < 0) 81 + return ERR_PTR(pos); 82 + } else { 83 + if (test_bit(entry, &pmb_map)) 84 + return ERR_PTR(-ENOSPC); 85 + pos = entry; 86 + } 81 87 82 88 pmbe = &pmb_entry_list[pos]; 83 89 if (!pmbe) ··· 193 187 if (size < pmb_sizes[i].size) 194 188 continue; 195 189 196 - pmbe = pmb_alloc(vaddr, phys, pmb_flags | pmb_sizes[i].flag); 190 + pmbe = pmb_alloc(vaddr, phys, pmb_flags | pmb_sizes[i].flag, 191 + PMB_NO_ENTRY); 197 192 if (IS_ERR(pmbe)) { 198 193 err = PTR_ERR(pmbe); 199 194 goto out; ··· 279 272 } while (pmbe); 280 273 } 281 274 275 + #ifdef CONFIG_PMB 282 276 int __uses_jump_to_uncached pmb_init(void) 283 277 { 284 278 unsigned int i; ··· 317 309 318 310 return 0; 319 311 } 312 + #else 313 + int __uses_jump_to_uncached pmb_init(void) 314 + { 315 + int i; 316 + unsigned long addr, data; 317 + 318 + jump_to_uncached(); 319 + 320 + for (i = 0; i < PMB_ENTRY_MAX; i++) { 321 + struct pmb_entry *pmbe; 322 + unsigned long vpn, ppn, flags; 323 + 324 + addr = PMB_DATA + (i << PMB_E_SHIFT); 325 + data = ctrl_inl(addr); 326 + if (!(data & PMB_V)) 327 + continue; 328 + 329 + if (data & PMB_C) { 330 + #if defined(CONFIG_CACHE_WRITETHROUGH) 331 + data |= PMB_WT; 332 + #elif defined(CONFIG_CACHE_WRITEBACK) 333 + data &= ~PMB_WT; 334 + #else 335 + data &= ~(PMB_C | PMB_WT); 336 + #endif 337 + } 338 + ctrl_outl(data, addr); 339 + 340 + ppn = data & PMB_PFN_MASK; 341 + 342 + flags = data & (PMB_C | PMB_WT | PMB_UB); 343 + flags |= data & PMB_SZ_MASK; 344 + 345 + addr = PMB_ADDR + (i << PMB_E_SHIFT); 346 + data = ctrl_inl(addr); 347 + 348 + vpn = data & PMB_PFN_MASK; 349 + 350 + pmbe = pmb_alloc(vpn, ppn, flags, i); 351 + WARN_ON(IS_ERR(pmbe)); 352 + } 353 + 354 + back_to_cached(); 355 + 356 + return 0; 357 + } 358 + #endif /* CONFIG_PMB */ 320 359 321 360 static int pmb_seq_show(struct seq_file *file, void *iter) 322 361 {