Skip to contentSkip to conversation

powerpc/4xx/ocm: Fix phys_addr_t printf warnings

PATCH In review Michael Ellerman 4 participants 9 messages Jan 1, 2019 – Jan 11, 2019 PowerPC

lore
Share & tools
lore

Michael Ellerman

author reviewer
#0 lore raw

PATCH 1/2 powerpc/4xx/ocm: Fix phys_addr_t printf warnings

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

---
 arch/powerpc/platforms/4xx/ocm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/4xx/ocm.c +3 -3
index c22b099c42f1..a1aaa1569d7c 100644
@@ -237,12 +237,12 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 			continue;
 
 		seq_printf(m, "PPC4XX OCM   : %d\n", ocm->index);
-		seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
+		seq_printf(m, "PhysAddr     : %pa[p]\n", &(ocm->phys));
 		seq_printf(m, "MemTotal     : %d Bytes\n", ocm->memtotal);
 		seq_printf(m, "MemTotal(NC) : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "MemTotal(C)  : %d Bytes\n\n", ocm->c.memtotal);
 
-		seq_printf(m, "NC.PhysAddr  : 0x%llx\n", ocm->nc.phys);
+		seq_printf(m, "NC.PhysAddr  : %pa[p]\n", &(ocm->nc.phys));
 		seq_printf(m, "NC.VirtAddr  : 0x%p\n", ocm->nc.virt);
 		seq_printf(m, "NC.MemTotal  : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "NC.MemFree   : %d Bytes\n", ocm->nc.memfree);
@@ -252,7 +252,7 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 							blk->size, blk->owner);
 		}
 
-		seq_printf(m, "\nC.PhysAddr   : 0x%llx\n", ocm->c.phys);
+		seq_printf(m, "\nC.PhysAddr   : %pa[p]\n", &(ocm->c.phys));
 		seq_printf(m, "C.VirtAddr   : 0x%p\n", ocm->c.virt);
 		seq_printf(m, "C.MemTotal   : %d Bytes\n", ocm->c.memtotal);
 		seq_printf(m, "C.MemFree    : %d Bytes\n", ocm->c.memfree);
Signature · 1 line
2.17.2
author reviewer
#1 lore raw

PATCH 2/2 powerpc/configs: Add PPC4xx_OCM to ppc40x_defconfig

There was recently a compilation break to this driver, but we didn't notice because none of our defconfigs have it enabled. Fix that.

---
 arch/powerpc/configs/ppc40x_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/configs/ppc40x_defconfig +1 -0
index 10fb1df63b46..689d7e276769 100644
@@ -85,3 +85,4 @@ CONFIG_CRYPTO_ECB=y
 CONFIG_CRYPTO_PCBC=y
 CONFIG_CRYPTO_MD5=y
 CONFIG_CRYPTO_DES=y
+CONFIG_PPC4xx_OCM=y
Signature · 1 line
2.17.2
#2 lore raw
In reply to Michael Ellerman

Michael Ellerman <[email protected]> a écrit :

Quoted 11 lines

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

When I fixed the same problem in prom.c, you suggested to simply cast it to unsigned long long. Is this a better solution ?

Christophe

Quoted 37 lines
---
 arch/powerpc/platforms/4xx/ocm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/4xx/ocm.c +2 -2
index c22b099c42f1..a1aaa1569d7c 100644
@@ -237,12 +237,12 @@ static int ocm_debugfs_show(struct seq_file  
 *m, void *v)
 			continue;
 
 		seq_printf(m, "PPC4XX OCM   : %d\n", ocm->index);
-		seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
+		seq_printf(m, "PhysAddr     : %pa[p]\n", &(ocm->phys));
 		seq_printf(m, "MemTotal     : %d Bytes\n", ocm->memtotal);
 		seq_printf(m, "MemTotal(NC) : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "MemTotal(C)  : %d Bytes\n\n", ocm->c.memtotal);
 
-		seq_printf(m, "NC.PhysAddr  : 0x%llx\n", ocm->nc.phys);
+		seq_printf(m, "NC.PhysAddr  : %pa[p]\n", &(ocm->nc.phys));
 		seq_printf(m, "NC.VirtAddr  : 0x%p\n", ocm->nc.virt);
 		seq_printf(m, "NC.MemTotal  : %d Bytes\n", ocm->nc.memtotal);
arch/powerpc/platforms/4xx/ocm.c +1 -2
 		seq_printf(m, "NC.MemFree   : %d Bytes\n", ocm->nc.memfree);
@@ -252,7 +252,7 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 							blk->size, blk->owner);
 		}
 
-		seq_printf(m, "\nC.PhysAddr   : 0x%llx\n", ocm->c.phys);
+		seq_printf(m, "\nC.PhysAddr   : %pa[p]\n", &(ocm->c.phys));
 		seq_printf(m, "C.VirtAddr   : 0x%p\n", ocm->c.virt);
 		seq_printf(m, "C.MemTotal   : %d Bytes\n", ocm->c.memtotal);
 		seq_printf(m, "C.MemFree    : %d Bytes\n", ocm->c.memfree);
--

2.17.2

author reviewer
#3 lore raw
Quoted 10 lines · LEROY Christophe

Michael Ellerman <[email protected]> a écrit :

Quoted 8 lines

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~
Quoted 6 lines
Quoted 3 lines

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

When I fixed the same problem in prom.c, you suggested to simply cast it to unsigned long long. Is this a better solution ?

Did I?

Oh you mean here:
https://patchwork.ozlabs.org/patch/1012875/

Yeah I was just commenting on the ifdef, I didn't actually realise it was a phys_addr_t that was the cause of the problem.

So yeah I guess it is preferable to use %pa[p] in prom.c as well.

cheers

#4 lore raw
In reply to Michael Ellerman
Quoted 5 lines · Michael Ellerman

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

Quoted 8 lines
     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

Series applied to powerpc fixes.

https://git.kernel.org/powerpc/c/52b88fa1e8c7bae03bb691178a9f8b

cheers

#5 lore raw
Quoted 13 lines · CET Michael Ellerman
Quoted 12 lines · Michael Ellerman

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

Quoted 5 lines
Quoted 1 line

Series applied to powerpc fixes.

https://git.kernel.org/powerpc/c/52b88fa1e8c7bae03bb691178a9f8b

Well, I guess I'm a late. I had issues with the getting 4.20+ crosscompiled on debian with make-kpkg.

Nevertheless, I finally got a working kernel and
on the MyBook Live APM82181:

---

root@mbl:/sys/kernel/debug# cat ppc4xx_ocm/info 
PPC4XX OCM   : 1
PhysAddr     : 0x0000000400040000[p]
MemTotal     : 32768 Bytes
MemTotal(NC) : 32768 Bytes
MemTotal(C)  : 0 Bytes

NC.PhysAddr : 0x0000000400040000[p]
NC.VirtAddr : 0x6bc84b36
NC.MemTotal : 32768 Bytes
NC.MemFree : 32768 Bytes

C.PhysAddr : 0x0000000000000000[p]
C.VirtAddr : 0x (null)
C.MemTotal : 0 Bytes
C.MemFree : 0 Bytes
---

Yes, nobody is using the ocm. Though I do have a patch for the crypto4xx and emac.

author reviewer
#6 lore raw
Quoted 39 lines · Christian Lamparter
Quoted 13 lines · CET Michael Ellerman
Quoted 12 lines · Michael Ellerman

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

Quoted 5 lines
Quoted 1 line

Series applied to powerpc fixes.

https://git.kernel.org/powerpc/c/52b88fa1e8c7bae03bb691178a9f8b

Well, I guess I'm a late. I had issues with the getting 4.20+ crosscompiled on debian with make-kpkg.

Nevertheless, I finally got a working kernel and
on the MyBook Live APM82181:

---

root@mbl:/sys/kernel/debug# cat ppc4xx_ocm/info 
PPC4XX OCM   : 1
PhysAddr     : 0x0000000400040000[p]
MemTotal     : 32768 Bytes
MemTotal(NC) : 32768 Bytes
MemTotal(C)  : 0 Bytes

NC.PhysAddr : 0x0000000400040000[p]
NC.VirtAddr : 0x6bc84b36
NC.MemTotal : 32768 Bytes
NC.MemFree : 32768 Bytes

Quoted 4 lines

C.PhysAddr : 0x0000000000000000[p]
C.VirtAddr : 0x (null)
C.MemTotal : 0 Bytes
C.MemFree : 0 Bytes

Oh right, I'm an idiot :)

The docs say:

Physical address types phys_addr_t
----------------------------------

	%pa[p]	0x01234567 or 0x0123456789abcdef

And if you grep for that there's eg:

drivers/ntb/test/ntb_tool.c: "Window Size \t%pa[p]\n",

So I just literally copied that.

But it's trying to indicate that the p is optional.

This should fix it, I won't merge it until you've tested it this time :)

cheers

arch/powerpc/platforms/4xx/ocm.c +3 -3
index a1aaa1569d7c..f0e488d97567 100644
@@ -237,12 +237,12 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 			continue;
 
 		seq_printf(m, "PPC4XX OCM   : %d\n", ocm->index);
-		seq_printf(m, "PhysAddr     : %pa[p]\n", &(ocm->phys));
+		seq_printf(m, "PhysAddr     : %pa\n", &(ocm->phys));
 		seq_printf(m, "MemTotal     : %d Bytes\n", ocm->memtotal);
 		seq_printf(m, "MemTotal(NC) : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "MemTotal(C)  : %d Bytes\n\n", ocm->c.memtotal);
 
-		seq_printf(m, "NC.PhysAddr  : %pa[p]\n", &(ocm->nc.phys));
+		seq_printf(m, "NC.PhysAddr  : %pa\n", &(ocm->nc.phys));
 		seq_printf(m, "NC.VirtAddr  : 0x%p\n", ocm->nc.virt);
 		seq_printf(m, "NC.MemTotal  : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "NC.MemFree   : %d Bytes\n", ocm->nc.memfree);
@@ -252,7 +252,7 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 							blk->size, blk->owner);
 		}
 
-		seq_printf(m, "\nC.PhysAddr   : %pa[p]\n", &(ocm->c.phys));
+		seq_printf(m, "\nC.PhysAddr   : %pa\n", &(ocm->c.phys));
 		seq_printf(m, "C.VirtAddr   : 0x%p\n", ocm->c.virt);
 		seq_printf(m, "C.MemTotal   : %d Bytes\n", ocm->c.memtotal);
 		seq_printf(m, "C.MemFree    : %d Bytes\n", ocm->c.memfree);
#7 lore raw
Quoted 88 lines · CET Michael Ellerman
Quoted 39 lines · Christian Lamparter
Quoted 13 lines · CET Michael Ellerman
Quoted 12 lines · Michael Ellerman

Currently the code produces several warnings, eg:

arch/powerpc/platforms/4xx/ocm.c:240:38: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'phys_addr_t {aka unsigned int}'

     seq_printf(m, "PhysAddr     : 0x%llx\n", ocm->phys);
                                   ~~~^     ~~~~~~~~~

Fix it by using the special %pa[p] format for printing phys_addr_t. Note we need to pass the value by reference for the special specifier to work.

Quoted 5 lines
Quoted 1 line

Series applied to powerpc fixes.

https://git.kernel.org/powerpc/c/52b88fa1e8c7bae03bb691178a9f8b

Well, I guess I'm a late. I had issues with the getting 4.20+ crosscompiled on debian with make-kpkg.

Nevertheless, I finally got a working kernel and
on the MyBook Live APM82181:

---

root@mbl:/sys/kernel/debug# cat ppc4xx_ocm/info 
PPC4XX OCM   : 1
PhysAddr     : 0x0000000400040000[p]
MemTotal     : 32768 Bytes
MemTotal(NC) : 32768 Bytes
MemTotal(C)  : 0 Bytes

NC.PhysAddr : 0x0000000400040000[p]
NC.VirtAddr : 0x6bc84b36
NC.MemTotal : 32768 Bytes
NC.MemFree : 32768 Bytes

Quoted 4 lines

C.PhysAddr : 0x0000000000000000[p]
C.VirtAddr : 0x (null)
C.MemTotal : 0 Bytes
C.MemFree : 0 Bytes

Oh right, I'm an idiot :)

The docs say:

Physical address types phys_addr_t
----------------------------------

	%pa[p]	0x01234567 or 0x0123456789abcdef

And if you grep for that there's eg:

drivers/ntb/test/ntb_tool.c: "Window Size \t%pa[p]\n",

So I just literally copied that.

But it's trying to indicate that the p is optional.

This should fix it, I won't merge it until you've tested it this time :)

cheers

arch/powerpc/platforms/4xx/ocm.c +2 -2
index a1aaa1569d7c..f0e488d97567 100644
@@ -237,12 +237,12 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 			continue;
 
 		seq_printf(m, "PPC4XX OCM   : %d\n", ocm->index);
-		seq_printf(m, "PhysAddr     : %pa[p]\n", &(ocm->phys));
+		seq_printf(m, "PhysAddr     : %pa\n", &(ocm->phys));
 		seq_printf(m, "MemTotal     : %d Bytes\n", ocm->memtotal);
 		seq_printf(m, "MemTotal(NC) : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "MemTotal(C)  : %d Bytes\n\n", ocm->c.memtotal);
 
-		seq_printf(m, "NC.PhysAddr  : %pa[p]\n", &(ocm->nc.phys));
+		seq_printf(m, "NC.PhysAddr  : %pa\n", &(ocm->nc.phys));
 		seq_printf(m, "NC.VirtAddr  : 0x%p\n", ocm->nc.virt);
 		seq_printf(m, "NC.MemTotal  : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "NC.MemFree   : %d Bytes\n", ocm->nc.memfree);

arch/powerpc/platforms/4xx/ocm.c static int ocm_debugfs_show(struct seq_file *m, void *v) · line 258

Quoted 8 lines
arch/powerpc/platforms/4xx/ocm.c +1 -1
@@ -252,7 +252,7 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 							blk->size, blk->owner);
 		}
 
-		seq_printf(m, "\nC.PhysAddr   : %pa[p]\n", &(ocm->c.phys));
+		seq_printf(m, "\nC.PhysAddr   : %pa\n", &(ocm->c.phys));
 		seq_printf(m, "C.VirtAddr   : 0x%p\n", ocm->c.virt);
 		seq_printf(m, "C.MemTotal   : %d Bytes\n", ocm->c.memtotal);
 		seq_printf(m, "C.MemFree    : %d Bytes\n", ocm->c.memfree);

Ok, with the patch applied it now looks like:

|root@mbl:/sys/kernel/debug/ppc4xx_ocm# cat info 
|PPC4XX OCM   : 1
|PhysAddr     : 0x0000000400040000
|MemTotal     : 32768 Bytes
|MemTotal(NC) : 32768 Bytes
|MemTotal(C)  : 0 Bytes
|
|NC.PhysAddr  : 0x0000000400040000
|NC.VirtAddr  : 0x54f5bce2
|NC.MemTotal  : 32768 Bytes
|NC.MemFree   : 32768 Bytes
|
|C.PhysAddr   : 0x0000000000000000
|C.VirtAddr   : 0x  (null)
|C.MemTotal   : 0 Bytes
|C.MemFree    : 0 Bytes

... just as expected. ;)

Thanks,
Christian

author reviewer
#8 lore raw
Quoted 2 lines · Christian Lamparter
Quoted 1 line · CET Michael Ellerman

Christian Lamparter <[email protected]> writes:

...

Quoted 48 lines
Quoted 20 lines
arch/powerpc/platforms/4xx/ocm.c +2 -2
index a1aaa1569d7c..f0e488d97567 100644
@@ -237,12 +237,12 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 			continue;
 
 		seq_printf(m, "PPC4XX OCM   : %d\n", ocm->index);
-		seq_printf(m, "PhysAddr     : %pa[p]\n", &(ocm->phys));
+		seq_printf(m, "PhysAddr     : %pa\n", &(ocm->phys));
 		seq_printf(m, "MemTotal     : %d Bytes\n", ocm->memtotal);
 		seq_printf(m, "MemTotal(NC) : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "MemTotal(C)  : %d Bytes\n\n", ocm->c.memtotal);
 
-		seq_printf(m, "NC.PhysAddr  : %pa[p]\n", &(ocm->nc.phys));
+		seq_printf(m, "NC.PhysAddr  : %pa\n", &(ocm->nc.phys));
 		seq_printf(m, "NC.VirtAddr  : 0x%p\n", ocm->nc.virt);
 		seq_printf(m, "NC.MemTotal  : %d Bytes\n", ocm->nc.memtotal);
 		seq_printf(m, "NC.MemFree   : %d Bytes\n", ocm->nc.memfree);

arch/powerpc/platforms/4xx/ocm.c static int ocm_debugfs_show(struct seq_file *m, void *v) · line 258

Quoted 8 lines
arch/powerpc/platforms/4xx/ocm.c +1 -1
@@ -252,7 +252,7 @@ static int ocm_debugfs_show(struct seq_file *m, void *v)
 							blk->size, blk->owner);
 		}
 
-		seq_printf(m, "\nC.PhysAddr   : %pa[p]\n", &(ocm->c.phys));
+		seq_printf(m, "\nC.PhysAddr   : %pa\n", &(ocm->c.phys));
 		seq_printf(m, "C.VirtAddr   : 0x%p\n", ocm->c.virt);
 		seq_printf(m, "C.MemTotal   : %d Bytes\n", ocm->c.memtotal);
 		seq_printf(m, "C.MemFree    : %d Bytes\n", ocm->c.memfree);

Ok, with the patch applied it now looks like:

|root@mbl:/sys/kernel/debug/ppc4xx_ocm# cat info 
|PPC4XX OCM   : 1
|PhysAddr     : 0x0000000400040000
|MemTotal     : 32768 Bytes
|MemTotal(NC) : 32768 Bytes
|MemTotal(C)  : 0 Bytes
|
|NC.PhysAddr  : 0x0000000400040000
|NC.VirtAddr  : 0x54f5bce2
|NC.MemTotal  : 32768 Bytes
|NC.MemFree   : 32768 Bytes
|
|C.PhysAddr   : 0x0000000000000000
|C.VirtAddr   : 0x  (null)
|C.MemTotal   : 0 Bytes
|C.MemFree    : 0 Bytes
Quoted 1 line

... just as expected. ;)

Thanks.

cheers