Commit be6d8026 authored by Kanigeri, Hari's avatar Kanigeri, Hari Committed by Hiroshi DOYU

omap iommu: add TLB preservation support

This patch adds TLB preservation support to IOMMU module
Signed-off-by: default avatarHari Kanigeri <h-kanigeri2@ti.com>
Signed-off-by: default avatarHiroshi DOYU <Hiroshi.DOYU@nokia.com>
parent 77bc5abb
...@@ -147,6 +147,7 @@ static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra) ...@@ -147,6 +147,7 @@ static u32 omap2_iommu_fault_isr(struct iommu *obj, u32 *ra)
printk("\n"); printk("\n");
iommu_write_reg(obj, stat, MMU_IRQSTATUS); iommu_write_reg(obj, stat, MMU_IRQSTATUS);
omap2_iommu_disable(obj);
return stat; return stat;
} }
...@@ -212,7 +213,8 @@ static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf) ...@@ -212,7 +213,8 @@ static ssize_t omap2_dump_cr(struct iommu *obj, struct cr_regs *cr, char *buf)
char *p = buf; char *p = buf;
/* FIXME: Need more detail analysis of cam/ram */ /* FIXME: Need more detail analysis of cam/ram */
p += sprintf(p, "%08x %08x\n", cr->cam, cr->ram); p += sprintf(p, "%08x %08x %01x\n", cr->cam, cr->ram,
(cr->cam & MMU_CAM_P) ? 1 : 0);
return p - buf; return p - buf;
} }
......
...@@ -172,15 +172,12 @@ static void iotlb_lock_get(struct iommu *obj, struct iotlb_lock *l) ...@@ -172,15 +172,12 @@ static void iotlb_lock_get(struct iommu *obj, struct iotlb_lock *l)
l->base = MMU_LOCK_BASE(val); l->base = MMU_LOCK_BASE(val);
l->vict = MMU_LOCK_VICT(val); l->vict = MMU_LOCK_VICT(val);
BUG_ON(l->base != 0); /* Currently no preservation is used */
} }
static void iotlb_lock_set(struct iommu *obj, struct iotlb_lock *l) static void iotlb_lock_set(struct iommu *obj, struct iotlb_lock *l)
{ {
u32 val; u32 val;
BUG_ON(l->base != 0); /* Currently no preservation is used */
val = (l->base << MMU_LOCK_BASE_SHIFT); val = (l->base << MMU_LOCK_BASE_SHIFT);
val |= (l->vict << MMU_LOCK_VICT_SHIFT); val |= (l->vict << MMU_LOCK_VICT_SHIFT);
...@@ -231,7 +228,14 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e) ...@@ -231,7 +228,14 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
clk_enable(obj->clk); clk_enable(obj->clk);
for (i = 0; i < obj->nr_tlb_entries; i++) { iotlb_lock_get(obj, &l);
if (l.base == obj->nr_tlb_entries) {
dev_warn(obj->dev, "%s: preserve entries full\n", __func__);
err = -EBUSY;
goto out;
}
if (!e->prsvd) {
for (i = l.base; i < obj->nr_tlb_entries; i++) {
struct cr_regs tmp; struct cr_regs tmp;
iotlb_lock_get(obj, &l); iotlb_lock_get(obj, &l);
...@@ -241,12 +245,15 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e) ...@@ -241,12 +245,15 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
if (!iotlb_cr_valid(&tmp)) if (!iotlb_cr_valid(&tmp))
break; break;
} }
if (i == obj->nr_tlb_entries) { if (i == obj->nr_tlb_entries) {
dev_dbg(obj->dev, "%s: full: no entry\n", __func__); dev_dbg(obj->dev, "%s: full: no entry\n", __func__);
err = -EBUSY; err = -EBUSY;
goto out; goto out;
} }
} else {
l.vict = l.base;
iotlb_lock_set(obj, &l);
}
cr = iotlb_alloc_cr(obj, e); cr = iotlb_alloc_cr(obj, e);
if (IS_ERR(cr)) { if (IS_ERR(cr)) {
...@@ -257,9 +264,11 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e) ...@@ -257,9 +264,11 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e)
iotlb_load_cr(obj, cr); iotlb_load_cr(obj, cr);
kfree(cr); kfree(cr);
if (e->prsvd)
l.base++;
/* increment victim for next tlb load */ /* increment victim for next tlb load */
if (++l.vict == obj->nr_tlb_entries) if (++l.vict == obj->nr_tlb_entries)
l.vict = 0; l.vict = l.base;
iotlb_lock_set(obj, &l); iotlb_lock_set(obj, &l);
out: out:
clk_disable(obj->clk); clk_disable(obj->clk);
......
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