devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of/flattree: print memory scan node results in CPU endian
@ 2015-04-08  6:44 Florian Fainelli
  2015-04-08 21:19 ` Frank Rowand
  0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2015-04-08  6:44 UTC (permalink / raw)
  To: devicetree; +Cc: linux-kernel, robh+dt, grant.likely, Florian Fainelli

Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
common code") consolidated some code from PowerPC (typically
big-endian), and ended-up adding a pr_debug() printing reg properties in
big-endian (DT native) format, not CPU endian. Unsurprisingly, when
these messages are turned on a little-endian systems, this is confusing,
so do the conversion while printing the values.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/of/fdt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3a896c9aeb74..0d8f0e4bd107 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -880,7 +880,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
 	endp = reg + (l / sizeof(__be32));
 
 	pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
-	    uname, l, reg[0], reg[1], reg[2], reg[3]);
+	    uname, l, be32_to_cpu(reg[0]), be32_to_cpu(reg[1]),
+	    be32_to_cpu(reg[2]), be32_to_cpu(reg[3]));
 
 	while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
 		u64 base, size;
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] of/flattree: print memory scan node results in CPU endian
  2015-04-08  6:44 [PATCH] of/flattree: print memory scan node results in CPU endian Florian Fainelli
@ 2015-04-08 21:19 ` Frank Rowand
       [not found]   ` <55259B4D.2020304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Frank Rowand @ 2015-04-08 21:19 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: devicetree, linux-kernel, robh+dt, grant.likely

On 4/7/2015 11:44 PM, Florian Fainelli wrote:
> Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
> common code") consolidated some code from PowerPC (typically
> big-endian), and ended-up adding a pr_debug() printing reg properties in
> big-endian (DT native) format, not CPU endian. Unsurprisingly, when
> these messages are turned on a little-endian systems, this is confusing,
> so do the conversion while printing the values.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/of/fdt.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9aeb74..0d8f0e4bd107 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -880,7 +880,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>  	endp = reg + (l / sizeof(__be32));
>  
>  	pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
> -	    uname, l, reg[0], reg[1], reg[2], reg[3]);
> +	    uname, l, be32_to_cpu(reg[0]), be32_to_cpu(reg[1]),
> +	    be32_to_cpu(reg[2]), be32_to_cpu(reg[3]));

The pr_debug() assumes that the length of reg[] is >= 4 elements, which might not be true.
Since the following while loop checks the length of reg[] and then uses pr_debug() to
print each (base, size) tuple with the correct endian, maybe it would be better to
just remove reg[0] through reg[3] from the above pr_debug() instead of fixing the
endian issue.

>  
>  	while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
>  		u64 base, size;
> 

-Frank

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] of/flattree: print memory scan node results in CPU endian
       [not found]   ` <55259B4D.2020304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-04-09  3:17     ` Florian Fainelli
  2015-04-12 20:16     ` [PATCH] of/fdt: Remove "reg" data prints from early_init_dt_scan_memory Florian Fainelli
  1 sibling, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2015-04-09  3:17 UTC (permalink / raw)
  To: frowand.list-Re5JQEeQqe8AvxtiuMwx3w
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A

Le 08/04/2015 14:19, Frank Rowand a écrit :
> On 4/7/2015 11:44 PM, Florian Fainelli wrote:
>> Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
>> common code") consolidated some code from PowerPC (typically
>> big-endian), and ended-up adding a pr_debug() printing reg properties in
>> big-endian (DT native) format, not CPU endian. Unsurprisingly, when
>> these messages are turned on a little-endian systems, this is confusing,
>> so do the conversion while printing the values.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  drivers/of/fdt.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 3a896c9aeb74..0d8f0e4bd107 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -880,7 +880,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>>  	endp = reg + (l / sizeof(__be32));
>>  
>>  	pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
>> -	    uname, l, reg[0], reg[1], reg[2], reg[3]);
>> +	    uname, l, be32_to_cpu(reg[0]), be32_to_cpu(reg[1]),
>> +	    be32_to_cpu(reg[2]), be32_to_cpu(reg[3]));
> 
> The pr_debug() assumes that the length of reg[] is >= 4 elements, which might not be true.
> Since the following while loop checks the length of reg[] and then uses pr_debug() to
> print each (base, size) tuple with the correct endian, maybe it would be better to
> just remove reg[0] through reg[3] from the above pr_debug() instead of fixing the
> endian issue.

Right, that works too, will follow-up with a patch removing the
reg[0..3] prints.

Thanks!
--
Florian
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] of/fdt: Remove "reg" data prints from early_init_dt_scan_memory
       [not found]   ` <55259B4D.2020304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2015-04-09  3:17     ` Florian Fainelli
@ 2015-04-12 20:16     ` Florian Fainelli
       [not found]       ` <1428869786-26897-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2015-04-12 20:16 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w, Florian Fainelli

Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
common code") consolidated some code from PowerPC (typically
big-endian), and ended-up adding a pr_debug() printing reg properties in
big-endian (DT native) format, not CPU endian.

This debug print suffers from two problems:
- we only print 4 "reg" values, while there could be more on typical
  systems having multiple memory ranges
- we print these 4 "reg" values in FDT endianess, that is big-endian,
  and these values could be confusing for little-endian configurations

Since we are already printing the base address and size of the memory
regions parsed by early_init_dt_scan_memory() later in a way that is
both endian correct, and takes into account arbitrary number of memory
banks, just remove that part of the debug print.

Suggested-by: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Patch against devicetree/next

 drivers/of/fdt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3a896c9..34bdc4d 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -879,8 +879,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
 
 	endp = reg + (l / sizeof(__be32));
 
-	pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
-	    uname, l, reg[0], reg[1], reg[2], reg[3]);
+	pr_debug("memory scan node %s, reg size %d,\n", uname, l);
 
 	while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
 		u64 base, size;
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] of/fdt: Remove "reg" data prints from early_init_dt_scan_memory
       [not found]       ` <1428869786-26897-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2015-04-15 12:52         ` Rob Herring
  0 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2015-04-15 12:52 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Rob Herring,
	Grant Likely, Frank Rowand

On Sun, Apr 12, 2015 at 3:16 PM, Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Commit 51975db0b7333 ("of/flattree: merge early_init_dt_scan_memory()
> common code") consolidated some code from PowerPC (typically
> big-endian), and ended-up adding a pr_debug() printing reg properties in
> big-endian (DT native) format, not CPU endian.
>
> This debug print suffers from two problems:
> - we only print 4 "reg" values, while there could be more on typical
>   systems having multiple memory ranges
> - we print these 4 "reg" values in FDT endianess, that is big-endian,
>   and these values could be confusing for little-endian configurations
>
> Since we are already printing the base address and size of the memory
> regions parsed by early_init_dt_scan_memory() later in a way that is
> both endian correct, and takes into account arbitrary number of memory
> banks, just remove that part of the debug print.
>
> Suggested-by: Frank Rowand <frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> Patch against devicetree/next

Applied. Thanks.

Rob

>
>  drivers/of/fdt.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9..34bdc4d 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -879,8 +879,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
>
>         endp = reg + (l / sizeof(__be32));
>
> -       pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
> -           uname, l, reg[0], reg[1], reg[2], reg[3]);
> +       pr_debug("memory scan node %s, reg size %d,\n", uname, l);
>
>         while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
>                 u64 base, size;
> --
> 2.1.0
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-15 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-08  6:44 [PATCH] of/flattree: print memory scan node results in CPU endian Florian Fainelli
2015-04-08 21:19 ` Frank Rowand
     [not found]   ` <55259B4D.2020304-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-09  3:17     ` Florian Fainelli
2015-04-12 20:16     ` [PATCH] of/fdt: Remove "reg" data prints from early_init_dt_scan_memory Florian Fainelli
     [not found]       ` <1428869786-26897-1-git-send-email-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-04-15 12:52         ` Rob Herring

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).