提交 c5cf5c53 编写于 作者: S Suman Anna 提交者: Joerg Roedel

iommu/omap: Fix bus error on debugfs access of unattached IOMMU

Any debugfs access on an OMAP IOMMU that is not enabled (done during
attach) results in a bus error due to access of registers without
the clock or the reset enabled for the respective IOMMU. So, add a
check to make sure the IOMMU is enabled/attached by a client device.
This gracefully prints a "Operation not permitted" trace when the
corresponding IOMMU is not enabled.
Signed-off-by: NSuman Anna <s-anna@ti.com>
Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 f24d9ad3
...@@ -24,6 +24,11 @@ static DEFINE_MUTEX(iommu_debug_lock); ...@@ -24,6 +24,11 @@ static DEFINE_MUTEX(iommu_debug_lock);
static struct dentry *iommu_debug_root; static struct dentry *iommu_debug_root;
static inline bool is_omap_iommu_detached(struct omap_iommu *obj)
{
return !obj->domain;
}
static ssize_t debug_read_regs(struct file *file, char __user *userbuf, static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
...@@ -31,6 +36,9 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf, ...@@ -31,6 +36,9 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
char *p, *buf; char *p, *buf;
ssize_t bytes; ssize_t bytes;
if (is_omap_iommu_detached(obj))
return -EPERM;
buf = kmalloc(count, GFP_KERNEL); buf = kmalloc(count, GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -54,6 +62,9 @@ static ssize_t debug_read_tlb(struct file *file, char __user *userbuf, ...@@ -54,6 +62,9 @@ static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
char *p, *buf; char *p, *buf;
ssize_t bytes, rest; ssize_t bytes, rest;
if (is_omap_iommu_detached(obj))
return -EPERM;
buf = kmalloc(count, GFP_KERNEL); buf = kmalloc(count, GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -139,6 +150,9 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf, ...@@ -139,6 +150,9 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
char *p, *buf; char *p, *buf;
size_t bytes; size_t bytes;
if (is_omap_iommu_detached(obj))
return -EPERM;
buf = (char *)__get_free_page(GFP_KERNEL); buf = (char *)__get_free_page(GFP_KERNEL);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册