From: Andrew Morton <akpm@linux-foundation.org>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Grant Likely <grant.likely@secretlab.ca>,
Rob Herring <rob.herring@calxeda.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Shawn Guo <shawn.guo@linaro.org>,
Richard Zhao <richard.zhao@freescale.com>,
Huang Shijie <shijie8@gmail.com>,
Dong Aisheng <dong.aisheng@linaro.org>,
Matt Porter <mporter@ti.com>,
Fabio Estevam <fabio.estevam@freescale.com>,
Javier Martin <javier.martin@vista-silicon.com>,
kernel@pengutronix.de, devicetree-discuss@lists.ozlabs.org
Subject: Re: [PATCH v6 1/4] genalloc: add a global pool list, allow to find pools by phys address
Date: Tue, 20 Nov 2012 23:46:13 -0800 [thread overview]
Message-ID: <20121120234613.47d8183c.akpm@linux-foundation.org> (raw)
In-Reply-To: <1353061817-3207-2-git-send-email-p.zabel@pengutronix.de>
On Fri, 16 Nov 2012 11:30:14 +0100 Philipp Zabel <p.zabel@pengutronix.de> wrote:
> This patch keeps all created pools in a global list and adds two
> functions that allow to retrieve the gen_pool pointer from a known
> physical address and from a device tree node.
>
> ...
>
> +/*
> + * gen_pool_find_by_phys - find a pool by physical start address
> + * @phys: physical address as added with gen_pool_add_virt
> + *
> + * Returns the pool that contains the chunk starting at phys,
> + * or NULL if not found.
> + */
> +struct gen_pool *gen_pool_find_by_phys(phys_addr_t phys)
> +{
> + struct gen_pool *pool, *found = NULL;
> + struct gen_pool_chunk *chunk;
> +
> + rcu_read_lock();
> + list_for_each_entry_rcu(pool, &pools, next_pool) {
> + list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
> + if (phys == chunk->phys_addr) {
> + found = pool;
> + break;
> + }
> + }
> + }
> + rcu_read_unlock();
> +
> + return found;
> +}
> +EXPORT_SYMBOL_GPL(gen_pool_find_by_phys);
It is rather pointless to use the fancy super-fast RCU locking
around a linear search! We have various data structures which can be
used to make this search much more efficient. radix-tree is one, if
the search keys are unique (which is the case here).
Secondly, that whole "phys" concept doesn't need to be in there. It
would be better to implement a far more general
gen_pool_find_by_key(unsigned long key) and then do the phys->ulong
specialization elsewhere.
Finally the changelog gives no indication *why* you feel the kernel
needs this feature. What is it for? What are the use cases? This is
the most important information for reviewers, hence it should be up
there front and center, in lavish detail.
Because once this is understood:
a) people might be able to suggest alternatives. Can't do that
without the required info and
b) people might then be interested in merging the patch into a kernel!
> +#ifdef CONFIG_OF
> +/**
> + * of_get_named_gen_pool - find a pool by phandle property
> + * @np: device node
> + * @propname: property name containing phandle(s)
> + * @index: index into the phandle array
> + *
> + * Returns the pool that contains the chunk starting at the physical
> + * address of the device tree node pointed at by the phandle property,
> + * or NULL if not found.
> + */
> +struct gen_pool *of_get_named_gen_pool(struct device_node *np,
> + const char *propname, int index)
> +{
> + struct device_node *np_pool;
> + struct resource res;
> + int ret;
> +
> + np_pool = of_parse_phandle(np, propname, index);
> + if (!np_pool)
> + return NULL;
> + ret = of_address_to_resource(np_pool, 0, &res);
> + if (ret < 0)
> + return NULL;
> + return gen_pool_find_by_phys((phys_addr_t) res.start);
> +}
> +EXPORT_SYMBOL_GPL(of_get_named_gen_pool);
Seems rather inappropriate that this should be in lib/genpool.c.
Put it somewhere such as drivers/of/base.c, perhaps.
next prev parent reply other threads:[~2012-11-21 7:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-16 10:30 [PATCH v6 0/4] Add generic driver for on-chip SRAM Philipp Zabel
2012-11-16 10:30 ` [PATCH v6 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
2012-11-21 7:46 ` Andrew Morton [this message]
2012-11-16 10:30 ` [PATCH v6 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
[not found] ` <1353061817-3207-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-16 10:30 ` [PATCH v6 3/4] media: coda: use genalloc API Philipp Zabel
[not found] ` <1353061817-3207-4-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-11-16 15:08 ` Paul Gortmaker
2012-11-16 15:21 ` Philipp Zabel
[not found] ` <1353079273.2413.160.camel-/rZezPiN1rtR6QfukMTsflXZhhPuCNm+@public.gmane.org>
2012-11-16 16:00 ` Paul Gortmaker
2012-11-16 16:51 ` Philipp Zabel
[not found] ` <1353084667.2413.414.camel-/rZezPiN1rtR6QfukMTsflXZhhPuCNm+@public.gmane.org>
2012-11-19 15:21 ` Paul Gortmaker
2012-11-16 10:30 ` [PATCH v6 4/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121120234613.47d8183c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dong.aisheng@linaro.org \
--cc=fabio.estevam@freescale.com \
--cc=grant.likely@secretlab.ca \
--cc=gregkh@linuxfoundation.org \
--cc=javier.martin@vista-silicon.com \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mporter@ti.com \
--cc=p.zabel@pengutronix.de \
--cc=paul.gortmaker@windriver.com \
--cc=richard.zhao@freescale.com \
--cc=rob.herring@calxeda.com \
--cc=shawn.guo@linaro.org \
--cc=shijie8@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).