* [PATCH 1/4] omap iommu: Check existence of arch_iommu
[not found] <4D8CB106.7030608@maxwell.research.nokia.com>
@ 2011-03-25 15:13 ` Sakari Ailus
2011-03-25 15:19 ` Sakari Ailus
2011-03-25 19:07 ` Hiremath, Vaibhav
2011-03-25 15:13 ` [PATCH 2/4] omap iommu: Add module information to struct iommu_functions Sakari Ailus
` (2 subsequent siblings)
3 siblings, 2 replies; 7+ messages in thread
From: Sakari Ailus @ 2011-03-25 15:13 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, david.cohen, hiroshi.doyu
Check that the arch_iommu has been installed before trying to use it. This
will lead to kernel oops if the arch_iommu isn't there.
Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
---
arch/arm/plat-omap/iommu.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index b1107c0..f0fea0b 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -104,6 +104,9 @@ static int iommu_enable(struct iommu *obj)
if (!obj)
return -EINVAL;
+ if (!arch_iommu)
+ return -ENOENT;
+
clk_enable(obj->clk);
err = arch_iommu->enable(obj);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] omap iommu: Add module information to struct iommu_functions
[not found] <4D8CB106.7030608@maxwell.research.nokia.com>
2011-03-25 15:13 ` [PATCH 1/4] omap iommu: Check existence of arch_iommu Sakari Ailus
@ 2011-03-25 15:13 ` Sakari Ailus
2011-03-25 15:13 ` [PATCH 3/4] omap2 iommu: Set module information in omap2_iommu_ops Sakari Ailus
2011-03-25 15:13 ` [PATCH 4/4] omap iommu: Prevent iommu implementations from being unloaded while in use Sakari Ailus
3 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2011-03-25 15:13 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, david.cohen, hiroshi.doyu
Whichever module that implements the struct, may not be unloaded while it's
in use. Prepare to this by adding module reference to the structure.
Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
---
arch/arm/plat-omap/include/plat/iommu.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/arch/arm/plat-omap/include/plat/iommu.h b/arch/arm/plat-omap/include/plat/iommu.h
index 69230d6..26fefb4 100644
--- a/arch/arm/plat-omap/include/plat/iommu.h
+++ b/arch/arm/plat-omap/include/plat/iommu.h
@@ -79,6 +79,7 @@ struct iotlb_lock {
/* architecture specific functions */
struct iommu_functions {
unsigned long version;
+ struct module *module;
int (*enable)(struct iommu *obj);
void (*disable)(struct iommu *obj);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] omap2 iommu: Set module information in omap2_iommu_ops
[not found] <4D8CB106.7030608@maxwell.research.nokia.com>
2011-03-25 15:13 ` [PATCH 1/4] omap iommu: Check existence of arch_iommu Sakari Ailus
2011-03-25 15:13 ` [PATCH 2/4] omap iommu: Add module information to struct iommu_functions Sakari Ailus
@ 2011-03-25 15:13 ` Sakari Ailus
2011-03-25 15:13 ` [PATCH 4/4] omap iommu: Prevent iommu implementations from being unloaded while in use Sakari Ailus
3 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2011-03-25 15:13 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, david.cohen, hiroshi.doyu
Set omap2_iommu_ops.module to point to THIS_MODULE.
Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
---
arch/arm/mach-omap2/iommu2.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/iommu2.c b/arch/arm/mach-omap2/iommu2.c
index 14ee686..cf0c32a 100644
--- a/arch/arm/mach-omap2/iommu2.c
+++ b/arch/arm/mach-omap2/iommu2.c
@@ -342,6 +342,8 @@ static const struct iommu_functions omap2_iommu_ops = {
.save_ctx = omap2_iommu_save_ctx,
.restore_ctx = omap2_iommu_restore_ctx,
.dump_ctx = omap2_iommu_dump_ctx,
+
+ .module = THIS_MODULE,
};
static int __init omap2_iommu_init(void)
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] omap iommu: Prevent iommu implementations from being unloaded while in use
[not found] <4D8CB106.7030608@maxwell.research.nokia.com>
` (2 preceding siblings ...)
2011-03-25 15:13 ` [PATCH 3/4] omap2 iommu: Set module information in omap2_iommu_ops Sakari Ailus
@ 2011-03-25 15:13 ` Sakari Ailus
3 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2011-03-25 15:13 UTC (permalink / raw)
To: linux-media; +Cc: laurent.pinchart, david.cohen, hiroshi.doyu
Prevent module implementing arch_iommu from being unloaded while the
arch_iommu is in use, essentially while the iommu has been acquired using
iommu_get() by increasing module use count.
This assumes that the arch_iommu has to be uninstalled at module unload
time.
Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
---
arch/arm/plat-omap/iommu.c | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index f0fea0b..430ed94 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -35,6 +35,7 @@ static const struct iommu_functions *arch_iommu;
static struct platform_driver omap_iommu_driver;
static struct kmem_cache *iopte_cachep;
+static struct mutex arch_iommu_mutex;
/**
* install_iommu_arch - Install archtecure specific iommu functions
@@ -45,10 +46,17 @@ static struct kmem_cache *iopte_cachep;
**/
int install_iommu_arch(const struct iommu_functions *ops)
{
- if (arch_iommu)
+ mutex_lock(&arch_iommu_mutex);
+
+ if (arch_iommu) {
+ mutex_unlock(&arch_iommu_mutex);
return -EBUSY;
+ }
arch_iommu = ops;
+
+ mutex_unlock(&arch_iommu_mutex);
+
return 0;
}
EXPORT_SYMBOL_GPL(install_iommu_arch);
@@ -58,13 +66,22 @@ EXPORT_SYMBOL_GPL(install_iommu_arch);
* @ops: a pointer to architecture specific iommu functions
*
* This interface uninstalls the iommu algorighm installed previously.
+ *
+ * Note: This function may only be called at module_exit() function of
+ * a module which implements arch_iommu. Otherwise another mechanism
+ * from the module use count only to ensure the arch_iommu stays there
+ * has to be implemented.
**/
void uninstall_iommu_arch(const struct iommu_functions *ops)
{
+ mutex_lock(&arch_iommu_mutex);
+
if (arch_iommu != ops)
pr_err("%s: not your arch\n", __func__);
arch_iommu = NULL;
+
+ mutex_unlock(&arch_iommu_mutex);
}
EXPORT_SYMBOL_GPL(uninstall_iommu_arch);
@@ -104,14 +121,20 @@ static int iommu_enable(struct iommu *obj)
if (!obj)
return -EINVAL;
- if (!arch_iommu)
+ mutex_lock(&arch_iommu_mutex);
+ if (!arch_iommu || !try_module_get(arch_iommu->module)) {
+ mutex_unlock(&arch_iommu_mutex);
return -ENOENT;
+ }
clk_enable(obj->clk);
err = arch_iommu->enable(obj);
clk_disable(obj->clk);
+
+ mutex_unlock(&arch_iommu_mutex);
+
return err;
}
@@ -125,6 +148,8 @@ static void iommu_disable(struct iommu *obj)
arch_iommu->disable(obj);
clk_disable(obj->clk);
+
+ module_put(arch_iommu->module);
}
/*
@@ -1058,6 +1083,8 @@ static int __init omap_iommu_init(void)
return -ENOMEM;
iopte_cachep = p;
+ mutex_init(&arch_iommu_mutex);
+
return platform_driver_register(&omap_iommu_driver);
}
module_init(omap_iommu_init);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] omap iommu: Check existence of arch_iommu
2011-03-25 15:13 ` [PATCH 1/4] omap iommu: Check existence of arch_iommu Sakari Ailus
@ 2011-03-25 15:19 ` Sakari Ailus
2011-03-25 19:07 ` Hiremath, Vaibhav
1 sibling, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2011-03-25 15:19 UTC (permalink / raw)
To: linux-media
Sakari Ailus wrote:
> Check that the arch_iommu has been installed before trying to use it. This
> will lead to kernel oops if the arch_iommu isn't there.
This was intended to go to linux-omap. Sorry for the noise.
--
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH 1/4] omap iommu: Check existence of arch_iommu
2011-03-25 15:13 ` [PATCH 1/4] omap iommu: Check existence of arch_iommu Sakari Ailus
2011-03-25 15:19 ` Sakari Ailus
@ 2011-03-25 19:07 ` Hiremath, Vaibhav
2011-03-27 17:04 ` Sakari Ailus
1 sibling, 1 reply; 7+ messages in thread
From: Hiremath, Vaibhav @ 2011-03-25 19:07 UTC (permalink / raw)
To: Sakari Ailus, linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com, david.cohen@nokia.com,
hiroshi.doyu@nokia.com
> -----Original Message-----
> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
> owner@vger.kernel.org] On Behalf Of Sakari Ailus
> Sent: Friday, March 25, 2011 8:43 PM
> To: linux-media@vger.kernel.org
> Cc: laurent.pinchart@ideasonboard.com; david.cohen@nokia.com;
> hiroshi.doyu@nokia.com
> Subject: [PATCH 1/4] omap iommu: Check existence of arch_iommu
>
> Check that the arch_iommu has been installed before trying to use it. This
> will lead to kernel oops if the arch_iommu isn't there.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
> ---
> arch/arm/plat-omap/iommu.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
> index b1107c0..f0fea0b 100644
> --- a/arch/arm/plat-omap/iommu.c
> +++ b/arch/arm/plat-omap/iommu.c
> @@ -104,6 +104,9 @@ static int iommu_enable(struct iommu *obj)
> if (!obj)
> return -EINVAL;
>
> + if (!arch_iommu)
> + return -ENOENT;
> +
[Hiremath, Vaibhav] Similar patch has already been submitted and accepted in community, not sure which baseline you are using. Please refer to below commit -
commit ef4815ab1ff10d642c21ef92faa6544934bc78d1
Author: Martin Hostettler <martin@neutronstar.dyndns.org>
Date: Thu Feb 24 12:51:31 2011 -0800
omap: iommu: Gracefully fail iommu_enable if no arch_iommu is registered
In a modular build of the iommu code it's possible that the arch iommu code
isn't loaded when trying to enable the iommu. Instead of blindly following a
null pointer return -NODEV in that case.
Signed-off-by: Martin Hostettler <martin@neutronstar.dyndns.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
index b1107c0..3d8f55e 100644
--- a/arch/arm/plat-omap/iommu.c
+++ b/arch/arm/plat-omap/iommu.c
@@ -104,6 +104,9 @@ static int iommu_enable(struct iommu *obj)
if (!obj)
return -EINVAL;
+ if (!arch_iommu)
+ return -ENODEV;
+
clk_enable(obj->clk);
err = arch_iommu->enable(obj);
Thanks,
Vaibhav
> clk_enable(obj->clk);
>
> err = arch_iommu->enable(obj);
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] omap iommu: Check existence of arch_iommu
2011-03-25 19:07 ` Hiremath, Vaibhav
@ 2011-03-27 17:04 ` Sakari Ailus
0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2011-03-27 17:04 UTC (permalink / raw)
To: Hiremath, Vaibhav
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
david.cohen@nokia.com, hiroshi.doyu@nokia.com
Hiremath, Vaibhav wrote:
>> -----Original Message-----
>> From: linux-media-owner@vger.kernel.org [mailto:linux-media-
>> owner@vger.kernel.org] On Behalf Of Sakari Ailus
>> Sent: Friday, March 25, 2011 8:43 PM
>> To: linux-media@vger.kernel.org
>> Cc: laurent.pinchart@ideasonboard.com; david.cohen@nokia.com;
>> hiroshi.doyu@nokia.com
>> Subject: [PATCH 1/4] omap iommu: Check existence of arch_iommu
>>
>> Check that the arch_iommu has been installed before trying to use it. This
>> will lead to kernel oops if the arch_iommu isn't there.
>>
>> Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
>> ---
>> arch/arm/plat-omap/iommu.c | 3 +++
>> 1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/plat-omap/iommu.c b/arch/arm/plat-omap/iommu.c
>> index b1107c0..f0fea0b 100644
>> --- a/arch/arm/plat-omap/iommu.c
>> +++ b/arch/arm/plat-omap/iommu.c
>> @@ -104,6 +104,9 @@ static int iommu_enable(struct iommu *obj)
>> if (!obj)
>> return -EINVAL;
>>
>> + if (!arch_iommu)
>> + return -ENOENT;
>> +
> [Hiremath, Vaibhav] Similar patch has already been submitted and
accepted in community, not sure which baseline you are using. Please
refer to below commit -
>
Thanks, Vaibhav. I guess I need to update my tree and resend the set...
Cheers,
--
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-03-27 17:02 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <4D8CB106.7030608@maxwell.research.nokia.com>
2011-03-25 15:13 ` [PATCH 1/4] omap iommu: Check existence of arch_iommu Sakari Ailus
2011-03-25 15:19 ` Sakari Ailus
2011-03-25 19:07 ` Hiremath, Vaibhav
2011-03-27 17:04 ` Sakari Ailus
2011-03-25 15:13 ` [PATCH 2/4] omap iommu: Add module information to struct iommu_functions Sakari Ailus
2011-03-25 15:13 ` [PATCH 3/4] omap2 iommu: Set module information in omap2_iommu_ops Sakari Ailus
2011-03-25 15:13 ` [PATCH 4/4] omap iommu: Prevent iommu implementations from being unloaded while in use Sakari Ailus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox