[PATCH 2/10] ppc64: msChunks cleanups
Michael Ellerman
michael at ellerman.id.au
Wed Aug 3 20:21:23 EST 2005
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 at ellerman.id.au>
arch/ppc64/kernel/LparData.c | 18 ------------------
arch/ppc64/kernel/iSeries_setup.c | 20 ++++++++++++++++++--
include/asm-ppc64/abs_addr.h | 15 +++++++++------
3 files changed, 27 insertions(+), 26 deletions(-)
Index: work/include/asm-ppc64/abs_addr.h
===================================================================
--- work.orig/include/asm-ppc64/abs_addr.h
+++ work/include/asm-ppc64/abs_addr.h
@@ -17,34 +17,37 @@
#include <asm/prom.h>
#include <asm/lmb.h>
-typedef u32 msChunks_entry;
struct msChunks {
unsigned long num_chunks;
unsigned long chunk_size;
unsigned long chunk_shift;
unsigned long chunk_mask;
- msChunks_entry *abs;
+ u32 *abs;
};
extern struct msChunks msChunks;
-extern unsigned long msChunks_alloc(unsigned long, unsigned long, unsigned long);
#ifdef CONFIG_MSCHUNKS
+/* Chunks are 256 KB */
+#define MSCHUNKS_CHUNK_SHIFT (18)
+#define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT)
+#define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1)
+
static inline unsigned long chunk_to_addr(unsigned long chunk)
{
- return chunk << msChunks.chunk_shift;
+ return chunk << MSCHUNKS_CHUNK_SHIFT;
}
static inline unsigned long addr_to_chunk(unsigned long addr)
{
- return addr >> msChunks.chunk_shift;
+ return addr >> MSCHUNKS_CHUNK_SHIFT;
}
static inline unsigned long chunk_offset(unsigned long addr)
{
- return addr & msChunks.chunk_mask;
+ return addr & MSCHUNKS_OFFSET_MASK;
}
static inline unsigned long abs_chunk(unsigned long pchunk)
Index: work/arch/ppc64/kernel/iSeries_setup.c
===================================================================
--- work.orig/arch/ppc64/kernel/iSeries_setup.c
+++ work/arch/ppc64/kernel/iSeries_setup.c
@@ -412,6 +412,22 @@ static void __init iSeries_init_early(vo
DBG(" <- iSeries_init_early()\n");
}
+struct msChunks msChunks = {
+ /* XXX We don't use these, but Piranha might need them. */
+ .chunk_size = MSCHUNKS_CHUNK_SIZE,
+ .chunk_shift = MSCHUNKS_CHUNK_SHIFT,
+ .chunk_mask = MSCHUNKS_OFFSET_MASK,
+};
+EXPORT_SYMBOL(msChunks);
+
+void msChunks_alloc(unsigned long num_chunks)
+{
+ klimit = _ALIGN(klimit, sizeof(u32));
+ msChunks.abs = (u32 *)klimit;
+ klimit += num_chunks * sizeof(u32);
+ msChunks.num_chunks = num_chunks;
+}
+
/*
* The iSeries may have very large memories ( > 128 GB ) and a partition
* may get memory in "chunks" that may be anywhere in the 2**52 real
@@ -449,7 +465,7 @@ static void __init build_iSeries_Memory_
/* Chunk size on iSeries is 256K bytes */
totalChunks = (u32)HvLpConfig_getMsChunks();
- klimit = msChunks_alloc(klimit, totalChunks, 1UL << 18);
+ msChunks_alloc(totalChunks);
/*
* Get absolute address of our load area
@@ -495,7 +511,7 @@ static void __init build_iSeries_Memory_
*/
hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress());
hptSizePages = (u32)HvCallHpt_getHptPages();
- hptSizeChunks = hptSizePages >> (msChunks.chunk_shift - PAGE_SHIFT);
+ hptSizeChunks = hptSizePages >> (MSCHUNKS_CHUNK_SHIFT - PAGE_SHIFT);
hptLastChunk = hptFirstChunk + hptSizeChunks - 1;
printk("HPT absolute addr = %016lx, size = %dK\n",
Index: work/arch/ppc64/kernel/LparData.c
===================================================================
--- work.orig/arch/ppc64/kernel/LparData.c
+++ work/arch/ppc64/kernel/LparData.c
@@ -291,21 +291,3 @@ struct ItVpdAreas itVpdAreas = {
0,0
}
};
-
-struct msChunks msChunks;
-EXPORT_SYMBOL(msChunks);
-
-unsigned long
-msChunks_alloc(unsigned long mem, unsigned long num_chunks, unsigned long chunk_size)
-{
- _msChunks->num_chunks = num_chunks;
- _msChunks->chunk_size = chunk_size;
- _msChunks->chunk_shift = __ilog2(chunk_size);
- _msChunks->chunk_mask = (1UL<<_msChunks->chunk_shift)-1;
-
- mem = _ALIGN(mem, sizeof(msChunks_entry));
- _msChunks->abs = (msChunks_entry *)mem;
- mem += num_chunks * sizeof(msChunks_entry);
-
- return mem;
-}
More information about the Linuxppc64-dev
mailing list