Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a1e31235 authored by Tony Lindgren's avatar Tony Lindgren
Browse files

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: default avatarTony Lindgren <tony@atomide.com>
parent c1ae3cfa
Loading
Loading
Loading
Loading
+3 −113
Original line number Original line Diff line number Diff line
@@ -138,7 +138,6 @@
#include <linux/mutex.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/bootmem.h>
#include <linux/cpu.h>
#include <linux/cpu.h>
#include <linux/of.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_address.h>
@@ -216,20 +215,6 @@ static LIST_HEAD(omap_hwmod_list);
/* mpu_oh: used to add/remove MPU initiator from sleepdep list */
/* mpu_oh: used to add/remove MPU initiator from sleepdep list */
static struct omap_hwmod *mpu_oh;
static struct omap_hwmod *mpu_oh;


/*
 * linkspace: ptr to a buffer that struct omap_hwmod_link records are
 * allocated from - used to reduce the number of small memory
 * allocations, which has a significant impact on performance
 */
static struct omap_hwmod_link *linkspace;

/*
 * free_ls, max_ls: array indexes into linkspace; representing the
 * next free struct omap_hwmod_link index, and the maximum number of
 * struct omap_hwmod_link records allocated (respectively)
 */
static unsigned short free_ls, max_ls, ls_supp;

/* inited: set to true once the hwmod code is initialized */
/* inited: set to true once the hwmod code is initialized */
static bool inited;
static bool inited;


@@ -250,7 +235,7 @@ static struct omap_hwmod_ocp_if *_fetch_next_ocp_if(struct list_head **p,
{
{
	struct omap_hwmod_ocp_if *oi;
	struct omap_hwmod_ocp_if *oi;


	oi = list_entry(*p, struct omap_hwmod_link, node)->ocp_if;
	oi = list_entry(*p, struct omap_hwmod_ocp_if, node);
	*p = (*p)->next;
	*p = (*p)->next;


	*i = *i + 1;
	*i = *i + 1;
@@ -2657,7 +2642,6 @@ static int __init _register(struct omap_hwmod *oh)


	list_add_tail(&oh->node, &omap_hwmod_list);
	list_add_tail(&oh->node, &omap_hwmod_list);


	INIT_LIST_HEAD(&oh->master_ports);
	INIT_LIST_HEAD(&oh->slave_ports);
	INIT_LIST_HEAD(&oh->slave_ports);
	spin_lock_init(&oh->_lock);
	spin_lock_init(&oh->_lock);
	lockdep_set_class(&oh->_lock, &oh->hwmod_key);
	lockdep_set_class(&oh->_lock, &oh->hwmod_key);
@@ -2674,50 +2658,11 @@ static int __init _register(struct omap_hwmod *oh)
	return 0;
	return 0;
}
}


/**
 * _alloc_links - return allocated memory for hwmod links
 * @ml: pointer to a struct omap_hwmod_link * for the master link
 * @sl: pointer to a struct omap_hwmod_link * for the slave link
 *
 * Return pointers to two struct omap_hwmod_link records, via the
 * addresses pointed to by @ml and @sl.  Will first attempt to return
 * memory allocated as part of a large initial block, but if that has
 * been exhausted, will allocate memory itself.  Since ideally this
 * second allocation path will never occur, the number of these
 * 'supplemental' allocations will be logged when debugging is
 * enabled.  Returns 0.
 */
static int __init _alloc_links(struct omap_hwmod_link **ml,
			       struct omap_hwmod_link **sl)
{
	unsigned int sz;

	if ((free_ls + LINKS_PER_OCP_IF) <= max_ls) {
		*ml = &linkspace[free_ls++];
		*sl = &linkspace[free_ls++];
		return 0;
	}

	sz = sizeof(struct omap_hwmod_link) * LINKS_PER_OCP_IF;

	*sl = NULL;
	*ml = memblock_virt_alloc(sz, 0);

	*sl = (void *)(*ml) + sizeof(struct omap_hwmod_link);

	ls_supp++;
	pr_debug("omap_hwmod: supplemental link allocations needed: %d\n",
		 ls_supp * LINKS_PER_OCP_IF);

	return 0;
};

/**
/**
 * _add_link - add an interconnect between two IP blocks
 * _add_link - add an interconnect between two IP blocks
 * @oi: pointer to a struct omap_hwmod_ocp_if record
 * @oi: pointer to a struct omap_hwmod_ocp_if record
 *
 *
 * Add struct omap_hwmod_link records connecting the master IP block
 * Add struct omap_hwmod_link records connecting the slave IP block
 * specified in @oi->master to @oi, and connecting the slave IP block
 * specified in @oi->slave to @oi.  This code is assumed to run before
 * specified in @oi->slave to @oi.  This code is assumed to run before
 * preemption or SMP has been enabled, thus avoiding the need for
 * preemption or SMP has been enabled, thus avoiding the need for
 * locking in this code.  Changes to this assumption will require
 * locking in this code.  Changes to this assumption will require
@@ -2725,19 +2670,10 @@ static int __init _alloc_links(struct omap_hwmod_link **ml,
 */
 */
static int __init _add_link(struct omap_hwmod_ocp_if *oi)
static int __init _add_link(struct omap_hwmod_ocp_if *oi)
{
{
	struct omap_hwmod_link *ml, *sl;

	pr_debug("omap_hwmod: %s -> %s: adding link\n", oi->master->name,
	pr_debug("omap_hwmod: %s -> %s: adding link\n", oi->master->name,
		 oi->slave->name);
		 oi->slave->name);


	_alloc_links(&ml, &sl);
	list_add(&oi->node, &oi->slave->slave_ports);

	ml->ocp_if = oi;
	list_add(&ml->node, &oi->master->master_ports);
	oi->master->masters_cnt++;

	sl->ocp_if = oi;
	list_add(&sl->node, &oi->slave->slave_ports);
	oi->slave->slaves_cnt++;
	oi->slave->slaves_cnt++;


	return 0;
	return 0;
@@ -2784,45 +2720,6 @@ static int __init _register_link(struct omap_hwmod_ocp_if *oi)
	return 0;
	return 0;
}
}


/**
 * _alloc_linkspace - allocate large block of hwmod links
 * @ois: pointer to an array of struct omap_hwmod_ocp_if records to count
 *
 * Allocate a large block of struct omap_hwmod_link records.  This
 * improves boot time significantly by avoiding the need to allocate
 * individual records one by one.  If the number of records to
 * allocate in the block hasn't been manually specified, this function
 * will count the number of struct omap_hwmod_ocp_if records in @ois
 * and use that to determine the allocation size.  For SoC families
 * that require multiple list registrations, such as OMAP3xxx, this
 * estimation process isn't optimal, so manual estimation is advised
 * in those cases.  Returns -EEXIST if the allocation has already occurred
 * or 0 upon success.
 */
static int __init _alloc_linkspace(struct omap_hwmod_ocp_if **ois)
{
	unsigned int i = 0;
	unsigned int sz;

	if (linkspace) {
		WARN(1, "linkspace already allocated\n");
		return -EEXIST;
	}

	if (max_ls == 0)
		while (ois[i++])
			max_ls += LINKS_PER_OCP_IF;

	sz = sizeof(struct omap_hwmod_link) * max_ls;

	pr_debug("omap_hwmod: %s: allocating %d byte linkspace (%d links)\n",
		 __func__, sz, max_ls);

	linkspace = memblock_virt_alloc(sz, 0);

	return 0;
}

/* Static functions intended only for use in soc_ops field function pointers */
/* Static functions intended only for use in soc_ops field function pointers */


/**
/**
@@ -3180,13 +3077,6 @@ int __init omap_hwmod_register_links(struct omap_hwmod_ocp_if **ois)
	if (ois[0] == NULL) /* Empty list */
	if (ois[0] == NULL) /* Empty list */
		return 0;
		return 0;


	if (!linkspace) {
		if (_alloc_linkspace(ois)) {
			pr_err("omap_hwmod: could not allocate link space\n");
			return -ENOMEM;
		}
	}

	i = 0;
	i = 0;
	do {
	do {
		r = _register_link(ois[i]);
		r = _register_link(ois[i]);
+1 −12
Original line number Original line Diff line number Diff line
@@ -313,6 +313,7 @@ struct omap_hwmod_ocp_if {
	struct omap_hwmod_addr_space	*addr;
	struct omap_hwmod_addr_space	*addr;
	const char			*clk;
	const char			*clk;
	struct clk			*_clk;
	struct clk			*_clk;
	struct list_head		node;
	union {
	union {
		struct omap_hwmod_omap2_firewall omap2;
		struct omap_hwmod_omap2_firewall omap2;
	}				fw;
	}				fw;
@@ -616,16 +617,6 @@ struct omap_hwmod_class {
	void					(*unlock)(struct omap_hwmod *oh);
	void					(*unlock)(struct omap_hwmod *oh);
};
};


/**
 * struct omap_hwmod_link - internal structure linking hwmods with ocp_ifs
 * @ocp_if: OCP interface structure record pointer
 * @node: list_head pointing to next struct omap_hwmod_link in a list
 */
struct omap_hwmod_link {
	struct omap_hwmod_ocp_if	*ocp_if;
	struct list_head		node;
};

/**
/**
 * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks)
 * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks)
 * @name: name of the hwmod
 * @name: name of the hwmod
@@ -688,7 +679,6 @@ struct omap_hwmod {
	struct omap_hwmod_opt_clk	*opt_clks;
	struct omap_hwmod_opt_clk	*opt_clks;
	char				*clkdm_name;
	char				*clkdm_name;
	struct clockdomain		*clkdm;
	struct clockdomain		*clkdm;
	struct list_head		master_ports; /* connect to *_IA */
	struct list_head		slave_ports; /* connect to *_TA */
	struct list_head		slave_ports; /* connect to *_TA */
	void				*dev_attr;
	void				*dev_attr;
	u32				_sysc_cache;
	u32				_sysc_cache;
@@ -703,7 +693,6 @@ struct omap_hwmod {
	u8				response_lat;
	u8				response_lat;
	u8				rst_lines_cnt;
	u8				rst_lines_cnt;
	u8				opt_clks_cnt;
	u8				opt_clks_cnt;
	u8				masters_cnt;
	u8				slaves_cnt;
	u8				slaves_cnt;
	u8				hwmods_cnt;
	u8				hwmods_cnt;
	u8				_int_flags;
	u8				_int_flags;