aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2017-03-14 16:13:19 -0400
committerTony Lindgren <tony@atomide.com>2017-03-14 16:13:19 -0400
commita1e312355d41cd63b9f47081ade9168eedc4574d (patch)
tree06f8df1cdc60714b958e4edea2b1a1f90388e8aa
parentc1ae3cfa0e89fa1a7ecc4c99031f5e9ae99d9201 (diff)
ARM: OMAP2+: Remove mostly unused hwmod linkspace
We want to be able to dynamically allocate struct omap_hwmod_ocp_if and struct omap_hwmod at device driver probe time based on .dts data. Current setup with the linkspace using memblock_virt_alloc() makes this tricky, so let's get rid of struct linkspace and directly set up struct omap_hwmod_ocp_if as the master and slave lists. As we are currently not using the master_ports either, let's remove it too. And let's add the struct omap_hwmod_ocp_if node directly to the slave_ports list. Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c116
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.h13
2 files changed, 4 insertions, 125 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 0da4f2ea76c4..7b7ba6d48e83 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -138,7 +138,6 @@
138#include <linux/mutex.h> 138#include <linux/mutex.h>
139#include <linux/spinlock.h> 139#include <linux/spinlock.h>
140#include <linux/slab.h> 140#include <linux/slab.h>
141#include <linux/bootmem.h>
142#include <linux/cpu.h> 141#include <linux/cpu.h>
143#include <linux/of.h> 142#include <linux/of.h>
144#include <linux/of_address.h> 143#include <linux/of_address.h>
@@ -216,20 +215,6 @@ static LIST_HEAD(omap_hwmod_list);
216/* mpu_oh: used to add/remove MPU initiator from sleepdep list */ 215/* mpu_oh: used to add/remove MPU initiator from sleepdep list */
217static struct omap_hwmod *mpu_oh; 216static struct omap_hwmod *mpu_oh;
218 217
219/*
220 * linkspace: ptr to a buffer that struct omap_hwmod_link records are
221 * allocated from - used to reduce the number of small memory
222 * allocations, which has a significant impact on performance
223 */
224static struct omap_hwmod_link *linkspace;
225
226/*
227 * free_ls, max_ls: array indexes into linkspace; representing the
228 * next free struct omap_hwmod_link index, and the maximum number of
229 * struct omap_hwmod_link records allocated (respectively)
230 */
231static unsigned short free_ls, max_ls, ls_supp;
232
233/* inited: set to true once the hwmod code is initialized */ 218/* inited: set to true once the hwmod code is initialized */
234static bool inited; 219static bool inited;
235 220
@@ -250,7 +235,7 @@ static struct omap_hwmod_ocp_if *_fetch_next_ocp_if(struct list_head **p,
250{ 235{
251 struct omap_hwmod_ocp_if *oi; 236 struct omap_hwmod_ocp_if *oi;
252 237
253 oi = list_entry(*p, struct omap_hwmod_link, node)->ocp_if; 238 oi = list_entry(*p, struct omap_hwmod_ocp_if, node);
254 *p = (*p)->next; 239 *p = (*p)->next;
255 240
256 *i = *i + 1; 241 *i = *i + 1;
@@ -2657,7 +2642,6 @@ static int __init _register(struct omap_hwmod *oh)
2657 2642
2658 list_add_tail(&oh->node, &omap_hwmod_list); 2643 list_add_tail(&oh->node, &omap_hwmod_list);
2659 2644
2660 INIT_LIST_HEAD(&oh->master_ports);
2661 INIT_LIST_HEAD(&oh->slave_ports); 2645 INIT_LIST_HEAD(&oh->slave_ports);
2662 spin_lock_init(&oh->_lock); 2646 spin_lock_init(&oh->_lock);
2663 lockdep_set_class(&oh->_lock, &oh->hwmod_key); 2647 lockdep_set_class(&oh->_lock, &oh->hwmod_key);
@@ -2675,49 +2659,10 @@ static int __init _register(struct omap_hwmod *oh)
2675} 2659}
2676 2660
2677/** 2661/**
2678 * _alloc_links - return allocated memory for hwmod links
2679 * @ml: pointer to a struct omap_hwmod_link * for the master link
2680 * @sl: pointer to a struct omap_hwmod_link * for the slave link
2681 *
2682 * Return pointers to two struct omap_hwmod_link records, via the
2683 * addresses pointed to by @ml and @sl. Will first attempt to return
2684 * memory allocated as part of a large initial block, but if that has
2685 * been exhausted, will allocate memory itself. Since ideally this
2686 * second allocation path will never occur, the number of these
2687 * 'supplemental' allocations will be logged when debugging is
2688 * enabled. Returns 0.
2689 */
2690static int __init _alloc_links(struct omap_hwmod_link **ml,
2691 struct omap_hwmod_link **sl)
2692{
2693 unsigned int sz;
2694
2695 if ((free_ls + LINKS_PER_OCP_IF) <= max_ls) {
2696 *ml = &linkspace[free_ls++];
2697 *sl = &linkspace[free_ls++];
2698 return 0;
2699 }
2700
2701 sz = sizeof(struct omap_hwmod_link) * LINKS_PER_OCP_IF;
2702
2703 *sl = NULL;
2704 *ml = memblock_virt_alloc(sz, 0);
2705
2706 *sl = (void *)(*ml) + sizeof(struct omap_hwmod_link);
2707
2708 ls_supp++;
2709 pr_debug("omap_hwmod: supplemental link allocations needed: %d\n",
2710 ls_supp * LINKS_PER_OCP_IF);
2711
2712 return 0;
2713};
2714
2715/**
2716 * _add_link - add an interconnect between two IP blocks 2662 * _add_link - add an interconnect between two IP blocks
2717 * @oi: pointer to a struct omap_hwmod_ocp_if record 2663 * @oi: pointer to a struct omap_hwmod_ocp_if record
2718 * 2664 *
2719 * Add struct omap_hwmod_link records connecting the master IP block 2665 * Add struct omap_hwmod_link records connecting the slave IP block
2720 * specified in @oi->master to @oi, and connecting the slave IP block
2721 * specified in @oi->slave to @oi. This code is assumed to run before 2666 * specified in @oi->slave to @oi. This code is assumed to run before
2722 * preemption or SMP has been enabled, thus avoiding the need for 2667 * preemption or SMP has been enabled, thus avoiding the need for
2723 * locking in this code. Changes to this assumption will require 2668 * locking in this code. Changes to this assumption will require
@@ -2725,19 +2670,10 @@ static int __init _alloc_links(struct omap_hwmod_link **ml,
2725 */ 2670 */
2726static int __init _add_link(struct omap_hwmod_ocp_if *oi) 2671static int __init _add_link(struct omap_hwmod_ocp_if *oi)
2727{ 2672{
2728 struct omap_hwmod_link *ml, *sl;
2729
2730 pr_debug("omap_hwmod: %s -> %s: adding link\n", oi->master->name, 2673 pr_debug("omap_hwmod: %s -> %s: adding link\n", oi->master->name,
2731 oi->slave->name); 2674 oi->slave->name);
2732 2675
2733 _alloc_links(&ml, &sl); 2676 list_add(&oi->node, &oi->slave->slave_ports);
2734
2735 ml->ocp_if = oi;
2736 list_add(&ml->node, &oi->master->master_ports);
2737 oi->master->masters_cnt++;
2738
2739 sl->ocp_if = oi;
2740 list_add(&sl->node, &oi->slave->slave_ports);
2741 oi->slave->slaves_cnt++; 2677 oi->slave->slaves_cnt++;
2742 2678
2743 return 0; 2679 return 0;
@@ -2784,45 +2720,6 @@ static int __init _register_link(struct omap_hwmod_ocp_if *oi)
2784 return 0; 2720 return 0;
2785} 2721}
2786 2722
2787/**
2788 * _alloc_linkspace - allocate large block of hwmod links
2789 * @ois: pointer to an array of struct omap_hwmod_ocp_if records to count
2790 *
2791 * Allocate a large block of struct omap_hwmod_link records. This
2792 * improves boot time significantly by avoiding the need to allocate
2793 * individual records one by one. If the number of records to
2794 * allocate in the block hasn't been manually specified, this function
2795 * will count the number of struct omap_hwmod_ocp_if records in @ois
2796 * and use that to determine the allocation size. For SoC families
2797 * that require multiple list registrations, such as OMAP3xxx, this
2798 * estimation process isn't optimal, so manual estimation is advised
2799 * in those cases. Returns -EEXIST if the allocation has already occurred
2800 * or 0 upon success.
2801 */
2802static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
2803{
2804 unsigned int i = 0;
2805 unsigned int sz;
2806
2807 if (linkspace) {
2808 WARN(1, "linkspace already allocated\n");
2809 return -EEXIST;
2810 }
2811
2812 if (max_ls == 0)
2813 while (ois[i++])
2814 max_ls += LINKS_PER_OCP_IF;
2815
2816 sz = sizeof(struct omap_hwmod_link) * max_ls;
2817
2818 pr_debug("omap_hwmod: %s: allocating %d byte linkspace (%d links)\n",
2819 __func__, sz, max_ls);
2820
2821 linkspace = memblock_virt_alloc(sz, 0);
2822
2823 return 0;
2824}
2825
2826/* Static functions intended only for use in soc_ops field function pointers */ 2723/* Static functions intended only for use in soc_ops field function pointers */
2827 2724
2828/** 2725/**
@@ -3180,13 +3077,6 @@ int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois)
3180 if (ois[0] == NULL) /* Empty list */ 3077 if (ois[0] == NULL) /* Empty list */
3181 return 0; 3078 return 0;
3182 3079
3183 if (!linkspace) {
3184 if (_alloc_linkspace(ois)) {
3185 pr_err("omap_hwmod: could not allocate link space\n");
3186 return -ENOMEM;
3187 }
3188 }
3189
3190 i = 0; 3080 i = 0;
3191 do { 3081 do {
3192 r = _register_link(ois[i]); 3082 r = _register_link(ois[i]);
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index 78904017f18c..03d5560d0ecd 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -313,6 +313,7 @@ struct omap_hwmod_ocp_if {
313 struct omap_hwmod_addr_space *addr; 313 struct omap_hwmod_addr_space *addr;
314 const char *clk; 314 const char *clk;
315 struct clk *_clk; 315 struct clk *_clk;
316 struct list_head node;
316 union { 317 union {
317 struct omap_hwmod_omap2_firewall omap2; 318 struct omap_hwmod_omap2_firewall omap2;
318 } fw; 319 } fw;
@@ -617,16 +618,6 @@ struct omap_hwmod_class {
617}; 618};
618 619
619/** 620/**
620 * struct omap_hwmod_link - internal structure linking hwmods with ocp_ifs
621 * @ocp_if: OCP interface structure record pointer
622 * @node: list_head pointing to next struct omap_hwmod_link in a list
623 */
624struct omap_hwmod_link {
625 struct omap_hwmod_ocp_if *ocp_if;
626 struct list_head node;
627};
628
629/**
630 * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks) 621 * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks)
631 * @name: name of the hwmod 622 * @name: name of the hwmod
632 * @class: struct omap_hwmod_class * to the class of this hwmod 623 * @class: struct omap_hwmod_class * to the class of this hwmod
@@ -688,7 +679,6 @@ struct omap_hwmod {
688 struct omap_hwmod_opt_clk *opt_clks; 679 struct omap_hwmod_opt_clk *opt_clks;
689 char *clkdm_name; 680 char *clkdm_name;
690 struct clockdomain *clkdm; 681 struct clockdomain *clkdm;
691 struct list_head master_ports; /* connect to *_IA */
692 struct list_head slave_ports; /* connect to *_TA */ 682 struct list_head slave_ports; /* connect to *_TA */
693 void *dev_attr; 683 void *dev_attr;
694 u32 _sysc_cache; 684 u32 _sysc_cache;
@@ -703,7 +693,6 @@ struct omap_hwmod {
703 u8 response_lat; 693 u8 response_lat;
704 u8 rst_lines_cnt; 694 u8 rst_lines_cnt;
705 u8 opt_clks_cnt; 695 u8 opt_clks_cnt;
706 u8 masters_cnt;
707 u8 slaves_cnt; 696 u8 slaves_cnt;
708 u8 hwmods_cnt; 697 u8 hwmods_cnt;
709 u8 _int_flags; 698 u8 _int_flags;