Commit d5a74afd authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'iommu-fixes-v3.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

IOMMU fixes for Linux 3.3-rc5

All the fixes are for the OMAP IOMMU driver. The first patch is the
biggest one. It fixes the calls of the function omap_find_iovm_area() in
the omap-iommu-debug module which expects a 'struct device' parameter
since commit fabdbca8 instead of an omap_iommu handle. The
omap-iommu-debug code still passed the handle to the function which
caused a crash.

The second patch fixes a NULL pointer dereference in the OMAP code and
the third patch makes sure that the omap-iommu is initialized before the
omap-isp driver, which relies on the iommu. The last patch is only a
workaround until defered probing is implemented.

* tag 'iommu-fixes-v3.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  ARM: OMAP: make iommu subsys_initcall to fix builtin omap3isp
  iommu/omap: fix NULL pointer dereference
  iommu/omap: fix erroneous omap-iommu-debug API calls
parents 586c6e70 435792d9
...@@ -412,7 +412,8 @@ static void __exit omap2_mbox_exit(void) ...@@ -412,7 +412,8 @@ static void __exit omap2_mbox_exit(void)
platform_driver_unregister(&omap2_mbox_driver); platform_driver_unregister(&omap2_mbox_driver);
} }
module_init(omap2_mbox_init); /* must be ready before omap3isp is probed */
subsys_initcall(omap2_mbox_init);
module_exit(omap2_mbox_exit); module_exit(omap2_mbox_exit);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
......
...@@ -44,7 +44,8 @@ static ssize_t debug_read_ver(struct file *file, char __user *userbuf, ...@@ -44,7 +44,8 @@ static ssize_t debug_read_ver(struct file *file, char __user *userbuf,
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)
{ {
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
struct omap_iommu *obj = dev_to_omap_iommu(dev);
char *p, *buf; char *p, *buf;
ssize_t bytes; ssize_t bytes;
...@@ -67,7 +68,8 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf, ...@@ -67,7 +68,8 @@ static ssize_t debug_read_regs(struct file *file, char __user *userbuf,
static ssize_t debug_read_tlb(struct file *file, char __user *userbuf, static ssize_t debug_read_tlb(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
struct omap_iommu *obj = dev_to_omap_iommu(dev);
char *p, *buf; char *p, *buf;
ssize_t bytes, rest; ssize_t bytes, rest;
...@@ -97,7 +99,8 @@ static ssize_t debug_write_pagetable(struct file *file, ...@@ -97,7 +99,8 @@ static ssize_t debug_write_pagetable(struct file *file,
struct iotlb_entry e; struct iotlb_entry e;
struct cr_regs cr; struct cr_regs cr;
int err; int err;
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
struct omap_iommu *obj = dev_to_omap_iommu(dev);
char buf[MAXCOLUMN], *p = buf; char buf[MAXCOLUMN], *p = buf;
count = min(count, sizeof(buf)); count = min(count, sizeof(buf));
...@@ -184,7 +187,8 @@ static ssize_t dump_ioptable(struct omap_iommu *obj, char *buf, ssize_t len) ...@@ -184,7 +187,8 @@ static ssize_t dump_ioptable(struct omap_iommu *obj, char *buf, ssize_t len)
static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf, static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
struct omap_iommu *obj = dev_to_omap_iommu(dev);
char *p, *buf; char *p, *buf;
size_t bytes; size_t bytes;
...@@ -212,7 +216,8 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf, ...@@ -212,7 +216,8 @@ static ssize_t debug_read_pagetable(struct file *file, char __user *userbuf,
static ssize_t debug_read_mmap(struct file *file, char __user *userbuf, static ssize_t debug_read_mmap(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
struct omap_iommu *obj = dev_to_omap_iommu(dev);
char *p, *buf; char *p, *buf;
struct iovm_struct *tmp; struct iovm_struct *tmp;
int uninitialized_var(i); int uninitialized_var(i);
...@@ -254,7 +259,7 @@ static ssize_t debug_read_mmap(struct file *file, char __user *userbuf, ...@@ -254,7 +259,7 @@ static ssize_t debug_read_mmap(struct file *file, char __user *userbuf,
static ssize_t debug_read_mem(struct file *file, char __user *userbuf, static ssize_t debug_read_mem(struct file *file, char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
char *p, *buf; char *p, *buf;
struct iovm_struct *area; struct iovm_struct *area;
ssize_t bytes; ssize_t bytes;
...@@ -268,8 +273,8 @@ static ssize_t debug_read_mem(struct file *file, char __user *userbuf, ...@@ -268,8 +273,8 @@ static ssize_t debug_read_mem(struct file *file, char __user *userbuf,
mutex_lock(&iommu_debug_lock); mutex_lock(&iommu_debug_lock);
area = omap_find_iovm_area(obj, (u32)ppos); area = omap_find_iovm_area(dev, (u32)ppos);
if (IS_ERR(area)) { if (!area) {
bytes = -EINVAL; bytes = -EINVAL;
goto err_out; goto err_out;
} }
...@@ -287,7 +292,7 @@ static ssize_t debug_read_mem(struct file *file, char __user *userbuf, ...@@ -287,7 +292,7 @@ static ssize_t debug_read_mem(struct file *file, char __user *userbuf,
static ssize_t debug_write_mem(struct file *file, const char __user *userbuf, static ssize_t debug_write_mem(struct file *file, const char __user *userbuf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct omap_iommu *obj = file->private_data; struct device *dev = file->private_data;
struct iovm_struct *area; struct iovm_struct *area;
char *p, *buf; char *p, *buf;
...@@ -305,8 +310,8 @@ static ssize_t debug_write_mem(struct file *file, const char __user *userbuf, ...@@ -305,8 +310,8 @@ static ssize_t debug_write_mem(struct file *file, const char __user *userbuf,
goto err_out; goto err_out;
} }
area = omap_find_iovm_area(obj, (u32)ppos); area = omap_find_iovm_area(dev, (u32)ppos);
if (IS_ERR(area)) { if (!area) {
count = -EINVAL; count = -EINVAL;
goto err_out; goto err_out;
} }
...@@ -350,7 +355,7 @@ DEBUG_FOPS(mem); ...@@ -350,7 +355,7 @@ DEBUG_FOPS(mem);
{ \ { \
struct dentry *dent; \ struct dentry *dent; \
dent = debugfs_create_file(#attr, mode, parent, \ dent = debugfs_create_file(#attr, mode, parent, \
obj, &debug_##attr##_fops); \ dev, &debug_##attr##_fops); \
if (!dent) \ if (!dent) \
return -ENOMEM; \ return -ENOMEM; \
} }
...@@ -362,20 +367,29 @@ static int iommu_debug_register(struct device *dev, void *data) ...@@ -362,20 +367,29 @@ static int iommu_debug_register(struct device *dev, void *data)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct omap_iommu *obj = platform_get_drvdata(pdev); struct omap_iommu *obj = platform_get_drvdata(pdev);
struct omap_iommu_arch_data *arch_data;
struct dentry *d, *parent; struct dentry *d, *parent;
if (!obj || !obj->dev) if (!obj || !obj->dev)
return -EINVAL; return -EINVAL;
arch_data = kzalloc(sizeof(*arch_data), GFP_KERNEL);
if (!arch_data)
return -ENOMEM;
arch_data->iommu_dev = obj;
dev->archdata.iommu = arch_data;
d = debugfs_create_dir(obj->name, iommu_debug_root); d = debugfs_create_dir(obj->name, iommu_debug_root);
if (!d) if (!d)
return -ENOMEM; goto nomem;
parent = d; parent = d;
d = debugfs_create_u8("nr_tlb_entries", 400, parent, d = debugfs_create_u8("nr_tlb_entries", 400, parent,
(u8 *)&obj->nr_tlb_entries); (u8 *)&obj->nr_tlb_entries);
if (!d) if (!d)
return -ENOMEM; goto nomem;
DEBUG_ADD_FILE_RO(ver); DEBUG_ADD_FILE_RO(ver);
DEBUG_ADD_FILE_RO(regs); DEBUG_ADD_FILE_RO(regs);
...@@ -384,6 +398,22 @@ static int iommu_debug_register(struct device *dev, void *data) ...@@ -384,6 +398,22 @@ static int iommu_debug_register(struct device *dev, void *data)
DEBUG_ADD_FILE_RO(mmap); DEBUG_ADD_FILE_RO(mmap);
DEBUG_ADD_FILE(mem); DEBUG_ADD_FILE(mem);
return 0;
nomem:
kfree(arch_data);
return -ENOMEM;
}
static int iommu_debug_unregister(struct device *dev, void *data)
{
if (!dev->archdata.iommu)
return 0;
kfree(dev->archdata.iommu);
dev->archdata.iommu = NULL;
return 0; return 0;
} }
...@@ -411,6 +441,7 @@ module_init(iommu_debug_init) ...@@ -411,6 +441,7 @@ module_init(iommu_debug_init)
static void __exit iommu_debugfs_exit(void) static void __exit iommu_debugfs_exit(void)
{ {
debugfs_remove_recursive(iommu_debug_root); debugfs_remove_recursive(iommu_debug_root);
omap_foreach_iommu_device(NULL, iommu_debug_unregister);
} }
module_exit(iommu_debugfs_exit) module_exit(iommu_debugfs_exit)
......
...@@ -1223,7 +1223,8 @@ static int __init omap_iommu_init(void) ...@@ -1223,7 +1223,8 @@ static int __init omap_iommu_init(void)
return platform_driver_register(&omap_iommu_driver); return platform_driver_register(&omap_iommu_driver);
} }
module_init(omap_iommu_init); /* must be ready before omap3isp is probed */
subsys_initcall(omap_iommu_init);
static void __exit omap_iommu_exit(void) static void __exit omap_iommu_exit(void)
{ {
......
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