All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] SH Mobile IOMMU fixes
@ 2013-12-17 17:18 ` Laurent Pinchart
  0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-17 17:18 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Simon Horman, Nguyen Viet Dung, linux-sh-u79uwXL29TY76Z2rM5mHXA

Hello,

These two small patches fix bugs in the SH Mobile IOMMU driver that result in
crashes at runtime. Given that the bugs have been present in the driver since
v3.9 there's no urgency to push the fixes to v3.13.

Laurent Pinchart (2):
  iommu/shmobile: Allocate archdata with kzalloc()
  iommu/shmobile: Turn the flush_lock mutex into a spinlock

 drivers/iommu/shmobile-iommu.c |  3 +--
 drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
 drivers/iommu/shmobile-ipmmu.h |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/2] SH Mobile IOMMU fixes
@ 2013-12-17 17:18 ` Laurent Pinchart
  0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-17 17:18 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Simon Horman, Nguyen Viet Dung, linux-sh-u79uwXL29TY76Z2rM5mHXA

Hello,

These two small patches fix bugs in the SH Mobile IOMMU driver that result in
crashes at runtime. Given that the bugs have been present in the driver since
v3.9 there's no urgency to push the fixes to v3.13.

Laurent Pinchart (2):
  iommu/shmobile: Allocate archdata with kzalloc()
  iommu/shmobile: Turn the flush_lock mutex into a spinlock

 drivers/iommu/shmobile-iommu.c |  3 +--
 drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
 drivers/iommu/shmobile-ipmmu.h |  2 +-
 3 files changed, 7 insertions(+), 8 deletions(-)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc()
       [not found] ` <1387300730-28783-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2013-12-17 17:18     ` Laurent Pinchart
  2014-01-07 14:36     ` Joerg Roedel
  1 sibling, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-17 17:18 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Simon Horman, Nguyen Viet Dung, linux-sh-u79uwXL29TY76Z2rM5mHXA

The archdata attached_list field isn't initialized, leading to random
crashes when accessed. Use kzalloc() to allocate the whole structure and
make sure all fields get initialized properly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/iommu/shmobile-iommu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/shmobile-iommu.c b/drivers/iommu/shmobile-iommu.c
index d572863..7a3b928 100644
--- a/drivers/iommu/shmobile-iommu.c
+++ b/drivers/iommu/shmobile-iommu.c
@@ -380,14 +380,13 @@ int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
 		kmem_cache_destroy(l1cache);
 		return -ENOMEM;
 	}
-	archdata = kmalloc(sizeof(*archdata), GFP_KERNEL);
+	archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
 	if (!archdata) {
 		kmem_cache_destroy(l1cache);
 		kmem_cache_destroy(l2cache);
 		return -ENOMEM;
 	}
 	spin_lock_init(&archdata->attach_lock);
-	archdata->attached = NULL;
 	archdata->ipmmu = ipmmu;
 	ipmmu_archdata = archdata;
 	bus_set_iommu(&platform_bus_type, &shmobile_iommu_ops);
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc()
@ 2013-12-17 17:18     ` Laurent Pinchart
  0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-17 17:18 UTC (permalink / raw)
  To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
  Cc: Simon Horman, Nguyen Viet Dung, linux-sh-u79uwXL29TY76Z2rM5mHXA

The archdata attached_list field isn't initialized, leading to random
crashes when accessed. Use kzalloc() to allocate the whole structure and
make sure all fields get initialized properly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
---
 drivers/iommu/shmobile-iommu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/shmobile-iommu.c b/drivers/iommu/shmobile-iommu.c
index d572863..7a3b928 100644
--- a/drivers/iommu/shmobile-iommu.c
+++ b/drivers/iommu/shmobile-iommu.c
@@ -380,14 +380,13 @@ int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
 		kmem_cache_destroy(l1cache);
 		return -ENOMEM;
 	}
-	archdata = kmalloc(sizeof(*archdata), GFP_KERNEL);
+	archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
 	if (!archdata) {
 		kmem_cache_destroy(l1cache);
 		kmem_cache_destroy(l2cache);
 		return -ENOMEM;
 	}
 	spin_lock_init(&archdata->attach_lock);
-	archdata->attached = NULL;
 	archdata->ipmmu = ipmmu;
 	ipmmu_archdata = archdata;
 	bus_set_iommu(&platform_bus_type, &shmobile_iommu_ops);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] iommu/shmobile: Turn the flush_lock mutex into a spinlock
  2013-12-17 17:18 ` Laurent Pinchart
@ 2013-12-17 17:18   ` Laurent Pinchart
  -1 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-17 17:18 UTC (permalink / raw)
  To: iommu; +Cc: linux-sh, Simon Horman, Nguyen Viet Dung

The lock is taken in atomic context, replace it with a spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
 drivers/iommu/shmobile-ipmmu.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/shmobile-ipmmu.c b/drivers/iommu/shmobile-ipmmu.c
index 8321f89..e3bc2e1 100644
--- a/drivers/iommu/shmobile-ipmmu.c
+++ b/drivers/iommu/shmobile-ipmmu.c
@@ -35,12 +35,12 @@ void ipmmu_tlb_flush(struct shmobile_ipmmu *ipmmu)
 	if (!ipmmu)
 		return;
 
-	mutex_lock(&ipmmu->flush_lock);
+	spin_lock(&ipmmu->flush_lock);
 	if (ipmmu->tlb_enabled)
 		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH | IMCTR1_TLBEN);
 	else
 		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH);
-	mutex_unlock(&ipmmu->flush_lock);
+	spin_unlock(&ipmmu->flush_lock);
 }
 
 void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
@@ -49,7 +49,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
 	if (!ipmmu)
 		return;
 
-	mutex_lock(&ipmmu->flush_lock);
+	spin_lock(&ipmmu->flush_lock);
 	switch (size) {
 	default:
 		ipmmu->tlb_enabled = 0;
@@ -85,7 +85,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
 	}
 	ipmmu_reg_write(ipmmu, IMTTBR, phys);
 	ipmmu_reg_write(ipmmu, IMASID, asid);
-	mutex_unlock(&ipmmu->flush_lock);
+	spin_unlock(&ipmmu->flush_lock);
 }
 
 static int ipmmu_probe(struct platform_device *pdev)
@@ -104,7 +104,7 @@ static int ipmmu_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "cannot allocate device data\n");
 		return -ENOMEM;
 	}
-	mutex_init(&ipmmu->flush_lock);
+	spin_lock_init(&ipmmu->flush_lock);
 	ipmmu->dev = &pdev->dev;
 	ipmmu->ipmmu_base = devm_ioremap_nocache(&pdev->dev, res->start,
 						resource_size(res));
diff --git a/drivers/iommu/shmobile-ipmmu.h b/drivers/iommu/shmobile-ipmmu.h
index 4d53684..9524743 100644
--- a/drivers/iommu/shmobile-ipmmu.h
+++ b/drivers/iommu/shmobile-ipmmu.h
@@ -14,7 +14,7 @@ struct shmobile_ipmmu {
 	struct device *dev;
 	void __iomem *ipmmu_base;
 	int tlb_enabled;
-	struct mutex flush_lock;
+	spinlock_t flush_lock;
 	const char * const *dev_names;
 	unsigned int num_dev_names;
 };
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/2] iommu/shmobile: Turn the flush_lock mutex into a spinlock
@ 2013-12-17 17:18   ` Laurent Pinchart
  0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-17 17:18 UTC (permalink / raw)
  To: iommu; +Cc: linux-sh, Simon Horman, Nguyen Viet Dung

The lock is taken in atomic context, replace it with a spinlock.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
 drivers/iommu/shmobile-ipmmu.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/shmobile-ipmmu.c b/drivers/iommu/shmobile-ipmmu.c
index 8321f89..e3bc2e1 100644
--- a/drivers/iommu/shmobile-ipmmu.c
+++ b/drivers/iommu/shmobile-ipmmu.c
@@ -35,12 +35,12 @@ void ipmmu_tlb_flush(struct shmobile_ipmmu *ipmmu)
 	if (!ipmmu)
 		return;
 
-	mutex_lock(&ipmmu->flush_lock);
+	spin_lock(&ipmmu->flush_lock);
 	if (ipmmu->tlb_enabled)
 		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH | IMCTR1_TLBEN);
 	else
 		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH);
-	mutex_unlock(&ipmmu->flush_lock);
+	spin_unlock(&ipmmu->flush_lock);
 }
 
 void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
@@ -49,7 +49,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
 	if (!ipmmu)
 		return;
 
-	mutex_lock(&ipmmu->flush_lock);
+	spin_lock(&ipmmu->flush_lock);
 	switch (size) {
 	default:
 		ipmmu->tlb_enabled = 0;
@@ -85,7 +85,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
 	}
 	ipmmu_reg_write(ipmmu, IMTTBR, phys);
 	ipmmu_reg_write(ipmmu, IMASID, asid);
-	mutex_unlock(&ipmmu->flush_lock);
+	spin_unlock(&ipmmu->flush_lock);
 }
 
 static int ipmmu_probe(struct platform_device *pdev)
@@ -104,7 +104,7 @@ static int ipmmu_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "cannot allocate device data\n");
 		return -ENOMEM;
 	}
-	mutex_init(&ipmmu->flush_lock);
+	spin_lock_init(&ipmmu->flush_lock);
 	ipmmu->dev = &pdev->dev;
 	ipmmu->ipmmu_base = devm_ioremap_nocache(&pdev->dev, res->start,
 						resource_size(res));
diff --git a/drivers/iommu/shmobile-ipmmu.h b/drivers/iommu/shmobile-ipmmu.h
index 4d53684..9524743 100644
--- a/drivers/iommu/shmobile-ipmmu.h
+++ b/drivers/iommu/shmobile-ipmmu.h
@@ -14,7 +14,7 @@ struct shmobile_ipmmu {
 	struct device *dev;
 	void __iomem *ipmmu_base;
 	int tlb_enabled;
-	struct mutex flush_lock;
+	spinlock_t flush_lock;
 	const char * const *dev_names;
 	unsigned int num_dev_names;
 };
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc()
  2013-12-17 17:18     ` Laurent Pinchart
@ 2013-12-18  1:15       ` Simon Horman
  -1 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-12-18  1:15 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: iommu, linux-sh, Nguyen Viet Dung

On Tue, Dec 17, 2013 at 06:18:49PM +0100, Laurent Pinchart wrote:
> The archdata attached_list field isn't initialized, leading to random
> crashes when accessed. Use kzalloc() to allocate the whole structure and
> make sure all fields get initialized properly.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/iommu/shmobile-iommu.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/shmobile-iommu.c b/drivers/iommu/shmobile-iommu.c
> index d572863..7a3b928 100644
> --- a/drivers/iommu/shmobile-iommu.c
> +++ b/drivers/iommu/shmobile-iommu.c
> @@ -380,14 +380,13 @@ int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
>  		kmem_cache_destroy(l1cache);
>  		return -ENOMEM;
>  	}
> -	archdata = kmalloc(sizeof(*archdata), GFP_KERNEL);
> +	archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
>  	if (!archdata) {
>  		kmem_cache_destroy(l1cache);
>  		kmem_cache_destroy(l2cache);
>  		return -ENOMEM;
>  	}
>  	spin_lock_init(&archdata->attach_lock);
> -	archdata->attached = NULL;
>  	archdata->ipmmu = ipmmu;
>  	ipmmu_archdata = archdata;
>  	bus_set_iommu(&platform_bus_type, &shmobile_iommu_ops);
> -- 
> 1.8.3.2
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc()
@ 2013-12-18  1:15       ` Simon Horman
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-12-18  1:15 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: iommu, linux-sh, Nguyen Viet Dung

On Tue, Dec 17, 2013 at 06:18:49PM +0100, Laurent Pinchart wrote:
> The archdata attached_list field isn't initialized, leading to random
> crashes when accessed. Use kzalloc() to allocate the whole structure and
> make sure all fields get initialized properly.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/iommu/shmobile-iommu.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/shmobile-iommu.c b/drivers/iommu/shmobile-iommu.c
> index d572863..7a3b928 100644
> --- a/drivers/iommu/shmobile-iommu.c
> +++ b/drivers/iommu/shmobile-iommu.c
> @@ -380,14 +380,13 @@ int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
>  		kmem_cache_destroy(l1cache);
>  		return -ENOMEM;
>  	}
> -	archdata = kmalloc(sizeof(*archdata), GFP_KERNEL);
> +	archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
>  	if (!archdata) {
>  		kmem_cache_destroy(l1cache);
>  		kmem_cache_destroy(l2cache);
>  		return -ENOMEM;
>  	}
>  	spin_lock_init(&archdata->attach_lock);
> -	archdata->attached = NULL;
>  	archdata->ipmmu = ipmmu;
>  	ipmmu_archdata = archdata;
>  	bus_set_iommu(&platform_bus_type, &shmobile_iommu_ops);
> -- 
> 1.8.3.2
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iommu/shmobile: Turn the flush_lock mutex into a spinlock
  2013-12-17 17:18   ` Laurent Pinchart
@ 2013-12-18  1:16     ` Simon Horman
  -1 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-12-18  1:16 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: iommu, linux-sh, Nguyen Viet Dung

On Tue, Dec 17, 2013 at 06:18:50PM +0100, Laurent Pinchart wrote:
> The lock is taken in atomic context, replace it with a spinlock.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
>  drivers/iommu/shmobile-ipmmu.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/shmobile-ipmmu.c b/drivers/iommu/shmobile-ipmmu.c
> index 8321f89..e3bc2e1 100644
> --- a/drivers/iommu/shmobile-ipmmu.c
> +++ b/drivers/iommu/shmobile-ipmmu.c
> @@ -35,12 +35,12 @@ void ipmmu_tlb_flush(struct shmobile_ipmmu *ipmmu)
>  	if (!ipmmu)
>  		return;
>  
> -	mutex_lock(&ipmmu->flush_lock);
> +	spin_lock(&ipmmu->flush_lock);
>  	if (ipmmu->tlb_enabled)
>  		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH | IMCTR1_TLBEN);
>  	else
>  		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH);
> -	mutex_unlock(&ipmmu->flush_lock);
> +	spin_unlock(&ipmmu->flush_lock);
>  }
>  
>  void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
> @@ -49,7 +49,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
>  	if (!ipmmu)
>  		return;
>  
> -	mutex_lock(&ipmmu->flush_lock);
> +	spin_lock(&ipmmu->flush_lock);
>  	switch (size) {
>  	default:
>  		ipmmu->tlb_enabled = 0;
> @@ -85,7 +85,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
>  	}
>  	ipmmu_reg_write(ipmmu, IMTTBR, phys);
>  	ipmmu_reg_write(ipmmu, IMASID, asid);
> -	mutex_unlock(&ipmmu->flush_lock);
> +	spin_unlock(&ipmmu->flush_lock);
>  }
>  
>  static int ipmmu_probe(struct platform_device *pdev)
> @@ -104,7 +104,7 @@ static int ipmmu_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev, "cannot allocate device data\n");
>  		return -ENOMEM;
>  	}
> -	mutex_init(&ipmmu->flush_lock);
> +	spin_lock_init(&ipmmu->flush_lock);
>  	ipmmu->dev = &pdev->dev;
>  	ipmmu->ipmmu_base = devm_ioremap_nocache(&pdev->dev, res->start,
>  						resource_size(res));
> diff --git a/drivers/iommu/shmobile-ipmmu.h b/drivers/iommu/shmobile-ipmmu.h
> index 4d53684..9524743 100644
> --- a/drivers/iommu/shmobile-ipmmu.h
> +++ b/drivers/iommu/shmobile-ipmmu.h
> @@ -14,7 +14,7 @@ struct shmobile_ipmmu {
>  	struct device *dev;
>  	void __iomem *ipmmu_base;
>  	int tlb_enabled;
> -	struct mutex flush_lock;
> +	spinlock_t flush_lock;
>  	const char * const *dev_names;
>  	unsigned int num_dev_names;
>  };
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" 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	[flat|nested] 14+ messages in thread

* Re: [PATCH 2/2] iommu/shmobile: Turn the flush_lock mutex into a spinlock
@ 2013-12-18  1:16     ` Simon Horman
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Horman @ 2013-12-18  1:16 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: iommu, linux-sh, Nguyen Viet Dung

On Tue, Dec 17, 2013 at 06:18:50PM +0100, Laurent Pinchart wrote:
> The lock is taken in atomic context, replace it with a spinlock.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
>  drivers/iommu/shmobile-ipmmu.h |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/shmobile-ipmmu.c b/drivers/iommu/shmobile-ipmmu.c
> index 8321f89..e3bc2e1 100644
> --- a/drivers/iommu/shmobile-ipmmu.c
> +++ b/drivers/iommu/shmobile-ipmmu.c
> @@ -35,12 +35,12 @@ void ipmmu_tlb_flush(struct shmobile_ipmmu *ipmmu)
>  	if (!ipmmu)
>  		return;
>  
> -	mutex_lock(&ipmmu->flush_lock);
> +	spin_lock(&ipmmu->flush_lock);
>  	if (ipmmu->tlb_enabled)
>  		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH | IMCTR1_TLBEN);
>  	else
>  		ipmmu_reg_write(ipmmu, IMCTR1, IMCTR1_FLUSH);
> -	mutex_unlock(&ipmmu->flush_lock);
> +	spin_unlock(&ipmmu->flush_lock);
>  }
>  
>  void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
> @@ -49,7 +49,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
>  	if (!ipmmu)
>  		return;
>  
> -	mutex_lock(&ipmmu->flush_lock);
> +	spin_lock(&ipmmu->flush_lock);
>  	switch (size) {
>  	default:
>  		ipmmu->tlb_enabled = 0;
> @@ -85,7 +85,7 @@ void ipmmu_tlb_set(struct shmobile_ipmmu *ipmmu, unsigned long phys, int size,
>  	}
>  	ipmmu_reg_write(ipmmu, IMTTBR, phys);
>  	ipmmu_reg_write(ipmmu, IMASID, asid);
> -	mutex_unlock(&ipmmu->flush_lock);
> +	spin_unlock(&ipmmu->flush_lock);
>  }
>  
>  static int ipmmu_probe(struct platform_device *pdev)
> @@ -104,7 +104,7 @@ static int ipmmu_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev, "cannot allocate device data\n");
>  		return -ENOMEM;
>  	}
> -	mutex_init(&ipmmu->flush_lock);
> +	spin_lock_init(&ipmmu->flush_lock);
>  	ipmmu->dev = &pdev->dev;
>  	ipmmu->ipmmu_base = devm_ioremap_nocache(&pdev->dev, res->start,
>  						resource_size(res));
> diff --git a/drivers/iommu/shmobile-ipmmu.h b/drivers/iommu/shmobile-ipmmu.h
> index 4d53684..9524743 100644
> --- a/drivers/iommu/shmobile-ipmmu.h
> +++ b/drivers/iommu/shmobile-ipmmu.h
> @@ -14,7 +14,7 @@ struct shmobile_ipmmu {
>  	struct device *dev;
>  	void __iomem *ipmmu_base;
>  	int tlb_enabled;
> -	struct mutex flush_lock;
> +	spinlock_t flush_lock;
>  	const char * const *dev_names;
>  	unsigned int num_dev_names;
>  };
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" 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	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc()
       [not found]       ` <20131218011521.GI18992-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
@ 2013-12-18 14:14           ` Laurent Pinchart
  0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-18 14:14 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Nguyen Viet Dung,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Simon Horman,
	Laurent Pinchart, linux-sh-u79uwXL29TY76Z2rM5mHXA

On Wednesday 18 December 2013 10:15:21 Simon Horman wrote:
> On Tue, Dec 17, 2013 at 06:18:49PM +0100, Laurent Pinchart wrote:
> > The archdata attached_list field isn't initialized, leading to random
> > crashes when accessed. Use kzalloc() to allocate the whole structure and
> > make sure all fields get initialized properly.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> 
> Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

Thank you Simon.

Joerg, could you please pick those two patches up for v3.14 ?

> > ---
> > 
> >  drivers/iommu/shmobile-iommu.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/shmobile-iommu.c
> > b/drivers/iommu/shmobile-iommu.c index d572863..7a3b928 100644
> > --- a/drivers/iommu/shmobile-iommu.c
> > +++ b/drivers/iommu/shmobile-iommu.c
> > @@ -380,14 +380,13 @@ int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
> >  		kmem_cache_destroy(l1cache);
> >  		return -ENOMEM;
> >  	}
> > -	archdata = kmalloc(sizeof(*archdata), GFP_KERNEL);
> > +	archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
> >  	if (!archdata) {
> >  		kmem_cache_destroy(l1cache);
> >  		kmem_cache_destroy(l2cache);
> >  		return -ENOMEM;
> >  	}
> >  	spin_lock_init(&archdata->attach_lock);
> > -	archdata->attached = NULL;
> >  	archdata->ipmmu = ipmmu;
> >  	ipmmu_archdata = archdata;
> >  	bus_set_iommu(&platform_bus_type, &shmobile_iommu_ops);

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc()
@ 2013-12-18 14:14           ` Laurent Pinchart
  0 siblings, 0 replies; 14+ messages in thread
From: Laurent Pinchart @ 2013-12-18 14:14 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Nguyen Viet Dung,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Simon Horman,
	Laurent Pinchart, linux-sh-u79uwXL29TY76Z2rM5mHXA

On Wednesday 18 December 2013 10:15:21 Simon Horman wrote:
> On Tue, Dec 17, 2013 at 06:18:49PM +0100, Laurent Pinchart wrote:
> > The archdata attached_list field isn't initialized, leading to random
> > crashes when accessed. Use kzalloc() to allocate the whole structure and
> > make sure all fields get initialized properly.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
> 
> Reviewed-by: Simon Horman <horms+renesas-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>

Thank you Simon.

Joerg, could you please pick those two patches up for v3.14 ?

> > ---
> > 
> >  drivers/iommu/shmobile-iommu.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/shmobile-iommu.c
> > b/drivers/iommu/shmobile-iommu.c index d572863..7a3b928 100644
> > --- a/drivers/iommu/shmobile-iommu.c
> > +++ b/drivers/iommu/shmobile-iommu.c
> > @@ -380,14 +380,13 @@ int ipmmu_iommu_init(struct shmobile_ipmmu *ipmmu)
> >  		kmem_cache_destroy(l1cache);
> >  		return -ENOMEM;
> >  	}
> > -	archdata = kmalloc(sizeof(*archdata), GFP_KERNEL);
> > +	archdata = kzalloc(sizeof(*archdata), GFP_KERNEL);
> >  	if (!archdata) {
> >  		kmem_cache_destroy(l1cache);
> >  		kmem_cache_destroy(l2cache);
> >  		return -ENOMEM;
> >  	}
> >  	spin_lock_init(&archdata->attach_lock);
> > -	archdata->attached = NULL;
> >  	archdata->ipmmu = ipmmu;
> >  	ipmmu_archdata = archdata;
> >  	bus_set_iommu(&platform_bus_type, &shmobile_iommu_ops);

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] SH Mobile IOMMU fixes
       [not found] ` <1387300730-28783-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
@ 2014-01-07 14:36     ` Joerg Roedel
  2014-01-07 14:36     ` Joerg Roedel
  1 sibling, 0 replies; 14+ messages in thread
From: Joerg Roedel @ 2014-01-07 14:36 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-sh-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Simon Horman,
	Nguyen Viet Dung

On Tue, Dec 17, 2013 at 06:18:48PM +0100, Laurent Pinchart wrote:
> Hello,
> 
> These two small patches fix bugs in the SH Mobile IOMMU driver that result in
> crashes at runtime. Given that the bugs have been present in the driver since
> v3.9 there's no urgency to push the fixes to v3.13.
> 
> Laurent Pinchart (2):
>   iommu/shmobile: Allocate archdata with kzalloc()
>   iommu/shmobile: Turn the flush_lock mutex into a spinlock
> 
>  drivers/iommu/shmobile-iommu.c |  3 +--
>  drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
>  drivers/iommu/shmobile-ipmmu.h |  2 +-
>  3 files changed, 7 insertions(+), 8 deletions(-)

Applied both, thanks.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/2] SH Mobile IOMMU fixes
@ 2014-01-07 14:36     ` Joerg Roedel
  0 siblings, 0 replies; 14+ messages in thread
From: Joerg Roedel @ 2014-01-07 14:36 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: linux-sh-u79uwXL29TY76Z2rM5mHXA,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Simon Horman,
	Nguyen Viet Dung

On Tue, Dec 17, 2013 at 06:18:48PM +0100, Laurent Pinchart wrote:
> Hello,
> 
> These two small patches fix bugs in the SH Mobile IOMMU driver that result in
> crashes at runtime. Given that the bugs have been present in the driver since
> v3.9 there's no urgency to push the fixes to v3.13.
> 
> Laurent Pinchart (2):
>   iommu/shmobile: Allocate archdata with kzalloc()
>   iommu/shmobile: Turn the flush_lock mutex into a spinlock
> 
>  drivers/iommu/shmobile-iommu.c |  3 +--
>  drivers/iommu/shmobile-ipmmu.c | 10 +++++-----
>  drivers/iommu/shmobile-ipmmu.h |  2 +-
>  3 files changed, 7 insertions(+), 8 deletions(-)

Applied both, thanks.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-01-07 14:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 17:18 [PATCH 0/2] SH Mobile IOMMU fixes Laurent Pinchart
2013-12-17 17:18 ` Laurent Pinchart
2013-12-17 17:18 ` [PATCH 2/2] iommu/shmobile: Turn the flush_lock mutex into a spinlock Laurent Pinchart
2013-12-17 17:18   ` Laurent Pinchart
2013-12-18  1:16   ` Simon Horman
2013-12-18  1:16     ` Simon Horman
     [not found] ` <1387300730-28783-1-git-send-email-laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org>
2013-12-17 17:18   ` [PATCH 1/2] iommu/shmobile: Allocate archdata with kzalloc() Laurent Pinchart
2013-12-17 17:18     ` Laurent Pinchart
2013-12-18  1:15     ` Simon Horman
2013-12-18  1:15       ` Simon Horman
     [not found]       ` <20131218011521.GI18992-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>
2013-12-18 14:14         ` Laurent Pinchart
2013-12-18 14:14           ` Laurent Pinchart
2014-01-07 14:36   ` [PATCH 0/2] SH Mobile IOMMU fixes Joerg Roedel
2014-01-07 14:36     ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.