Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 167162
b: refs/heads/master
c: fc2bdef
h: refs/heads/master
v: v3
  • Loading branch information
Matt Fleming authored and Paul Mundt committed Oct 9, 2009
1 parent 050e612 commit 9036f34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 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: a6325247f50628c7e53a483807d0ef2c24a7aa90
refs/heads/master: fc2bdefdde89b54d8fcde7bbf7d0adc0ce5cb044
30 changes: 24 additions & 6 deletions trunk/arch/sh/mm/pmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#define NR_PMB_ENTRIES 16

static void __pmb_unmap(struct pmb_entry *);

static struct kmem_cache *pmb_cache;
static unsigned long pmb_map;

Expand Down Expand Up @@ -218,9 +220,10 @@ static struct {
long pmb_remap(unsigned long vaddr, unsigned long phys,
unsigned long size, unsigned long flags)
{
struct pmb_entry *pmbp;
struct pmb_entry *pmbp, *pmbe;
unsigned long wanted;
int pmb_flags, i;
long err;

/* Convert typical pgprot value to the PMB equivalent */
if (flags & _PAGE_CACHABLE) {
Expand All @@ -236,20 +239,22 @@ long pmb_remap(unsigned long vaddr, unsigned long phys,

again:
for (i = 0; i < ARRAY_SIZE(pmb_sizes); i++) {
struct pmb_entry *pmbe;
int ret;

if (size < pmb_sizes[i].size)
continue;

pmbe = pmb_alloc(vaddr, phys, pmb_flags | pmb_sizes[i].flag);
if (IS_ERR(pmbe))
return PTR_ERR(pmbe);
if (IS_ERR(pmbe)) {
err = PTR_ERR(pmbe);
goto out;
}

ret = set_pmb_entry(pmbe);
if (ret != 0) {
pmb_free(pmbe);
return -EBUSY;
err = -EBUSY;
goto out;
}

phys += pmb_sizes[i].size;
Expand All @@ -270,6 +275,12 @@ long pmb_remap(unsigned long vaddr, unsigned long phys,
goto again;

return wanted - size;

out:
if (pmbp)
__pmb_unmap(pmbp);

return err;
}

void pmb_unmap(unsigned long addr)
Expand All @@ -283,12 +294,19 @@ void pmb_unmap(unsigned long addr)
if (unlikely(!pmbe))
return;

__pmb_unmap(pmbe);
}

static void __pmb_unmap(struct pmb_entry *pmbe)
{
WARN_ON(!test_bit(pmbe->entry, &pmb_map));

do {
struct pmb_entry *pmblink = pmbe;

clear_pmb_entry(pmbe);
if (pmbe->entry != PMB_NO_ENTRY)
clear_pmb_entry(pmbe);

pmbe = pmblink->link;

pmb_free(pmblink);
Expand Down

0 comments on commit 9036f34

Please sign in to comment.