* [PATCH 1/3] add of_find_next_cache_node()
@ 2008-12-11 0:46 Nathan Lynch
2008-12-11 0:46 ` [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node() Nathan Lynch
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-11 0:46 UTC (permalink / raw)
To: linuxppc-dev
We have more than one piece of code that looks up cache nodes manually
using the "l2-cache" property. Add a common helper routine which does
this and handles ePAPR's "next-level-cache" property as well as
powermac.
Signed-off-by: Nathan Lynch <ntl@pobox.com>
---
arch/powerpc/include/asm/prom.h | 3 +++
arch/powerpc/kernel/prom.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index eb3bd2e..6ff0418 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -253,6 +253,9 @@ extern void kdump_move_device_tree(void);
/* CPU OF node matching */
struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
+/* cache lookup */
+struct device_node *of_find_next_cache_node(struct device_node *np);
+
/* Get the MAC address */
extern const void *of_get_mac_address(struct device_node *np);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 3a2dc7e..d8266dd 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1271,6 +1271,37 @@ struct device_node *of_find_node_by_phandle(phandle handle)
EXPORT_SYMBOL(of_find_node_by_phandle);
/**
+ * of_find_next_cache_node - Find a node's subsidiary cache
+ * @np: node of type "cpu" or "cache"
+ *
+ * Returns a node pointer with refcount incremented, use
+ * of_node_put() on it when done. Caller should hold a reference
+ * to np.
+ */
+struct device_node *of_find_next_cache_node(struct device_node *np)
+{
+ struct device_node *child;
+ const phandle *handle;
+
+ handle = of_get_property(np, "l2-cache", NULL);
+ if (!handle)
+ handle = of_get_property(np, "next-level-cache", NULL);
+
+ if (handle)
+ return of_find_node_by_phandle(*handle);
+
+ /* OF on pmac has nodes instead of properties named "l2-cache"
+ * beneath CPU nodes.
+ */
+ if (!strcmp(np->type, "cpu"))
+ for_each_child_of_node(np, child)
+ if (!strcmp(child->type, "cache"))
+ return child;
+
+ return NULL;
+}
+
+/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
--
1.5.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node()
2008-12-11 0:46 [PATCH 1/3] add of_find_next_cache_node() Nathan Lynch
@ 2008-12-11 0:46 ` Nathan Lynch
2008-12-11 1:42 ` Stephen Rothwell
2008-12-11 6:16 ` [PATCH 2/3 v2] " Nathan Lynch
2008-12-11 0:46 ` [PATCH 3/3] convert sysfs cache code " Nathan Lynch
2008-12-14 23:11 ` [PATCH 1/3] add of_find_next_cache_node() Benjamin Herrenschmidt
2 siblings, 2 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-11 0:46 UTC (permalink / raw)
To: linuxppc-dev
The smp code uses cache information to populate cpu_core_map; change
it to use common code for cache lookup.
Signed-off-by: Nathan Lynch <ntl@pobox.com>
---
arch/powerpc/kernel/smp.c | 10 +---------
1 files changed, 1 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index ff9f701..450865b 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -408,8 +408,6 @@ out:
static struct device_node *cpu_to_l2cache(int cpu)
{
struct device_node *np;
- const phandle *php;
- phandle ph;
if (!cpu_present(cpu))
return NULL;
@@ -418,13 +416,7 @@ static struct device_node *cpu_to_l2cache(int cpu)
if (np == NULL)
return NULL;
- php = of_get_property(np, "l2-cache", NULL);
- if (php == NULL)
- return NULL;
- ph = *php;
- of_node_put(np);
-
- return of_find_node_by_phandle(ph);
+ return of_find_next_cache_node(np);
}
/* Activate a secondary processor. */
--
1.5.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/3] convert sysfs cache code to of_find_next_cache_node()
2008-12-11 0:46 [PATCH 1/3] add of_find_next_cache_node() Nathan Lynch
2008-12-11 0:46 ` [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node() Nathan Lynch
@ 2008-12-11 0:46 ` Nathan Lynch
2008-12-14 23:11 ` [PATCH 1/3] add of_find_next_cache_node() Benjamin Herrenschmidt
2 siblings, 0 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-11 0:46 UTC (permalink / raw)
To: linuxppc-dev
Using the common code means that more complete cache information will
provided in sysfs on platforms that don't use the l2-cache property
convention.
Signed-off-by: Nathan Lynch <ntl@pobox.com>
---
arch/powerpc/kernel/sysfs.c | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 20885a3..0c64f10 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -566,7 +566,6 @@ static bool cache_is_unified(struct device_node *np)
static struct cache_desc * __cpuinit create_cache_index_info(struct device_node *np, struct kobject *parent, int index, int level)
{
- const phandle *next_cache_phandle;
struct device_node *next_cache;
struct cache_desc *new, **end;
@@ -591,11 +590,7 @@ static struct cache_desc * __cpuinit create_cache_index_info(struct device_node
while (*end)
end = &(*end)->next;
- next_cache_phandle = of_get_property(np, "l2-cache", NULL);
- if (!next_cache_phandle)
- goto out;
-
- next_cache = of_find_node_by_phandle(*next_cache_phandle);
+ next_cache = of_find_next_cache_node(np);
if (!next_cache)
goto out;
--
1.5.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node()
2008-12-11 0:46 ` [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node() Nathan Lynch
@ 2008-12-11 1:42 ` Stephen Rothwell
2008-12-11 2:00 ` Nathan Lynch
2008-12-11 6:16 ` [PATCH 2/3 v2] " Nathan Lynch
1 sibling, 1 reply; 11+ messages in thread
From: Stephen Rothwell @ 2008-12-11 1:42 UTC (permalink / raw)
To: Nathan Lynch; +Cc: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 576 bytes --]
Hi Nathan,
On Wed, 10 Dec 2008 18:46:05 -0600 Nathan Lynch <ntl@pobox.com> wrote:
>
> @@ -418,13 +416,7 @@ static struct device_node *cpu_to_l2cache(int cpu)
> if (np == NULL)
> return NULL;
>
> - php = of_get_property(np, "l2-cache", NULL);
> - if (php == NULL)
> - return NULL;
> - ph = *php;
> - of_node_put(np);
> -
> - return of_find_node_by_phandle(ph);
> + return of_find_next_cache_node(np);
> }
This leaks a reference on np ...
--
Cheers,
Stephen Rothwell sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node()
2008-12-11 1:42 ` Stephen Rothwell
@ 2008-12-11 2:00 ` Nathan Lynch
0 siblings, 0 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-11 2:00 UTC (permalink / raw)
To: Stephen Rothwell; +Cc: linuxppc-dev
Stephen Rothwell wrote:
> On Wed, 10 Dec 2008 18:46:05 -0600 Nathan Lynch <ntl@pobox.com> wrote:
> >
> > @@ -418,13 +416,7 @@ static struct device_node *cpu_to_l2cache(int cpu)
> > if (np == NULL)
> > return NULL;
> >
> > - php = of_get_property(np, "l2-cache", NULL);
> > - if (php == NULL)
> > - return NULL;
> > - ph = *php;
> > - of_node_put(np);
> > -
> > - return of_find_node_by_phandle(ph);
> > + return of_find_next_cache_node(np);
> > }
>
> This leaks a reference on np ...
Thanks, will fix.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/3 v2] convert cpu_to_l2cache() to of_find_next_cache_node()
2008-12-11 0:46 ` [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node() Nathan Lynch
2008-12-11 1:42 ` Stephen Rothwell
@ 2008-12-11 6:16 ` Nathan Lynch
1 sibling, 0 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-11 6:16 UTC (permalink / raw)
To: linuxppc-dev
The smp code uses cache information to populate cpu_core_map; change
it to use common code for cache lookup.
Signed-off-by: Nathan Lynch <ntl@pobox.com>
---
arch/powerpc/kernel/smp.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
v2: Fix refcount imbalance, thanks to sfr.
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index ff9f701..a112ba9 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -408,8 +408,7 @@ out:
static struct device_node *cpu_to_l2cache(int cpu)
{
struct device_node *np;
- const phandle *php;
- phandle ph;
+ struct device_node *cache;
if (!cpu_present(cpu))
return NULL;
@@ -418,13 +417,11 @@ static struct device_node *cpu_to_l2cache(int cpu)
if (np == NULL)
return NULL;
- php = of_get_property(np, "l2-cache", NULL);
- if (php == NULL)
- return NULL;
- ph = *php;
+ cache = of_find_next_cache_node(np);
+
of_node_put(np);
- return of_find_node_by_phandle(ph);
+ return cache;
}
/* Activate a secondary processor. */
--
1.5.5
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] add of_find_next_cache_node()
2008-12-11 0:46 [PATCH 1/3] add of_find_next_cache_node() Nathan Lynch
2008-12-11 0:46 ` [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node() Nathan Lynch
2008-12-11 0:46 ` [PATCH 3/3] convert sysfs cache code " Nathan Lynch
@ 2008-12-14 23:11 ` Benjamin Herrenschmidt
2008-12-14 23:19 ` Nathan Lynch
2008-12-15 22:33 ` Nathan Lynch
2 siblings, 2 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2008-12-14 23:11 UTC (permalink / raw)
To: Nathan Lynch; +Cc: linuxppc-dev
On Wed, 2008-12-10 at 18:46 -0600, Nathan Lynch wrote:
> + /* OF on pmac has nodes instead of properties named "l2-cache"
> + * beneath CPU nodes.
> + */
> + if (!strcmp(np->type, "cpu"))
> + for_each_child_of_node(np, child)
> + if (!strcmp(child->type, "cache"))
> + return child;
> +
pmac has both actually. And the property points to the node. It's a
problem for /proc/device-tree so we rename them iirc, but only in /proc,
ie, they should still be intact in the tree I think.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] add of_find_next_cache_node()
2008-12-14 23:11 ` [PATCH 1/3] add of_find_next_cache_node() Benjamin Herrenschmidt
@ 2008-12-14 23:19 ` Nathan Lynch
2008-12-15 22:33 ` Nathan Lynch
1 sibling, 0 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-14 23:19 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
Benjamin Herrenschmidt wrote:
> On Wed, 2008-12-10 at 18:46 -0600, Nathan Lynch wrote:
> > + /* OF on pmac has nodes instead of properties named "l2-cache"
> > + * beneath CPU nodes.
> > + */
> > + if (!strcmp(np->type, "cpu"))
> > + for_each_child_of_node(np, child)
> > + if (!strcmp(child->type, "cache"))
> > + return child;
> > +
>
> pmac has both actually. And the property points to the node. It's a
> problem for /proc/device-tree so we rename them iirc, but only in /proc,
> ie, they should still be intact in the tree I think.
Okay, I'll check on this.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] add of_find_next_cache_node()
2008-12-14 23:11 ` [PATCH 1/3] add of_find_next_cache_node() Benjamin Herrenschmidt
2008-12-14 23:19 ` Nathan Lynch
@ 2008-12-15 22:33 ` Nathan Lynch
2008-12-15 23:33 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 11+ messages in thread
From: Nathan Lynch @ 2008-12-15 22:33 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
Benjamin Herrenschmidt wrote:
> On Wed, 2008-12-10 at 18:46 -0600, Nathan Lynch wrote:
> > + /* OF on pmac has nodes instead of properties named "l2-cache"
> > + * beneath CPU nodes.
> > + */
> > + if (!strcmp(np->type, "cpu"))
> > + for_each_child_of_node(np, child)
> > + if (!strcmp(child->type, "cache"))
> > + return child;
> > +
>
> pmac has both actually. And the property points to the node. It's a
> problem for /proc/device-tree so we rename them iirc, but only in /proc,
> ie, they should still be intact in the tree I think.
I see the 'l2-cache' property (renamed to 'l2-cache#1' in /proc) on a
G4 iBook, but it is not present on the two G5 models I've checked.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] add of_find_next_cache_node()
2008-12-15 22:33 ` Nathan Lynch
@ 2008-12-15 23:33 ` Benjamin Herrenschmidt
2008-12-16 0:07 ` Nathan Lynch
0 siblings, 1 reply; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2008-12-15 23:33 UTC (permalink / raw)
To: Nathan Lynch; +Cc: linuxppc-dev
On Mon, 2008-12-15 at 16:33 -0600, Nathan Lynch wrote:
> Benjamin Herrenschmidt wrote:
> > On Wed, 2008-12-10 at 18:46 -0600, Nathan Lynch wrote:
> > > + /* OF on pmac has nodes instead of properties named "l2-cache"
> > > + * beneath CPU nodes.
> > > + */
> > > + if (!strcmp(np->type, "cpu"))
> > > + for_each_child_of_node(np, child)
> > > + if (!strcmp(child->type, "cache"))
> > > + return child;
> > > +
> >
> > pmac has both actually. And the property points to the node. It's a
> > problem for /proc/device-tree so we rename them iirc, but only in /proc,
> > ie, they should still be intact in the tree I think.
>
> I see the 'l2-cache' property (renamed to 'l2-cache#1' in /proc) on a
> G4 iBook, but it is not present on the two G5 models I've checked.
Ah crap.
Oh well, keep your fallback then.
Don't 970MP have a shared L2 tho ? That will make it look like it's not,
I suppose there isn't much we can do about it tho...
Cheers,
Ben.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] add of_find_next_cache_node()
2008-12-15 23:33 ` Benjamin Herrenschmidt
@ 2008-12-16 0:07 ` Nathan Lynch
0 siblings, 0 replies; 11+ messages in thread
From: Nathan Lynch @ 2008-12-16 0:07 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
Benjamin Herrenschmidt wrote:
>
> Don't 970MP have a shared L2 tho ?
The 970MP UM describes 1MB L2 per core, and the device tree on the
quad G5 reflects that... might be interesting to know what it looks
like on IBM JS21 for comparison's sake, but I think we're okay.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-12-16 0:07 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-11 0:46 [PATCH 1/3] add of_find_next_cache_node() Nathan Lynch
2008-12-11 0:46 ` [PATCH 2/3] convert cpu_to_l2cache() to of_find_next_cache_node() Nathan Lynch
2008-12-11 1:42 ` Stephen Rothwell
2008-12-11 2:00 ` Nathan Lynch
2008-12-11 6:16 ` [PATCH 2/3 v2] " Nathan Lynch
2008-12-11 0:46 ` [PATCH 3/3] convert sysfs cache code " Nathan Lynch
2008-12-14 23:11 ` [PATCH 1/3] add of_find_next_cache_node() Benjamin Herrenschmidt
2008-12-14 23:19 ` Nathan Lynch
2008-12-15 22:33 ` Nathan Lynch
2008-12-15 23:33 ` Benjamin Herrenschmidt
2008-12-16 0:07 ` Nathan Lynch
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).