Commit-ID:  3ad2a5f57656a14d964b673a5a0e4ab0e583c870
Gitweb:     http://git.kernel.org/tip/3ad2a5f57656a14d964b673a5a0e4ab0e583c870
Author:     Minghuan Lian <minghuan.l...@freescale.com>
AuthorDate: Wed, 20 May 2015 10:13:15 -0500
Committer:  Thomas Gleixner <t...@linutronix.de>
CommitDate: Wed, 20 May 2015 22:13:37 +0200

irqchip/gicv3-its: ITS table size should not be smaller than PSZ

When allocating a device table, if the requested allocation is smaller
than the default granule size of the ITS then, we need to round up to
the default size.

Signed-off-by: Minghuan Lian <minghuan.l...@freescale.com>
[ stuart: Added comments and massaged changelog ]
Signed-off-by: Stuart Yoder <stuart.yo...@freescale.com>
Reviewed-by: Marc Zygnier <marc.zyng...@arm.com>
Cc: <linux-arm-ker...@lists.infradead.org>
Cc: <ja...@lakedaemon.net>
Link: 
http://lkml.kernel.org/r/1432134795-661-1-git-send-email-stuart.yo...@freescale.com
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
---
 drivers/irqchip/irq-gic-v3-its.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 9687f8a..1b7e155 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -828,7 +828,14 @@ static int its_alloc_tables(struct its_node *its)
                        u64 typer = readq_relaxed(its->base + GITS_TYPER);
                        u32 ids = GITS_TYPER_DEVBITS(typer);
 
-                       order = get_order((1UL << ids) * entry_size);
+                       /*
+                        * 'order' was initialized earlier to the default page
+                        * granule of the the ITS.  We can't have an allocation
+                        * smaller than that.  If the requested allocation
+                        * is smaller, round up to the default page granule.
+                        */
+                       order = max(get_order((1UL << ids) * entry_size),
+                                   order);
                        if (order >= MAX_ORDER) {
                                order = MAX_ORDER - 1;
                                pr_warn("%s: Device Table too large, reduce its 
page order to %u\n",
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to