Skip to content

Commit

Permalink
[PATCH] ppc64: msChunks cleanups
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Ellerman authored and Paul Mackerras committed Aug 29, 2005
1 parent 38e85dc commit 34c8f69
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
18 changes: 0 additions & 18 deletions arch/ppc64/kernel/LparData.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,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;
}
20 changes: 18 additions & 2 deletions arch/ppc64/kernel/iSeries_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,22 @@ static void __init iSeries_init_early(void)
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
Expand Down Expand Up @@ -452,7 +468,7 @@ static void __init build_iSeries_Memory_Map(void)

/* 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
Expand Down Expand Up @@ -498,7 +514,7 @@ static void __init build_iSeries_Memory_Map(void)
*/
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",
Expand Down
15 changes: 9 additions & 6 deletions include/asm-ppc64/abs_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 34c8f69

Please sign in to comment.