Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 186491
b: refs/heads/master
c: 6eb3c73
h: refs/heads/master
i:
  186489: 44e071b
  186487: 5a8544d
v: v3
  • Loading branch information
Paul Mundt committed Mar 2, 2010
1 parent a457532 commit 37dd864
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 47 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: 4cfa8e75d6854699597e21fd570721d63f899934
refs/heads/master: 6eb3c735d29e799810ce82118f9260d0044327b7
97 changes: 51 additions & 46 deletions trunk/arch/sh/mm/pmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,60 +270,19 @@ static void set_pmb_entry(struct pmb_entry *pmbe)

int pmb_bolt_mapping(unsigned long vaddr, phys_addr_t phys,
unsigned long size, pgprot_t prot)
{
return 0;
}

void __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size,
pgprot_t prot, void *caller)
{
struct pmb_entry *pmbp, *pmbe;
unsigned long pmb_flags;
int i, mapped;
unsigned long orig_addr, vaddr;
phys_addr_t offset, last_addr;
phys_addr_t align_mask;
unsigned long aligned;
struct vm_struct *area;

if (!pmb_iomapping_enabled)
return NULL;

/*
* Small mappings need to go through the TLB.
*/
if (size < SZ_16M)
return ERR_PTR(-EINVAL);
if (!pmb_prot_valid(prot))
return ERR_PTR(-EINVAL);
if (!pmb_addr_valid(vaddr, size))
return -EFAULT;

pmbp = NULL;
pmb_flags = pgprot_to_pmb_flags(prot);
mapped = 0;

for (i = 0; i < ARRAY_SIZE(pmb_sizes); i++)
if (size >= pmb_sizes[i].size)
break;

last_addr = phys + size;
align_mask = ~(pmb_sizes[i].size - 1);
offset = phys & ~align_mask;
phys &= align_mask;
aligned = ALIGN(last_addr, pmb_sizes[i].size) - phys;

area = __get_vm_area_caller(aligned, VM_IOREMAP, uncached_end,
P3SEG, caller);
if (!area)
return NULL;

area->phys_addr = phys;
orig_addr = vaddr = (unsigned long)area->addr;

if (!pmb_addr_valid(vaddr, aligned))
return ERR_PTR(-EFAULT);
pmbp = NULL;

again:
for (i = 0; i < ARRAY_SIZE(pmb_sizes); i++) {
for (i = mapped = 0; i < ARRAY_SIZE(pmb_sizes); i++) {
unsigned long flags;

if (size < pmb_sizes[i].size)
Expand All @@ -333,7 +292,7 @@ void __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size,
PMB_NO_ENTRY);
if (IS_ERR(pmbe)) {
pmb_unmap_entry(pmbp, mapped);
return pmbe;
return PTR_ERR(pmbe);
}

spin_lock_irqsave(&pmbe->lock, flags);
Expand Down Expand Up @@ -372,6 +331,52 @@ void __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size,
if (size >= SZ_16M)
goto again;

return 0;
}

void __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size,
pgprot_t prot, void *caller)
{
unsigned long orig_addr, vaddr;
phys_addr_t offset, last_addr;
phys_addr_t align_mask;
unsigned long aligned;
struct vm_struct *area;
int i, ret;

if (!pmb_iomapping_enabled)
return NULL;

/*
* Small mappings need to go through the TLB.
*/
if (size < SZ_16M)
return ERR_PTR(-EINVAL);
if (!pmb_prot_valid(prot))
return ERR_PTR(-EINVAL);

for (i = 0; i < ARRAY_SIZE(pmb_sizes); i++)
if (size >= pmb_sizes[i].size)
break;

last_addr = phys + size;
align_mask = ~(pmb_sizes[i].size - 1);
offset = phys & ~align_mask;
phys &= align_mask;
aligned = ALIGN(last_addr, pmb_sizes[i].size) - phys;

area = __get_vm_area_caller(aligned, VM_IOREMAP, uncached_end,
P3SEG, caller);
if (!area)
return NULL;

area->phys_addr = phys;
orig_addr = vaddr = (unsigned long)area->addr;

ret = pmb_bolt_mapping(vaddr, phys, size, prot);
if (ret != 0)
return ERR_PTR(ret);

return (void __iomem *)(offset + (char *)orig_addr);
}

Expand Down

0 comments on commit 37dd864

Please sign in to comment.