aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/irqchip/irq-gic-v3-its.c
diff options
context:
space:
mode:
authorShanker Donthineni <shankerd@codeaurora.org>2016-06-06 19:17:29 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2016-06-13 06:53:52 -0400
commit4b75c4598b5b8312b8e3d37b6486729cf333dbf5 (patch)
treeda8b58922274d93331877634e9bea1cfd9da273f /drivers/irqchip/irq-gic-v3-its.c
parent2d81d425b6d5cc2262912cce9f9ec7f706a3ea65 (diff)
irqchip/gicv3-its: Add a new function for parsing device table BASERn
Only the device table BASERn needs to be handled differently as compared to all other tables. So, adding a separate function for easy code maintenance and improved code readability. Signed-off-by: Shanker Donthineni <shankerd@codeaurora.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'drivers/irqchip/irq-gic-v3-its.c')
-rw-r--r--drivers/irqchip/irq-gic-v3-its.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index a8a1144205e6..5cfa29991eed 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -840,6 +840,30 @@ static void its_write_baser(struct its_node *its, struct its_baser *baser,
840 baser->val = its_read_baser(its, baser); 840 baser->val = its_read_baser(its, baser);
841} 841}
842 842
843static void its_parse_baser_device(struct its_node *its, struct its_baser *baser,
844 u32 *order)
845{
846 u64 esz = GITS_BASER_ENTRY_SIZE(its_read_baser(its, baser));
847 u32 ids = its->device_ids;
848 u32 new_order = *order;
849
850 /*
851 * Allocate as many entries as required to fit the
852 * range of device IDs that the ITS can grok... The ID
853 * space being incredibly sparse, this results in a
854 * massive waste of memory.
855 */
856 new_order = max_t(u32, get_order(esz << ids), new_order);
857 if (new_order >= MAX_ORDER) {
858 new_order = MAX_ORDER - 1;
859 ids = ilog2(PAGE_ORDER_TO_SIZE(new_order) / esz);
860 pr_warn("ITS@%pa: Device Table too large, reduce ids %u->%u\n",
861 &its->phys_base, its->device_ids, ids);
862 }
863
864 *order = new_order;
865}
866
843static void its_free_tables(struct its_node *its) 867static void its_free_tables(struct its_node *its)
844{ 868{
845 int i; 869 int i;
@@ -891,29 +915,8 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
891 if (type == GITS_BASER_TYPE_NONE) 915 if (type == GITS_BASER_TYPE_NONE)
892 continue; 916 continue;
893 917
894 /* 918 if (type == GITS_BASER_TYPE_DEVICE)
895 * Allocate as many entries as required to fit the 919 its_parse_baser_device(its, baser, &order);
896 * range of device IDs that the ITS can grok... The ID
897 * space being incredibly sparse, this results in a
898 * massive waste of memory.
899 *
900 * For other tables, only allocate a single page.
901 */
902 if (type == GITS_BASER_TYPE_DEVICE) {
903 /*
904 * 'order' was initialized earlier to the default page
905 * granule of the the ITS. We can't have an allocation
906 * smaller than that. If the requested allocation
907 * is smaller, round up to the default page granule.
908 */
909 order = max(get_order((1UL << ids) * entry_size),
910 order);
911 if (order >= MAX_ORDER) {
912 order = MAX_ORDER - 1;
913 pr_warn("%s: Device Table too large, reduce its page order to %u\n",
914 node_name, order);
915 }
916 }
917 920
918retry_alloc_baser: 921retry_alloc_baser:
919 alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz); 922 alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);