diff options
author | Suman Anna <s-anna@ti.com> | 2014-10-22 18:22:34 -0400 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2014-10-23 08:33:48 -0400 |
commit | c5cf5c5377fbd0a1ff2a09ad1f0c7e261aabc567 (patch) | |
tree | ec305e6778337e821ca617e8b9286e86cec24d68 /drivers/iommu/omap-iommu-debug.c | |
parent | f24d9ad3fafd7c4ee47ec75947657d768873b6e4 (diff) |
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: Suman Anna <s-anna@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu/omap-iommu-debug.c')
-rw-r--r-- | drivers/iommu/omap-iommu-debug.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c index 4813d3a71a00..41b09a1d78ea 100644 --- a/drivers/iommu/omap-iommu-debug.c +++ b/drivers/iommu/omap-iommu-debug.c | |||
@@ -24,6 +24,11 @@ static DEFINE_MUTEX(iommu_debug_lock); | |||
24 | 24 | ||
25 | static struct dentry *iommu_debug_root; | 25 | static struct dentry *iommu_debug_root; |
26 | 26 | ||
27 | static inline bool is_omap_iommu_detached(struct omap_iommu *obj) | ||
28 | { | ||
29 | return !obj->domain; | ||
30 | } | ||
31 | |||
27 | static ssize_t debug_read_regs(struct file *file, char __user *userbuf, | 32 | static ssize_t debug_read_regs(struct file *file, char __user *userbuf, |
28 | size_t count, loff_t *ppos) | 33 | size_t count, loff_t *ppos) |
29 | { | 34 | { |
@@ -31,6 +36,9 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf, | |||
31 | char *p, *buf; | 36 | char *p, *buf; |
32 | ssize_t bytes; | 37 | ssize_t bytes; |
33 | 38 | ||
39 | if (is_omap_iommu_detached(obj)) | ||
40 | return -EPERM; | ||
41 | |||
34 | buf = kmalloc(count, GFP_KERNEL); | 42 | buf = kmalloc(count, GFP_KERNEL); |
35 | if (!buf) | 43 | if (!buf) |
36 | return -ENOMEM; | 44 | return -ENOMEM; |
@@ -54,6 +62,9 @@ static ssize_t debug_read_tlb(struct file *file, char __user *userbuf, | |||
54 | char *p, *buf; | 62 | char *p, *buf; |
55 | ssize_t bytes, rest; | 63 | ssize_t bytes, rest; |
56 | 64 | ||
65 | if (is_omap_iommu_detached(obj)) | ||
66 | return -EPERM; | ||
67 | |||
57 | buf = kmalloc(count, GFP_KERNEL); | 68 | buf = kmalloc(count, GFP_KERNEL); |
58 | if (!buf) | 69 | if (!buf) |
59 | return -ENOMEM; | 70 | return -ENOMEM; |
@@ -139,6 +150,9 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf, | |||
139 | char *p, *buf; | 150 | char *p, *buf; |
140 | size_t bytes; | 151 | size_t bytes; |
141 | 152 | ||
153 | if (is_omap_iommu_detached(obj)) | ||
154 | return -EPERM; | ||
155 | |||
142 | buf = (char *)__get_free_page(GFP_KERNEL); | 156 | buf = (char *)__get_free_page(GFP_KERNEL); |
143 | if (!buf) | 157 | if (!buf) |
144 | return -ENOMEM; | 158 | return -ENOMEM; |