linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Some OMAP IOMMU Cleanups
@ 2016-04-04 22:46 Suman Anna
       [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Suman Anna @ 2016-04-04 22:46 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

Hi Joerg,

Following are some minor cleanups to the OMAP IOMMU driver intended
for the next merge window.

Patch 1 fixes a crash when the IOMMU device is attempted to be unbound
from the driver using sysfs when no clients were attached to the MMU.
This is not a critical failure during normal usage flow. Feel free to
pick it up either for the -rc cycle or for the next merge window.

Remaining patches are trivial cleanups addressing some of the current
checkpatch warnings/checks.

regards
Suman

Suman Anna (4):
  iommu/omap: Remove iopgtable_clear_entry_all() from driver remove
  iommu/omap: Replace BUG() in iopgtable_store_entry_core()
  iommu/omap: Use WARN_ON for page table alignment check
  iommu/omap: Align code with open parenthesis

 drivers/iommu/omap-iommu-debug.c |  2 +-
 drivers/iommu/omap-iommu.c       | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

-- 
2.7.4

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

* [PATCH 1/4] iommu/omap: Remove iopgtable_clear_entry_all() from driver remove
       [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
@ 2016-04-04 22:46   ` Suman Anna
  2016-04-04 22:46   ` [PATCH 2/4] iommu/omap: Replace BUG() in iopgtable_store_entry_core() Suman Anna
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Suman Anna @ 2016-04-04 22:46 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

The function iopgtable_clear_entry_all() is used for clearing all
the page table entries. These entries are neither created nor
initialized during the OMAP IOMMU driver probe, and are managed
only when a client device attaches to the IOMMU. So, there is no
need to invoke this function on a driver remove.

Removing this fixes a NULL pointer dereference crash if the IOMMU
device is unbound from the driver with no client device attached
to the IOMMU device.

Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
---
 drivers/iommu/omap-iommu.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 3dc5b65f3990..c05d48f88596 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -987,7 +987,6 @@ static int omap_iommu_remove(struct platform_device *pdev)
 {
 	struct omap_iommu *obj = platform_get_drvdata(pdev);
 
-	iopgtable_clear_entry_all(obj);
 	omap_iommu_debugfs_remove(obj);
 
 	pm_runtime_disable(obj->dev);
-- 
2.7.4

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

* [PATCH 2/4] iommu/omap: Replace BUG() in iopgtable_store_entry_core()
       [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
  2016-04-04 22:46   ` [PATCH 1/4] iommu/omap: Remove iopgtable_clear_entry_all() from driver remove Suman Anna
@ 2016-04-04 22:46   ` Suman Anna
  2016-04-04 22:46   ` [PATCH 3/4] iommu/omap: Use WARN_ON for page table alignment check Suman Anna
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Suman Anna @ 2016-04-04 22:46 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

The iopgtable_store_entry_core() function uses a BUG() statement
for an unsupported page size entry programming. Replace this with
a less severe WARN_ON() and perform a graceful bailout on error.

Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
---
 drivers/iommu/omap-iommu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index c05d48f88596..f6cf728ee32a 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -628,10 +628,12 @@ iopgtable_store_entry_core(struct omap_iommu *obj, struct iotlb_entry *e)
 		break;
 	default:
 		fn = NULL;
-		BUG();
 		break;
 	}
 
+	if (WARN_ON(!fn))
+		return -EINVAL;
+
 	prot = get_iopte_attr(e);
 
 	spin_lock(&obj->page_table_lock);
-- 
2.7.4

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

* [PATCH 3/4] iommu/omap: Use WARN_ON for page table alignment check
       [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
  2016-04-04 22:46   ` [PATCH 1/4] iommu/omap: Remove iopgtable_clear_entry_all() from driver remove Suman Anna
  2016-04-04 22:46   ` [PATCH 2/4] iommu/omap: Replace BUG() in iopgtable_store_entry_core() Suman Anna
@ 2016-04-04 22:46   ` Suman Anna
  2016-04-04 22:46   ` [PATCH 4/4] iommu/omap: Align code with open parenthesis Suman Anna
  2016-04-05 15:54   ` [PATCH 0/4] Some OMAP IOMMU Cleanups Joerg Roedel
  4 siblings, 0 replies; 6+ messages in thread
From: Suman Anna @ 2016-04-04 22:46 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

The OMAP IOMMU page table needs to be aligned on a 16K boundary,
and the current code uses a BUG_ON on the alignment sanity check
in the .domain_alloc() ops implementation. Replace this with a
less severe WARN_ON and bail out gracefully.

Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
---
 drivers/iommu/omap-iommu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index f6cf728ee32a..e2583cce2cc1 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -1162,7 +1162,8 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
 	 * should never fail, but please keep this around to ensure
 	 * we keep the hardware happy
 	 */
-	BUG_ON(!IS_ALIGNED((long)omap_domain->pgtable, IOPGD_TABLE_SIZE));
+	if (WARN_ON(!IS_ALIGNED((long)omap_domain->pgtable, IOPGD_TABLE_SIZE)))
+		goto fail_align;
 
 	clean_dcache_area(omap_domain->pgtable, IOPGD_TABLE_SIZE);
 	spin_lock_init(&omap_domain->lock);
@@ -1173,6 +1174,8 @@ static struct iommu_domain *omap_iommu_domain_alloc(unsigned type)
 
 	return &omap_domain->domain;
 
+fail_align:
+	kfree(omap_domain->pgtable);
 fail_nomem:
 	kfree(omap_domain);
 out:
-- 
2.7.4

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

* [PATCH 4/4] iommu/omap: Align code with open parenthesis
       [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-04-04 22:46   ` [PATCH 3/4] iommu/omap: Use WARN_ON for page table alignment check Suman Anna
@ 2016-04-04 22:46   ` Suman Anna
  2016-04-05 15:54   ` [PATCH 0/4] Some OMAP IOMMU Cleanups Joerg Roedel
  4 siblings, 0 replies; 6+ messages in thread
From: Suman Anna @ 2016-04-04 22:46 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

This patch fixes one existing alignment checkpatch check
warning of the type "Alignment should match open parenthesis"
in the OMAP IOMMU debug source file.

Signed-off-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org>
---
 drivers/iommu/omap-iommu-debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 9bc20e2119a3..505548aafeff 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -136,7 +136,7 @@ static ssize_t iotlb_dump_cr(struct omap_iommu *obj, struct cr_regs *cr,
 			     struct seq_file *s)
 {
 	seq_printf(s, "%08x %08x %01x\n", cr->cam, cr->ram,
-			  (cr->cam & MMU_CAM_P) ? 1 : 0);
+		   (cr->cam & MMU_CAM_P) ? 1 : 0);
 	return 0;
 }
 
-- 
2.7.4

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

* Re: [PATCH 0/4] Some OMAP IOMMU Cleanups
       [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-04-04 22:46   ` [PATCH 4/4] iommu/omap: Align code with open parenthesis Suman Anna
@ 2016-04-05 15:54   ` Joerg Roedel
  4 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2016-04-05 15:54 UTC (permalink / raw)
  To: Suman Anna
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA

On Mon, Apr 04, 2016 at 05:46:17PM -0500, Suman Anna wrote:
> Suman Anna (4):
>   iommu/omap: Remove iopgtable_clear_entry_all() from driver remove
>   iommu/omap: Replace BUG() in iopgtable_store_entry_core()
>   iommu/omap: Use WARN_ON for page table alignment check
>   iommu/omap: Align code with open parenthesis

Applied them all, thanks.

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

end of thread, other threads:[~2016-04-05 15:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-04 22:46 [PATCH 0/4] Some OMAP IOMMU Cleanups Suman Anna
     [not found] ` <1459809981-37984-1-git-send-email-s-anna-l0cyMroinI0@public.gmane.org>
2016-04-04 22:46   ` [PATCH 1/4] iommu/omap: Remove iopgtable_clear_entry_all() from driver remove Suman Anna
2016-04-04 22:46   ` [PATCH 2/4] iommu/omap: Replace BUG() in iopgtable_store_entry_core() Suman Anna
2016-04-04 22:46   ` [PATCH 3/4] iommu/omap: Use WARN_ON for page table alignment check Suman Anna
2016-04-04 22:46   ` [PATCH 4/4] iommu/omap: Align code with open parenthesis Suman Anna
2016-04-05 15:54   ` [PATCH 0/4] Some OMAP IOMMU Cleanups Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).