[PATCH] ppc64: msChunks cleanups

Chunks are 256KB, so use constants for the size/shift/mask, rather than
getting them from the msChunks struct. The iSeries debugger (??) might still
need access to the values in the msChunks struct, so we keep them around
for now, but set them from the constant values.

Replace msChunks_entry typedef with regular u32.

Simplify msChunks_alloc() to manipulate klimit directly, rather than via
a parameter.

Move msChunks_alloc() and msChunks into iSeries_setup.c, as that's where
they're used.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by

Michael Ellerman and committed by
Paul Mackerras
34c8f696 38e85dc1

+27 -26
-18
arch/ppc64/kernel/LparData.c
··· 225 0,0 226 } 227 }; 228 - 229 - struct msChunks msChunks; 230 - EXPORT_SYMBOL(msChunks); 231 - 232 - unsigned long 233 - msChunks_alloc(unsigned long mem, unsigned long num_chunks, unsigned long chunk_size) 234 - { 235 - _msChunks->num_chunks = num_chunks; 236 - _msChunks->chunk_size = chunk_size; 237 - _msChunks->chunk_shift = __ilog2(chunk_size); 238 - _msChunks->chunk_mask = (1UL<<_msChunks->chunk_shift)-1; 239 - 240 - mem = _ALIGN(mem, sizeof(msChunks_entry)); 241 - _msChunks->abs = (msChunks_entry *)mem; 242 - mem += num_chunks * sizeof(msChunks_entry); 243 - 244 - return mem; 245 - }
··· 225 0,0 226 } 227 };
+18 -2
arch/ppc64/kernel/iSeries_setup.c
··· 415 DBG(" <- iSeries_init_early()\n"); 416 } 417 418 /* 419 * The iSeries may have very large memories ( > 128 GB ) and a partition 420 * may get memory in "chunks" that may be anywhere in the 2**52 real ··· 468 469 /* Chunk size on iSeries is 256K bytes */ 470 totalChunks = (u32)HvLpConfig_getMsChunks(); 471 - klimit = msChunks_alloc(klimit, totalChunks, 1UL << 18); 472 473 /* 474 * Get absolute address of our load area ··· 514 */ 515 hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress()); 516 hptSizePages = (u32)HvCallHpt_getHptPages(); 517 - hptSizeChunks = hptSizePages >> (msChunks.chunk_shift - PAGE_SHIFT); 518 hptLastChunk = hptFirstChunk + hptSizeChunks - 1; 519 520 printk("HPT absolute addr = %016lx, size = %dK\n",
··· 415 DBG(" <- iSeries_init_early()\n"); 416 } 417 418 + struct msChunks msChunks = { 419 + /* XXX We don't use these, but Piranha might need them. */ 420 + .chunk_size = MSCHUNKS_CHUNK_SIZE, 421 + .chunk_shift = MSCHUNKS_CHUNK_SHIFT, 422 + .chunk_mask = MSCHUNKS_OFFSET_MASK, 423 + }; 424 + EXPORT_SYMBOL(msChunks); 425 + 426 + void msChunks_alloc(unsigned long num_chunks) 427 + { 428 + klimit = _ALIGN(klimit, sizeof(u32)); 429 + msChunks.abs = (u32 *)klimit; 430 + klimit += num_chunks * sizeof(u32); 431 + msChunks.num_chunks = num_chunks; 432 + } 433 + 434 /* 435 * The iSeries may have very large memories ( > 128 GB ) and a partition 436 * may get memory in "chunks" that may be anywhere in the 2**52 real ··· 452 453 /* Chunk size on iSeries is 256K bytes */ 454 totalChunks = (u32)HvLpConfig_getMsChunks(); 455 + msChunks_alloc(totalChunks); 456 457 /* 458 * Get absolute address of our load area ··· 498 */ 499 hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress()); 500 hptSizePages = (u32)HvCallHpt_getHptPages(); 501 + hptSizeChunks = hptSizePages >> (MSCHUNKS_CHUNK_SHIFT - PAGE_SHIFT); 502 hptLastChunk = hptFirstChunk + hptSizeChunks - 1; 503 504 printk("HPT absolute addr = %016lx, size = %dK\n",
+9 -6
include/asm-ppc64/abs_addr.h
··· 17 #include <asm/prom.h> 18 #include <asm/lmb.h> 19 20 - typedef u32 msChunks_entry; 21 struct msChunks { 22 unsigned long num_chunks; 23 unsigned long chunk_size; 24 unsigned long chunk_shift; 25 unsigned long chunk_mask; 26 - msChunks_entry *abs; 27 }; 28 29 extern struct msChunks msChunks; 30 31 - extern unsigned long msChunks_alloc(unsigned long, unsigned long, unsigned long); 32 33 #ifdef CONFIG_MSCHUNKS 34 35 static inline unsigned long chunk_to_addr(unsigned long chunk) 36 { 37 - return chunk << msChunks.chunk_shift; 38 } 39 40 static inline unsigned long addr_to_chunk(unsigned long addr) 41 { 42 - return addr >> msChunks.chunk_shift; 43 } 44 45 static inline unsigned long chunk_offset(unsigned long addr) 46 { 47 - return addr & msChunks.chunk_mask; 48 } 49 50 static inline unsigned long abs_chunk(unsigned long pchunk)
··· 17 #include <asm/prom.h> 18 #include <asm/lmb.h> 19 20 struct msChunks { 21 unsigned long num_chunks; 22 unsigned long chunk_size; 23 unsigned long chunk_shift; 24 unsigned long chunk_mask; 25 + u32 *abs; 26 }; 27 28 extern struct msChunks msChunks; 29 30 31 #ifdef CONFIG_MSCHUNKS 32 33 + /* Chunks are 256 KB */ 34 + #define MSCHUNKS_CHUNK_SHIFT (18) 35 + #define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT) 36 + #define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1) 37 + 38 static inline unsigned long chunk_to_addr(unsigned long chunk) 39 { 40 + return chunk << MSCHUNKS_CHUNK_SHIFT; 41 } 42 43 static inline unsigned long addr_to_chunk(unsigned long addr) 44 { 45 + return addr >> MSCHUNKS_CHUNK_SHIFT; 46 } 47 48 static inline unsigned long chunk_offset(unsigned long addr) 49 { 50 + return addr & MSCHUNKS_OFFSET_MASK; 51 } 52 53 static inline unsigned long abs_chunk(unsigned long pchunk)