Skip to content

Commit c5df7f7

Browse files
herraa1glikely
authored andcommitted
powerpc: allow ioremap within reserved memory regions
Add a flag to let a platform ioremap memory regions marked as reserved. This flag will be used later by the Nintendo Wii support code to allow ioremapping the I/O region sitting between MEM1 and MEM2 and marked as reserved RAM in the patch "wii: use both mem1 and mem2 as ram". This will no longer be needed when proper discontig memory support for 32-bit PowerPC is added to the kernel. Signed-off-by: Albert Herranz <[email protected]> Acked-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: Grant Likely <[email protected]>
1 parent de32400 commit c5df7f7

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

arch/powerpc/mm/init_32.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ extern struct task_struct *current_set[NR_CPUS];
8282
int __map_without_bats;
8383
int __map_without_ltlbs;
8484

85+
/*
86+
* This tells the system to allow ioremapping memory marked as reserved.
87+
*/
88+
int __allow_ioremap_reserved;
89+
8590
/* max amount of low RAM to map in */
8691
unsigned long __max_low_memory = MAX_LOW_MEM;
8792

arch/powerpc/mm/mmu_decl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ extern void settlbcam(int index, unsigned long virt, phys_addr_t phys,
115115
extern void invalidate_tlbcam_entry(int index);
116116

117117
extern int __map_without_bats;
118+
extern int __allow_ioremap_reserved;
118119
extern unsigned long ioremap_base;
119120
extern unsigned int rtas_data, rtas_size;
120121

arch/powerpc/mm/pgtable_32.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/vmalloc.h>
2727
#include <linux/init.h>
2828
#include <linux/highmem.h>
29+
#include <linux/lmb.h>
2930

3031
#include <asm/pgtable.h>
3132
#include <asm/pgalloc.h>
@@ -191,7 +192,8 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags,
191192
* Don't allow anybody to remap normal RAM that we're using.
192193
* mem_init() sets high_memory so only do the check after that.
193194
*/
194-
if (mem_init_done && (p < virt_to_phys(high_memory))) {
195+
if (mem_init_done && (p < virt_to_phys(high_memory)) &&
196+
!(__allow_ioremap_reserved && lmb_is_region_reserved(p, size))) {
195197
printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n",
196198
(unsigned long long)p, __builtin_return_address(0));
197199
return NULL;

include/linux/lmb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern u64 __init lmb_phys_mem_size(void);
5454
extern u64 lmb_end_of_DRAM(void);
5555
extern void __init lmb_enforce_memory_limit(u64 memory_limit);
5656
extern int __init lmb_is_reserved(u64 addr);
57+
extern int lmb_is_region_reserved(u64 base, u64 size);
5758
extern int lmb_find(struct lmb_property *res);
5859

5960
extern void lmb_dump_all(void);

lib/lmb.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ long __init lmb_reserve(u64 base, u64 size)
263263
return lmb_add_region(_rgn, base, size);
264264
}
265265

266-
long __init lmb_overlaps_region(struct lmb_region *rgn, u64 base, u64 size)
266+
long lmb_overlaps_region(struct lmb_region *rgn, u64 base, u64 size)
267267
{
268268
unsigned long i;
269269

@@ -493,6 +493,11 @@ int __init lmb_is_reserved(u64 addr)
493493
return 0;
494494
}
495495

496+
int lmb_is_region_reserved(u64 base, u64 size)
497+
{
498+
return lmb_overlaps_region(&lmb.reserved, base, size);
499+
}
500+
496501
/*
497502
* Given a <base, len>, find which memory regions belong to this range.
498503
* Adjust the request and return a contiguous chunk.

0 commit comments

Comments
 (0)