Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 274227
b: refs/heads/master
c: 1dc91c3
h: refs/heads/master
i:
  274225: 76577c9
  274223: 18229ed
v: v3
  • Loading branch information
Kumar Gala committed Oct 12, 2011
1 parent 2a8e4d8 commit c576e6e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba14f6491768acad5cf50a3c7dc8927b7614d692
refs/heads/master: 1dc91c3eb374ca01ec99dc0ca2a38babc509beb3
31 changes: 19 additions & 12 deletions trunk/arch/powerpc/mm/fsl_booke_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,29 +146,36 @@ static void settlbcam(int index, unsigned long virt, phys_addr_t phys,
loadcam_entry(index);
}

unsigned long calc_cam_sz(unsigned long ram, unsigned long virt,
phys_addr_t phys)
{
unsigned int camsize = __ilog2(ram) & ~1U;
unsigned int align = __ffs(virt | phys) & ~1U;
unsigned long max_cam = (mfspr(SPRN_TLB1CFG) >> 16) & 0xf;

/* Convert (4^max) kB to (2^max) bytes */
max_cam = max_cam * 2 + 10;

if (camsize > align)
camsize = align;
if (camsize > max_cam)
camsize = max_cam;

return 1UL << camsize;
}

unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx)
{
int i;
unsigned long virt = PAGE_OFFSET;
phys_addr_t phys = memstart_addr;
unsigned long amount_mapped = 0;
unsigned long max_cam = (mfspr(SPRN_TLB1CFG) >> 16) & 0xf;

/* Convert (4^max) kB to (2^max) bytes */
max_cam = max_cam * 2 + 10;

/* Calculate CAM values */
for (i = 0; ram && i < max_cam_idx; i++) {
unsigned int camsize = __ilog2(ram) & ~1U;
unsigned int align = __ffs(virt | phys) & ~1U;
unsigned long cam_sz;

if (camsize > align)
camsize = align;
if (camsize > max_cam)
camsize = max_cam;

cam_sz = 1UL << camsize;
cam_sz = calc_cam_sz(ram, virt, phys);
settlbcam(i, virt, phys, cam_sz, PAGE_KERNEL_X, 0);

ram -= cam_sz;
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/powerpc/mm/mmu_decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ extern unsigned long mmu_mapin_ram(unsigned long top);

#elif defined(CONFIG_PPC_FSL_BOOK3E)
extern unsigned long map_mem_in_cams(unsigned long ram, int max_cam_idx);
extern unsigned long calc_cam_sz(unsigned long ram, unsigned long virt,
phys_addr_t phys);
#ifdef CONFIG_PPC32
extern void MMU_init_hw(void);
extern unsigned long mmu_mapin_ram(unsigned long top);
Expand Down
21 changes: 18 additions & 3 deletions trunk/arch/powerpc/mm/tlb_nohash.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,28 @@ void __cpuinit early_init_mmu_secondary(void)
void setup_initial_memory_limit(phys_addr_t first_memblock_base,
phys_addr_t first_memblock_size)
{
/* On Embedded 64-bit, we adjust the RMA size to match
/* On non-FSL Embedded 64-bit, we adjust the RMA size to match
* the bolted TLB entry. We know for now that only 1G
* entries are supported though that may eventually
* change. We crop it to the size of the first MEMBLOCK to
* change.
*
* on FSL Embedded 64-bit, we adjust the RMA size to match the
* first bolted TLB entry size. We still limit max to 1G even if
* the TLB could cover more. This is due to what the early init
* code is setup to do.
*
* We crop it to the size of the first MEMBLOCK to
* avoid going over total available memory just in case...
*/
ppc64_rma_size = min_t(u64, first_memblock_size, 0x40000000);
#ifdef CONFIG_PPC_FSL_BOOK3E
if (mmu_has_feature(MMU_FTR_TYPE_FSL_E)) {
unsigned long linear_sz;
linear_sz = calc_cam_sz(first_memblock_size, PAGE_OFFSET,
first_memblock_base);
ppc64_rma_size = min_t(u64, linear_sz, 0x40000000);
} else
#endif
ppc64_rma_size = min_t(u64, first_memblock_size, 0x40000000);

/* Finally limit subsequent allocations */
memblock_set_current_limit(first_memblock_base + ppc64_rma_size);
Expand Down

0 comments on commit c576e6e

Please sign in to comment.