Skip to contentSkip to conversation

enable RTAS /proc for PowerPC/CHRP platform

PATCH In review Nicolas DET 9 participants 32 messages Oct 17, 2006 – Oct 20, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 enable RTAS /proc for PowerPC/CHRP platform

This patch enables RTAS /proc support for PowerPC 32bits / CHRP platform.

A new entry is created (/proc/ppc/rtas/) which contains the RTAS nodes. Theses nodes and the code are the exact same than with the ppc64 architecture.

This patch has been succefully applied on the kernel 2.6.18.1 and tested on bPlan's OpenFirmware.

arch/powerpc/kernel/rtas-proc.c +35 -8
@@ -253,43 +253,70 @@ static void get_location_code(struct seq
 static void check_location_string(struct seq_file *m, char *c);
 static void check_location(struct seq_file *m, char *c);
 
+#ifdef CONFIG_PPC64
+#define PROCRTAS_ROOT "ppc64"
+#else
+#define PROCRTAS_ROOT "ppc"
+static int __init proc_ppc32_create(void)
+{
+        struct proc_dir_entry *root;
+
+        root = proc_mkdir(PROCRTAS_ROOT , NULL);
+        if (!root)
+                return -1;
+
+        if (!proc_mkdir("rtas", root))
+                return -1;
+
+        if (!proc_symlink("rtas", NULL, PROCRTAS_ROOT "/rtas"))
+                return -1;
+
+        return 0;
+}
+#endif
+
 static int __init proc_rtas_init(void)
 {
 	struct proc_dir_entry *entry;
 
-	if (!machine_is(pseries))
+	if ( ! ( machine_is(pseries) || machine_is(chrp) ) )
 		return -ENODEV;
 
 	rtas_node = of_find_node_by_name(NULL, "rtas");
 	if (rtas_node == NULL)
 		return -ENODEV;
 
-	entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL);
+#ifndef CONFIG_PPC64
+	if (proc_ppc32_create() != 0)
+		return -ENODEV;
+#endif
+
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/progress", S_IRUGO|S_IWUSR, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_progress_operations;
 
-	entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL);
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/clock", S_IRUGO|S_IWUSR, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_clock_operations;
 
-	entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_poweron_operations;
 
-	entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL);
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/sensors", S_IRUGO, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_sensors_operations;
 
-	entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO,
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/frequency", S_IWUSR|S_IRUGO,
 				  NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_tone_freq_operations;
 
-	entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL);
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/volume", S_IWUSR|S_IRUGO, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_tone_volume_operations;
 
-	entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL);
+	entry = create_proc_entry(PROCRTAS_ROOT "/rtas/rmo_buffer", S_IRUSR, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_rmo_buf_ops;
 

begin:vcard
fn:Nicolas DET ( bplan GmbH )
n:DET;Nicolas
org:bplan GmbH
adr:;;;;;;Germany
email;internet:[email protected]
title:Software Entwicklung
tel;work:+49 6171 9187 - 31
x-mozilla-html:FALSE
url:http://www.bplan-gmbh.de
version:2.1
end:vcard

#1 lore raw

arch/powerpc/kernel/rtas-proc.c static void get_location_code(struct seq · line 259

Quoted 10 lines
arch/powerpc/kernel/rtas-proc.c +4 -0
@@ -253,43 +253,70 @@ static void get_location_code(struct seq
 static void check_location_string(struct seq_file *m, char *c);
 static void check_location(struct seq_file *m, char *c);
 
+#ifdef CONFIG_PPC64
+#define PROCRTAS_ROOT "ppc64"
+#else
+#define PROCRTAS_ROOT "ppc"

Please don't do any pathname changes. Even if ppc64 isn't correct it's what applications expect and what we should provide for a coherent user interface.

arch/powerpc/kernel/rtas-proc.c static void get_location_code(struct seq · line 283

Quoted 3 lines
arch/powerpc/kernel/rtas-proc.c +1 -1
-	if (!machine_is(pseries))
+	if ( ! ( machine_is(pseries) || machine_is(chrp) ) )
 		return -ENODEV;

This should be the only change you need, and it should follow kernel coding style, aka:

	if (!machine_is(pseries) && !machine_is(chrp))
		return -ENODEV;

arch/powerpc/kernel/rtas-proc.c static void get_location_code(struct seq · line 287

Quoted 3 lines
arch/powerpc/kernel/rtas-proc.c +0 -0
 	rtas_node = of_find_node_by_name(NULL, "rtas");
 	if (rtas_node == NULL)
 		return -ENODEV;

And given this check I wonder why we need the platform check at all. It should be safe to just remove it.

#2 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 6 lines
arch/powerpc/kernel/rtas-proc.c 2006-10-16 10:46:16.000000000 +0200 renamed from arch/powerpc/kernel/rtas-proc.c 2006-10-14 05:34:03.000000000 +0200 +0 -0
@@ -253,43 +253,70 @@ static void get_location_code(struct seq
 static void check_location_string(struct seq_file *m, char *c);
 static void check_location(struct seq_file *m, char *c);
 
Quoted 8 lines

arch/powerpc/kernel/rtas-proc.c 2006-10-16 10:46:16.000000000 +0200 static void get_location_code(struct seq · line 259

Quoted 4 lines
arch/powerpc/kernel/rtas-proc.c 2006-10-16 10:46:16.000000000 +0200 renamed from arch/powerpc/kernel/rtas-proc.c 2006-10-14 05:34:03.000000000 +0200 +4 -0
+#ifdef CONFIG_PPC64
+#define PROCRTAS_ROOT "ppc64"
+#else
+#define PROCRTAS_ROOT "ppc"

Please don't do any pathname changes. Even if ppc64 isn't correct it's what applications expect and what we should provide for a coherent user interface.

Humm, ok.
However, in this case 'ppc' (could be 32 or 64 as it is not specified) is more generic than 'ppc64'.

Quoted 6 lines

This should be the only change you need, and it should follow kernel coding style, aka:

    if (!machine_is(pseries) && !machine_is(chrp))
        return -ENODEV;
Quoted 8 lines

arch/powerpc/kernel/rtas-proc.c 2006-10-16 10:46:16.000000000 +0200 static void get_location_code(struct seq · line 262

Quoted 3 lines
arch/powerpc/kernel/rtas-proc.c 2006-10-16 10:46:16.000000000 +0200 renamed from arch/powerpc/kernel/rtas-proc.c 2006-10-14 05:34:03.000000000 +0200 +0 -0
     rtas_node = of_find_node_by_name(NULL, "rtas");
     if (rtas_node == NULL)
         return -ENODEV;

And given this check I wonder why we need the platform check at all. It should be safe to just remove it.

Indeed, however I can only test on CHRP. I'll remove the check in the upcomming patch.

The patch also include a small code to create the /proc/ppc/rtas entry. Should this be done here, or somewhere in arch/powerpc/chrp/setup.c ?

I will re submit a patch as soon as I can.

begin:vcard
fn:Nicolas DET ( bplan GmbH )
n:DET;Nicolas
org:bplan GmbH
adr:;;;;;;Germany
email;internet:[email protected]
title:Software Entwicklung
tel;work:+49 6171 9187 - 31
x-mozilla-html:FALSE
url:http://www.bplan-gmbh.de
version:2.1
end:vcard

#3 lore raw
Quoted 18 lines · Nicolas DET
Quoted 1 line · Christoph Hellwig
Quoted 1 line

--- a/arch/powerpc/kernel/rtas-proc.c 2006-10-14

05:34:03.000000000 +0200

Quoted 1 line
Quoted 1 line

+++ b/arch/powerpc/kernel/rtas-proc.c 2006-10-16

10:46:16.000000000 +0200

Quoted 4 lines
Quoted 4 lines
arch/powerpc/kernel/rtas-proc.c +0 -0
@@ -253,43 +253,70 @@ static void get_location_code(struct seq
 static void check_location_string(struct seq_file *m, char *c);
 static void check_location(struct seq_file *m, char *c);
 
Quoted 8 lines

arch/powerpc/kernel/rtas-proc.c static void get_location_code(struct seq · line 259

Quoted 4 lines
arch/powerpc/kernel/rtas-proc.c +4 -0
+#ifdef CONFIG_PPC64
+#define PROCRTAS_ROOT "ppc64"
+#else
+#define PROCRTAS_ROOT "ppc"

Please don't do any pathname changes. Even if ppc64 isn't correct it's what applications expect and what we should provide for a coherent user interface.

Quoted 3 lines

Humm, ok.
However, in this case 'ppc' (could be 32 or 64 as it is not specified) is more generic than 'ppc64'.

Christoph, Nicolas, ...

What about doing the logical thing, and switching it to "powerpc" like the recent arch change, or more logically, to "power" like the current rebranding of the whole thing ?

I suppose we can also provide some symlinking or similar for compatibility ? Or move the whole stuff under /sys/.../power/rtas ?

Friendly,

Sven Luther

#4 lore raw
In reply to Nicolas DET
Quoted 18 lines · Nicolas DET
Quoted 1 line · Christoph Hellwig
Quoted 1 line

--- a/arch/powerpc/kernel/rtas-proc.c 2006-10-14

05:34:03.000000000 +0200

Quoted 1 line
Quoted 1 line

+++ b/arch/powerpc/kernel/rtas-proc.c 2006-10-16

10:46:16.000000000 +0200

Quoted 4 lines
Quoted 4 lines
arch/powerpc/kernel/rtas-proc.c +0 -0
@@ -253,43 +253,70 @@ static void get_location_code(struct seq
 static void check_location_string(struct seq_file *m, char *c);
 static void check_location(struct seq_file *m, char *c);
 
Quoted 8 lines

arch/powerpc/kernel/rtas-proc.c static void get_location_code(struct seq · line 259

Quoted 4 lines
arch/powerpc/kernel/rtas-proc.c +4 -0
+#ifdef CONFIG_PPC64
+#define PROCRTAS_ROOT "ppc64"
+#else
+#define PROCRTAS_ROOT "ppc"

Please don't do any pathname changes. Even if ppc64 isn't correct it's what applications expect and what we should provide for a coherent user interface.

Quoted 3 lines

Humm, ok.
However, in this case 'ppc' (could be 32 or 64 as it is not specified) is more generic than 'ppc64'.

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

Quoted 10 lines
Quoted 10 lines

This should be the only change you need, and it should follow kernel coding style, aka:

    if (!machine_is(pseries) && !machine_is(chrp))
        return -ENODEV;
Quoted 3 lines
arch/powerpc/kernel/rtas-proc.c +0 -0
     rtas_node = of_find_node_by_name(NULL, "rtas");
     if (rtas_node == NULL)
         return -ENODEV;
Quoted 7 lines
Quoted 4 lines

And given this check I wonder why we need the platform check at all. It should be safe to just remove it.

Indeed, however I can only test on CHRP. I'll remove the check in the upcomming patch.

That should be fine AFAICT, you should probably just check that each of the proc routines checks for errors - ie. just because you have an "/rtas" node doesn't mean you necessarily have "/rtas/set-indicator" or whatever.

Quoted 2 lines

The patch also include a small code to create the /proc/ppc/rtas entry. Should this be done here, or somewhere in arch/powerpc/chrp/setup.c ?

That code is almost entirely the same as proc_ppc64_create(), so I think you should try and merge them - we want to minimise the number of foo_ppc64() and foo_ppc32() routines we have.

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#5 lore raw
Quoted 9 lines · Michael Ellerman
Quoted 9 lines
Quoted 8 lines

arch/powerpc/kernel/rtas-proc.c static void get_location_code(struct seq · line 259

Quoted 4 lines
arch/powerpc/kernel/rtas-proc.c +4 -0
+#ifdef CONFIG_PPC64
+#define PROCRTAS_ROOT "ppc64"
+#else
+#define PROCRTAS_ROOT "ppc"

Please don't do any pathname changes. Even if ppc64 isn't correct it's what applications expect and what we should provide for a coherent user interface.

Quoted 6 lines
Quoted 3 lines

Humm, ok.
However, in this case 'ppc' (could be 32 or 64 as it is not specified) is more generic than 'ppc64'.

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

Ok. No problem

Quoted 8 lines
Quoted 3 lines

Indeed, however I can only test on CHRP. I'll remove the check in the upcomming patch.

That should be fine AFAICT, you should probably just check that each of the proc routines checks for errors - ie. just because you have an "/rtas" node doesn't mean you necessarily have "/rtas/set-indicator" or whatever.

ok

Quoted 8 lines
Quoted 3 lines

The patch also include a small code to create the /proc/ppc/rtas entry. Should this be done here, or somewhere in arch/powerpc/chrp/setup.c ?

That code is almost entirely the same as proc_ppc64_create(), so I think you should try and merge them - we want to minimise the number of foo_ppc64() and foo_ppc32() routines we have.

Ok.
proc_ppc64_create() is now locate in arch/powerpc/kernel/proc_ppc64.c. Maybe a new file could be created (arch/powerpc/kernel/proc_ppc.c) ?

Any other suggestions?

Just indicate me the direction, and I would provide others patches.

Regards

begin:vcard
fn:Nicolas DET ( bplan GmbH )
n:DET;Nicolas
org:bplan GmbH
adr:;;;;;;Germany
email;internet:[email protected]
title:Software Entwicklung
tel;work:+49 6171 9187 - 31
x-mozilla-html:FALSE
url:http://www.bplan-gmbh.de
version:2.1
end:vcard

#6 lore raw
In reply to Michael Ellerman
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..
You better leave that simple interface.

#7 lore raw
Quoted 7 lines · Olaf Hering
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..

That's really ugly ! You really do that ? Gack...

Quoted 1 line

You better leave that simple interface.

#8 lore raw
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 7 lines · Olaf Hering
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..

That's really ugly ! You really do that ? Gack...

What way should I use?

#9 lore raw
Quoted 8 lines · Olaf Hering
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Olaf Hering
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..

That's really ugly ! You really do that ? Gack...

What way should I use?

uname ? /proc/cpuinfo ? Whatever but not that.

Ben.

#10 lore raw
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 8 lines · Olaf Hering
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines · Olaf Hering
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..

That's really ugly ! You really do that ? Gack...

What way should I use?

uname ? /proc/cpuinfo ? Whatever but not that.

uname can be faked with powerpc32 or setarch. grep POWER /proc/cpuinfo might be an option. I think its only used in rpm preinstall scripts to reject 64bit kernel on 32bit systems or the other way around.

#11 lore raw
Quoted 16 lines · Olaf Hering
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 13 lines · Olaf Hering
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 7 lines · Olaf Hering
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..

That's really ugly ! You really do that ? Gack...

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

What way should I use?

uname ? /proc/cpuinfo ? Whatever but not that.

uname can be faked with powerpc32 or setarch. grep POWER /proc/cpuinfo might be an option. I think its only used in rpm preinstall scripts to reject 64bit kernel on 32bit systems or the other way around.

grep POWER won't do good on 970 among others.

uname can be faked but why do you care ?

In fact, is somebody is faking it, maybe it's because they -want- your scripts to think they are running on a 32 bits box....

I still think uname is the way to go.

Ben.

#12 lore raw
Quoted 25 lines · Benjamin Herrenschmidt
Quoted 16 lines · Olaf Hering
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 13 lines · Olaf Hering
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 7 lines · Olaf Hering
Quoted 2 lines · Michael Ellerman

But it's called '/proc/ppc64' right now on lots of machines, so you can't go changing it.

if test -d /proc/ppc64 .. is a quick way to check wether the system is 64bit or not. Similar to if test -d /proc/iSeries ..

That's really ugly ! You really do that ? Gack...

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

What way should I use?

uname ? /proc/cpuinfo ? Whatever but not that.

uname can be faked with powerpc32 or setarch. grep POWER /proc/cpuinfo might be an option. I think its only used in rpm preinstall scripts to reject 64bit kernel on 32bit systems or the other way around.

Quoted 9 lines

grep POWER won't do good on 970 among others.

uname can be faked but why do you care ?

In fact, is somebody is faking it, maybe it's because they -want- your scripts to think they are running on a 32 bits box....

I still think uname is the way to go.

Ben, would it make sense to add two informations to /proc/cpuinfo ? It would be great to have a field there which will allow to check for the kernel flavour to run, namely if the kernel/processor/whatever is running in 32bit or 64bit mode. The second field would be a generalized machine field, or plateform or whatever, which would easily allow to differentiate between an apple machine, a ibm chrp, a pegasos or other genesi product, etc. Without necessarily having to maintain a huge amount of userlanf mappings from all those different machine: fields, which all have CHRP, true, but no finer grained informations, while we do have it in the kernel.

Friendly,

Sven Luther

#13 lore raw
Quoted 9 lines · Sven Luther

Ben, would it make sense to add two informations to /proc/cpuinfo ? It would be great to have a field there which will allow to check for the kernel flavour to run, namely if the kernel/processor/whatever is running in 32bit or 64bit mode. The second field would be a generalized machine field, or plateform or whatever, which would easily allow to differentiate between an apple machine, a ibm chrp, a pegasos or other genesi product, etc. Without necessarily having to maintain a huge amount of userlanf mappings from all those different machine: fields, which all have CHRP, true, but no finer grained informations, while we do have it in the kernel.

/proc/device-tree/{model,device_type,compatible} is enough to map everything reliable in the installer. Dont pollute /proc/cpuinfo further. There has already enough stuff that doesnt belong there, like pmac-generation, 'pmac flags', 'detected as', motherboard and machine. Oh, and bogomips...

About 32bit/64bit, maybe VmallocTotal from /proc/meminfo can be used. incredible large numer == must be a 64bit kernel
No idea how reliable it is. There are those 36bit systems, but I bet they dont run a distro.

#14 lore raw
Quoted 12 lines · Olaf Hering
Quoted 9 lines · Sven Luther

Ben, would it make sense to add two informations to /proc/cpuinfo ? It would be great to have a field there which will allow to check for the kernel flavour to run, namely if the kernel/processor/whatever is running in 32bit or 64bit mode. The second field would be a generalized machine field, or plateform or whatever, which would easily allow to differentiate between an apple machine, a ibm chrp, a pegasos or other genesi product, etc. Without necessarily having to maintain a huge amount of userlanf mappings from all those different machine: fields, which all have CHRP, true, but no finer grained informations, while we do have it in the kernel.

Quoted 1 line

/proc/device-tree/{model,device_type,compatible} is enough to map

Yeah, well.

Quoted 4 lines

everything reliable in the installer. Dont pollute /proc/cpuinfo further. There has already enough stuff that doesnt belong there, like pmac-generation, 'pmac flags', 'detected as', motherboard and machine. Oh, and bogomips...

Exact, it is not about poluting, but about rationalizing. The fact is that these are the two infos that are the most necessary to userland, then why disseminate the info in thousand different places, instead of making it easily available in a canonical place in a standard format for everyone ?

Quoted 4 lines

About 32bit/64bit, maybe VmallocTotal from /proc/meminfo can be used. incredible large numer == must be a 64bit kernel
No idea how reliable it is. There are those 36bit systems, but I bet they dont run a distro.

This sounds like the ugliest hack i have seen around, and is prone to break. A proper /proc/cpuinfo flag would be most welcome to solve this cleanly.

Friendly,

Sven Luther

#15 lore raw
Quoted 5 lines

Exact, it is not about poluting, but about rationalizing. The fact is that these are the two infos that are the most necessary to userland, then why disseminate the info in thousand different places, instead of making it easily available in a canonical place in a standard format for everyone ?

Why would that be absolutely necessary to userland ? We've lived very well without that so far.

Quoted 7 lines
Quoted 4 lines

About 32bit/64bit, maybe VmallocTotal from /proc/meminfo can be used. incredible large numer == must be a 64bit kernel
No idea how reliable it is. There are those 36bit systems, but I bet they dont run a distro.

This sounds like the ugliest hack i have seen around, and is prone to break. A proper /proc/cpuinfo flag would be most welcome to solve this cleanly.

uname is your friend... damn, and if you want to be real sure, then just try to run a 64 bits binary and see what happens :)

Ben.

#16 lore raw
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines

Exact, it is not about poluting, but about rationalizing. The fact is that these are the two infos that are the most necessary to userland, then why disseminate the info in thousand different places, instead of making it easily available in a canonical place in a standard format for everyone ?

Why would that be absolutely necessary to userland ? We've lived very well without that so far.

Because i already coded at least 4 times in 4 different places, code which does the differentiation for userland, and it is only in debian. All other distributions have this kind of code in their own individual way.

And if there is a new hardware coming out you didn't think about, it is not enough to add support in the kernel, but you have to change all those userland tools all over the place, with load of chances to forget something and break them.

The kernel knows about this, and it would be easy enough to pass that information clearly to userland. /proc/device-tree is indeed a solution for this part.

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

About 32bit/64bit, maybe VmallocTotal from /proc/meminfo can be used. incredible large numer == must be a 64bit kernel
No idea how reliable it is. There are those 36bit systems, but I bet they dont run a distro.

This sounds like the ugliest hack i have seen around, and is prone to break. A proper /proc/cpuinfo flag would be most welcome to solve this cleanly.

uname is your friend... damn, and if you want to be real sure, then just try to run a 64 bits binary and see what happens :)

Why not say it directly in a standard way ? So we avoid all distros and/or different tools who need to know, to implement their own slightly different way ?

Friendly,

Sven Luther

#17 lore raw
Quoted 4 lines

Why not say it directly in a standard way ? So we avoid all distros and/or different tools who need to know, to implement their own slightly different way ?

There is a standard way... uname

Ben.

#18 lore raw
In reply to Sven Luther
Quoted 4 lines · Sven Luther

Exact, it is not about poluting, but about rationalizing. The fact is that these are the two infos that are the most necessary to userland, then why disseminate the info in thousand different places, instead of making it easily available in a canonical place in a standard format for everyone ?

cpuinfo is about the cpu, not the board layout nor the firmware expectations.

#19 lore raw
Quoted 9 lines · Olaf Hering
Quoted 4 lines · Sven Luther

Exact, it is not about poluting, but about rationalizing. The fact is that these are the two infos that are the most necessary to userland, then why disseminate the info in thousand different places, instead of making it easily available in a canonical place in a standard format for everyone ?

cpuinfo is about the cpu, not the board layout nor the firmware expectations.

What is the machine: field doing there then ? Would it make sense to provide a machineinfo then ?

Friendly,

Sven Luther

#20 lore raw
Quoted 8 lines · Sven Luther
Quoted 7 lines · Olaf Hering
Quoted 4 lines · Sven Luther

Exact, it is not about poluting, but about rationalizing. The fact is that these are the two infos that are the most necessary to userland, then why disseminate the info in thousand different places, instead of making it easily available in a canonical place in a standard format for everyone ?

Quoted 5 lines
Quoted 2 lines

cpuinfo is about the cpu, not the board layout nor the firmware expectations.

What is the machine: field doing there then ? Would it make sense to provide a machineinfo then ?

All historical bullshit. Use the device-tree.

#21 lore raw
In reply to Sven Luther
Quoted 5 lines
Quoted 2 lines

cpuinfo is about the cpu, not the board layout nor the firmware expectations.

What is the machine: field doing there then ? Would it make sense to provide a machineinfo then ?

Yes. Or better, don't use /proc, get all info from sysfs (with a nice userland tool to summarize the info, perhaps).

Segher

#22 lore raw
Quoted 9 lines · Segher Boessenkool
Quoted 6 lines
Quoted 2 lines

cpuinfo is about the cpu, not the board layout nor the firmware expectations.

What is the machine: field doing there then ? Would it make sense to provide a
machineinfo then ?

Yes. Or better, don't use /proc, get all info from sysfs (with a nice userland tool to summarize the info, perhaps).

Yeah, that makes sense. Will the device-tree move to /sys some day ? What about things like the /rtas node ?

But it will be years before all the distros move to it probably, see how most of them still use parsing of the parted command line output for handling partition table detection, and thus fail on anything not MBR.

Friendly,

Sven Luther

#23 lore raw
Quoted 1 line · Sven Luther

Yeah, that makes sense. Will the device-tree move to /sys some day ? What

Moving /proc/device-tree would be an insane change.

#24 lore raw
Quoted 3 lines
Quoted 1 line

Yeah, that makes sense. Will the device-tree move to /sys some day ? What

Moving /proc/device-tree would be an insane change.

It should really be a separate filesystem, not part of procfs; and then people can mount it wherever they want (in theory).

Segher

#25 lore raw
In reply to Olaf Hering
Quoted 12 lines · Olaf Hering
Quoted 9 lines · Sven Luther

Ben, would it make sense to add two informations to /proc/cpuinfo ? It would be great to have a field there which will allow to check for the kernel flavour to run, namely if the kernel/processor/whatever is running in 32bit or 64bit mode. The second field would be a generalized machine field, or plateform or whatever, which would easily allow to differentiate between an apple machine, a ibm chrp, a pegasos or other genesi product, etc. Without necessarily having to maintain a huge amount of userlanf mappings from all those different machine: fields, which all have CHRP, true, but no finer grained informations, while we do have it in the kernel.

Quoted 5 lines

/proc/device-tree/{model,device_type,compatible} is enough to map everything reliable in the installer. Dont pollute /proc/cpuinfo further. There has already enough stuff that doesnt belong there, like pmac-generation, 'pmac flags', 'detected as', motherboard and machine. Oh, and bogomips...

Some powermac detection bits for older models are not actually available via the device-tree :)

Quoted 4 lines

About 32bit/64bit, maybe VmallocTotal from /proc/meminfo can be used. incredible large numer == must be a 64bit kernel
No idea how reliable it is. There are those 36bit systems, but I bet they dont run a distro.

But why are you absolutely trying to defeat uname ?

If somebody is trying to fake it, then use the faked version !

Ben.

#26 lore raw
Quoted 8 lines · Benjamin Herrenschmidt
Quoted 5 lines

/proc/device-tree/{model,device_type,compatible} is enough to map everything reliable in the installer. Dont pollute /proc/cpuinfo further. There has already enough stuff that doesnt belong there, like pmac-generation, 'pmac flags', 'detected as', motherboard and machine. Oh, and bogomips...

Some powermac detection bits for older models are not actually available via the device-tree :)

What is missing?

#27 lore raw
Quoted 8 lines · Olaf Hering
Quoted 6 lines · Benjamin Herrenschmidt
Quoted 5 lines

/proc/device-tree/{model,device_type,compatible} is enough to map everything reliable in the installer. Dont pollute /proc/cpuinfo further. There has already enough stuff that doesnt belong there, like pmac-generation, 'pmac flags', 'detected as', motherboard and machine. Oh, and bogomips...

Quoted 4 lines
Quoted 2 lines

Some powermac detection bits for older models are not actually available via the device-tree :)

What is missing?

Well, PowerBook 2400 vs. 3400 typically. There is more that we don't even implement in the kernel yet but maybe one day ... :)

Ben.

#28 lore raw
In reply to Olaf Hering
Quoted 4 lines · Olaf Hering

About 32bit/64bit, maybe VmallocTotal from /proc/meminfo can be used. incredible large numer == must be a 64bit kernel
No idea how reliable it is. There are those 36bit systems, but I bet they dont run a distro.

They only have 32-bit effective addresses and therefore a similar VmallocTotal to any other 32-bit powerpc machine.

Paul.

#29 lore raw
In reply to Christoph Hellwig
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines

=A0=A0=A0=A0=A0=A0rtas_node =3D of_find_node_by_name(NULL, "rtas"); =A0=A0=A0=A0=A0=A0if (rtas_node =3D=3D NULL) =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0return -ENODEV;

=20
And given this check I wonder why we need the platform check at all. =A0It should be safe to just remove it.
=20

One difference would be that it triggers on machines running SLOF (QS20,=20 some JS20/JS21) and maybe some older Macs, which is probably a good thing.

I wonder if it should be a little stricter though:

Quoted 3 lines
	rtas_node =3D of_find_node_by_path("/rtas");
	if (!rtas_node)
		return -ENODEV;

In case there is a node called "rtas" somewhere else.

	Arnd <><
#30 lore raw
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · Christoph Hellwig
Quoted 3 lines
      rtas_node = of_find_node_by_name(NULL, "rtas");
      if (rtas_node == NULL)
              return -ENODEV;
Quoted 7 lines
Quoted 3 lines

And given this check I wonder why we need the platform check at all. It should be safe to just remove it.

One difference would be that it triggers on machines running SLOF (QS20, some JS20/JS21) and maybe some older Macs, which is probably a good thing.

Older macs may have bits of RTAS, but it doesn't work. I'd rather still blacklist machine_is(powermac).

Quoted 7 lines

I wonder if it should be a little stricter though:

Quoted 3 lines
	rtas_node = of_find_node_by_path("/rtas");
	if (!rtas_node)
		return -ENODEV;

In case there is a node called "rtas" somewhere else.

Yeah, just in case...

Ben.

#31 lore raw
In reply to Arnd Bergmann
Quoted 13 lines · Arnd Bergmann
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines
      rtas_node = of_find_node_by_name(NULL, "rtas");
      if (rtas_node == NULL)
              return -ENODEV;

And given this check I wonder why we need the platform check at all. It should be safe to just remove it.

One difference would be that it triggers on machines running SLOF (QS20, some JS20/JS21) and maybe some older Macs, which is probably a good thing.

I wonder if it should be a little stricter though:

Quoted 8 lines
Quoted 3 lines
    rtas_node = of_find_node_by_path("/rtas");
    if (!rtas_node)
        return -ENODEV;

In case there is a node called "rtas" somewhere else.

    Arnd <><

Maybe we could check for the RTAS revision. The CHRP manual define this properties 'rtas-version' in /rtas/. This should be 1 for current implementation.

You can find here a new patch. It does not create the /proc/rtas and the symlink /proc/ppc64/rtas in arch/powerpc/kernel/proc_ppc64.c anymore but rather create the entry (/proc/rtas) in arch/powerpc/kernel/rtas-proc.c and only the ppc64/ratas link for 64bit machine.

This has been tested on our PowerPC 32bit machine. It would be nice if PowerPC64 developer could reveiw and test it.

I stay ready to test upcomming patch if required.

Regards

arch/powerpc/kernel/proc_ppc64.c +0 -9
diff -uprN a/arch/powerpc/kernel/proc_ppc64.c b/arch/powerpc/kernel/proc_ppc64.c
@@ -51,15 +51,6 @@ static int __init proc_ppc64_create(void
 	if (!root)
 		return 1;
 
-	if (!of_find_node_by_path("/rtas"))
-		return 0;
-
-	if (!proc_mkdir("rtas", root))
-		return 1;
-
-	if (!proc_symlink("rtas", NULL, "ppc64/rtas"))
-		return 1;
-
 	return 0;
 }
 core_initcall(proc_ppc64_create);
arch/powerpc/kernel/rtas-proc.c +27 -10
diff -uprN a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
@@ -253,43 +253,60 @@ static void get_location_code(struct seq
 static void check_location_string(struct seq_file *m, char *c);
 static void check_location(struct seq_file *m, char *c);
 
+static int __init proc_rtas_create(void)
+{
+        struct proc_dir_entry *root;
+
+        root = proc_mkdir("rtas" , NULL);
+        if (!root)
+                return -1;
+
+
+#ifdef CONFIG_PPC64
+        if (!proc_symlink("rtas", NULL, "ppc64/rtas"))
+                return -1;
+#endif
+
+        return 0;
+}
+
 static int __init proc_rtas_init(void)
 {
 	struct proc_dir_entry *entry;
 
-	if (!machine_is(pseries))
-		return -ENODEV;
-
 	rtas_node = of_find_node_by_name(NULL, "rtas");
 	if (rtas_node == NULL)
 		return -ENODEV;
 
-	entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL);
+	if (proc_rtas_create() != 0)
+		return -ENODEV;
+
+	entry = create_proc_entry("/rtas/progress", S_IRUGO|S_IWUSR, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_progress_operations;
 
-	entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL);
+	entry = create_proc_entry("/rtas/clock", S_IRUGO|S_IWUSR, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_clock_operations;
 
-	entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
+	entry = create_proc_entry("/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_poweron_operations;
 
-	entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL);
+	entry = create_proc_entry("/rtas/sensors", S_IRUGO, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_sensors_operations;
 
-	entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO,
+	entry = create_proc_entry("/rtas/frequency", S_IWUSR|S_IRUGO,
 				  NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_tone_freq_operations;
 
-	entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL);
+	entry = create_proc_entry("/rtas/volume", S_IWUSR|S_IRUGO, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_tone_volume_operations;
 
-	entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL);
+	entry = create_proc_entry("/rtas/rmo_buffer", S_IRUSR, NULL);
 	if (entry)
 		entry->proc_fops = &ppc_rtas_rmo_buf_ops;
 

begin:vcard
fn:Nicolas DET ( bplan GmbH )
n:DET;Nicolas
org:bplan GmbH
adr:;;;;;;Germany
email;internet:[email protected]
title:Software Entwicklung
tel;work:+49 6171 9187 - 31
x-mozilla-html:FALSE
url:http://www.bplan-gmbh.de
version:2.1
end:vcard