Commit 19188f5a authored by Russell King's avatar Russell King

[ARM] Update ioremap implementation.

Use flush_cache_vmap() after creating mappings.  Also use BUG_ON()
rather than if() BUG().
parent cac923d2
...@@ -28,8 +28,9 @@ ...@@ -28,8 +28,9 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned long size, static inline void
unsigned long phys_addr, pgprot_t pgprot) remap_area_pte(pte_t * pte, unsigned long address, unsigned long size,
unsigned long phys_addr, pgprot_t pgprot)
{ {
unsigned long end; unsigned long end;
...@@ -37,22 +38,26 @@ static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned l ...@@ -37,22 +38,26 @@ static inline void remap_area_pte(pte_t * pte, unsigned long address, unsigned l
end = address + size; end = address + size;
if (end > PMD_SIZE) if (end > PMD_SIZE)
end = PMD_SIZE; end = PMD_SIZE;
if (address >= end) BUG_ON(address >= end);
BUG();
do { do {
if (!pte_none(*pte)) { if (!pte_none(*pte))
printk("remap_area_pte: page already exists\n"); goto bad;
BUG();
}
set_pte(pte, pfn_pte(phys_addr >> PAGE_SHIFT, pgprot)); set_pte(pte, pfn_pte(phys_addr >> PAGE_SHIFT, pgprot));
address += PAGE_SIZE; address += PAGE_SIZE;
phys_addr += PAGE_SIZE; phys_addr += PAGE_SIZE;
pte++; pte++;
} while (address && (address < end)); } while (address && (address < end));
return;
bad:
printk("remap_area_pte: page already exists\n");
BUG();
} }
static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size, static inline int
unsigned long phys_addr, unsigned long flags) remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned long size,
unsigned long phys_addr, unsigned long flags)
{ {
unsigned long end; unsigned long end;
pgprot_t pgprot; pgprot_t pgprot;
...@@ -64,8 +69,7 @@ static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned lo ...@@ -64,8 +69,7 @@ static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned lo
end = PGDIR_SIZE; end = PGDIR_SIZE;
phys_addr -= address; phys_addr -= address;
if (address >= end) BUG_ON(address >= end);
BUG();
pgprot = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_WRITE | flags); pgprot = __pgprot(L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY | L_PTE_WRITE | flags);
do { do {
...@@ -79,35 +83,38 @@ static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned lo ...@@ -79,35 +83,38 @@ static inline int remap_area_pmd(pmd_t * pmd, unsigned long address, unsigned lo
return 0; return 0;
} }
static int remap_area_pages(unsigned long address, unsigned long phys_addr, static int
unsigned long size, unsigned long flags) remap_area_pages(unsigned long start, unsigned long phys_addr,
unsigned long size, unsigned long flags)
{ {
int error; unsigned long address = start;
unsigned long end = start + size;
int err = 0;
pgd_t * dir; pgd_t * dir;
unsigned long end = address + size;
phys_addr -= address; phys_addr -= address;
dir = pgd_offset(&init_mm, address); dir = pgd_offset(&init_mm, address);
flush_cache_all(); BUG_ON(address >= end);
if (address >= end)
BUG();
spin_lock(&init_mm.page_table_lock); spin_lock(&init_mm.page_table_lock);
do { do {
pmd_t *pmd; pmd_t *pmd = pmd_alloc(&init_mm, dir, address);
pmd = pmd_alloc(&init_mm, dir, address); if (!pmd) {
error = -ENOMEM; err = -ENOMEM;
if (!pmd)
break; break;
}
if (remap_area_pmd(pmd, address, end - address, if (remap_area_pmd(pmd, address, end - address,
phys_addr + address, flags)) phys_addr + address, flags)) {
err = -ENOMEM;
break; break;
error = 0; }
address = (address + PGDIR_SIZE) & PGDIR_MASK; address = (address + PGDIR_SIZE) & PGDIR_MASK;
dir++; dir++;
} while (address && (address < end)); } while (address && (address < end));
spin_unlock(&init_mm.page_table_lock); spin_unlock(&init_mm.page_table_lock);
flush_tlb_all(); flush_cache_vmap(start, end);
return error; return err;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment