zynq: only tmpmap() while splhi(), remove unneeded coherence() after tmpunmap(), splhi() in l2free()
we have to call tmpmap() with interrupts disabled as the map is a per cpu and a interrupt can preempt us while we where commited to use a entry but *before* we wrote it! tmpunmap() already calls coherence() before flushpg() so it is not needed after tmpunmap(). splhi() in l2free() isnt needed as l2free() is always called with interrupts disabled from mmuswitch() and mmurelease().
This commit is contained in:
parent
9b5387fbde
commit
ed5c9fd00a
1 changed files with 15 additions and 18 deletions
|
@ -100,13 +100,11 @@ upallocl1(void)
|
||||||
static void
|
static void
|
||||||
l2free(Proc *proc)
|
l2free(Proc *proc)
|
||||||
{
|
{
|
||||||
int s;
|
|
||||||
ulong *t;
|
ulong *t;
|
||||||
Page *p, **l;
|
Page *p, **l;
|
||||||
|
|
||||||
if(proc->l1 == nil || proc->mmuused == nil)
|
if(proc->l1 == nil || proc->mmuused == nil)
|
||||||
return;
|
return;
|
||||||
s = splhi();
|
|
||||||
l = &proc->mmuused;
|
l = &proc->mmuused;
|
||||||
for(p = *l; p != nil; p = p->next){
|
for(p = *l; p != nil; p = p->next){
|
||||||
t = proc->l1->va + p->daddr;
|
t = proc->l1->va + p->daddr;
|
||||||
|
@ -116,7 +114,6 @@ l2free(Proc *proc)
|
||||||
*t = 0;
|
*t = 0;
|
||||||
l = &p->next;
|
l = &p->next;
|
||||||
}
|
}
|
||||||
splx(s);
|
|
||||||
*l = proc->mmufree;
|
*l = proc->mmufree;
|
||||||
proc->mmufree = proc->mmuused;
|
proc->mmufree = proc->mmuused;
|
||||||
proc->mmuused = 0;
|
proc->mmuused = 0;
|
||||||
|
@ -143,6 +140,7 @@ putmmu(uintptr va, uintptr pa, Page *pg)
|
||||||
ulong *l2;
|
ulong *l2;
|
||||||
PTE old;
|
PTE old;
|
||||||
uintptr l2p;
|
uintptr l2p;
|
||||||
|
int s;
|
||||||
|
|
||||||
if(up->l1 == nil)
|
if(up->l1 == nil)
|
||||||
upallocl1();
|
upallocl1();
|
||||||
|
@ -150,11 +148,15 @@ putmmu(uintptr va, uintptr pa, Page *pg)
|
||||||
pa |= L2CACHED;
|
pa |= L2CACHED;
|
||||||
e = &up->l1->va[L1RX(va)];
|
e = &up->l1->va[L1RX(va)];
|
||||||
if((*e & 3) == 0){
|
if((*e & 3) == 0){
|
||||||
if(up->mmufree != nil){
|
p = up->mmufree;
|
||||||
p = up->mmufree;
|
if(p != nil)
|
||||||
up->mmufree = p->next;
|
up->mmufree = p->next;
|
||||||
}else
|
else
|
||||||
p = newpage(0, 0, 0);
|
p = newpage(0, 0, 0);
|
||||||
|
p->daddr = L1RX(va);
|
||||||
|
p->next = up->mmuused;
|
||||||
|
up->mmuused = p;
|
||||||
|
s = splhi();
|
||||||
l2p = p->pa;
|
l2p = p->pa;
|
||||||
l2 = tmpmap(l2p);
|
l2 = tmpmap(l2p);
|
||||||
memset(l2, 0, BY2PG);
|
memset(l2, 0, BY2PG);
|
||||||
|
@ -164,10 +166,8 @@ putmmu(uintptr va, uintptr pa, Page *pg)
|
||||||
e[2] = e[1] + L2SZ;
|
e[2] = e[1] + L2SZ;
|
||||||
e[3] = e[2] + L2SZ;
|
e[3] = e[2] + L2SZ;
|
||||||
coherence();
|
coherence();
|
||||||
p->daddr = L1RX(va);
|
|
||||||
p->next = up->mmuused;
|
|
||||||
up->mmuused = p;
|
|
||||||
}else{
|
}else{
|
||||||
|
s = splhi();
|
||||||
l2p = *e & ~(BY2PG - 1);
|
l2p = *e & ~(BY2PG - 1);
|
||||||
l2 = tmpmap(l2p);
|
l2 = tmpmap(l2p);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ putmmu(uintptr va, uintptr pa, Page *pg)
|
||||||
old = *e;
|
old = *e;
|
||||||
*e = pa | L2VALID | L2USER | L2LOCAL;
|
*e = pa | L2VALID | L2USER | L2LOCAL;
|
||||||
tmpunmap(l2);
|
tmpunmap(l2);
|
||||||
coherence();
|
splx(s);
|
||||||
if((old & L2VALID) != 0)
|
if((old & L2VALID) != 0)
|
||||||
flushpg((void *) va);
|
flushpg((void *) va);
|
||||||
if(pg->cachectl[0] == PG_TXTFLUSH){
|
if(pg->cachectl[0] == PG_TXTFLUSH){
|
||||||
|
@ -274,8 +274,7 @@ KMap *
|
||||||
kmap(Page *page)
|
kmap(Page *page)
|
||||||
{
|
{
|
||||||
ulong *e, *v;
|
ulong *e, *v;
|
||||||
int i;
|
int i, s;
|
||||||
ulong s;
|
|
||||||
|
|
||||||
if(up == nil)
|
if(up == nil)
|
||||||
panic("kmap: up=0 pc=%#.8lux", getcallerpc(&page));
|
panic("kmap: up=0 pc=%#.8lux", getcallerpc(&page));
|
||||||
|
@ -283,23 +282,20 @@ kmap(Page *page)
|
||||||
upallocl1();
|
upallocl1();
|
||||||
if(up->nkmap < 0)
|
if(up->nkmap < 0)
|
||||||
panic("kmap %lud %s: nkmap=%d", up->pid, up->text, up->nkmap);
|
panic("kmap %lud %s: nkmap=%d", up->pid, up->text, up->nkmap);
|
||||||
s = splhi();
|
|
||||||
up->nkmap++;
|
up->nkmap++;
|
||||||
e = &up->l1->va[L1X(KMAP)];
|
e = &up->l1->va[L1X(KMAP)];
|
||||||
if((*e & 3) == 0){
|
if((*e & 3) == 0){
|
||||||
if(up->kmaptable != nil)
|
if(up->kmaptable != nil)
|
||||||
panic("kmaptable");
|
panic("kmaptable");
|
||||||
spllo();
|
|
||||||
up->kmaptable = newpage(0, 0, 0);
|
up->kmaptable = newpage(0, 0, 0);
|
||||||
splhi();
|
s = splhi();
|
||||||
v = tmpmap(up->kmaptable->pa);
|
v = tmpmap(up->kmaptable->pa);
|
||||||
memset(v, 0, BY2PG);
|
memset(v, 0, BY2PG);
|
||||||
v[0] = page->pa | L2KERRW | L2VALID | L2CACHED | L2LOCAL;
|
v[0] = page->pa | L2KERRW | L2VALID | L2CACHED | L2LOCAL;
|
||||||
v[NKMAP] = up->kmaptable->pa | L2KERRW | L2VALID | L2CACHED | L2LOCAL;
|
v[NKMAP] = up->kmaptable->pa | L2KERRW | L2VALID | L2CACHED | L2LOCAL;
|
||||||
tmpunmap(v);
|
tmpunmap(v);
|
||||||
coherence();
|
|
||||||
*e = up->kmaptable->pa | L1PT;
|
|
||||||
splx(s);
|
splx(s);
|
||||||
|
*e = up->kmaptable->pa | L1PT;
|
||||||
coherence();
|
coherence();
|
||||||
return (KMap *) KMAP;
|
return (KMap *) KMAP;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +305,6 @@ kmap(Page *page)
|
||||||
for(i = 0; i < NKMAP; i++)
|
for(i = 0; i < NKMAP; i++)
|
||||||
if((e[i] & 3) == 0){
|
if((e[i] & 3) == 0){
|
||||||
e[i] = page->pa | L2KERRW | L2VALID | L2CACHED | L2LOCAL;
|
e[i] = page->pa | L2KERRW | L2VALID | L2CACHED | L2LOCAL;
|
||||||
splx(s);
|
|
||||||
coherence();
|
coherence();
|
||||||
return (KMap *) (KMAP + i * BY2PG);
|
return (KMap *) (KMAP + i * BY2PG);
|
||||||
}
|
}
|
||||||
|
@ -345,6 +340,8 @@ tmpmap(ulong pa)
|
||||||
ulong *u, *ub, *ue;
|
ulong *u, *ub, *ue;
|
||||||
void *v;
|
void *v;
|
||||||
|
|
||||||
|
if(islo())
|
||||||
|
panic("tmpmap: islow %#p", getcallerpc(&pa));
|
||||||
if(cankaddr(pa))
|
if(cankaddr(pa))
|
||||||
return KADDR(pa);
|
return KADDR(pa);
|
||||||
ub = (ulong *) TMAPL2(m->machno);
|
ub = (ulong *) TMAPL2(m->machno);
|
||||||
|
|
Loading…
Reference in a new issue